diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/SurvivingComparison.lean b/lean/OAI/NumberTheory/TotientAsymptotic/SurvivingComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..c8025a2841d2a7967e586347e07bc503fb76fa3d --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/SurvivingComparison.lean @@ -0,0 +1,118 @@ +import OAI.NumberTheory.TotientAsymptotic.CollisionCanceled +import OAI.NumberTheory.TotientAsymptotic.ComparisonLargePart + +namespace OAI + +/-! Assemble Ford's pointwise comparison hypotheses for actual surviving lists. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter + +namespace TotientAsymptotic + +lemma normal_prime_omega_below {S y : ℝ} {p : ℕ} (hp : IsNormalPrime S p) + (hS : 1 < S) (hBS : 0 ≤ B S) (hSy : S ≤ y) (hpy : (p-1 : ℕ) ≤ y) : + ((p-1).primeFactorsList.length : ℝ) ≤ 4*B y := by + have hSb : B S ≤ B y := Real.log_le_log (Real.log_pos hS) + (Real.log_le_log (zero_lt_one.trans hS) hSy) + have hBy := hBS.trans hSb + by_cases hp3 : 3 ≤ p + · have hp1 : (1 : ℝ) < (p-1 : ℕ) := by exact_mod_cast (show 2 ≤ p-1 by omega) + have hpb : B (p-1 : ℕ) ≤ B y := Real.log_le_log (Real.log_pos hp1) + (Real.log_le_log (zero_lt_one.trans hp1) hpy) + exact (normality_total_uniform hp hS hBS hSb hpb).trans (by linarith) + · have he : p=2 := by have := hp.1.two_le; omega + simp only [he, Nat.reduceSub, Nat.primeFactorsList_one, List.length_nil, Nat.cast_zero] + positivity + +/-- All pointwise hypotheses, including the large-prime-part condition, follow +for the actual canceled lists once their ordered factor intervals are chosen. +The remaining interval construction and summation are separate obligations. -/ +theorem surviving_comparison_conditions : ∀ᶠ y : ℝ in atTop, + ∀ {x : ℝ} {H i p q : ℕ} {η ξ : RemainderDatum (L x H)}, + IsBasicRemainder x H η → IsBasicRemainder x H ξ → p.Prime → + L x H < m x → R x H < L x H → i ≤ R x H → collisionLastIndex x i < L x H → + tupleValue (witnessTuple p η)=tupleValue (witnessTuple q ξ) → + wholeWitnessPrime p η i ≠ wholeWitnessPrime q ξ i → + (∀ j < i, wholeWitnessPrime p η j=wholeWitnessPrime q ξ j) → + GoodWitnessConditions p η → GoodWitnessConditions q ξ → + ∀ Y U : ℕ → ℝ, + 1 < normalityScale x i → 0 ≤ B (normalityScale x i) → normalityScale x i ≤ y → + Y (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card=collisionSmoothCutoff x i → + (∀ j : Fin (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card, + U j ≤ largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).left j-1) ∧ + (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).left j-1) : ℝ) ≤ Y j ∧ + U j ≤ largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).right j-1) ∧ + (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).right j-1) : ℝ) ≤ Y j) → + ((suffixPreimage η (collisionLastIndex x i)).totient * + (∏ j ∈ Finset.Icc i (collisionLastIndex x i), (wholeWitnessPrime p η j-1)) : ℕ) ≤ y → + (largestPrimeFactor (collisionResidual ξ i) : ℝ) ≤ collisionSmoothCutoff x i → + y^(9/10 : ℝ) ≤ wholeWitnessPrime p η i → 1 ≤ Y 1 → + Y 1 ≤ Real.exp (Real.exp ((4/5 : ℝ)*B y)) → + FordComparisonConditions (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card + y (normalityScale x i) (collisionResidual η i) + (collisionCanceledProduct p q η ξ i (collisionLastIndex x i)) Y U + (survivingPair p q η ξ i (collisionLastIndex x i)) := by + filter_upwards [comparison_large_prime_part] with y hlarge + intro x H i p q η ξ hη hξ hp hL hR hi hk hv hfirst hcommon hgη hgξ Y U hS hBS hSy hYb hinterval hsize hres hhead hY1 hY1u + have hik : i ≤ collisionLastIndex x i := Nat.le_add_right _ _ + have heq := surviving_collision_identity hη hξ hp hL hR hk hik hv hfirst hcommon + have hgood := surviving_good_conditions hi hgη hgξ + have hrpos := collisionCanceledProduct_pos hη hp hk.le (q := q) (ξ := ξ) (i := i) + have hDpos := Nat.totient_pos.mpr (suffixPreimage_pos hη (i := collisionLastIndex x i)) + have hrempos := Nat.totient_pos.mpr (suffixPreimage_pos hξ (i := collisionLastIndex x i)) + have hprodpos : 0 < (collisionResidual η i)* + shiftedProduct (survivingPair p q η ξ i (collisionLastIndex x i)).left := by + apply Nat.mul_pos hDpos + apply Finset.prod_pos + intro j _ + exact Nat.sub_pos_of_lt (hgood j).1.1.one_lt + have hfactor : collisionCanceledProduct p q η ξ i (collisionLastIndex x i) * + ((collisionResidual η i)*shiftedProduct (survivingPair p q η ξ i (collisionLastIndex x i)).left) = + (collisionResidual η i)*∏ j ∈ Finset.Icc i (collisionLastIndex x i), (wholeWitnessPrime p η j-1) := by + rw [mul_left_comm, canceled_surviving_product] + have hprodsize : ((collisionResidual η i)*shiftedProduct + (survivingPair p q η ξ i (collisionLastIndex x i)).left : ℕ) ≤ y := by + have hh := Nat.le_mul_of_pos_left + ((collisionResidual η i)*shiftedProduct (survivingPair p q η ξ i (collisionLastIndex x i)).left) hrpos + rw [hfactor] at hh + exact (show (((collisionResidual η i)*shiftedProduct + (survivingPair p q η ξ i (collisionLastIndex x i)).left : ℕ) : ℝ) ≤ + ((collisionResidual η i)*∏ j ∈ Finset.Icc i (collisionLastIndex x i), + (wholeWitnessPrime p η j-1) : ℕ) by exact_mod_cast hh).trans hsize + have hshift (j : Fin (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card) : + (((survivingPair p q η ξ i (collisionLastIndex x i)).left j-1 : ℕ) : ℝ) ≤ y := by + exact (show (((survivingPair p q η ξ i (collisionLastIndex x i)).left j-1 : ℕ) : ℝ) ≤ + ((collisionResidual η i)*shiftedProduct (survivingPair p q η ξ i (collisionLastIndex x i)).left : ℕ) by + exact_mod_cast Nat.le_of_dvd hprodpos + ((shifted_factor_dvd _ j).trans (dvd_mul_left _ _))).trans hprodsize + refine ⟨hrempos,?_,heq,?_,?_,?_,?_⟩ + · intro j + exact ⟨(hgood j).1,(hgood j).2.1,(hgood j).2.2.1, + (hinterval j).1,(hinterval j).2.1,(hinterval j).2.2.1,(hinterval j).2.2.2, + hYb.symm ▸ (hgood j).2.2.2.1,hYb.symm ▸ (hgood j).2.2.2.2⟩ + · apply (le_div_iff₀ (by exact_mod_cast hrpos : (0 : ℝ) < collisionCanceledProduct p q η ξ i (collisionLastIndex x i))).mpr + rw [mul_comm,← Nat.cast_mul,hfactor] + exact hsize + · simpa only [hYb,survivingPair,collisionResidual] using hres + · intro hb + obtain ⟨hb',hfirstidx⟩ := survivingIndex_first hik hfirst + have hfirstp : (survivingPair p q η ξ i (collisionLastIndex x i)).left ⟨0,hb⟩ = + wholeWitnessPrime p η i := by + change wholeWitnessPrime p η (survivingIndex p q η ξ i (collisionLastIndex x i) ⟨0,hb⟩)=_ + rw [hfirstidx] + apply hlarge _ _ (hgood ⟨0,hb⟩).1.1 (by simpa only [hfirstp] using hhead) hY1 hY1u + exact normal_prime_omega_below (hgood ⟨0,hb⟩).1 hS hBS hSy (hshift ⟨0,hb⟩) + + · rw [hYb] + apply squarefreeAbove_of_dvd ?_ + ((hgη i (Finset.mem_Icc.mpr ⟨Nat.zero_le _,hi⟩)).2.2.1) + refine ⟨collisionCanceledProduct p q η ξ i (collisionLastIndex x i),?_⟩ + rw [mul_comm,canceled_surviving_product] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/SurvivingGridGeometry.lean b/lean/OAI/NumberTheory/TotientAsymptotic/SurvivingGridGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..4320717418534134438b97cbdecc7ed1cd8b930a --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/SurvivingGridGeometry.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.TotientAsymptotic.CollisionFactorHeights +import OAI.NumberTheory.TotientAsymptotic.PairedComparisonGrid + +namespace OAI + +/-! Numerical grid margins for the ordered surviving Ford bands. -/ + +noncomputable section + +namespace TotientAsymptotic + +lemma collision_last_band_le_half {x : ℝ} {i : ℕ} (hB : 1 norm_num [B] at hn + +/-- Unlike the positive-coordinate band lemma, this also covers collisions +whose first different prime is the largest prime of the tuple. -/ +theorem surviving_factor_heights : ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, + ∀ i p q : ℕ, i ≤ R x H → + ∀ η ξ : RemainderDatum (L x H), IsBasicRemainder x H η → IsBasicRemainder x H ξ → + GoodWitnessConditions p η → GoodWitnessConditions q ξ → + wholeWitnessPrime p η i ≠ wholeWitnessPrime q ξ i → ∀ y : ℝ, + 1 intro hn; simpa only [Nat.add_zero,hfirst] using (le_refl i) + | succ n ih => + intro hn + have hn' : n< b := by omega + have hprev := ih hn' + have hs := j.strictMono (show (⟨n,hn'⟩ : Fin b)<⟨n+1,hn⟩ from Nat.lt_succ_self n) + omega + exact hall r.val r.isLt + +lemma shifted_slack_sum {J i : ℕ} (hi : i≤ J) (u : ℕ → ℝ) : + (∑ k ∈ Finset.Icc 1 (J-i), a k*u (i+k)) = + ∑ r ∈ Finset.Icc (i+1) J, a (r-i)*u r := by + apply Finset.sum_bij (fun k _ => i+k) + · intro k hk + have := Finset.mem_Icc.mp hk + apply Finset.mem_Icc.mpr + omega + · intro k hk l hl he + omega + · intro r hr + refine ⟨r-i,?_,?_⟩ + · have := Finset.mem_Icc.mp hr + apply Finset.mem_Icc.mpr + omega + · have := Finset.mem_Icc.mp hr + omega + · intro k hk + simp only [Nat.add_sub_cancel_left] + +/-- The discarded matching coordinates cannot consume slack. This is stated +for the actual order embedding of survivors, with the original index offset. -/ +theorem surviving_weighted_slack {x : ℝ} {H i p q : ℕ} + {η ξ : RemainderDatum (L x H)} + (hη : IsBasicRemainder x H η) (hk : collisionLastIndex x i< L x H) + (hfirst : wholeWitnessPrime p η i≠wholeWitnessPrime q ξ i) + (ν : ℕ → ℝ) {Y σ e : ℝ} (hY : 0< Y) + (hbudget : (∑ r ∈ Finset.Icc (i+1) (L x H), a (r-i)*remainderCoord x η r)≤(1-σ)*Y) + (hgrid : ∀ r (hr : r ∈ Finset.Icc 1 ((collisionSurvivors p q η ξ i (collisionLastIndex x i)).card-1)), + ν r≤ remainderCoord x η (survivingIndex p q η ξ i (collisionLastIndex x i) + ⟨r,by have := Finset.mem_Icc.mp hr; omega⟩)/Y+e) : + (∑ r ∈ Finset.Icc 1 ((collisionSurvivors p q η ξ i (collisionLastIndex x i)).card-1), a r*ν r)≤ + 1-σ+e*(∑ r ∈ Finset.Icc 1 ((collisionSurvivors p q η ξ i (collisionLastIndex x i)).card-1), a r) := by + obtain ⟨hb,hidx0⟩ := survivingIndex_first (Nat.le_add_right i _) hfirst + change 0 < (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card at hb + change survivingIndex p q η ξ i (collisionLastIndex x i) ⟨0,hb⟩=i at hidx0 + let b := (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card + let j : ℕ → ℕ := fun r => if hr : r< b then + survivingIndex p q η ξ i (collisionLastIndex x i) ⟨r,hr⟩-i else 0 + let u : ℕ → ℝ := fun r => remainderCoord x η (i+r) + have hir : i≤ L x H := (Nat.le_add_right i (collisionCutoff (m x-i))).trans hk.le + have hidx (r : ℕ) (hr : r∈Finset.Icc 1 (b-1)) : + r≤ j r ∧ j r≤ L x H-i := by + have hrb : r< b := by have := Finset.mem_Icc.mp hr; omega + have hoff := orderEmbedding_offset_le (survivingIndex p q η ξ i (collisionLastIndex x i)) hb hidx0 ⟨r,hrb⟩ + change i+r ≤ survivingIndex p q η ξ i (collisionLastIndex x i) ⟨r,hrb⟩ at hoff + have hmem := survivingIndex_mem p q η ξ i (collisionLastIndex x i) ⟨r,hrb⟩ + have hupper := (Finset.mem_Icc.mp (Finset.mem_filter.mp hmem).1).2 + simp only [j,dite_eq_left hrb] + constructor <;> omega + have hinj : Set.InjOn j (↑(Finset.Icc 1 (b-1)) : Set ℕ) := by + intro r hr s hs he + have hrb : r< b := by have := Finset.mem_Icc.mp hr; omega + have hsb : s< b := by have := Finset.mem_Icc.mp hs; omega + simp only [j,dite_eq_left hrb,dite_eq_left hsb] at he + have hrlo := (orderEmbedding_offset_le (survivingIndex p q η ξ i (collisionLastIndex x i)) hb hidx0 ⟨r,hrb⟩) + have hslo := (orderEmbedding_offset_le (survivingIndex p q η ξ i (collisionLastIndex x i)) hb hidx0 ⟨s,hsb⟩) + change i+r ≤ survivingIndex p q η ξ i (collisionLastIndex x i) ⟨r,hrb⟩ at hrlo + change i+s ≤ survivingIndex p q η ξ i (collisionLastIndex x i) ⟨s,hsb⟩ at hslo + have heq : survivingIndex p q η ξ i (collisionLastIndex x i) ⟨r,hrb⟩= + survivingIndex p q η ξ i (collisionLastIndex x i) ⟨s,hsb⟩ := by omega + exact congrArg Fin.val ((survivingIndex p q η ξ i (collisionLastIndex x i)).injective heq) + apply gridded_weighted_slack (b-1) (L x H-i) j u ν Y σ e hY hinj hidx + · intro r hr + have hmem := Finset.mem_Icc.mp hr + have hirL : i+r∈Finset.Icc 1 (L x H) := by apply Finset.mem_Icc.mpr; omega + have hu := (hη.2.1 (i+r) hirL).2.1 + exact (mul_nonneg (by norm_num) (bandScale_nonnegative _ _)).trans hu + · simpa only [u,shifted_slack_sum hir] using hbudget + · intro r hr + have hrb : r< b := by have := Finset.mem_Icc.mp hr; omega + have hoff := orderEmbedding_offset_le (survivingIndex p q η ξ i (collisionLastIndex x i)) hb hidx0 ⟨r,hrb⟩ + have hadd : i+(survivingIndex p q η ξ i (collisionLastIndex x i) ⟨r,hrb⟩-i)= + survivingIndex p q η ξ i (collisionLastIndex x i) ⟨r,hrb⟩ := by omega + simpa only [u,j,dite_eq_left hrb,hadd] using hgrid r hr + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TailArray.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TailArray.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b177e28c642b038aec32c094c61a591e042f65f --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TailArray.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.TotientAsymptotic.RemainderSplit + +namespace OAI + +/-! The discrete tail, in the coordinate order used by the full simplex. -/ + +noncomputable section +open scoped BigOperators + +namespace TotientAsymptotic + +def tailVector {H : ℕ} (η : TailDatum H) : Fin (H-P H) → ℝ := + fun i => tailLog η (H-1-i.val) + +lemma tailVector_nonneg {H : ℕ} {s : ℝ} {η : TailDatum H} + (hη : IsWitness H s η) (i : Fin (H-P H)) : 0 ≤ tailVector η i := by + apply tailLog_nonneg hη + apply Finset.mem_Ico.mpr + have := i.isLt + omega + +lemma D_eq_tailVector_sum {H : ℕ} (η : TailDatum H) (hPH : P H ≤ H) (h : ℕ) : + D h η = ∑ i : Fin (H-P H), a (h-(H-1-i.val))*tailVector η i := by + unfold D + apply Finset.sum_bij (fun l hl => (⟨H-1-l, by + have := Finset.mem_Ico.mp hl + omega⟩ : Fin (H-P H))) + · intro l hl + exact Finset.mem_univ _ + · intro l hl k hk he + have := Finset.mem_Ico.mp hl + have := Finset.mem_Ico.mp hk + have hv := congrArg Fin.val he + simp only at hv + omega + · intro i _ + have hi := i.isLt + refine ⟨H-1-i.val, Finset.mem_Ico.mpr ⟨by omega, by omega⟩, ?_⟩ + apply Fin.ext + simp only + omega + · intro l hl + have := Finset.mem_Ico.mp hl + dsimp only [tailVector] + have he : H-1-(H-1-l)=l := by omega + rw [he] + +lemma tailVector_row {H : ℕ} (η : TailDatum H) (i : Fin (H-P H)) : + (∑ j : Fin (H-P H), if i < j then a (j.val-i.val)*tailVector η j else 0) = + ∑ l ∈ Finset.Ico (P H) (H-1-i.val), a (H-1-i.val-l)*tailLog η l := by + rw [← Finset.sum_filter] + apply Finset.sum_bij (fun j _ => H-1-j.val) + · intro j hj + have hj' : i < j := (Finset.mem_filter.mp hj).2 + have hi := i.isLt + have hjb := j.isLt + exact Finset.mem_Ico.mpr (by simp only [Fin.lt_def] at hj'; omega) + · intro j hj k hk he + apply Fin.ext + have := j.isLt + have := k.isLt + omega + · intro l hl + have hl' := Finset.mem_Ico.mp hl + refine ⟨⟨H-1-l, by omega⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩, ?_⟩ + · change i.val < H-1-l + omega + · simp only + omega + · intro j hj + have hij : i < j := (Finset.mem_filter.mp hj).2 + have hi := i.isLt + have hjb := j.isLt + dsimp only [tailVector] + congr 2 + simp only [Fin.lt_def] at hij + omega + +lemma tailVector_simplex {H : ℕ} {s : ℝ} {η : TailDatum H} + (hη : IsWitness H s η) (i : Fin (H-P H)) : + (∑ j : Fin (H-P H), if i < j then a (j.val-i.val)*tailVector η j else 0) ≤ + (1+(1/10000 : ℝ)*Real.exp (-((H-1-i.val : ℕ) : ℝ)/40))*tailVector η i := by + rw [tailVector_row] + have hi : H-1-i.val ∈ Finset.Ico (P H) H := by + have := i.isLt + exact Finset.mem_Ico.mpr (by omega) + exact (hη.2.2.1 _ hi).2.2.2 + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TailBelowPrefix.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TailBelowPrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..30f34a8b398eab3614d4657fbdafc90817c9f45c --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TailBelowPrefix.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.TotientAsymptotic.CofactorShellDecay +import OAI.NumberTheory.TotientAsymptotic.SuffixSize +import OAI.NumberTheory.TotientAsymptotic.CollisionIndices + +namespace OAI + +noncomputable section +open scoped Topology +open Filter + +namespace TotientAsymptotic + +lemma tail_log_comparison : ∀ᶠ b : ℝ in atTop, + 4*b*Real.exp ((7/10 : ℝ)*b) < Real.exp ((9/10 : ℝ)*b) := by + have ht : Tendsto (fun b : ℝ => 4*(b*Real.exp (-(1/5 : ℝ)*b))) atTop (nhds 0) := by + simpa only [Real.rpow_one,mul_zero] using + (tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero 1 (1/5) (by norm_num : (0 : ℝ)<1/5)).const_mul 4 + filter_upwards [ht.eventually (eventually_lt_nhds (by norm_num : (0 : ℝ)<1))] with b hb + have h := mul_lt_mul_of_pos_right hb (Real.exp_pos ((9/10 : ℝ)*b)) + rw [mul_assoc,mul_assoc,← Real.exp_add] at h + rw [show -(1/5 : ℝ)*b+9/10*b=(7/10 : ℝ)*b by ring,one_mul] at h + simpa only [mul_assoc] using h + +/-- The exact arithmetic tail lies below every retained prefix prime. This is +uniform in the phase; the cofactor cut grows much slower than the prefix cut. -/ +theorem basic_tail_lt_last_prefix : ∀ᶠ H : ℕ in atTop, + ∀ x : ℝ, theta x ∈ Set.Ico (0 : ℝ) 1 → H < m x → + ∀ η : RemainderDatum (L x H), IsBasicRemainder x H η → + remainderTail x H η < remainderPrime η (R x H) := by + obtain ⟨b₀,hb₀⟩ := eventually_atTop.mp tail_log_comparison + filter_upwards [eventually_ge_atTop 2, + P_tendsto.eventually (eventually_ge_atTop 1), + cofactor_envelope_le_self (2*(lam/rho)), + (tendsto_natCast_atTop_atTop.const_mul_atTop lam_pos).eventually (eventually_ge_atTop b₀)] + with H hH hP hcof hlarge + intro x hs hm η hη + have hPH := P_lt_self hH + have hR : 0 < R x H := by unfold R; omega + have hRL : R x H < L x H := by unfold R L; omega + have hRmem : R x H ∈ Finset.Icc 1 (L x H) := Finset.mem_Icc.mpr ⟨hR,hRL.le⟩ + have hRH : m x-R x H=H := by unfold R; omega + have hLP : m x-L x H=P H := by unfold L; omega + let b := bandScale x (R x H) + have hb0 : 0 ≤ b := bandScale_nonnegative _ _ + have hα : lam ≤ alpha (theta x) := by + unfold alpha + exact le_mul_of_one_le_right lam_pos.le (Real.one_le_exp (mul_nonneg lam_pos.le hs.1)) + have hpow : (1 : ℝ) ≤ (rho^H)⁻¹ := one_le_inv₀ (pow_pos rho_pos H) |>.mpr + (pow_le_one₀ rho_pos.le rho_lt_one.le) + have hbH : lam*H ≤ b := by + change _ ≤ alpha (theta x)*(m x-R x H : ℕ)*(rho^(m x-R x H))⁻¹ + rw [hRH] + exact (mul_le_mul_of_nonneg_right hα (Nat.cast_nonneg H)).trans + (le_mul_of_one_le_right (mul_nonneg (alpha_pos _).le (Nat.cast_nonneg _)) hpow) + have hHb : (H : ℝ) ≤ 2*b := by + have hl := collision_lambda_bounds.1 + nlinarith [Nat.cast_nonneg (α := ℝ) H] + have hsuc : (11/10 : ℝ)*bandScale x (R x H+1) ≤ (7/10 : ℝ)*b := by + have hh := bandScale_succ_le x (R x H) + have hr := collision_rho_bounds.2 + change bandScale x (R x H+1) ≤ rho*b at hh + nlinarith + have hlast : Real.exp (2*bandScale x (L x H)) ≤ H := by + apply (Real.exp_le_exp.mpr ?_).trans hcof + rw [bandScale,hLP] + unfold cofactorScale + have hi := (inv_pos.mpr (pow_pos rho_pos (P H))).le + have ha := alpha_le _ hs + nlinarith [mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right ha (Nat.cast_nonneg (P H))) hi] + have hlen : L x H-R x H ≤ H := by unfold L R; omega + have hlenR : (L x H-R x H : ℕ) ≤ (H : ℝ) := by exact_mod_cast hlen + have he : (1 : ℝ) ≤ Real.exp ((7/10 : ℝ)*b) := Real.one_le_exp (by positivity) + have hlog := basic_suffix_log_bound (j := R x H) hη + have hu : Real.log (remainderTail x H η : ℝ) < Real.exp ((9/10 : ℝ)*b) := by + change Real.log (suffixPreimage η (R x H) : ℝ) < _ + calc + _ ≤ (H : ℝ)*Real.exp ((7/10 : ℝ)*b)+H := hlog.trans + (add_le_add (mul_le_mul hlenR (Real.exp_le_exp.mpr hsuc) (Real.exp_pos _).le (Nat.cast_nonneg _)) hlast) + _ ≤ 4*b*Real.exp ((7/10 : ℝ)*b) := by nlinarith + _ < _ := hb₀ b (hlarge.trans hbH) + have hp := hη.2.1 _ hRmem + have hpR : (1 : ℝ) < remainderPrime η (R x H) := by exact_mod_cast hp.1.one_lt + have hlower : Real.exp ((9/10 : ℝ)*b) ≤ Real.log (remainderPrime η (R x H) : ℝ) := by + apply (Real.le_log_iff_exp_le (Real.log_pos hpR)).mp + simpa only [remainderCoord,ite_eq_right (ne_of_gt hR)] using hp.2.1 + have hpos : (0 : ℝ) < remainderTail x H η := by + exact_mod_cast suffixPreimage_pos (i := R x H) hη + exact_mod_cast (Real.log_lt_log_iff hpos (zero_lt_one.trans hpR)).mp (hu.trans_le hlower) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TailBounds.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TailBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..50a697f15656956c62d9ac3a78ddaec66e488953 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TailBounds.lean @@ -0,0 +1,377 @@ +import OAI.NumberTheory.TotientAsymptotic.Renewal + +namespace OAI + +/-! Uniform finite tail bounds and nonnegative coefficients from exponential random variables. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter + +namespace TotientAsymptotic + +lemma alpha_le (s : ℝ) (hs : s ∈ Set.Ico (0 : ℝ) 1) : alpha s ≤ lam / rho := by + have h : lam * s ≤ lam := by nlinarith [lam_pos, hs.2] + have he : Real.exp lam = 1 / rho := Real.exp_log (div_pos zero_lt_one rho_pos) + unfold alpha + calc + lam * Real.exp (lam * s) ≤ lam * Real.exp lam := + mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr h) lam_pos.le + _ = lam / rho := by rw [he]; ring + +def tailPrimeBound (H : ℕ) : ℕ := + ⌈Real.exp (Real.exp ((11/10 : ℝ) * (lam/rho) * H * (rho^H)⁻¹))⌉₊ + +def tailCofactorBound (H : ℕ) : ℕ := + ⌈Real.exp (Real.exp (2 * (lam/rho) * (P H : ℝ) * (rho^(P H))⁻¹))⌉₊ + +lemma one_le_tailPrimeBound (H : ℕ) : 1 ≤ tailPrimeBound H := by + have h : (1 : ℝ) ≤ Real.exp + (Real.exp ((11/10 : ℝ) * (lam/rho) * H * (rho^H)⁻¹)) := + Real.one_le_exp (Real.exp_pos _).le + exact_mod_cast h.trans (Nat.le_ceil _) + +lemma index_inv_pow_mono {h H : ℕ} (hh : h ≤ H) : + (h : ℝ) * (rho^h)⁻¹ ≤ (H : ℝ) * (rho^H)⁻¹ := by + have hr := rho_pos + apply mul_le_mul (by exact_mod_cast hh) + · exact (inv_le_inv₀ (pow_pos rho_pos _) (pow_pos rho_pos _)).2 + (pow_le_pow_of_le_one rho_pos.le rho_lt_one.le hh) + · positivity + · positivity + +lemma witness_prime_bound {H : ℕ} {s : ℝ} {η : TailDatum H} + (hs : s ∈ Set.Ico (0 : ℝ) 1) (hη : IsWitness H s η) (i : Fin H) : + 1 ≤ η.Q i ∧ η.Q i ≤ tailPrimeBound H := by + by_cases hi : i.val < P H + · rw [hη.1 i hi] + exact ⟨le_rfl, one_le_tailPrimeBound H⟩ + · have himem : i.val ∈ Finset.Ico (P H) H := by simp; omega + obtain ⟨hprime, hlo, hhi, hineq⟩ := hη.2.2.1 i.val himem + have ht : tailPrime η i.val = η.Q i := by simp [tailPrime, i.isLt] + rw [ht] at hprime + have hQ : (1 : ℝ) < η.Q i := by exact_mod_cast hprime.one_lt + have hlog : Real.log (η.Q i : ℝ) > 0 := Real.log_pos hQ + have hupper : tailLog η i.val ≤ + (11/10 : ℝ) * (lam/rho) * H * (rho^H)⁻¹ := by + apply hhi.trans + calc + _ = (11/10 : ℝ) * alpha s * ((i.val : ℝ) * (rho^i.val)⁻¹) := by ring + _ ≤ (11/10 : ℝ) * (lam/rho) * ((H : ℝ) * (rho^H)⁻¹) := by + apply mul_le_mul + · exact mul_le_mul_of_nonneg_left (alpha_le s hs) (by norm_num) + · exact index_inv_pow_mono (Nat.le_of_lt i.isLt) + · have := rho_pos; positivity + · have := lam_pos; have := rho_pos; positivity + _ = _ := by ring + change Real.log (Real.log (tailPrime η i.val : ℝ)) ≤ _ at hupper + rw [ht] at hupper + have hh := (Real.log_le_iff_le_exp hlog).1 hupper + have hh' := (Real.log_le_iff_le_exp (lt_trans zero_lt_one hQ)).1 hh + have hb : (η.Q i : ℝ) ≤ (tailPrimeBound H : ℝ) := hh'.trans (Nat.le_ceil _) + exact ⟨hprime.pos, by exact_mod_cast hb⟩ + +lemma witness_cofactor_bound {H : ℕ} {s : ℝ} {η : TailDatum H} + (hs : s ∈ Set.Ico (0 : ℝ) 1) (hη : IsWitness H s η) : + 1 ≤ η.cofactor ∧ η.cofactor ≤ tailCofactorBound H := by + have hpos : (0 : ℝ) < η.cofactor := by exact_mod_cast hη.2.1 + have hlog : Real.log (η.cofactor : ℝ) ≤ + Real.exp (2 * (lam/rho) * (P H : ℝ) * (rho^(P H))⁻¹) := by + apply hη.2.2.2.2.trans + apply Real.exp_le_exp.mpr + have hr := rho_pos + gcongr + exact alpha_le s hs + have hb : (η.cofactor : ℝ) ≤ (tailCofactorBound H : ℝ) := + ((Real.log_le_iff_le_exp hpos).1 hlog).trans (Nat.le_ceil _) + exact ⟨hη.2.1, by exact_mod_cast hb⟩ + +def tailUniverse (H : ℕ) : Set (TailDatum H) := + {η | (∀ i, η.Q i ∈ Set.Icc 1 (tailPrimeBound H)) ∧ + η.cofactor ∈ Set.Icc 1 (tailCofactorBound H)} + +lemma tailUniverse_finite (H : ℕ) : (tailUniverse H).Finite := by + let F : TailDatum H → (Fin H → ℕ) × ℕ := fun η => (η.Q, η.cofactor) + have hF : Function.Injective F := by + intro η ξ h + cases η + cases ξ + simpa [F, Prod.mk.injEq] using h + have hf := (Set.Finite.pi (fun _ : Fin H => Set.finite_Icc 1 (tailPrimeBound H))).prod + (Set.finite_Icc 1 (tailCofactorBound H)) + have hp := hf.preimage hF.injOn + convert hp using 1 + ext η + simp [tailUniverse, F, Pi.le_def, forall_and, and_assoc, and_left_comm, and_comm] + +lemma witness_mem_tailUniverse {H : ℕ} {s : ℝ} {η : TailDatum H} + (hs : s ∈ Set.Ico (0 : ℝ) 1) (hη : IsWitness H s η) : η ∈ tailUniverse H := by + exact ⟨fun i => witness_prime_bound hs hη i, witness_cofactor_bound hs hη⟩ + +theorem finite_tail_data (H : ℕ) : + {η : TailDatum H | ∃ s ∈ Set.Ico (0 : ℝ) 1, IsWitness H s η}.Finite := by + apply (tailUniverse_finite H).subset + rintro η ⟨s, hs, hη⟩ + exact witness_mem_tailUniverse hs hη + +lemma witnesses_finite (H : ℕ) {s : ℝ} (hs : s ∈ Set.Ico (0 : ℝ) 1) (d : ℕ) : + (witnesses H s d).Finite := by + apply (finite_tail_data H).subset + intro η hη + exact ⟨s, hs, hη.1⟩ + + + +lemma witness_w_bound {H : ℕ} {s : ℝ} {η : TailDatum H} + (hs : s ∈ Set.Ico (0 : ℝ) 1) (hη : IsWitness H s η) : + w η ≤ tailCofactorBound H * (tailPrimeBound H)^(H-P H) := by + have hp : ∏ h ∈ Finset.Ico (P H) H, tailPrime η h ≤ + (tailPrimeBound H)^(H-P H) := by + calc + _ ≤ ∏ _h ∈ Finset.Ico (P H) H, tailPrimeBound H := by + apply Finset.prod_le_prod + intro h hh + have hhH := (Finset.mem_Ico.mp hh).2 + simpa [tailPrime, hhH] using (witness_prime_bound hs hη ⟨h, hhH⟩).2 + _ = _ := by simp + exact Nat.mul_le_mul (witness_cofactor_bound hs hη).2 hp + +lemma witness_totient_bound {H : ℕ} {s : ℝ} {d : ℕ} + (hs : s ∈ Set.Ico (0 : ℝ) 1) (η : TailDatum H) (hη : η ∈ witnesses H s d) : + d ≤ tailCofactorBound H * (tailPrimeBound H)^(H-P H) := by + rw [← hη.2] + exact (Nat.totient_le _).trans (witness_w_bound hs hη.1) + +lemma tailLog_nonneg {H : ℕ} {s : ℝ} {η : TailDatum H} + (hη : IsWitness H s η) {l : ℕ} (hl : l ∈ Finset.Ico (P H) H) : + 0 ≤ tailLog η l := by + have hr := rho_pos + exact (by have := alpha_pos s; positivity : + (0 : ℝ) ≤ (9/10 : ℝ) * alpha s * l * (rho^l)⁻¹).trans (hη.2.2.1 l hl).2.1 + +lemma D_nonneg {H : ℕ} {s : ℝ} {η : TailDatum H} + (hη : IsWitness H s η) {h : ℕ} (hh : H ≤ h) : 0 ≤ D h η := by + unfold D + apply Finset.sum_nonneg + intro l hl + have hlH := (Finset.mem_Ico.mp hl).2 + exact mul_nonneg (a_pos (by omega)).le (tailLog_nonneg hη hl) + +def tailMass {H : ℕ} (η : TailDatum H) : ℝ := ∑ l ∈ Finset.Ico (P H) H, tailLog η l + +lemma tailMass_nonneg {H : ℕ} {s : ℝ} {η : TailDatum H} + (hη : IsWitness H s η) : 0 ≤ tailMass η := + Finset.sum_nonneg (fun _ hl => tailLog_nonneg hη hl) + +lemma D_le_log {H : ℕ} {s : ℝ} {η : TailDatum H} + (hη : IsWitness H s η) {h : ℕ} (hh : H ≤ h) : + D h η ≤ Real.log (h+1 : ℝ) * tailMass η := by + unfold D tailMass + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro l hl + have hlH := (Finset.mem_Ico.mp hl).2 + have hj : 1 ≤ h-l := by omega + apply mul_le_mul_of_nonneg_right _ (tailLog_nonneg hη hl) + apply (a_le_log hj).trans + apply Real.log_le_log (by positivity) + have hsub : h-l ≤ h := Nat.sub_le _ _ + exact_mod_cast Nat.add_le_add_right hsub 1 + +lemma D_le_linear {H : ℕ} {s : ℝ} {η : TailDatum H} + (hη : IsWitness H s η) {h : ℕ} (hh : H ≤ h) : D h η ≤ h * tailMass η := by + apply (D_le_log hη hh).trans + apply mul_le_mul_of_nonneg_right _ (tailMass_nonneg hη) + have hlog := Real.log_le_sub_one_of_pos (x := (h+1 : ℝ)) (by positivity) + linarith + +lemma maxD_nonneg {H : ℕ} {s : ℝ} {T : Finset (TailDatum H)} + (hT : ∀ η ∈ T, IsWitness H s η) {h : ℕ} (hh : H ≤ h) : 0 ≤ maxD h T := by + classical + unfold maxD + split_ifs with ht + · obtain ⟨η, hη⟩ := ht + exact (D_nonneg (hT η hη) hh).trans (Finset.le_sup' (s := T) (D h) hη) + · exact le_rfl + +lemma maxD_le_linear {H : ℕ} {s : ℝ} {T : Finset (TailDatum H)} + (hT : ∀ η ∈ T, IsWitness H s η) {h : ℕ} (hh : H ≤ h) : + maxD h T ≤ (h : ℝ) * ∑ η ∈ T, tailMass η := by + classical + unfold maxD + split_ifs with ht + · apply Finset.sup'_le + intro η hη + apply (D_le_linear (hT η hη) hh).trans + apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) + exact Finset.single_le_sum (fun ξ hξ => tailMass_nonneg (hT ξ hξ)) hη + · have hz : T = ∅ := Finset.not_nonempty_iff_eq_empty.mp ht + simp [hz] + +theorem summable_tail_threshold {H : ℕ} {s : ℝ} {T : Finset (TailDatum H)} + (hT : ∀ η ∈ T, IsWitness H s η) : + Summable (fun n : ℕ => rho^(H+n) * maxD (H+n) T) := by + have hs : Summable (fun n : ℕ => (n : ℝ) * rho^n) := by + simpa using summable_pow_mul_geometric_of_norm_lt_one 1 + (show ‖rho‖ < 1 by simpa [Real.norm_eq_abs, abs_of_pos rho_pos] using rho_lt_one) + have hshift : Summable (fun n : ℕ => ((H+n : ℕ) : ℝ) * rho^(H+n)) := by + simpa [Nat.add_comm] using (summable_nat_add_iff H).2 hs + apply Summable.of_nonneg_of_le + (fun n => mul_nonneg (pow_nonneg rho_pos.le _) + (maxD_nonneg hT (by omega))) + (fun n => ?_) + (hshift.mul_right (∑ η ∈ T, tailMass η)) + have hb := mul_le_mul_of_nonneg_left + (maxD_le_linear hT (h := H+n) (by omega)) (pow_nonneg rho_pos.le (H+n)) + simpa only [mul_assoc, mul_comm, mul_left_comm] using hb + +lemma finite_witness_subsets (H : ℕ) {s : ℝ} (hs : s ∈ Set.Ico (0 : ℝ) 1) (d : ℕ) : + {T : Finset (TailDatum H) | (↑T : Set (TailDatum H)) ⊆ witnesses H s d}.Finite := by + have h := (witnesses_finite H hs d).finite_subsets + exact h.preimage Finset.coe_injective.injOn + + +open MeasureTheory ProbabilityTheory +open scoped Classical + +private instance expOne_probability : IsProbabilityMeasure (expMeasure 1) := + isProbabilityMeasure_expMeasure zero_lt_one + +def exponentialProduct : Measure (ℕ → ℝ) := + Measure.infinitePi (fun _ : ℕ => expMeasure 1) + +instance exponentialProduct_probability : IsProbabilityMeasure exponentialProduct := by + unfold exponentialProduct + infer_instance + +lemma expOne_real_Ioi {t : ℝ} (ht : 0 ≤ t) : + (expMeasure 1).real (Set.Ioi t) = Real.exp (-t) := by + rw [← Set.compl_Iic, probReal_compl_eq_one_sub measurableSet_Iic, + ← cdf_eq_real, cdf_expMeasure_eq zero_lt_one, ite_eq_left ht, one_mul] + ring + +lemma expOne_Ioi {t : ℝ} (ht : 0 ≤ t) : + expMeasure 1 (Set.Ioi t) = ENNReal.ofReal (Real.exp (-t)) := by + rw [← expOne_real_Ioi ht, measureReal_def, ENNReal.ofReal_toReal (measure_ne_top _ _)] + +lemma exponential_box_probability (b : ℕ → ℝ) (hb : ∀ n, 0 ≤ b n) (hbs : Summable b) : + exponentialProduct.real (Set.univ.pi (fun n => Set.Ioi (b n))) = + Real.exp (-(∑' n, b n)) := by + have hp : HasProd (fun n : ℕ => ENNReal.ofReal (Real.exp (-b n))) + (ENNReal.ofReal (Real.exp (-∑' n, b n))) := by + have hs := hbs.hasSum.neg.rexp + have he := (ENNReal.continuous_ofReal.tendsto (Real.exp (-∑' n, b n))).comp hs + unfold HasProd + convert he using 1 + ext T + exact (ENNReal.ofReal_prod_of_nonneg (fun n _ => Real.exp_nonneg (-b n))).symm + unfold Measure.real exponentialProduct + rw [Measure.infinitePi_pi_univ _ (fun _ => measurableSet_Ioi)] + simp_rw [expOne_Ioi (hb _)] + rw [hp.tprod_eq, ENNReal.toReal_ofReal (Real.exp_nonneg _)] + +def witnessEvent {H : ℕ} (s : ℝ) (η : TailDatum H) : Set (ℕ → ℝ) := + Set.univ.pi (fun n => Set.Ioi ((gamma / alpha s) * rho^(H+n) * D (H+n) η)) + +lemma measurableSet_witnessEvent {H : ℕ} (s : ℝ) (η : TailDatum H) : + MeasurableSet (witnessEvent s η) := + MeasurableSet.pi Set.countable_univ (fun _ _ => measurableSet_Ioi) + +lemma threshold_coefficient_pos (H n : ℕ) (s : ℝ) : + 0 < (gamma / alpha s) * rho^(H+n) := + mul_pos (div_pos gamma_pos (alpha_pos s)) (pow_pos rho_pos _) + +lemma witnessEvent_intersection {H : ℕ} (s : ℝ) (T : Finset (TailDatum H)) (ht : T.Nonempty) : + (⋂ η ∈ T, witnessEvent s η) = + Set.univ.pi (fun n => Set.Ioi ((gamma / alpha s) * rho^(H+n) * maxD (H+n) T)) := by + classical + ext u + simp only [Set.mem_iInter, witnessEvent, Set.mem_pi, Set.mem_univ, + forall_true_left, Set.mem_Ioi] + constructor + · intro h n + unfold maxD + rw [dite_eq_left ht] + rw [mul_comm ((gamma / alpha s) * rho^(H+n))] + apply (lt_div_iff₀ (threshold_coefficient_pos H n s)).mp + rw [Finset.sup'_lt_iff ht] + intro η hη + apply (lt_div_iff₀ (threshold_coefficient_pos H n s)).mpr + simpa only [mul_comm] using h η hη n + · intro h η hη n + apply lt_of_le_of_lt _ (h n) + apply mul_le_mul_of_nonneg_left _ (threshold_coefficient_pos H n s).le + unfold maxD + rw [dite_eq_left ht] + exact Finset.le_sup' (s := T) (D (H+n)) hη + +lemma witnessEvent_intersection_probability {H : ℕ} {s : ℝ} + (T : Finset (TailDatum H)) (ht : T.Nonempty) (hT : ∀ η ∈ T, IsWitness H s η) : + exponentialProduct.real (⋂ η ∈ T, witnessEvent s η) = + Real.exp (-(gamma / alpha s) * ∑' n, rho^(H+n) * maxD (H+n) T) := by + rw [witnessEvent_intersection s T ht] + have hs : Summable (fun n => (gamma / alpha s) * rho^(H+n) * maxD (H+n) T) := by + simpa only [mul_assoc] using (summable_tail_threshold hT).mul_left (gamma / alpha s) + rw [exponential_box_probability _ (fun n => mul_nonneg + (threshold_coefficient_pos H n s).le (maxD_nonneg hT (by omega))) hs] + congr 1 + simp only [mul_assoc, tsum_mul_left, neg_mul] + +lemma coefficient_eq_union_probability (H : ℕ) {s : ℝ} + (hs : s ∈ Set.Ico (0 : ℝ) 1) (d : ℕ) : + (∑ᶠ T : Finset (TailDatum H), + if T.Nonempty ∧ (↑T : Set (TailDatum H)) ⊆ witnesses H s d then + (-1 : ℝ)^(T.card-1) * Real.exp (-(gamma / alpha s) * + ∑' n : ℕ, rho^(H+n) * maxD (H+n) T) + else 0) = + exponentialProduct.real (⋃ η ∈ (witnesses_finite H hs d).toFinset, witnessEvent s η) := by + classical + let W := (witnesses_finite H hs d).toFinset + have hW (T : Finset (TailDatum H)) : + (↑T : Set (TailDatum H)) ⊆ witnesses H s d ↔ T ⊆ W := by + constructor + · intro h η hη + exact ((witnesses_finite H hs d).mem_toFinset).mpr (h hη) + · intro h η hη + exact ((witnesses_finite H hs d).mem_toFinset).mp (h hη) + rw [finsum_eq_sum_of_support_subset _ (s := W.powerset.filter Finset.Nonempty)] + · rw [measureReal_biUnion_eq_sum_powerset (fun η _ => measurableSet_witnessEvent s η)] + apply Finset.sum_congr rfl + intro T hT + obtain ⟨hTW, ht⟩ := Finset.mem_filter.mp hT + have hsub : (↑T : Set (TailDatum H)) ⊆ witnesses H s d := + (hW T).mpr (Finset.mem_powerset.mp hTW) + rw [ite_eq_left ⟨ht, hsub⟩, witnessEvent_intersection_probability T ht + (fun η hη => (hsub hη).1)] + congr 1 + have hc : T.card + 1 = T.card - 1 + 2 := by + have := Finset.card_pos.mpr ht + omega + rw [hc, pow_add] + norm_num + · intro T hT + have ht : T.Nonempty ∧ (↑T : Set (TailDatum H)) ⊆ witnesses H s d := by + by_contra h + simp only [Function.mem_support, ite_eq_right h, ne_eq, not_true_eq_false] at hT + exact Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr ((hW T).mp ht.2), ht.1⟩ + +theorem AH_nonneg (H : ℕ) {s : ℝ} (hs : s ∈ Set.Ico (0 : ℝ) 1) + (f : ℝ → ℝ) (hf : ∀ r : ℝ, 1 ≤ r → 0 ≤ f r ∧ f r ≤ 1) : + 0 ≤ AH H f s := by + classical + unfold AH + apply mul_nonneg (mul_nonneg (pow_nonneg rho_pos.le _) + (pow_nonneg (div_pos gamma_pos (alpha_pos s)).le _)) + apply finsum_nonneg + intro d + split_ifs with hd + · apply mul_nonneg (div_nonneg (hf _ (one_le_ell_ratio hd)).1 (Nat.cast_nonneg d)) + rw [coefficient_eq_union_probability H hs d] + exact measureReal_nonneg + · exact le_rfl + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TailBoxAggregation.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TailBoxAggregation.lean new file mode 100644 index 0000000000000000000000000000000000000000..134f48de0b749caff8b255eddc0b7355d951ffa8 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TailBoxAggregation.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.TotientAsymptotic.PrimeBoxGeometry +import Mathlib.MeasureTheory.Constructions.Pi + +namespace OAI + +/-! Aggregate all discrete tails in a box before measuring the continuous +prefix. No factor counting the number of tail witnesses occurs. -/ + +noncomputable section +open scoped BigOperators +open MeasureTheory + +namespace TotientAsymptotic + +def tailBoxLift {R T : ℕ} (K : Finset (Fin T → ℕ)) + (U : (Fin T → ℕ) → Set (Fin R → ℝ)) : + Set ((Fin R → ℝ) × (Fin T → ℝ)) := + ⋃ b ∈ K, U b ×ˢ unitGridCell b + +lemma measurableSet_tailBoxLift {R T : ℕ} (K : Finset (Fin T → ℕ)) + (U : (Fin T → ℕ) → Set (Fin R → ℝ)) + (hU : ∀ b ∈ K, MeasurableSet (U b)) : MeasurableSet (tailBoxLift K U) := + K.measurableSet_biUnion (fun b hb => (hU b hb).prod (measurableSet_unitGridCell b)) + +lemma volume_tailBoxLift {R T : ℕ} (K : Finset (Fin T → ℕ)) + (U : (Fin T → ℕ) → Set (Fin R → ℝ)) + (hU : ∀ b ∈ K, MeasurableSet (U b)) : + volume (tailBoxLift K U) = ∑ b ∈ K, volume (U b) := by + unfold tailBoxLift + rw [measure_biUnion_finset] + · apply Finset.sum_congr rfl + intro b _ + rw [Measure.volume_eq_prod, Measure.prod_prod, volume_unitGridCell, mul_one] + · intro b _ c _ hbc + exact Set.disjoint_left.mpr (fun z hz hw => + Set.disjoint_left.mp (unitGridCell_disjoint hbc) hz.2 hw.2) + · intro b hb + exact (hU b hb).prod (measurableSet_unitGridCell b) + +lemma volumeReal_tailBoxLift {R T : ℕ} (K : Finset (Fin T → ℕ)) + (U : (Fin T → ℕ) → Set (Fin R → ℝ)) + (hU : ∀ b ∈ K, MeasurableSet (U b)) (hfin : ∀ b ∈ K, volume (U b) ≠ ⊤) : + volume.real (tailBoxLift K U) = ∑ b ∈ K, volume.real (U b) := by + simp only [measureReal_def, volume_tailBoxLift K U hU, ENNReal.toReal_sum hfin] + +/-- A common prefix envelope for every tail in one unit box costs only the +reciprocal prime mass of that box. Summing disjoint tail boxes then gives +one full-dimensional volume. -/ +theorem tail_box_aggregation {R T : ℕ} (K : Finset (Fin T → ℕ)) + (S : (Fin T → ℕ) → Set (Fin R → ℝ)) + (U : (Fin T → ℕ) → Set (Fin R → ℝ)) (C : ℝ) + (hU : ∀ b ∈ K, MeasurableSet (U b)) (hfin : ∀ b ∈ K, volume (U b) ≠ ⊤) + (hsub : ∀ b ∈ K, ∀ p ∈ primeBoxTuples b, S p ⊆ U b) + (hmass : ∀ b ∈ K, (∏ i, unitPrimeWeight (b i)) ≤ C) : + (∑ p ∈ gridPrimeTuples K, reciprocalShiftWeight p * volume.real (S p)) ≤ + C * volume.real (tailBoxLift K U) := by + classical + rw [gridPrimeTuples, Finset.sum_biUnion + (fun b _ c _ hbc => primeBoxTuples_disjoint hbc), + volumeReal_tailBoxLift K U hU hfin, Finset.mul_sum] + apply Finset.sum_le_sum + intro b hb + calc + _ ≤ ∑ p ∈ primeBoxTuples b, reciprocalShiftWeight p * volume.real (U b) := by + apply Finset.sum_le_sum + intro p hp + exact mul_le_mul_of_nonneg_left (measureReal_mono (hsub b hb p hp) (hfin b hb)) + (reciprocalShiftWeight_nonneg p) + _ = (∏ i, unitPrimeWeight (b i))*volume.real (U b) := by + rw [← Finset.sum_mul, prime_box_mass] + _ ≤ C*volume.real (U b) := mul_le_mul_of_nonneg_right (hmass b hb) measureReal_nonneg + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TailBoxCoordinates.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TailBoxCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..657e3033bd47879a69dc8ad6c888654b12171d3c --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TailBoxCoordinates.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.TotientAsymptotic.TailBoxAggregation + +namespace OAI + +/-! The prefix-times-tail-box measure is the usual full-coordinate volume. -/ + +noncomputable section +open scoped BigOperators +open MeasureTheory + +namespace TotientAsymptotic + +def joinCoordinates (R T : ℕ) : + ((Fin R → ℝ) × (Fin T → ℝ)) ≃ᵐ (Fin (R+T) → ℝ) := + (MeasurableEquiv.sumPiEquivProdPi (fun _ : Fin R ⊕ Fin T => ℝ)).symm.trans + (MeasurableEquiv.piCongrLeft (fun _ : Fin (R+T) => ℝ) finSumFinEquiv) + +lemma joinCoordinates_left {R T : ℕ} (u : (Fin R → ℝ) × (Fin T → ℝ)) (i : Fin R) : + joinCoordinates R T u (Fin.castAdd T i) = u.1 i := by + simp [joinCoordinates, MeasurableEquiv.piCongrLeft, + Equiv.piCongrLeft, finSumFinEquiv] + rfl + +lemma joinCoordinates_right {R T : ℕ} (u : (Fin R → ℝ) × (Fin T → ℝ)) (i : Fin T) : + joinCoordinates R T u (Fin.natAdd R i) = u.2 i := by + simp [joinCoordinates, MeasurableEquiv.piCongrLeft, + Equiv.piCongrLeft, finSumFinEquiv] + rfl + +lemma joinCoordinates_preserves_volume (R T : ℕ) : + MeasurePreserving (joinCoordinates R T) volume volume := + (volume_measurePreserving_piCongrLeft (fun _ : Fin (R+T) => ℝ) finSumFinEquiv).comp + (volume_measurePreserving_sumPiEquivProdPi_symm (fun _ : Fin R ⊕ Fin T => ℝ)) + +lemma volume_joinCoordinates_image {R T : ℕ} + (S : Set ((Fin R → ℝ) × (Fin T → ℝ))) : + volume (joinCoordinates R T '' S) = volume S := by + have hh := (joinCoordinates_preserves_volume R T).measure_preimage_equiv + (joinCoordinates R T '' S) + rw [Set.preimage_image_eq S (joinCoordinates R T).injective] at hh + exact hh.symm + +/-- A full-dimensional enclosure bounds the aggregated weighted prefix +volumes without multiplying by the number of tail witnesses. -/ +theorem tail_box_aggregation_enclosure {R T : ℕ} (K : Finset (Fin T → ℕ)) + (S : (Fin T → ℕ) → Set (Fin R → ℝ)) + (U : (Fin T → ℕ) → Set (Fin R → ℝ)) + (W : Set (Fin (R+T) → ℝ)) (C : ℝ) + (hC : 0 ≤ C) (hU : ∀ b ∈ K, MeasurableSet (U b)) + (hfin : volume W ≠ ⊤) + (hsub : ∀ b ∈ K, ∀ p ∈ primeBoxTuples b, S p ⊆ U b) + (hmass : ∀ b ∈ K, (∏ i, unitPrimeWeight (b i)) ≤ C) + (henclose : joinCoordinates R T '' tailBoxLift K U ⊆ W) : + (∑ p ∈ gridPrimeTuples K, reciprocalShiftWeight p * volume.real (S p)) ≤ + C * volume.real W := by + have hmeasure : volume (tailBoxLift K U) ≤ volume W := by + rw [← volume_joinCoordinates_image] + exact measure_mono henclose + have hUfin (b) (hb : b ∈ K) : volume (U b) ≠ ⊤ := by + apply ne_top_of_le_ne_top hfin + apply le_trans _ hmeasure + have hh : U b ×ˢ unitGridCell b ⊆ tailBoxLift K U := by + intro z hz + exact Set.mem_iUnion.mpr ⟨b, Set.mem_iUnion.mpr ⟨hb, hz⟩⟩ + have hm : volume (U b ×ˢ unitGridCell b) ≤ volume (tailBoxLift K U) := measure_mono hh + simpa only [Measure.volume_eq_prod, Measure.prod_prod, volume_unitGridCell, mul_one] using hm + exact (tail_box_aggregation K S U C hU hUfin hsub hmass).trans + (mul_le_mul_of_nonneg_left (ENNReal.toReal_mono hfin hmeasure) hC) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TailCofactor.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TailCofactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9b29e6c9290920082191f37399850cbcf2ddf38 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TailCofactor.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TotientAsymptotic.CofactorEnvelope + +namespace OAI + +/-! The uniform reciprocal cofactor envelope at the discrete tail cut. -/ + +noncomputable section +open scoped BigOperators + +namespace TotientAsymptotic + +def exponentialCofactorCap (T : ℝ) : ℕ := ⌈Real.exp (Real.exp T)⌉₊ + +lemma exponentialCofactorCap_bounds {T : ℝ} (hT : 0 ≤ T) : + 2 ≤ exponentialCofactorCap T ∧ + Real.log (exponentialCofactorCap T : ℝ) ≤ 2*Real.exp T := by + have he : 1 ≤ Real.exp T := Real.one_le_exp hT + have hY : 2 ≤ Real.exp (Real.exp T) := by linarith [Real.add_one_le_exp (Real.exp T)] + have hN : (2 : ℝ) ≤ exponentialCofactorCap T := hY.trans (Nat.le_ceil _) + have hNpos : (0 : ℝ) < exponentialCofactorCap T := by linarith + refine ⟨by exact_mod_cast hN, ?_⟩ + have hcap : (exponentialCofactorCap T : ℝ) ≤ 2*Real.exp (Real.exp T) := by + have hh := Nat.ceil_lt_add_one (Real.exp_pos (Real.exp T)).le + change (exponentialCofactorCap T : ℝ) < Real.exp (Real.exp T)+1 at hh + linarith + calc + _ ≤ Real.log (2*Real.exp (Real.exp T)) := Real.log_le_log hNpos hcap + _ = Real.log 2+Real.exp T := by rw [Real.log_mul (by norm_num) (Real.exp_pos _).ne', Real.log_exp] + _ ≤ 2*Real.exp T := by linarith [Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ)<2)] + +theorem exponential_cofactor_sum (hmertens : MertensProductInput) : + ∃ C : ℝ, 0 < C ∧ ∀ T : ℝ, 0 ≤ T → + (∑ a ∈ Finset.Icc 1 (exponentialCofactorCap T), (a.totient : ℝ)⁻¹) ≤ + C*Real.exp (2*T) := by + obtain ⟨C, hC, hc⟩ := sum_reciprocal_totient_le hmertens + refine ⟨6*C, by positivity, ?_⟩ + intro T hT + obtain ⟨hN, hlog⟩ := exponentialCofactorCap_bounds hT + have he := Real.one_le_exp hT + have hlog0 : 0 ≤ Real.log (exponentialCofactorCap T : ℝ) := + Real.log_nonneg (by exact_mod_cast (show 1 ≤ exponentialCofactorCap T by omega)) + apply (hc _ hN).trans + calc + _ ≤ C*(2*Real.exp T)*(3*Real.exp T) := by + apply mul_le_mul + · exact mul_le_mul_of_nonneg_left hlog hC.le + · linarith + · linarith + · positivity + _ = 6*C*Real.exp (2*T) := by rw [show 2*T=T+T by ring, Real.exp_add]; ring + +/-- The entire allowed cofactor sum has the manuscript's exponential envelope +in `P rho^(-P)`, uniformly over the phase. -/ +theorem tail_cofactor_sum (hmertens : MertensProductInput) : + ∃ C : ℝ, 0 < C ∧ ∀ H : ℕ, + (∑ a ∈ Finset.Icc 1 (tailCofactorBound H), (a.totient : ℝ)⁻¹) ≤ + C*Real.exp (4*(lam/rho)*(P H : ℝ)*(rho^(P H))⁻¹) := by + obtain ⟨C, hC, hc⟩ := exponential_cofactor_sum hmertens + refine ⟨C, hC, fun H => ?_⟩ + have h := hc (2*(lam/rho)*(P H : ℝ)*(rho^(P H))⁻¹) (by + have := lam_pos + have := rho_pos + positivity) + convert h using 1 + · rfl + · congr 2 + ring + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TailCutScale.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TailCutScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b6aa4f593b57b8a97d30c46c9a782aa24a9e82b --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TailCutScale.lean @@ -0,0 +1,45 @@ +import OAI.NumberTheory.TotientAsymptotic.MassUpper + +namespace OAI + +/-! The logarithmic tail cut is negligible relative to the retained cut. -/ + +noncomputable section +open scoped Topology +open Filter + +namespace TotientAsymptotic + +lemma P_div_self_tendsto : + Tendsto (fun H : ℕ => (P H : ℝ)/(H : ℝ)) atTop (nhds 0) := by + have hlog := Real.tendsto_log_atTop.comp (tendsto_natCast_atTop_atTop : + Tendsto (fun H : ℕ => (H : ℝ)) atTop atTop) + have hLL := Real.tendsto_log_atTop.comp hlog + have ht := Real.isLittleO_log_id_atTop.tendsto_div_nhds_zero.comp + (tendsto_natCast_atTop_atTop : Tendsto (fun H : ℕ => (H : ℝ)) atTop atTop) + apply squeeze_zero' (g := fun H : ℕ => Real.log (H : ℝ)/(H : ℝ)) + · exact Eventually.of_forall (fun _ => div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) + · filter_upwards [hLL.eventually (eventually_ge_atTop (0 : ℝ)), + eventually_ge_atTop (1 : ℕ)] with H hloglog hH + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + exact (Nat.floor_le hloglog).trans + (Real.log_le_self (Real.log_nonneg (by exact_mod_cast hH))) + · exact ht + +lemma eventually_tail_cut_separated : ∀ᶠ H : ℕ in atTop, + 1 ≤ P H ∧ P H+2 ≤ H ∧ 100*P H ≤ H ∧ 2*P H ≤ H := by + filter_upwards [P_tendsto.eventually (eventually_ge_atTop 1), + P_div_self_tendsto.eventually (eventually_lt_nhds (by norm_num : (0 : ℝ)<1/100)), + eventually_ge_atTop (1 : ℕ)] with H hP hratio hH + have hHpos : (0 : ℝ) < H := by exact_mod_cast (show 0 < H by omega) + have hh : (100 : ℝ)*(P H : ℝ) ≤ H := by + have hx := (div_lt_iff₀ hHpos).mp hratio + linarith + have hnat : 100*P H ≤ H := by exact_mod_cast hh + exact ⟨hP, by omega, hnat, by omega⟩ + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TailEncoding.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TailEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbb1ae2c1eadf9b7a34a2cbbd92ddd807435d72f --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TailEncoding.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.TotientAsymptotic.TailArray +import OAI.NumberTheory.TotientAsymptotic.CofactorMass +import OAI.NumberTheory.TotientAsymptotic.PrimeBoxGeometry + +namespace OAI + +/-! A fixed cofactor and the ordered tail-prime vector determine a witness. -/ + +noncomputable section +open scoped BigOperators + +namespace TotientAsymptotic + +def tailPrimeVector {H : ℕ} (η : TailDatum H) : Fin (H-P H) → ℕ := + fun i => tailPrime η (H-1-i.val) + +lemma tailVector_eq_primeCoord {H : ℕ} (η : TailDatum H) : + tailVector η = primePrefixCoord (tailPrimeVector η) := rfl + +lemma tailPrimeVector_prime {H : ℕ} {s : ℝ} {η : TailDatum H} + (hη : IsWitness H s η) (i : Fin (H-P H)) : (tailPrimeVector η i).Prime := by + apply (hη.2.2.1 _ _).1 + have := i.isLt + exact Finset.mem_Ico.mpr (by omega) + +lemma tailDatum_eq_of_primeVector {H : ℕ} {s t : ℝ} {η ξ : TailDatum H} + (hη : IsWitness H s η) (hξ : IsWitness H t ξ) + (hcof : η.cofactor=ξ.cofactor) (hvec : tailPrimeVector η=tailPrimeVector ξ) : η=ξ := by + have hQ : η.Q=ξ.Q := by + funext i + by_cases hi : i.val < P H + · rw [hη.1 i hi, hξ.1 i hi] + · have hib := i.isLt + let j : Fin (H-P H) := ⟨H-1-i.val, by omega⟩ + have hh := congrFun hvec j + have he : H-1-j.val=i.val := by dsimp [j]; omega + simpa only [tailPrimeVector, he, tailPrime, dite_eq_left i.isLt] using hh + cases η + cases ξ + cases hQ + cases hcof + rfl + +lemma prod_tail_indices {M : Type*} [CommMonoid M] {H : ℕ} (hPH : P H ≤ H) (f : ℕ → M) : + (∏ l ∈ Finset.Ico (P H) H, f l) = ∏ i : Fin (H-P H), f (H-1-i.val) := by + apply Finset.prod_bij (fun l hl => (⟨H-1-l, by + have := Finset.mem_Ico.mp hl + omega⟩ : Fin (H-P H))) + · intro l hl + exact Finset.mem_univ _ + · intro l hl k hk he + have := Finset.mem_Ico.mp hl + have := Finset.mem_Ico.mp hk + have hv := congrArg Fin.val he + simp only at hv + omega + · intro i _ + have hi := i.isLt + refine ⟨H-1-i.val, Finset.mem_Ico.mpr ⟨by omega, by omega⟩, ?_⟩ + apply Fin.ext + simp only + omega + · intro l hl + have := Finset.mem_Ico.mp hl + have he : H-1-(H-1-l)=l := by omega + rw [he] + +lemma tail_value_eq_vector {H : ℕ} (η : TailDatum H) (hPH : P H ≤ H) : + w η = η.cofactor*∏ i, tailPrimeVector η i := by + rw [w, prod_tail_indices hPH] + rfl + +lemma tail_reciprocal_vector {H : ℕ} {s : ℝ} {η : TailDatum H} + (hη : IsWitness H s η) (hPH : P H ≤ H) : + ((w η).totient : ℝ)⁻¹ ≤ + (η.cofactor.totient : ℝ)⁻¹*reciprocalShiftWeight (tailPrimeVector η) := by + have hh := tail_reciprocal_majorant hη + rw [prod_tail_indices hPH] at hh + have he : (∏ i : Fin (H-P H), (tailPrime η (H-1-i.val)-1 : ℝ)⁻¹) = + reciprocalShiftWeight (tailPrimeVector η) := by + unfold reciprocalShiftWeight + rw [Nat.cast_prod, ← Finset.prod_inv_distrib] + apply Finset.prod_congr rfl + intro i _ + rw [Nat.cast_sub (tailPrimeVector_prime hη i).one_lt.le, Nat.cast_one] + rfl + rwa [he] at hh + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TailHeadCount.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TailHeadCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..808daa54fb903f9d9baa3b6bd20d32d7880cdc89 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TailHeadCount.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TotientAsymptotic.HeadPrimeCount +import OAI.NumberTheory.TotientAsymptotic.OrderedPrimeProduct +import OAI.NumberTheory.TotientAsymptotic.PPTComparisonBridge +import Mathlib.Order.Fin.Tuple + +namespace OAI + +/-! Counting distinct candidate integers by a finite sum over ordered tails. -/ +noncomputable section +open scoped BigOperators Topology +open Filter +namespace TotientAsymptotic + +lemma prime_tail_totient_weight {n : ℕ} (p : Fin n → ℕ) + (hp : ∀ i,(p i).Prime) (horder : StrictAnti p) : + ((∏ i,p i).totient:ℝ)⁻¹=reciprocalShiftWeight p := by + rw [ppt_totient_primeProduct p hp horder.injective] + rfl + +def tailHeadPairs {n : ℕ} (x : ℝ) (d : ℕ) (Q : Finset (Fin n → ℕ)) : + Finset (Σ _p : Fin n → ℕ,ℕ) := + Q.sigma (fun p => primeInterval + (x/(2*((d*(∏ i,p i).totient:ℕ):ℝ))) + (x/((d*(∏ i,p i).totient:ℕ):ℝ))) + +theorem tail_head_pair_count : ∀ᶠ x : ℝ in atTop, + ∀ d : ℕ,0 < d → ∀ n : ℕ,∀ Q : Finset (Fin n → ℕ), + (∀ p ∈ Q,(∀ i,(p i).Prime) ∧ StrictAnti p ∧ + Real.log ((d*(∏ i,p i).totient:ℕ):ℝ) ≤ (Real.log x)^(4/5:ℝ)) → + (x/(4*d*Real.log x))*(∑ p ∈ Q,reciprocalShiftWeight p) ≤ + ((tailHeadPairs x d Q).card:ℝ) := by + filter_upwards [head_prime_count_lower,eventually_gt_atTop (1:ℝ)] with x hx hx1 + intro d hd n Q hQ + have hcount (p) (hp : p ∈ Q) : + (x/(4*d*Real.log x))*reciprocalShiftWeight p ≤ + ((primeInterval (x/(2*((d*(∏ i,p i).totient:ℕ):ℝ))) + (x/((d*(∏ i,p i).totient:ℕ):ℝ))).card:ℝ) := by + obtain ⟨hprime,horder,hlog⟩ := hQ p hp + have hr : 0 < ∏ i,p i := Finset.prod_pos (fun i _ => (hprime i).pos) + have hφ := Nat.totient_pos.mpr hr + have hD : (1:ℝ) ≤ ((d*(∏ i,p i).totient:ℕ):ℝ) := by + exact_mod_cast Nat.mul_pos hd hφ + have hh := hx _ hD hlog + apply le_trans _ hh + rw [←prime_tail_totient_weight p hprime horder,Nat.cast_mul] + ring_nf + exact le_rfl + have hh := Finset.sum_le_sum hcount + simpa only [tailHeadPairs,Finset.card_sigma,Nat.cast_sum,Finset.mul_sum] using hh + +lemma ordered_head_product_injective {n : ℕ} {p q : Fin n → ℕ} {a b : ℕ} + (hp : ∀ i,(p i).Prime) (hq : ∀ i,(q i).Prime) (ha : a.Prime) (hb : b.Prime) + (hpo : StrictAnti p) (hqo : StrictAnti q) + (hap : ∀ i,p i < a) (hbq : ∀ i,q i < b) + (he : a*(∏ i,p i)=b*(∏ i,q i)) : a=b ∧ p=q := by + have hpc : ∀ i : Fin (n+1),Nat.Prime ((Fin.cons a p : Fin (n+1) → ℕ) i) := by + intro i + refine Fin.cases ha (fun j => ?_) i + simpa using hp j + have hqc : ∀ i : Fin (n+1),Nat.Prime ((Fin.cons b q : Fin (n+1) → ℕ) i) := by + intro i + refine Fin.cases hb (fun j => ?_) i + simpa using hq j + have hpa : StrictAnti (Fin.cons a p) := + (Fin.strictMono_cons (α:=OrderDual ℕ)).mpr ⟨hap,hpo⟩ + have hqa : StrictAnti (Fin.cons b q) := + (Fin.strictMono_cons (α:=OrderDual ℕ)).mpr ⟨hbq,hqo⟩ + have hh := ordered_prime_product_injective hpc hqc hpa hqa + (by simpa only [Fin.prod_cons] using he) + constructor + · simpa only [Fin.cons_zero] using congrFun hh 0 + · funext i + simpa only [Fin.cons_succ] using congrFun hh i.succ + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TailPower.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TailPower.lean new file mode 100644 index 0000000000000000000000000000000000000000..b26f040fbea62a59335dbd268df3014616d780f1 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TailPower.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.TotientAsymptotic.TailRenewal +import OAI.NumberTheory.TotientAsymptotic.PowerApproximation + +namespace OAI + +/-! Exponential limit of the finite-tail simplex factor, uniformly in phase. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter + +namespace TotientAsymptotic + +lemma tailBudget_nonneg {x : ℝ} {H : ℕ} {s : ℝ} (T : Finset (TailDatum H)) + (hT : ∀ η ∈ T, IsWitness H s η) (hm : H ≤ m x) : 0 ≤ tailBudget x H T := by + unfold tailBudget + apply add_nonneg (maxD_nonneg hT hm) + apply Finset.sum_nonneg + intro i _ + apply mul_nonneg (g_pos _).le + apply maxD_nonneg hT + have hi := i.isLt + unfold R at hi + omega + +/-- The exact power appearing in each intersection volume tends to its +phase-dependent exponential weight; no continuity in the phase is assumed. -/ +theorem tail_simplex_power_limit (hford : FordRenewalInput) + {H : ℕ} {s : ℝ} (T : Finset (TailDatum H)) + (hT : ∀ η ∈ T, IsWitness H s η) : + Tendsto (fun x : ℝ => + (max (1-tailBudget x H T/B x) 0)^(R x H) - + Real.exp (-(gamma/alpha (theta x)) * + ∑' n : ℕ, rho^(H+n)*maxD (H+n) T)) atTop (nhds 0) := by + let S := ∑' n : ℕ, rho^(H+n)*maxD (H+n) T + let q : ℝ → ℝ := fun x => tailBudget x H T/B x + let b : ℝ → ℝ := fun x => (gamma/alpha (theta x))*S + let K := (gamma/lam)*S + have hS : 0 ≤ S := tsum_nonneg (fun n => + mul_nonneg (pow_nonneg rho_pos.le _) (maxD_nonneg hT (by omega))) + have hK : 0 ≤ K := mul_nonneg (div_pos gamma_pos lam_pos).le hS + have hq : ∀ᶠ x : ℝ in atTop, 0 ≤ q x := by + filter_upwards [m_tendsto.eventually (eventually_ge_atTop H), + B_tendsto.eventually (eventually_gt_atTop 0)] with x hm hB + exact div_nonneg (tailBudget_nonneg T hT hm) hB.le + have hb : ∀ᶠ x : ℝ in atTop, 0 ≤ b x ∧ b x ≤ K := by + filter_upwards [theta_eventually_mem] with x hx + refine ⟨mul_nonneg (div_pos gamma_pos (alpha_pos _)).le hS, ?_⟩ + exact mul_le_mul_of_nonneg_right + (div_le_div_of_nonneg_left gamma_pos.le lam_pos (alpha_ge_lam hx.1)) hS + have hmerr : Tendsto (fun x => (m x : ℝ)*q x-b x) atTop (nhds 0) := by + simpa only [q, b, S, mul_div_assoc] using tailBudget_exponent_error hford T hT + have hbound : ∀ᶠ x : ℝ in atTop, (m x : ℝ)*q x ≤ K+1 := by + filter_upwards [hmerr.eventually (eventually_lt_nhds (show (0 : ℝ) < 1 by norm_num)), hb] + with x he hb + linarith + have hq0 : Tendsto q atTop (nhds 0) := by + apply squeeze_zero' hq + · filter_upwards [hbound, m_tendsto.eventually (eventually_gt_atTop 0)] with x hx hm + have hmR : (0 : ℝ) < m x := Nat.cast_pos.mpr hm + show q x ≤ (K+1)*(m x : ℝ)⁻¹ + rw [← div_eq_mul_inv, le_div_iff₀ hmR] + nlinarith + · simpa using (tendsto_inv_atTop_zero.comp + (tendsto_natCast_atTop_atTop.comp m_tendsto)).const_mul (K+1) + have hRerr : Tendsto (fun x => (R x H : ℝ)*q x-b x) atTop (nhds 0) := by + have hh : Tendsto (fun x => (m x : ℝ)*q x-b x-(H : ℝ)*q x) + atTop (nhds 0) := by + simpa using hmerr.sub (hq0.const_mul (H : ℝ)) + apply hh.congr' + filter_upwards [m_tendsto.eventually (eventually_ge_atTop H)] with x hm + dsimp [R] + rw [Nat.cast_sub hm] + ring + have hlim := simplex_power_approximation (fun x => R x H) q b K hK + ((tendsto_sub_atTop_nat H).comp m_tendsto) hq hb hRerr + simpa only [q, b, S, neg_mul] using hlim + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TailProductBounds.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TailProductBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..f053d7fe18aa3151e2bb693379641a1a791dc396 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TailProductBounds.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.TotientAsymptotic.HeadLimitedPrimeMass + +namespace OAI + +/-! The capped tail has the subpower denominator required by the prime window. -/ +noncomputable section +open scoped BigOperators Topology +open Filter +namespace TotientAsymptotic + +lemma prime_tail_log_bound {n : ℕ} (p : Fin n → ℕ) + (hp : ∀ i,(p i).Prime) {T : ℝ} (hT : ∀ i,primePrefixCoord p i ≤ T) : + Real.log ((∏ i,p i : ℕ):ℝ) ≤ n*Real.exp T := by + rw [Nat.cast_prod,Real.log_prod (fun i _ => by exact_mod_cast (hp i).ne_zero)] + calc + _ ≤ ∑ i : Fin n,Real.exp T := by + apply Finset.sum_le_sum + intro i _ + have hi := Real.exp_le_exp.mpr (hT i) + have hip : (1:ℝ) < p i := by exact_mod_cast (hp i).one_lt + simpa only [primePrefixCoord,Real.exp_log (Real.log_pos hip)] using hi + _ = _ := by simp + +lemma capped_tail_denominator_budget (d : ℕ) : ∀ᶠ x : ℝ in atTop, + Real.log (d:ℝ)+(m x:ℝ)*Real.exp ((19/25:ℝ)*B x) ≤ (Real.log x)^(4/5:ℝ) := by + have h₁ : Tendsto (fun x : ℝ => B x*Real.exp (-(1/25:ℝ)*B x)) atTop (nhds 0) := by + simpa only [Real.rpow_one,Function.comp_def,neg_mul] using + (tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero (1:ℝ) (1/25) (by norm_num)).comp B_tendsto + have h₂ : Tendsto (fun x : ℝ => Real.log (d:ℝ)*Real.exp (-(4/5:ℝ)*B x)) atTop (nhds 0) := by + simpa only [Real.rpow_zero,one_mul,mul_zero,Function.comp_def,neg_mul] using + ((tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero (0:ℝ) (4/5) (by norm_num)).comp B_tendsto).const_mul (Real.log (d:ℝ)) + have hs := (h₁.add h₂).eventually (eventually_lt_nhds (by norm_num : (0:ℝ)+0<1)) + filter_upwards [hs,ambient_polynomial_budget 1 1,eventually_gt_atTop (1:ℝ)] with x hx hm hx1 + have hm' : (m x:ℝ) ≤ B x := by simpa only [one_mul,pow_one] using hm + have he : (B x*Real.exp (-(1/25:ℝ)*B x)+Real.log (d:ℝ)*Real.exp (-(4/5:ℝ)*B x))* + Real.exp ((4/5:ℝ)*B x)= + B x*Real.exp ((19/25:ℝ)*B x)+Real.log (d:ℝ) := by + rw [add_mul,mul_assoc,mul_assoc,←Real.exp_add,←Real.exp_add] + rw [show -(1/25:ℝ)*B x+(4/5:ℝ)*B x=(19/25:ℝ)*B x by ring, + show -(4/5:ℝ)*B x+(4/5:ℝ)*B x=0 by ring,Real.exp_zero,mul_one] + have hh := mul_le_mul_of_nonneg_right hx.le (Real.exp_pos ((4/5:ℝ)*B x)).le + rw [he,one_mul] at hh + have hpower : Real.exp ((4/5:ℝ)*B x)=(Real.log x)^(4/5:ℝ) := by + rw [Real.rpow_def_of_pos (Real.log_pos hx1)] + unfold B + rw [mul_comm] + rw [hpower] at hh + have hmul := mul_le_mul_of_nonneg_right hm' (Real.exp_pos ((19/25:ℝ)*B x)).le + linarith only [hmul,hh] + +lemma capped_prime_tail_denominator {d : ℕ} (hd : 0 < d) : + ∀ᶠ x : ℝ in atTop,∀ n : ℕ,n ≤ m x → ∀ p : Fin n → ℕ, + (∀ i,(p i).Prime) → (∀ i,primePrefixCoord p i ≤ (19/25:ℝ)*B x) → + Real.log ((d*(∏ i,p i).totient:ℕ):ℝ) ≤ (Real.log x)^(4/5:ℝ) := by + filter_upwards [capped_tail_denominator_budget d] with x hx + intro n hn p hp hcap + have hr : 0 < ∏ i,p i := Finset.prod_pos (fun i _ => (hp i).pos) + have hφ : 0 < (∏ i,p i).totient := Nat.totient_pos.mpr hr + have hd' : (0:ℝ) < d := by exact_mod_cast hd + have hφ' : (0:ℝ) < (∏ i,p i:ℕ).totient := by exact_mod_cast hφ + have hlog := Real.log_le_log hφ' + (show ((∏ i,p i:ℕ).totient:ℝ) ≤ (∏ i,p i:ℕ) by + exact_mod_cast Nat.totient_le (∏ i,p i)) + have htail := prime_tail_log_bound p hp hcap + have hdim := mul_le_mul_of_nonneg_right (show (n:ℝ) ≤ m x by exact_mod_cast hn) + (Real.exp_pos ((19/25:ℝ)*B x)).le + rw [Nat.cast_mul,Real.log_mul hd'.ne' hφ'.ne'] + linarith only [hlog,htail,hdim,hx] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TailRenewal.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TailRenewal.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7792526f23d0a41520957866c68900e4701c08e --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TailRenewal.lean @@ -0,0 +1,120 @@ +import OAI.NumberTheory.TotientAsymptotic.TailVolume +import OAI.NumberTheory.TotientAsymptotic.RenewalConvolution +import OAI.NumberTheory.TotientAsymptotic.BandComparison + +namespace OAI + +/-! The normalized finite-tail budget and its renewal-convolution limit. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter + +namespace TotientAsymptotic + +def tailSequence {H : ℕ} (T : Finset (TailDatum H)) (n : ℕ) : ℝ := + rho^(H+n)*maxD (H+n) T + +lemma tailBudget_eq_sum (x : ℝ) (H : ℕ) (T : Finset (TailDatum H)) : + tailBudget x H T = + ∑ i ∈ Finset.range (R x H+1), g i*maxD (m x-i) T := by + rw [Finset.sum_range_succ'] + have hg0 : g 0 = 1 := by simp [g] + simp only [Nat.sub_zero, hg0, one_mul] + rw [← Fin.sum_univ_eq_sum_range] + unfold tailBudget + ring + +lemma renewalConvolution_tailSequence (x : ℝ) (H : ℕ) (T : Finset (TailDatum H)) + (hm : H ≤ m x) : + renewalConvolution (tailSequence T) (R x H) = rho^(m x)*tailBudget x H T := by + rw [renewalConvolution, tailBudget_eq_sum, Finset.mul_sum] + apply Finset.sum_bij (fun i _ => R x H-i) + · intro i hi + have hi' := Finset.mem_range.mp hi + exact Finset.mem_range.mpr (by omega) + · intro i hi j hj hij + have hi' := Finset.mem_range.mp hi + have hj' := Finset.mem_range.mp hj + omega + · intro j hj + have hj' := Finset.mem_range.mp hj + exact ⟨R x H-j, Finset.mem_range.mpr (by omega), by omega⟩ + · intro i hi + have hi' := Finset.mem_range.mp hi + have hR : R x H = m x-H := rfl + have hidx : m x-(R x H-i) = H+i := by omega + have hexp : (R x H-i)+(H+i) = m x := by omega + have hpow : rho^(R x H-i)*rho^(H+i) = rho^(m x) := by + rw [← pow_add, hexp] + dsimp [normalizedRenewal, tailSequence] + rw [hidx] + calc + _ = (rho^(R x H-i)*rho^(H+i)) * + (g (R x H-i)*maxD (H+i) T) := by ring + _ = _ := by rw [hpow] + +/-- The exact tail budget converges after multiplication by `rho^m`. +This is the analytic numerator in the manuscript's finite-tail approximation. -/ +theorem normalized_tailBudget_tendsto (hford : FordRenewalInput) + {H : ℕ} {s : ℝ} (T : Finset (TailDatum H)) + (hT : ∀ η ∈ T, IsWitness H s η) : + Tendsto (fun x : ℝ => rho^(m x)*tailBudget x H T) atTop + (nhds (gamma * ∑' n : ℕ, rho^(H+n)*maxD (H+n) T)) := by + have hc : Summable (tailSequence T) := summable_tail_threshold hT + have hh := (renewalConvolution_tendsto hford (tailSequence T) hc).comp + ((tendsto_sub_atTop_nat H).comp m_tendsto) + apply hh.congr' + filter_upwards [m_tendsto.eventually (eventually_ge_atTop H)] with x hx + exact renewalConvolution_tailSequence x H T hx + +lemma alpha_ge_lam {s : ℝ} (hs : 0 ≤ s) : lam ≤ alpha s := by + unfold alpha + have he : 1 ≤ Real.exp (lam*s) := Real.one_le_exp (mul_nonneg lam_pos.le hs) + nlinarith [lam_pos] + +lemma phase_division_error {ι : Type*} {l : Filter ι} (z v a : ι → ℝ) + (L c : ℝ) (hc : 0 < c) (hz : Tendsto z l (nhds L)) + (hv : Tendsto v l (nhds 1)) (ha : ∀ᶠ x in l, c ≤ a x) : + Tendsto (fun x => z x/(a x*v x)-L/a x) l (nhds 0) := by + have ht : Tendsto (fun x => z x/v x-L) l (nhds 0) := by + simpa using (hz.div hv (by norm_num : (1 : ℝ) ≠ 0)).sub_const L + apply squeeze_zero_norm' (a := fun x => |z x/v x-L|/c) + · filter_upwards [ha] with x hx + have he : z x/(a x*v x)-L/a x = (z x/v x-L)/a x := by + simp only [div_eq_mul_inv, mul_inv_rev] + ring + rw [he, Real.norm_eq_abs, abs_div, abs_of_pos (hc.trans_le hx)] + exact div_le_div_of_nonneg_left (abs_nonneg _) hc hx + · simpa using ht.abs.div_const c + +/-- The phase-dependent exponent in the simplex volume, before replacing `m` +by the prefix dimension `m-H`. -/ +theorem tailBudget_exponent_error (hford : FordRenewalInput) + {H : ℕ} {s : ℝ} (T : Finset (TailDatum H)) + (hT : ∀ η ∈ T, IsWitness H s η) : + Tendsto (fun x : ℝ => (m x : ℝ)*tailBudget x H T/B x - + (gamma / alpha (theta x)) * ∑' n : ℕ, rho^(H+n)*maxD (H+n) T) + atTop (nhds 0) := by + have hphase : ∀ᶠ x : ℝ in atTop, lam ≤ alpha (theta x) := + theta_eventually_mem.mono (fun _ hx => alpha_ge_lam hx.1) + have hh := phase_division_error + (fun x : ℝ => rho^(m x)*tailBudget x H T) bandCenterRatio + (fun x => alpha (theta x)) + (gamma * ∑' n : ℕ, rho^(H+n)*maxD (H+n) T) lam lam_pos + (normalized_tailBudget_tendsto hford T hT) bandCenterRatio_tendsto hphase + apply hh.congr' + filter_upwards [B_tendsto.eventually (eventually_gt_atTop (1 : ℝ)), + m_tendsto.eventually (eventually_gt_atTop 0)] with x hB hm + have hmn : (m x : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr hm.ne' + have hr : rho^(m x) ≠ 0 := pow_ne_zero _ rho_pos.ne' + have hl : Real.log (B x) ≠ 0 := (Real.log_pos hB).ne' + rw [alpha_theta_eq hB] + unfold bandCenterRatio + field_simp [hmn, hr, hl, lam_pos.ne', (zero_lt_one.trans hB).ne'] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TailVolume.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TailVolume.lean new file mode 100644 index 0000000000000000000000000000000000000000..ebb5cb49b339c58db74778507a80bac2451e9a8a --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TailVolume.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TotientAsymptotic.SimplexVolume +import OAI.NumberTheory.TotientAsymptotic.TailBounds + +namespace OAI + +/-! Exact finite-tail intersection volumes, before prime-box approximation. -/ + +noncomputable section +open scoped BigOperators +open MeasureTheory + +namespace TotientAsymptotic + +lemma prod_g_shifted (N : ℕ) : + (∏ i : Fin N, g (i.val+1)) = ∏ i ∈ Finset.Icc 1 N, g i := by + rw [Fin.prod_univ_eq_prod_range (fun i => g (i+1))] + apply Finset.prod_bij (fun i _ => i+1) + · intro i hi + have := Finset.mem_range.mp hi + exact Finset.mem_Icc.mpr (by omega) + · intro i _ j _ hij + omega + · intro j hj + have := Finset.mem_Icc.mp hj + refine ⟨j-1, Finset.mem_range.mpr (by omega), by omega⟩ + · intro i _ + rfl + +def tailPrefixRegion (x : ℝ) (H : ℕ) (η : TailDatum H) : + Set (Fin (R x H) → ℝ) := + prefixRegion (R x H) (B x) (D (m x) η) + (fun i => D (m x-(i.val+1)) η) + +def tailIntersection (x : ℝ) (H : ℕ) (T : Finset (TailDatum H)) : + Set (Fin (R x H) → ℝ) := + {u | ∀ η ∈ T, u ∈ tailPrefixRegion x H η} + +def tailBudget (x : ℝ) (H : ℕ) (T : Finset (TailDatum H)) : ℝ := + maxD (m x) T + ∑ i : Fin (R x H), g (i.val+1) * maxD (m x-(i.val+1)) T + +lemma tailIntersection_eq (x : ℝ) (H : ℕ) (T : Finset (TailDatum H)) + (hT : T.Nonempty) : + tailIntersection x H T = prefixRegion (R x H) (B x) (maxD (m x) T) + (fun i => maxD (m x-(i.val+1)) T) := by + unfold tailIntersection tailPrefixRegion + rw [prefixRegion_intersection (R x H) (B x) T hT] + simp only [maxD, dite_eq_left hT] + +/-- The intersection-volume identity with the tail budget indexed by the prefix. +This form avoids a reversed-index convention in subsequent finite sums. -/ +theorem volume_tailIntersection (x : ℝ) (H : ℕ) (T : Finset (TailDatum H)) + (hT : T.Nonempty) (hR : 0 < R x H) (hB : 0 < B x) : + volume (tailIntersection x H T) = + ENNReal.ofReal (G x (R x H) * (max (1-tailBudget x H T/B x) 0)^(R x H)) := by + rw [tailIntersection_eq x H T hT, volume_prefixRegion_explicit _ hR] + have hb : max (B x-tailBudget x H T) 0 = + B x * max (1-tailBudget x H T/B x) 0 := by + have he : B x * (1-tailBudget x H T/B x) = B x-tailBudget x H T := by + field_simp + rw [mul_max_of_nonneg _ _ hB.le, he, mul_zero] + have he : B x - maxD (m x) T - + ∑ i : Fin (R x H), g (i.val+1)*maxD (m x-(i.val+1)) T = + B x-tailBudget x H T := by unfold tailBudget; ring + rw [he, hb, mul_pow, prod_g_shifted] + congr 1 + unfold G + ring + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TerminalBandCount.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalBandCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..5fa5fe8284e3cd46e1d7ccc38e05a37ea07123d5 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalBandCount.lean @@ -0,0 +1,109 @@ +import OAI.NumberTheory.TotientAsymptotic.FixedTerminalMass +import OAI.NumberTheory.TotientAsymptotic.SmoothTerminalMassBound +import OAI.NumberTheory.TotientAsymptotic.TerminalMassSeries +import OAI.NumberTheory.TotientAsymptotic.PrefixResidualCount +import OAI.NumberTheory.TotientAsymptotic.SmallTerminalPrefix + +namespace OAI + +/-! Count actual values in a terminal-coordinate strip through distinct residuals. -/ +noncomputable section +open scoped BigOperators Topology +open Filter +namespace TotientAsymptotic + +theorem terminal_band_value_count (H : ℕ) : ∃ C c : ℝ,0 < C ∧ 0 < c ∧ + ∀ᶠ x : ℝ in atTop,∀ N : ℕ,N+2+H=m x → ∀ k : ℕ,2 ≤ k → + ∀ Q : Finset ℕ,∀ n : ℕ → ℕ, + (∀ v ∈ Q,0 < n v ∧ (n v).totient=v ∧ + x^(1/4:ℝ) ≤ fordPrime (n v) 0 ∧ (v:ℝ) ≤ x ∧ + N+2 ≤ (n v).primeFactorsList.length ∧ + fordPrime (n v) (N+2) < fordPrime (n v) (N+1) ∧ + (k:ℝ) ≤ fordPrimeCoordinate (n v) (N+2) ∧ + fordPrimeCoordinate (n v) (N+2) ≤ (k:ℝ)+1 ∧ + ∀ i < N+2,fordRowSum (m x) (fordPrimeCoordinate (n v)) i ≤ + xi x i*(if i=0 then B x else fordPrimeCoordinate (n v) i)) → + (Q.card:ℝ) ≤ C*(x/Real.log x)*G x (N+1)*terminalMassWeight c k := by + classical + obtain ⟨A,c,hA,hc,hmass⟩ := fixed_terminal_prime_mass (H+1) + obtain ⟨D,hD,hres⟩ := smooth_terminal_mass_bound + refine ⟨64*A*D,c,by positivity,hc,?_⟩ + filter_upwards [hmass,large_prime_product_value_count,eventually_gt_atTop (1:ℝ), + B_tendsto.eventually (eventually_gt_atTop (0:ℝ))] + with x hm hcount hx hB + intro N hNm k hk Q n hQ + let P := Q.image (fun v => fordPrefixPrimes (n v) (N+1)) + let R := Q.image (fun v => (fordCofactor (n v) (N+2)).totient) + have hk' : (2:ℝ) ≤ k := by exact_mod_cast hk + have hpre (v) (hv : v ∈ Q) : + (∀ i,(fordPrefixPrimes (n v) (N+1) i).Prime) ∧ + primePrefixCoord (fordPrefixPrimes (n v) (N+1)) ∈ + enlargedSimplex (N+1) (B x) (xi x 0) (fun i => xi x (i.val+1)) ∧ + (1/100:ℝ) ≤ primePrefixCoord (fordPrefixPrimes (n v) (N+1)) (Fin.last N) := by + have ho := ford_coordinate_antitone (n v) (show N+1 ≤ N+2 by omega) + have hprev : 1 < fordPrimeCoordinate (n v) (N+1) := by + linarith only [ho,(hQ v hv).2.2.2.2.2.2.1,hk'] + have hh := terminal_prefix_conditions (j:=N+2) (L:=m x) (by omega) (by omega) + (by norm_num : (1/100:ℝ) ≤ 1) hprev (hQ v hv).2.2.2.2.2.2.2.2 + exact ⟨hh.1,hh.2.1,hh.2.2 (Fin.last N) (by simp)⟩ + have hlast (v) (hv : v ∈ Q) : + primePrefixCoord (fordPrefixPrimes (n v) (N+1)) (Fin.last N)= + fordPrimeCoordinate (n v) (N+1) := by + have ho := ford_coordinate_antitone (n v) (show N+1 ≤ N+2 by omega) + have hpos : 0 < fordPrimeCoordinate (n v) (N+1) := by + linarith only [ho,(hQ v hv).2.2.2.2.2.2.1,hk'] + change primeDoubleLog (n v) (N+1)=fordPrimeCoordinate (n v) (N+1) + exact (fordPrimeCoordinate_eq_raw_of_pos hpos).symm + have hPmass : (∑ p ∈ P,reciprocalShiftWeight p) ≤ + A*G x (N+1)*Real.exp (-c*(k:ℝ)) := by + apply hm N (by omega) k (by positivity) P + intro p hp + obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hp + refine ⟨(hpre v hv).1,?_,(hpre v hv).2.2,?_⟩ + · simpa only [xi_eq_simplexBoxError,Nat.sub_zero] using (hpre v hv).2.1 + · rw [hlast v hv] + exact ((hQ v hv).2.2.2.2.2.2.1).trans + (ford_coordinate_antitone (n v) (by omega)) + have hRpos (d) (hd : d ∈ R) : 0 < d := by + obtain ⟨v,_,rfl⟩ := Finset.mem_image.mp hd + exact Nat.totient_pos.mpr (fordCofactor_pos _ _) + have hRmass : (∑ d ∈ R,(d:ℝ)⁻¹) ≤ D*Real.exp (10*(Real.log ((k:ℝ)+5))^2) := by + apply hres k (by positivity) R + intro d hd + obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hd + exact ⟨⟨fordCofactor (n v) (N+2),fordCofactor_pos _ _,rfl⟩, + small_terminal_smooth (by positivity) (hQ v hv).2.2.2.2.2.2.2.1⟩ + have hh := hcount (N+1) P R Q (by + intro p hp + obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hp + exact (hpre v hv).1) hRpos (by + intro v hv + obtain ⟨hn,hφ,hhead,hvx,hlen,hgap,_,_,_⟩ := hQ v hv + refine ⟨n v,fordPrime (n v) 0,hn,hφ,fordPrime_prime (by omega),?_,hhead,hvx,?_⟩ + · have he := fordCofactor_step (n v) 0 + rw [fordCofactor_zero hn] at he + exact ⟨fordCofactor (n v) 1,he⟩ + · apply Finset.mem_image.mpr + refine ⟨(fordPrefixPrimes (n v) (N+1),(fordCofactor (n v) (N+2)).totient), + Finset.mem_product.mpr ⟨Finset.mem_image.mpr ⟨v,hv,rfl⟩, + Finset.mem_image.mpr ⟨v,hv,rfl⟩⟩,?_⟩ + exact (strict_gap_residual_totient hn (by omega) hlen hgap).symm) + have hnon : 0 ≤ 64*x/Real.log x := by + have hl := Real.log_pos hx + positivity + have hsum := mul_le_mul hPmass hRmass + (Finset.sum_nonneg (fun _ _ => inv_nonneg.mpr (Nat.cast_nonneg _))) + (by have hG := G_pos hB (N+1); positivity) + apply hh.trans + have hmul := mul_le_mul_of_nonneg_left hsum hnon + rw [←mul_assoc] at hmul + apply hmul.trans_eq + unfold terminalMassWeight + rw [show 10*(Real.log ((k:ℝ)+5))^2-c*k=(-c*(k:ℝ))+10*(Real.log ((k:ℝ)+5))^2 by ring,Real.exp_add] + ring + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TerminalLogBudget.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalLogBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..845cf3d01df1e981dab847eedf391189aed34f1b --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalLogBudget.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.TotientAsymptotic.TerminalStateMass + +namespace OAI + +/-! Absorption of the terminal allocation factor into Ford's logarithmic exponent. -/ +noncomputable section +namespace TotientAsymptotic + +lemma terminal_allocation_log_le {k : ℕ} (hk : 2 ≤ k) : + Real.log ((k:ℝ)*(k+1)) ≤ 3*Real.log k := by + have hkR : (2:ℝ) ≤ k := by exact_mod_cast hk + have hk0 : (0:ℝ) < k := by linarith + have hle : (k:ℝ)+1 ≤ (k:ℝ)^2 := by nlinarith + have hh := Real.log_le_log (by linarith : (0:ℝ) < k+1) hle + rw [Real.log_pow] at hh + norm_num only [Nat.cast_ofNat] at hh + rw [Real.log_mul hk0.ne' (by linarith : (k:ℝ)+1 ≠ 0)] + linarith + +lemma terminal_allocation_log_budget {k : ℕ} {v : ℝ} (hk : 2 ≤ k) + (hv : 1 < v) (hBv : 0 ≤ B v) : + ((k:ℝ)*(k+1))^(4*(k:ℝ)*B v)*(Real.log v) ≤ + (Real.log v)^(20*(k:ℝ)*Real.log k+1) := by + have hkR : (2:ℝ) ≤ k := by exact_mod_cast hk + have hk0 : (0:ℝ) < k := by linarith + have hbase : (0:ℝ) < (k:ℝ)*(k+1) := by positivity + have hlogv : 0 < Real.log v := Real.log_pos hv + have hlogk : 0 ≤ Real.log k := Real.log_nonneg (by linarith) + have he : 4*(k:ℝ)*B v*Real.log ((k:ℝ)*(k+1)) ≤ + (20*(k:ℝ)*Real.log k)*B v := by + have h := mul_le_mul_of_nonneg_left (terminal_allocation_log_le hk) + (show 0 ≤ 4*(k:ℝ)*B v by positivity) + nlinarith [mul_nonneg (mul_nonneg hk0.le hBv) hlogk] + have hh : ((k:ℝ)*(k+1))^(4*(k:ℝ)*B v) ≤ + (Real.log v)^(20*(k:ℝ)*Real.log k) := by + rw [Real.rpow_def_of_pos hbase,Real.rpow_def_of_pos hlogv] + apply Real.exp_le_exp.mpr + simpa only [B,mul_comm] using he + calc + _ ≤ (Real.log v)^(20*(k:ℝ)*Real.log k)*Real.log v := + mul_le_mul_of_nonneg_right hh hlogv.le + _ = _ := by rw [Real.rpow_add hlogv,Real.rpow_one] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TerminalMassSeries.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalMassSeries.lean new file mode 100644 index 0000000000000000000000000000000000000000..c34073e1812bd5b0c13e161722cc1a9835d18eec --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalMassSeries.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.TotientAsymptotic.QuarterPowerBudget + +namespace OAI + +/-! The smooth residual mass is summable against terminal-coordinate decay. -/ +noncomputable section +open scoped BigOperators Topology +open Filter +namespace TotientAsymptotic + +def terminalMassWeight (c : ℝ) (k : ℕ) : ℝ := + Real.exp (10*(Real.log ((k:ℝ)+5))^2-c*k) + +lemma terminalMassWeight_pos (c : ℝ) (k : ℕ) : 0 < terminalMassWeight c k := Real.exp_pos _ + +theorem summable_terminalMassWeight {c : ℝ} (hc : 0 < c) : + Summable (terminalMassWeight c) := by + let q := Real.exp (-c/2) + have hq0 : 0 ≤ q := (Real.exp_pos _).le + have hq1 : q < 1 := Real.exp_lt_one_iff.mpr (by linarith only [hc]) + apply (summable_geometric_of_lt_one hq0 hq1).of_norm_bounded_eventually_nat + filter_upwards [tendsto_natCast_atTop_atTop.eventually + (eventually_ge_atTop (((10000*((0:ℝ)+31)^2)/(c/4))^(4/3:ℝ))), + eventually_ge_atTop (1:ℕ)] with k hk hk1 + have hk0 : (1:ℝ) ≤ k := by exact_mod_cast hk1 + have hb : 1 ≤ (k:ℝ)+1 := by linarith only [hk0] + have hthreshold : ((10000*((0:ℝ)+31)^2)/(c/4))^(4/3:ℝ) ≤ (k:ℝ)+1 := by + linarith only [hk] + have hbudget := four_thirds_threshold_budget hb (le_refl (0:ℝ)) + (show 0 < c/4 by linarith only [hc]) hthreshold + have hlog : 0 ≤ Real.log ((k:ℝ)+5) := Real.log_nonneg (by linarith only [hk0]) + have he : 10*(Real.log ((k:ℝ)+5))^2-c*k ≤ -(c/2)*(k:ℝ) := by + simp only [add_zero] at hbudget + rw [show (k:ℝ)+1+4=(k:ℝ)+5 by ring] at hbudget + have hh : c/4*((k:ℝ)+1) ≤ (c/2)*(k:ℝ) := by nlinarith only [hc,hk0] + nlinarith only [hbudget,hh,hlog,sq_nonneg (Real.log ((k:ℝ)+5))] + rw [Real.norm_eq_abs,abs_of_pos (terminalMassWeight_pos c k)] + dsimp only [terminalMassWeight,q] + rw [← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + nlinarith only [he] + +lemma finite_terminal_mass_bound {c : ℝ} (hc : 0 < c) (I : Finset ℕ) : + (∑ k ∈ I,terminalMassWeight c k) ≤ ∑' k : ℕ,terminalMassWeight c k := + (summable_terminalMassWeight hc).sum_le_tsum _ (fun k _ => (terminalMassWeight_pos c k).le) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TerminalPrefixMassCount.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalPrefixMassCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..821ef467a9f32426d099266c79a990753a03fb74 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalPrefixMassCount.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.TotientAsymptotic.TerminalBandCount + +namespace OAI + +/-! Retain an arbitrary restriction on the prime prefix while counting a +terminal strip through its distinct residual totients. -/ +noncomputable section +open scoped BigOperators Topology +open Filter +namespace TotientAsymptotic + +theorem terminal_prefix_mass_count : ∃ D : ℝ,0 < D ∧ + ∀ᶠ x : ℝ in atTop,∀ K k : ℕ,∀ Q : Finset ℕ,∀ n : ℕ → ℕ, + (∀ v∈Q,0 < n v ∧ (n v).totient=v ∧ + x^(1/4:ℝ) ≤ fordPrime (n v) 0 ∧ (v:ℝ) ≤ x ∧ + K+1 ≤ (n v).primeFactorsList.length ∧ + fordPrime (n v) (K+1) < fordPrime (n v) K ∧ + fordPrimeCoordinate (n v) (K+1) ≤ (k:ℝ)+1) → + (Q.card:ℝ) ≤ D*(x/Real.log x)* + (∑ p∈Q.image (fun v => fordPrefixPrimes (n v) K),reciprocalShiftWeight p)* + Real.exp (10*(Real.log ((k:ℝ)+5))^2) := by + obtain ⟨D,hD,hres⟩ := smooth_terminal_mass_bound + refine ⟨64*D,by positivity,?_⟩ + filter_upwards [large_prime_product_value_count,eventually_gt_atTop (1:ℝ)] + with x hx hx1 + intro K k Q n hQ + let P := Q.image (fun v => fordPrefixPrimes (n v) K) + let R := Q.image (fun v => (fordCofactor (n v) (K+1)).totient) + have hRpos (d) (hd : d∈R) : 0 < d := by + obtain ⟨v,_,rfl⟩ := Finset.mem_image.mp hd + exact Nat.totient_pos.mpr (fordCofactor_pos _ _) + have hRmass : (∑ d∈R,(d:ℝ)⁻¹) ≤ D*Real.exp (10*(Real.log ((k:ℝ)+5))^2) := by + apply hres k (by positivity) R + intro d hd + obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hd + exact ⟨⟨fordCofactor (n v) (K+1),fordCofactor_pos _ _,rfl⟩, + small_terminal_smooth (by positivity) (hQ v hv).2.2.2.2.2.2⟩ + have hh := hx K P R Q (by + intro p hp i + obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hp + apply fordPrime_prime + have hlen := (hQ v hv).2.2.2.2.1 + have := i.isLt + omega) hRpos (by + intro v hv + obtain ⟨hn,hφ,hhead,hvx,hlen,hgap,_⟩ := hQ v hv + refine ⟨n v,fordPrime (n v) 0,hn,hφ,fordPrime_prime (by omega),?_,hhead,hvx,?_⟩ + · have he := fordCofactor_step (n v) 0 + rw [fordCofactor_zero hn] at he + exact ⟨fordCofactor (n v) 1,he⟩ + · apply Finset.mem_image.mpr + refine ⟨(fordPrefixPrimes (n v) K,(fordCofactor (n v) (K+1)).totient), + Finset.mem_product.mpr ⟨Finset.mem_image.mpr ⟨v,hv,rfl⟩, + Finset.mem_image.mpr ⟨v,hv,rfl⟩⟩,?_⟩ + have he := (strict_gap_residual_totient (n:=n v) (j:=K+1) hn (by omega) hlen hgap).symm + change (fordCofactor (n v) (K+1)).totient * + (∏ i : Fin K,fordPrime (n v) (i.val+1)).totient = _ + rw [Fin.prod_univ_eq_prod_range (fun i => fordPrime (n v) (i+1))] at he ⊢ + simpa only [Nat.add_sub_cancel] using he) + apply hh.trans + have hcoef : 0 ≤ (64*x/Real.log x)*(∑ p∈P,reciprocalShiftWeight p) := + mul_nonneg (div_nonneg (by positivity) (Real.log_pos hx1).le) + (Finset.sum_nonneg (fun p _ => reciprocalShiftWeight_nonneg p)) + have hh' := mul_le_mul_of_nonneg_left hRmass hcoef + convert hh' using 1; dsimp only [P]; ring + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TerminalPrimeGap.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalPrimeGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..5282cf5c87ee9e79c479c03935ea5303f561d345 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalPrimeGap.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.TotientAsymptotic.SmallTerminalPrefix + +namespace OAI + +/-! A valid Ford row forbids three consecutive equal positive coordinates. -/ +noncomputable section +open scoped BigOperators +namespace TotientAsymptotic + +lemma ford_first_two_coefficient_sum : (32/25:ℝ) ≤ a 1+a 2 := by + have he : a 1+a 2=3*Real.log 3-2 := by norm_num [a]; ring + rw [he] + linarith [Real.log_three_gt_d9] + +lemma ford_row_forbids_flat_triple {x : ℝ} {n L i : ℕ} + (hi : i+2 ≤ L) (hpos : 0 < fordPrimeCoordinate n i) + (h1 : fordPrimeCoordinate n (i+1)=fordPrimeCoordinate n i) + (h2 : fordPrimeCoordinate n (i+2)=fordPrimeCoordinate n i) + (hrow : fordRowSum L (fordPrimeCoordinate n) i ≤ xi x i*fordPrimeCoordinate n i) : False := by + have hs : a 1*fordPrimeCoordinate n (i+1)+a 2*fordPrimeCoordinate n (i+2) ≤ + fordRowSum L (fordPrimeCoordinate n) i := by + calc + _ = ∑ r ∈ ({i+1,i+2}:Finset ℕ),a (r-i)*fordPrimeCoordinate n r := by + simp + _ ≤ _ := by + apply Finset.sum_le_sum_of_subset_of_nonneg + · intro r hr + rcases Finset.mem_insert.mp hr with rfl | hr + · exact Finset.mem_Icc.mpr (by omega) + · have he := Finset.mem_singleton.mp hr + subst r + exact Finset.mem_Icc.mpr (by omega) + · intro r hr _ + have hr := Finset.mem_Icc.mp hr + exact mul_nonneg (a_pos (by omega)).le (le_max_left _ _) + have hxi : xi x i ≤ (10001/10000:ℝ) := by + have he : Real.exp (-((m x-i:ℕ):ℝ)/40) ≤ 1 := Real.exp_le_one_iff.mpr + (by have := Nat.cast_nonneg (α:=ℝ) (m x-i); linarith) + unfold xi + linarith only [he] + rw [h1,h2] at hs + have ha := mul_le_mul_of_nonneg_right ford_first_two_coefficient_sum hpos.le + have hb := mul_le_mul_of_nonneg_right hxi hpos.le + nlinarith only [hs,hrow,ha,hb,hpos] + +/-- At one of the last two boundaries there is a strict prime gap, and the +residual largest coordinate is exactly the final one. -/ +lemma terminal_strict_prime_gap {x : ℝ} {n L : ℕ} (hL : 3 ≤ L) + (hpos : 0 < fordPrimeCoordinate n L) + (hrow : fordRowSum L (fordPrimeCoordinate n) (L-2) ≤ + xi x (L-2)*fordPrimeCoordinate n (L-2)) : + ∃ j : ℕ,L-1 ≤ j ∧ j ≤ L ∧ + fordPrime n j < fordPrime n (j-1) ∧ + fordPrimeCoordinate n j=fordPrimeCoordinate n L := by + have hprev := ford_coordinate_antitone n (show L-1 ≤ L by omega) + by_cases hgap : fordPrimeCoordinate n L < fordPrimeCoordinate n (L-1) + · exact ⟨L,by omega,le_rfl,fordPrime_lt_of_coordinate_lt hgap,rfl⟩ + have he : fordPrimeCoordinate n (L-1)=fordPrimeCoordinate n L := le_antisymm (le_of_not_gt hgap) hprev + have hprev' := ford_coordinate_antitone n (show L-2 ≤ L-1 by omega) + have hgap' : fordPrimeCoordinate n (L-1) < fordPrimeCoordinate n (L-2) := by + by_contra hh + have he' : fordPrimeCoordinate n (L-2)=fordPrimeCoordinate n (L-1) := + le_antisymm (le_of_not_gt hh) hprev' + apply ford_row_forbids_flat_triple (i:=L-2) (by omega) (by linarith only [he,he',hpos]) + ?_ ?_ hrow + · simpa only [show L-2+1=L-1 by omega] using he'.symm + · simpa only [show L-2+2=L by omega] using (he'.trans he).symm + refine ⟨L-1,le_rfl,by omega,?_,he⟩ + have hh := fordPrime_lt_of_coordinate_lt hgap' + simpa only [Nat.sub_sub] using hh + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TerminalSliceCount.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalSliceCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..756f391dcbdb5d965f29f90c786e81e92bc2a101 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalSliceCount.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TotientAsymptotic.TerminalBandCount + +namespace OAI + +/-! Sum the actual terminal-coordinate strips using their finite residual masses. -/ +noncomputable section +open scoped BigOperators Topology +open Filter +namespace TotientAsymptotic + +theorem terminal_slice_value_count (H : ℕ) : ∃ C : ℝ,0 < C ∧ + ∀ᶠ x : ℝ in atTop,∀ N : ℕ,N+2+H=m x → + ∀ Q : Finset ℕ,∀ n : ℕ → ℕ, + (∀ v ∈ Q,0 < n v ∧ (n v).totient=v ∧ + x^(1/4:ℝ) ≤ fordPrime (n v) 0 ∧ (v:ℝ) ≤ x ∧ + N+2 ≤ (n v).primeFactorsList.length ∧ + fordPrime (n v) (N+2) < fordPrime (n v) (N+1) ∧ + 2 < fordPrimeCoordinate (n v) (N+2) ∧ + ∀ i < N+2,fordRowSum (m x) (fordPrimeCoordinate (n v)) i ≤ + xi x i*(if i=0 then B x else fordPrimeCoordinate (n v) i)) → + (Q.card:ℝ) ≤ C*(x/Real.log x)*G x (N+1) := by + classical + obtain ⟨A,c,hA,hc,hcount⟩ := terminal_band_value_count H + let T := ∑' k : ℕ,terminalMassWeight c k + have hT : 0 ≤ T := tsum_nonneg (fun k => (terminalMassWeight_pos c k).le) + refine ⟨A*(T+1),by positivity,?_⟩ + filter_upwards [hcount,eventually_gt_atTop (1:ℝ), + B_tendsto.eventually (eventually_gt_atTop (0:ℝ))] with x hx hx1 hB + intro N hNm Q n hQ + let key : ℕ → ℕ := fun v => ⌊fordPrimeCoordinate (n v) (N+2)⌋₊ + let I := Q.image key + let R (k : ℕ) := Q.filter (fun v => key v=k) + have hcover : Q ⊆ I.biUnion R := by + intro v hv + exact Finset.mem_biUnion.mpr ⟨key v,Finset.mem_image.mpr ⟨v,hv,rfl⟩, + Finset.mem_filter.mpr ⟨hv,rfl⟩⟩ + have hcard : (Q.card:ℝ) ≤ ∑ k ∈ I,((R k).card:ℝ) := by + exact_mod_cast (Finset.card_le_card hcover).trans Finset.card_biUnion_le + have hrow (k : ℕ) (hk : k ∈ I) : ((R k).card:ℝ) ≤ + A*(x/Real.log x)*G x (N+1)*terminalMassWeight c k := by + obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hk + have hk2 : 2 ≤ key v := Nat.le_floor (hQ v hv).2.2.2.2.2.2.1.le + apply hx N hNm (key v) hk2 (R (key v)) n + intro w hw + obtain ⟨hw,hkey⟩ := Finset.mem_filter.mp hw + obtain ⟨hn,hφ,hhead,hwx,hlen,hgap,hlarge,hrows⟩ := hQ w hw + refine ⟨hn,hφ,hhead,hwx,hlen,hgap,?_,?_,hrows⟩ + · rw [← hkey] + exact Nat.floor_le (le_max_left _ _) + · rw [← hkey] + exact (Nat.lt_floor_add_one _).le + have hfac : 0 ≤ A*(x/Real.log x)*G x (N+1) := by + have hlog := Real.log_pos hx1 + have hG := G_pos hB (N+1) + positivity + calc + _ ≤ ∑ k ∈ I,((R k).card:ℝ) := hcard + _ ≤ ∑ k ∈ I,A*(x/Real.log x)*G x (N+1)*terminalMassWeight c k := + Finset.sum_le_sum hrow + _ = (A*(x/Real.log x)*G x (N+1))*(∑ k ∈ I,terminalMassWeight c k) := by + rw [Finset.mul_sum] + _ ≤ (A*(x/Real.log x)*G x (N+1))*T := + mul_le_mul_of_nonneg_left (finite_terminal_mass_bound hc I) hfac + _ ≤ (A*(x/Real.log x)*G x (N+1))*(T+1) := + mul_le_mul_of_nonneg_left (by linarith) hfac + _ = _ := by ring + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TerminalStateCount.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalStateCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..01e557d11042cc87482f1822fedec884443fadaa --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalStateCount.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TotientAsymptotic.BandStates +import OAI.NumberTheory.TotientAsymptotic.TupleRecovery +import OAI.NumberTheory.TotientAsymptotic.ResidualFactorCount + +namespace OAI + +/-! Exact multiplicity bounds for the final smooth factor states. -/ +noncomputable section +open scoped BigOperators +attribute [local instance] Classical.propDecidable +namespace TotientAsymptotic + +def terminalRight {k : ℕ} (t : ShiftedPair k) : Fin (k+1) → ℕ := + Fin.cons t.remainder t.right + +lemma terminalRight_product {k : ℕ} (t : ShiftedPair k) : + (∏ j,terminalRight t j)=t.remainder*(∏ j,t.right j) := by + simp only [terminalRight,Fin.prod_univ_succ,Fin.cons_zero,Fin.cons_succ] + +lemma terminal_state_encoding_injective {k : ℕ} : + Function.Injective (fun t : ShiftedPair k => (t.left,terminalRight t)) := by + intro t s he + have hl : t.left=s.left := congrArg Prod.fst he + have hr : terminalRight t=terminalRight s := congrArg Prod.snd he + have he₀ : t.remainder=s.remainder := congrFun hr 0 + have he₁ : t.right=s.right := by + funext j + exact congrFun hr j.succ + cases t + cases s + cases hl + cases he₁ + cases he₀ + rfl + +lemma terminal_state_card_le {k d s : ℕ} (hd : 0 < d) (hs : 0 < s) + (Q : Finset (ShiftedPair k)) + (hQ : ∀ t ∈ Q,factorProduct t=s ∧ d*factorProduct t=t.remainder*(∏ j,t.right j)) : + Q.card ≤ (k+1)^d.primeFactorsList.length*(k*(k+1))^s.primeFactorsList.length := by + classical + let L := Q.image (fun t => t.left) + let R := Q.image terminalRight + let E := Q.image (fun t => (t.left,terminalRight t)) + have hE : E ⊆ L ×ˢ R := by + intro w hw + obtain ⟨t,ht,rfl⟩ := Finset.mem_image.mp hw + exact Finset.mem_product.mpr ⟨Finset.mem_image.mpr ⟨t,ht,rfl⟩,Finset.mem_image.mpr ⟨t,ht,rfl⟩⟩ + have hc := ordered_factorization_pairs_card_le s (d*s) hs (Nat.mul_pos hd hs) L R + (by + intro f hf + obtain ⟨t,ht,rfl⟩ := Finset.mem_image.mp hf + exact (hQ t ht).1) + (by + intro f hf + obtain ⟨t,ht,rfl⟩ := Finset.mem_image.mp hf + rw [terminalRight_product,← (hQ t ht).2,(hQ t ht).1]) + have hcard : E.card=Q.card := Finset.card_image_of_injective Q terminal_state_encoding_injective + calc + Q.card=E.card := hcard.symm + _ ≤ (L ×ˢ R).card := Finset.card_le_card hE + _ ≤ k^s.primeFactorsList.length*(k+1)^(d*s).primeFactorsList.length := by + simpa only [Fintype.card_fin] using hc + _ = _ := by rw [omega_count_mul hd.ne' hs.ne',pow_add,mul_pow]; ring + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TerminalStateMass.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalStateMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..d5b9266695c17c0957660e4ce54a392c8b2c8dc9 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TerminalStateMass.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TotientAsymptotic.TerminalStateCount +import OAI.NumberTheory.TotientAsymptotic.SmoothResidualMass + +namespace OAI + +/-! The final smooth-state mass with its exact cancelled-product exponent. -/ +noncomputable section +open scoped BigOperators +attribute [local instance] Classical.propDecidable +namespace TotientAsymptotic + +theorem terminal_state_mass {k d N : ℕ} {L : ℝ} (hk : 1 ≤ k) (hd : 0 < d) + (Q : Finset (ShiftedPair k)) + (hQ : ∀ t ∈ Q,0 < factorProduct t ∧ + d*factorProduct t=t.remainder*(∏ j,t.right j) ∧ + largestPrimeFactor (factorProduct t) ≤ N ∧ + ((factorProduct t).primeFactorsList.length:ℝ) ≤ L) : + (∑ t ∈ Q,(factorProduct t:ℝ)⁻¹) ≤ + (k+1:ℝ)^d.primeFactorsList.length*((k:ℝ)*(k+1))^L*primeEulerProduct N := by + classical + let P := Q.image factorProduct + let W := (k+1:ℝ)^d.primeFactorsList.length*((k:ℝ)*(k+1))^L + have hW : 0 ≤ W := by dsimp [W]; positivity + have hmap : ∀ t ∈ Q,factorProduct t ∈ P := fun t ht => Finset.mem_image.mpr ⟨t,ht,rfl⟩ + have hP (s : ℕ) (hs : s ∈ P) : 0 < s ∧ largestPrimeFactor s ≤ N ∧ + (s.primeFactorsList.length:ℝ) ≤ L := by + obtain ⟨t,ht,rfl⟩ := Finset.mem_image.mp hs + exact ⟨(hQ t ht).1,(hQ t ht).2.2⟩ + have hfiber (s : ℕ) (hs : s ∈ P) : + (∑ t ∈ Q.filter (fun t => factorProduct t=s),(factorProduct t:ℝ)⁻¹) ≤ W*(s:ℝ)⁻¹ := by + let F := Q.filter (fun t => factorProduct t=s) + have hF : ∀ t ∈ F,factorProduct t=s ∧ d*factorProduct t=t.remainder*(∏ j,t.right j) := by + intro t ht + exact ⟨(Finset.mem_filter.mp ht).2,(hQ t (Finset.mem_filter.mp ht).1).2.1⟩ + have hc := terminal_state_card_le hd (hP s hs).1 F hF + have hcr : (F.card:ℝ) ≤ (k+1:ℝ)^d.primeFactorsList.length* + ((k:ℝ)*(k+1))^s.primeFactorsList.length := by exact_mod_cast hc + have hkR : (1:ℝ) ≤ k := by exact_mod_cast hk + have hb : (1:ℝ) ≤ (k:ℝ)*(k+1) := by nlinarith + have hp := Real.rpow_le_rpow_of_exponent_le hb (hP s hs).2.2 + rw [Real.rpow_natCast] at hp + have hcard : (F.card:ℝ) ≤ W := hcr.trans + (mul_le_mul_of_nonneg_left hp (by positivity)) + have he : (∑ t ∈ F,(factorProduct t:ℝ)⁻¹)=(F.card:ℝ)*(s:ℝ)⁻¹ := by + calc + _ = ∑ _t ∈ F,(s:ℝ)⁻¹ := Finset.sum_congr rfl (fun t ht => by rw [(hF t ht).1]) + _ = _ := by simp + rw [show Q.filter (fun t => factorProduct t=s)=F from rfl,he] + exact mul_le_mul_of_nonneg_right hcard (inv_nonneg.mpr (Nat.cast_nonneg s)) + calc + _ = ∑ s ∈ P,∑ t ∈ Q.filter (fun t => factorProduct t=s),(factorProduct t:ℝ)⁻¹ := + (Finset.sum_fiberwise_of_maps_to hmap (fun t => (factorProduct t:ℝ)⁻¹)).symm + _ ≤ ∑ s ∈ P,W*(s:ℝ)⁻¹ := Finset.sum_le_sum hfiber + _ = W*(∑ s ∈ P,(s:ℝ)⁻¹) := (Finset.mul_sum ..).symm + _ ≤ _ := mul_le_mul_of_nonneg_left + (smooth_residual_reciprocal_mass N P (fun s hs => ⟨(hP s hs).1,(hP s hs).2.1⟩)) hW + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/ThickenedWitness.lean b/lean/OAI/NumberTheory/TotientAsymptotic/ThickenedWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..78a323449ab911fa296308cec3d70e4a488636ad --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/ThickenedWitness.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.TotientAsymptotic.JoinedSimplex +import OAI.NumberTheory.TotientAsymptotic.PointEnclosure +import OAI.NumberTheory.TotientAsymptotic.TailCutScale + +namespace OAI + +/-! Thickening a discrete witness tail to its entire unit box preserves +membership in the same controlled full-dimensional enlargement. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter + +namespace TotientAsymptotic + +lemma thickened_witness_enclosure {x : ℝ} {H : ℕ} {η : TailDatum H} + (hs : 0 ≤ theta x) (hcut : 4 ≤ lam*(P H : ℝ)) + (hHm : H ≤ m x) (hPH : P H < H) (hB : 0 ≤ B x) + (hBr : 1 ≤ B x*rho^(m x)) (hη : IsWitness H (theta x) η) + {u : Fin (R x H) → ℝ} (hu : u ∈ tailPrefixRegion x H η) + (hprefix : ∀ i, 1 ≤ rho^(m x-(i.val+1))*u i) + {v : Fin (H-P H) → ℝ} (hv : ∀ i, |tailVector η i-v i| ≤ 1) : + joinCoordinates (R x H) (H-P H) (u,v) ∈ + enlargedSimplex (R x H+(H-P H)) (B x) (1+simplexBoxError 4 (m x)) + (fun i => 1+simplexBoxError 4 (m x-(i.val+1))) := by + have hP : 1 ≤ P H := by + by_contra hn + have hz : P H=0 := by omega + simp only [hz, Nat.cast_zero, mul_zero] at hcut + norm_num at hcut + have hsize : R x H+(H-P H) < m x := by unfold R; omega + apply point_cube_full_enclosure hsize hBr (join_witness_enlarged hη hPH hHm hB hu) + · intro i + refine Fin.addCases (fun j => ?_) (fun j => ?_) i + · simp only [joinCoordinates_left, sub_self, abs_zero, zero_le_one] + · simpa only [joinCoordinates_right] using hv j + · intro i + refine Fin.addCases (fun j => ?_) (fun j => ?_) i + · simpa only [Fin.val_castAdd, joinCoordinates_left] using hprefix j + · simp only [Fin.val_natAdd, joinCoordinates_right] + have hj := j.isLt + have he : m x-(R x H+j.val+1)=H-1-j.val := by unfold R; omega + have hmem : H-1-j.val ∈ Finset.Ico (P H) H := Finset.mem_Ico.mpr (by omega) + have hb := (hη.2.2.1 _ hmem).2.1 + have hband : (9/10 : ℝ)*bandScale x (R x H+j.val+1) ≤ tailVector η j := by + simpa only [bandScale, he, tailVector, mul_assoc] using hb + exact cube_band_lower hs hcut (by unfold R; omega) hband (hv j) + +/-- The prefix lower-bound hypothesis above is automatic uniformly over all +witnesses and all prefix points once the tail cut is large. -/ +theorem eventually_thickened_witness_enclosure (hren : FordRenewalInput) : + ∀ᶠ H : ℕ in atTop, ∀ {x : ℝ} {η : TailDatum H}, + 0 ≤ theta x → H ≤ m x → P H < H → 0 ≤ B x → + 1 ≤ B x*rho^(m x) → IsWitness H (theta x) η → + ∀ {u : Fin (R x H) → ℝ}, u ∈ tailPrefixRegion x H η → + ∀ {v : Fin (H-P H) → ℝ}, (∀ i, |tailVector η i-v i| ≤ 1) → + joinCoordinates (R x H) (H-P H) (u,v) ∈ + enlargedSimplex (R x H+(H-P H)) (B x) (1+simplexBoxError 4 (m x)) + (fun i => 1+simplexBoxError 4 (m x-(i.val+1))) := by + obtain ⟨c, hc, hlower⟩ := tailPrefixRegion_scaled_lower hren + have hgrow : Tendsto (fun H : ℕ => c*((H-1 : ℕ) : ℝ)) atTop atTop := + (tendsto_natCast_atTop_atTop.comp (tendsto_sub_atTop_nat 1)).const_mul_atTop hc + have hcut : Tendsto (fun H : ℕ => lam*(P H : ℝ)) atTop atTop := + (tendsto_natCast_atTop_atTop.comp P_tendsto).const_mul_atTop lam_pos + filter_upwards [hgrow.eventually (eventually_ge_atTop (1 : ℝ)), + hcut.eventually (eventually_ge_atTop (4 : ℝ))] with H hH hP + intro x η hs hHm hPH hB hBr hη u hu v hv + apply thickened_witness_enclosure hs hP hHm hPH hB hBr hη hu _ hv + intro i + exact hH.trans (hlower hs hη hPH hHm hu i) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/ThirdPrimeSize.lean b/lean/OAI/NumberTheory/TotientAsymptotic/ThirdPrimeSize.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2ec0d6b65d82c617f80e3e9d1cbbfd799dd870d --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/ThirdPrimeSize.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.TotientAsymptotic.FordCoordinateBounds + +namespace OAI + +/-! The complement of the two-coordinate exception has a small third prime. -/ +noncomputable section +namespace TotientAsymptotic + +lemma ford_coordinate_antitone (n : ℕ) {i j : ℕ} (hij : i ≤ j) : + fordPrimeCoordinate n j ≤ fordPrimeCoordinate n i := by + by_cases hj : j < n.primeFactorsList.length + · have hi : i < n.primeFactorsList.length := by omega + have hp := fordPrime_prime hj + have horder := fordPrime_antitone hi hj hij + have hB : primeDoubleLog n j ≤ primeDoubleLog n i := + Real.log_le_log (Real.log_pos (by exact_mod_cast hp.one_lt)) + (Real.log_le_log (by exact_mod_cast hp.pos) (by exact_mod_cast horder)) + exact max_le_max le_rfl hB + · have he : fordPrime n j=1 := by + unfold fordPrime + rw [List.getElem?_eq_none (by simpa using Nat.le_of_not_gt hj)] + rfl + simp only [fordPrimeCoordinate,primeDoubleLog,he,Nat.cast_one,Real.log_one,Real.log_zero,max_self] + exact le_max_left _ _ + +lemma third_coordinate_bound {x : ℝ} {n : ℕ} + (hscore : a 1*fordPrimeCoordinate n 1+a 2*fordPrimeCoordinate n 2 ≤ (101/100:ℝ)*B x) : + fordPrimeCoordinate n 2 ≤ (4/5:ℝ)*B x := by + have ha := first_two_a_bounds + have hsum : (32/25:ℝ) ≤ a 1+a 2 := by + have he : a 1+a 2=3*Real.log 3-2 := by norm_num [a]; ring + rw [he] + linarith [Real.log_three_gt_d9] + have horder := ford_coordinate_antitone n (show 1 ≤ 2 by norm_num) + have hnon : 0 ≤ fordPrimeCoordinate n 2 := le_max_left _ _ + have h1 := mul_le_mul_of_nonneg_left horder ha.1.le + have h2 := mul_le_mul_of_nonneg_right hsum hnon + nlinarith only [hscore,h1,h2,hnon] + +lemma third_prime_size {x : ℝ} {n : ℕ} (hx : 1 < x) + (hscore : a 1*fordPrimeCoordinate n 1+a 2*fordPrimeCoordinate n 2 ≤ (101/100:ℝ)*B x) : + (fordPrime n 2:ℝ) ≤ Real.exp ((Real.log x)^(4/5:ℝ)) := by + have hcoord := third_coordinate_bound hscore + have hraw : B (fordPrime n 2) ≤ (4/5:ℝ)*B x := (le_max_right _ _).trans hcoord + by_cases hi : 2 < n.primeFactorsList.length + · have hp := fordPrime_prime hi + have hplog : 0 < Real.log (fordPrime n 2) := Real.log_pos (by exact_mod_cast hp.one_lt) + have hxp : 0 < Real.log x := Real.log_pos hx + have hh := Real.exp_le_exp.mpr (Real.exp_le_exp.mpr hraw) + rw [B,Real.exp_log hplog,Real.exp_log (by exact_mod_cast hp.pos)] at hh + convert hh using 1 + rw [Real.rpow_def_of_pos hxp] + congr 2 + unfold B + ring + · have he : fordPrime n 2=1 := by + unfold fordPrime + rw [List.getElem?_eq_none (by simpa using Nat.le_of_not_gt hi)] + rfl + rw [he,Nat.cast_one] + exact Real.one_le_exp (Real.rpow_nonneg (Real.log_pos hx).le _) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TopRowCount.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TopRowCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa9d65302ce90779ce8cfd9009361ae62c3d6d3e --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TopRowCount.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.TotientAsymptotic.FailedRowCutoff +import OAI.NumberTheory.TotientAsymptotic.FordDimensionScale + +namespace OAI + +/-! Failure of the initial Ford simplex row has a uniform Gaussian saving. -/ +noncomputable section +open scoped BigOperators Topology +open Filter +namespace TotientAsymptotic + +theorem top_row_failure_count : ∃ C : ℝ,0 < C ∧ + ∀ᶠ x : ℝ in atTop, ∀ Ψ : ℕ, Ψ ≤ m x → ∀ Q : Finset ℕ, + (∀ v ∈ Q,∃ n : ℕ,0 < n ∧ n.totient=v ∧ (v:ℝ) ≤ x ∧ + xi x 0*B x < fordRowSum (m x) (fordPrimeCoordinate n) 0) → + (Q.card:ℝ) ≤ C*(x/Real.log x)*G x (m x)*Real.exp (-(Ψ:ℝ)^2/4) := by + obtain ⟨C,F,hC,hF,hcount⟩ := real_coordinate_deviation + refine ⟨C,hC,?_⟩ + filter_upwards [dimension_row_model_budget hF.le,central_volume_one_le, + eventually_ge_atTop (512:ℝ),eventually_ge_atTop (2*Real.exp (Real.exp 1)), + B_tendsto.eventually (eventually_gt_atTop (0:ℝ))] with x hb hG hx hxexp hB + intro Ψ hΨ Q hQ + let k := m x + let ω : ℝ := Real.exp (-(k:ℝ)/40)/10000 + have hω : 0 < ω := by dsimp [ω]; positivity + have hω1 : ω ≤ 1 := by + have he : Real.exp (-(k:ℝ)/40) ≤ 1 := Real.exp_le_one_iff.mpr + (by have := Nat.cast_nonneg (α:=ℝ) k; linarith) + dsimp [ω] + linarith only [he] + have hmodel : coordinateDecay (ω/4) k=rowModelDecay k := by + dsimp [coordinateDecay,rowModelDecay,ω] + ring + have hbudget := failed_row_cutoff_budget hF.le hω hω1 k + obtain ⟨_,_,_,_,_,_,hthreshold,_,_⟩ := hbudget + rw [failed_row_cutoff_loglog,hmodel] at hthreshold + have hthreshold' : max 300000000 ((coordinateBudgetConstant F/coordinateDecay (ω/4) k)^(4/3:ℝ)) ≤ B x-1 := by + rw [hmodel] + exact hthreshold.trans (by dsimp [k] at *; linarith only [hb.1]) + have hc := hcount x hx hxexp k (ω/4) (by linarith) (by linarith) hthreshold' Q (by + intro v hv + obtain ⟨n,hn,hφ,hvx,hrow⟩ := hQ v hv + refine ⟨⟨n,hn,hφ⟩,hvx,n,hn,hφ,?_⟩ + have hxi : xi x 0=1+ω := by dsimp [xi,ω,k]; ring + rw [hxi] at hrow + have hsum : fordRowSum (m x) (fordPrimeCoordinate n) 0 = + ∑ i : Fin k,a (i.val+1)*fordPrimeCoordinate n (i.val+1) := by + simpa only [Nat.sub_zero,fordCofactor_zero hn] using + (fordRowSum_cofactor (n:=n) (L:=m x) (j:=0) (Nat.zero_le _)) + rw [hsum] at hrow + have hh := mul_le_mul_of_nonneg_right (show 1+ω/4 ≤ 1+ω by linarith) hB.le + exact hh.trans hrow.le) + have hΨsq : (Ψ:ℝ)^2 ≤ (m x:ℝ)^2 := by + have hle : (Ψ:ℝ) ≤ m x := by exact_mod_cast hΨ + nlinarith only [hle,Nat.cast_nonneg (α:=ℝ) Ψ,Nat.cast_nonneg (α:=ℝ) (m x)] + have hsave : Real.exp (-coordinateDecay (ω/4) k*B x) ≤ Real.exp (-(Ψ:ℝ)^2/4) := by + apply Real.exp_le_exp.mpr + rw [hmodel] + dsimp [k] + linarith only [hb.2,hΨsq] + have hx1 : 1 < x := by linarith only [hx] + have hfac : 0 ≤ C*(x/Real.log x) := mul_nonneg hC.le + (div_nonneg (by linarith only [hx]) (Real.log_pos hx1).le) + calc + _ ≤ C*(x/Real.log x)*Real.exp (-coordinateDecay (ω/4) k*B x) := by + simpa only [div_eq_mul_inv,mul_assoc] using hc + _ ≤ C*(x/Real.log x)*Real.exp (-(Ψ:ℝ)^2/4) := mul_le_mul_of_nonneg_left hsave hfac + _ ≤ _ := by + have hh := mul_le_mul_of_nonneg_left hG hfac + simpa only [mul_one] using mul_le_mul_of_nonneg_right hh (Real.exp_pos _).le + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TotientCountingEnvelope.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TotientCountingEnvelope.lean new file mode 100644 index 0000000000000000000000000000000000000000..b56f588834919a6ad421978fa3403b4bd946e509 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TotientCountingEnvelope.lean @@ -0,0 +1,97 @@ +import OAI.NumberTheory.TotientAsymptotic.FiniteDyadicHarmonic +import OAI.NumberTheory.TotientAsymptotic.TupleTotients + +namespace OAI + +/-! The finite dyadic counting envelope used to bootstrap the global upper bound. -/ +noncomputable section +open scoped BigOperators +namespace TotientAsymptotic + +def dyadicTotientEnvelope (J : ℕ) : ℝ := + max 1 ((Finset.range (J+1)).sup' (by simp) + (fun k => V ((2:ℝ)^k)*(k:ℝ)/(2:ℝ)^k)) + +lemma dyadicTotientEnvelope_one_le (J : ℕ) : 1 ≤ dyadicTotientEnvelope J := le_max_left _ _ + +lemma dyadicTotientEnvelope_mono {I J : ℕ} (hIJ : I ≤ J) : + dyadicTotientEnvelope I ≤ dyadicTotientEnvelope J := by + unfold dyadicTotientEnvelope + apply max_le_max le_rfl + exact Finset.sup'_mono (s₁ := Finset.range (I+1)) (s₂ := Finset.range (J+1)) + (fun k : ℕ => V ((2:ℝ)^k)*(k:ℝ)/(2:ℝ)^k) + (Finset.range_mono (Nat.add_le_add_right hIJ 1)) (by simp) + +lemma dyadicTotientEnvelope_term_le {k J : ℕ} (hkJ : k ≤ J) : + V ((2:ℝ)^k)*(k:ℝ)/(2:ℝ)^k ≤ dyadicTotientEnvelope J := by + unfold dyadicTotientEnvelope + have hs : k ∈ Finset.range (J+1) := Finset.mem_range.mpr (by omega) + exact (Finset.le_sup' (s:=Finset.range (J+1)) + (fun k => V ((2:ℝ)^k)*(k:ℝ)/(2:ℝ)^k) hs).trans (le_max_right _ _) + +lemma dyadic_totient_count_le {k J : ℕ} (hk : 1 ≤ k) (hkJ : k ≤ J) : + V ((2:ℝ)^k) ≤ dyadicTotientEnvelope J*(2:ℝ)^k/(k:ℝ) := by + have hk0 : (0:ℝ) < k := by exact_mod_cast hk + have hpow : (0:ℝ) < 2^k := by positivity + have he := dyadicTotientEnvelope_term_le hkJ + apply (le_div_iff₀ hk0).mpr + exact (div_le_iff₀ hpow).mp he + +lemma totient_values_subset {x y : ℝ} (hxy : x ≤ y) : totientValues x ⊆ totientValues y := by + classical + intro v hv + obtain ⟨hv,ht⟩ := Finset.mem_filter.mp hv + exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr + ⟨(Finset.mem_Icc.mp hv).1,(Finset.mem_Icc.mp hv).2.trans (Nat.floor_mono hxy)⟩,ht⟩ + +lemma V_monotone : Monotone V := by + intro x y hxy + exact Nat.cast_le.mpr (Finset.card_le_card (totient_values_subset hxy)) + +lemma dyadic_totient_reciprocal_mass {J : ℕ} (_hJ : 1 ≤ J) (Q : Finset ℕ) + (hQ : ∀ v ∈ Q,IsTotient v ∧ (v:ℝ) ≤ (2:ℝ)^J) : + (∑ v ∈ Q,(v:ℝ)⁻¹) ≤ 1+4*dyadicTotientEnvelope J*(1+Real.log J) := by + classical + let E := Q.erase 1 + have hE (v : ℕ) (hv : v ∈ E) : IsTotient v ∧ 1 < v ∧ (v:ℝ) ≤ (2:ℝ)^J := by + obtain ⟨hne,hv⟩ := Finset.mem_erase.mp hv + have h := hQ v hv + exact ⟨h.1,by have := isTotient_pos h.1; omega,h.2⟩ + have hn : ∀ v ∈ E,Nat.clog 2 v ∈ Finset.Icc 1 J := by + intro v hv + have hb := dyadic_nat_bounds (hE v hv).2.1 + refine Finset.mem_Icc.mpr ⟨hb.1,?_⟩ + apply (Nat.clog_le_iff_le_pow (by decide : 1 < 2)).mpr + exact_mod_cast (hE v hv).2.2 + have hcount (k : ℕ) (hk : k ∈ Finset.Icc 1 J) : + ((E.filter (fun v => Nat.clog 2 v=k)).card:ℝ) ≤ + dyadicTotientEnvelope J*(2:ℝ)^k/(k:ℝ) := by + have hsub : E.filter (fun v => Nat.clog 2 v=k) ⊆ totientValues ((2:ℝ)^k) := by + intro v hv + obtain ⟨hv,he⟩ := Finset.mem_filter.mp hv + have h := hE v hv + have hb := (dyadic_nat_bounds h.2.1).2.2 + rw [he] at hb + exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr ⟨isTotient_pos h.1,Nat.le_floor hb⟩,h.1⟩ + exact (Nat.cast_le.mpr (Finset.card_le_card hsub)).trans + (dyadic_totient_count_le (Finset.mem_Icc.mp hk).1 (Finset.mem_Icc.mp hk).2) + have hm := finite_dyadic_harmonic_mass E (Nat.clog 2) (fun v => (v:ℝ)) J + (zero_le_one.trans (dyadicTotientEnvelope_one_le J)) hn (by + intro v hv + have hh := (dyadic_nat_bounds (hE v hv).2.1).2.1 + have hp : (0:ℝ) < 2^(Nat.clog 2 v) := by positivity + linarith) hcount + have hs : (∑ v ∈ Q,(v:ℝ)⁻¹) ≤ 1+∑ v ∈ E,(v:ℝ)⁻¹ := by + by_cases h1 : 1 ∈ Q + · rw [← Finset.add_sum_erase Q _ h1] + norm_num [E] + · have he : E=Q := Finset.erase_eq_of_notMem h1 + rw [he] + linarith + exact hs.trans (add_le_add le_rfl hm) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TotientPreimageBound.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TotientPreimageBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..adf1af6e584e211517b73fe21b4d21c1b10eb9b7 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TotientPreimageBound.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.TotientAsymptotic.TotientRatioLogLog + +namespace OAI + +/-! Concrete preimage bounds for the finite totient counting reductions. -/ +noncomputable section +open scoped BigOperators +namespace TotientAsymptotic + +lemma prime_le_shift_square {p : ℕ} (hp : p.Prime) (hp2 : p ≠ 2) : p ≤ (p-1)^2 := by + have h3 : 3 ≤ p := by have := hp.two_le; omega + have he : p-1+1=p := by omega + nlinarith + +lemma radical_le_twice_shift_product_square (n : ℕ) : + (∏ p ∈ n.primeFactors,p) ≤ 2*(∏ p ∈ n.primeFactors,(p-1))^2 := by + let E := n.primeFactors.erase 2 + have hprod : (∏ p ∈ E,p) ≤ (∏ p ∈ E,(p-1))^2 := by + rw [← Finset.prod_pow] + apply Finset.prod_le_prod + intro p hp + exact prime_le_shift_square (Nat.prime_of_mem_primeFactors (Finset.mem_of_mem_erase hp)) + (Finset.mem_erase.mp hp).1 + by_cases h2 : 2 ∈ n.primeFactors + · have hrad := Finset.mul_prod_erase n.primeFactors (fun p : ℕ => p) h2 + have hshift := Finset.mul_prod_erase n.primeFactors (fun p : ℕ => p-1) h2 + norm_num only [Nat.reduceSub,one_mul] at hshift + rw [← hrad,← hshift] + exact Nat.mul_le_mul_left 2 hprod + · have hE : E=n.primeFactors := Finset.erase_eq_of_notMem h2 + rw [hE] at hprod + omega + +lemma totient_preimage_quadratic {n : ℕ} (hn : 0 < n) : n ≤ 2*n.totient^2 := by + let r := ∏ p ∈ n.primeFactors,p + let s := ∏ p ∈ n.primeFactors,(p-1) + have hr : 0 < r := Finset.prod_pos (fun p hp => (Nat.prime_of_mem_primeFactors hp).pos) + have hs : 0 < s := Finset.prod_pos (fun p hp => by have := (Nat.prime_of_mem_primeFactors hp).two_le; omega) + obtain ⟨w,hw⟩ := n.prod_primeFactors_dvd + change n=r*w at hw + have hw0 : 0 < w := by nlinarith + have he := Nat.totient_mul_prod_primeFactors n + change n.totient*r=n*s at he + have hφ : n.totient=w*s := by + apply Nat.eq_of_mul_eq_mul_left hr + rw [Nat.mul_comm r n.totient,he,hw] + ring + have hrad : r ≤ 2*s^2 := radical_le_twice_shift_product_square n + rw [hφ,hw] + nlinarith [Nat.mul_le_mul_right w hrad,show w ≤ w^2 by nlinarith] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TotientRatioLogLog.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TotientRatioLogLog.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1234866ca7e568244937ec6c5d49370d7377159 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TotientRatioLogLog.lean @@ -0,0 +1,128 @@ +import OAI.NumberTheory.TotientAsymptotic.MertensProduct +import OAI.NumberTheory.TotientAsymptotic.CanceledPrimeMass + +namespace OAI + +/-! A uniform log-log bound for the elementary totient ratio. -/ +noncomputable section +open scoped BigOperators +namespace TotientAsymptotic + +lemma totient_factor_large_prime {p : ℕ} (hp : p.Prime) {L : ℝ} + (hL : 0 Nat.prime_of_mem_primeFactors (hT hp) + have hprod0 : (0:ℝ)<(∏ p ∈ T,p : ℕ) := by + exact_mod_cast Finset.prod_pos (fun p hp => (hprimes p hp).pos) + have hdvd : (∏ p ∈ T,p) ∣ b := + (Finset.prod_dvd_prod_of_subset T b.primeFactors id hT).trans b.prod_primeFactors_dvd + have hsum : (∑ p ∈ T,Real.log p) ≤ L := by + have he : Real.log ((∏ p ∈ T,p : ℕ):ℝ) = ∑ p ∈ T,Real.log p := by + rw [Nat.cast_prod,Real.log_prod (fun p hp => by exact_mod_cast (hprimes p hp).ne_zero)] + rw [← he] + exact (Real.log_le_log hprod0 (by exact_mod_cast Nat.le_of_dvd hb hdvd)).trans hbL + calc + _ ≤ ∏ p ∈ T,Real.exp (4*Real.log p/L) := by + apply Finset.prod_le_prod₀ + · intro p hp + have hp1 : (1:ℝ)

(p:ℝ)≤Real.log x) + let T := b.primeFactors.filter (fun p : ℕ => ¬(p:ℝ)≤Real.log x) + have hsmall : (∏ p ∈ S,(p:ℝ)/(p-1)) ≤ primeEulerProduct ⌊Real.log x⌋₊ := by + apply Finset.prod_le_prod_of_subset_of_one_le₀ + · intro p hp + obtain ⟨hpb,hpL⟩ := Finset.mem_filter.mp hp + exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr + ⟨(Nat.prime_of_mem_primeFactors hpb).two_le,Nat.le_floor hpL⟩, + Nat.prime_of_mem_primeFactors hpb⟩ + · intro p hp + have hp1 : (1:ℝ)

(le_of_not_ge (Finset.mem_filter.mp hp).2)) + have hsmall0 : 0 ≤ ∏ p ∈ S,(p:ℝ)/(p-1) := by + apply Finset.prod_nonneg + intro p hp + have hp1 : (1:ℝ)

(p:ℝ)≤Real.log x) (fun p => (p:ℝ)/(p-1))).symm + have hlN : Real.log (⌊Real.log x⌋₊:ℝ) ≤ Real.log (Real.log x) := + Real.log_le_log (by exact_mod_cast (show 0<⌊Real.log x⌋₊ by omega)) + (Nat.floor_le (by linarith)) + calc + (b:ℝ)/b.totient = _ := hsplit + _ ≤ primeEulerProduct ⌊Real.log x⌋₊ * Real.exp 4 := + mul_le_mul hsmall hlarge (Finset.prod_nonneg (fun p hp => by + have hp1 : (1:ℝ)

N+2-i.val) + ↑(Finset.univ : Finset (Fin (N+1))) := by + intro i _ j _ he + apply Fin.ext + change N+2-i.val=N+2-j.val at he + have := i.isLt + have := j.isLt + omega + have he (i : Fin (N+1)) : Real.exp (-c*((N+2-i.val:ℕ):ℝ))=q^(N+2-i.val) := by + dsimp [q] + rw [←Real.exp_nat_mul] + congr 1 + ring + simp_rw [he] + rw [←Finset.sum_image hinj] + have hs := hasSum_geometric_of_lt_one hq hq1 + simpa only [one_div,q] using + (hs.summable.sum_le_tsum _ (fun k _ => pow_nonneg hq k)).trans_eq hs.tsum_eq + +theorem translated_prefix_inversions : ∃ A c s : ℝ,0 < A ∧ 0 < c ∧ 0 < s ∧ + ∀ (N : ℕ) (B t T : ℝ),0 < B → 0 ≤ T → s*T ≤ B → + (∀ i : Fin (N+1),rho^(i.val+1)*T ≤ + renewalBackground (N+2) t i.castSucc-renewalBackground (N+2) t i.succ) → + volume.real {u : Fin (N+2) → ℝ | u ∈ prefixRegion (N+2) B 0 0 ∧ + ¬StrictAnti (fun i => u i+renewalBackground (N+2) t i)} ≤ + (Real.exp (A-s*(N+2:ℝ)*T/B)/(1-Real.exp (-c)))* + volume.real (prefixRegion (N+2) B 0 0) := by + classical + obtain ⟨A,c,s,hA,hc,hs,hbound⟩ := prefix_gap_volume + refine ⟨A,c,s,hA,hc,hs,?_⟩ + intro N B t T hB hT hTB hgap + let S := prefixRegion (N+2) B 0 0 + let E (i : Fin (N+1)) := S ∩ + {u | u i.castSucc-u i.succ ≤ -rho^(i.val+1)*T} + have hsub : {u : Fin (N+2) → ℝ | u ∈ S ∧ + ¬StrictAnti (fun i => u i+renewalBackground (N+2) t i)} ⊆ ⋃ i,E i := by + intro u hu + have hn := hu.2 + rw [Fin.strictAnti_iff_succ_lt] at hn + push Not at hn + obtain ⟨i,hi⟩ := hn + apply Set.mem_iUnion.mpr + refine ⟨i,hu.1,?_⟩ + have hg := hgap i + change u i.castSucc-u i.succ ≤ -rho^(i.val+1)*T + nlinarith only [hi,hg] + have hfinite : volume (⋃ i,E i) ≠ ⊤ := by + apply ne_top_of_le_ne_top (show volume S ≠ ⊤ from ?_) + (measure_mono (by intro u hu; obtain ⟨i,hi⟩ := Set.mem_iUnion.mp hu; exact hi.1)) + dsimp [S] + rw [volume_prefixRegion_explicit (N+2) (by omega)] + exact ENNReal.ofReal_ne_top + have hmeasure := ENNReal.toReal_mono hfinite (measure_mono hsub) + apply hmeasure.trans + apply (measureReal_iUnion_fintype_le E).trans + have hsum := Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => hbound N i B T hB hT hTB) + apply hsum.trans + have he (i : Fin (N+1)) : + Real.exp (A-c*((N+2-i.val:ℕ):ℝ)-s*(N+2:ℝ)*T/B)= + Real.exp (A-s*(N+2:ℝ)*T/B)*Real.exp (-c*((N+2-i.val:ℕ):ℝ)) := by + rw [←Real.exp_add] + congr 1 + ring + simp_rw [he] + rw [←Finset.sum_mul,←Finset.mul_sum] + have hh := mul_le_mul_of_nonneg_left (finite_gap_exponential_sum hc N) + (Real.exp_pos (A-s*(N+2:ℝ)*T/B)).le + simpa only [div_eq_mul_inv,mul_assoc,one_mul,S] using + mul_le_mul_of_nonneg_right hh (show 0 ≤ volume.real S from ENNReal.toReal_nonneg) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TranslatedPrefix.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TranslatedPrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..68bb0853fc7aa6e81931646805be7ac518775ec5 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TranslatedPrefix.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.TotientAsymptotic.RenewalBackground +import OAI.NumberTheory.TotientAsymptotic.SimplexVolume + +namespace OAI + +/-! A renewal translate gives strict positive slack without losing dimension. -/ +noncomputable section +open scoped BigOperators +open MeasureTheory +namespace TotientAsymptotic + +lemma renewal_translate_prefix {N : ℕ} {B t : ℝ} (ht : 0 ≤ t) + {u : Fin N → ℝ} + (hu : u ∈ prefixRegion N (B-t*(g (N+1)-a (N+1))) 0 0) : + u+renewalBackground N t ∈ prefixRegion N B 0 0 ∧ + ∀ i,t*a (N-i.val) ≤ prefixLinear N (u+renewalBackground N t) i := by + have hslack (i : Fin N) : t*a (N-i.val) ≤ + prefixLinear N (u+renewalBackground N t) i := by + rw [map_add,Pi.add_apply,renewalBackground_slack] + have hh := hu.1 i + change 0 ≤ prefixLinear N u i at hh + linarith only [hh] + refine ⟨⟨?_,?_⟩,hslack⟩ + · intro i + exact (mul_nonneg ht (a_pos (by have := i.isLt; omega)).le).trans (hslack i) + · change (∑ i : Fin N,a (i.val+1)*(u i+renewalBackground N t i)) ≤ B-0 + simp only [mul_add,Finset.sum_add_distrib,renewalBackground_top,sub_zero] + have hh := hu.2 + simp only [sub_zero] at hh + linarith only [hh] + +lemma renewal_translated_volume (N : ℕ) (hN : 0 < N) (B t : ℝ) : + volume {v : Fin N → ℝ | + v-renewalBackground N t ∈ + prefixRegion N (B-t*(g (N+1)-a (N+1))) 0 0} = + ENNReal.ofReal ((max (B-t*(g (N+1)-a (N+1))) 0)^N/ + ((N.factorial:ℝ)*∏ i : Fin N,g (i.val+1))) := by + have hh := measure_preimage_add_right (volume : Measure (Fin N → ℝ)) + (-renewalBackground N t) (prefixRegion N (B-t*(g (N+1)-a (N+1))) 0 0) + change volume ((fun v => v-renewalBackground N t) ⁻¹' + prefixRegion N (B-t*(g (N+1)-a (N+1))) 0 0)=_ + rw [show (fun v : Fin N → ℝ => v-renewalBackground N t)= + (fun v => v+(-renewalBackground N t)) by rfl,hh] + rw [volume_prefixRegion_explicit N hN] + simp only [Pi.zero_apply,mul_zero,Finset.sum_const_zero,sub_zero] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TripleDensity.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TripleDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..aee286b997ffd3401900054c072928da426fc4af --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TripleDensity.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.TotientAsymptotic.TripleSieveModel + +namespace OAI + +/-! Exact multiplicative residue proportions for the three-form sieve. -/ +noncomputable section +open scoped BigOperators +namespace TotientAsymptotic + +lemma tripleRootCount_one (a b : ℕ) : tripleRootCount 1 a b = 1 := by + rw [tripleRootCount_eq_count 1 a b (by norm_num),Nat.count_one] + simp [tripleSievePolynomial] + +lemma tripleRootCount_prod (a b : ℕ) (S : Finset ℕ) (hS : ∀ p ∈ S,p.Prime) : + tripleRootCount (∏ p ∈ S,p) a b = ∏ p ∈ S,tripleRootCount p a b := by + classical + induction S using Finset.induction_on with + | empty => simpa using tripleRootCount_one a b + | @insert p S hp ih => + have hprime := hS p (Finset.mem_insert_self _ _) + have hS' : ∀ q ∈ S,q.Prime := fun q hq => hS q (Finset.mem_insert_of_mem hq) + have hcop : p.Coprime (∏ q ∈ S,q) := by + apply Nat.Coprime.prod_right + intro q hq + apply hprime.coprime_iff_not_dvd.mpr + intro hd + have he := (Nat.prime_dvd_prime_iff_eq hprime (hS' q hq)).mp hd + exact hp (he ▸ hq) + rw [Finset.prod_insert hp,tripleRootCount_mul hprime.ne_zero + (Finset.prod_ne_zero_iff.mpr (fun q hq => (hS' q hq).ne_zero)) hcop, + ih hS',Finset.prod_insert hp] + +lemma tripleRootCount_density (a b d : ℕ) (hd : Squarefree d) : + (tripleRootCount d a b:ℝ) = d*tripleSieveDensity a b d := by + classical + have hprod : ∏ p ∈ d.primeFactors,p = d := Nat.prod_primeFactors_of_squarefree hd + have hcount : tripleRootCount d a b = ∏ p ∈ d.primeFactors,tripleRootCount p a b := by + conv_lhs => rw [← hprod] + exact tripleRootCount_prod a b d.primeFactors (fun p hp => Nat.prime_of_mem_primeFactors hp) + have hdensity : tripleSieveDensity a b d = + ∏ p ∈ d.primeFactors,(tripleRootCount p a b:ℝ)/p := + ArithmeticFunction.prodPrimeFactors_apply hd.ne_zero + calc + _ = ∏ p ∈ d.primeFactors,(tripleRootCount p a b:ℝ) := by rw [hcount,Nat.cast_prod] + _ = ∏ p ∈ d.primeFactors,(p:ℝ)*((tripleRootCount p a b:ℝ)/p) := by + apply Finset.prod_congr rfl + intro p hp + have hp0 : (p:ℝ) ≠ 0 := by exact_mod_cast (Nat.prime_of_mem_primeFactors hp).ne_zero + field_simp + _ = _ := by rw [Finset.prod_mul_distrib,hdensity,← Nat.cast_prod,hprod] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TripleDiscriminant.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TripleDiscriminant.lean new file mode 100644 index 0000000000000000000000000000000000000000..a9fb335b9d80c258cad9a356af5c28a63b028bbe --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TripleDiscriminant.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.TotientAsymptotic.TripleSieveDenominator + +namespace OAI + +/-! Exactly the primes dividing ab(b-a) can merge roots of the three forms. -/ +noncomputable section +namespace TotientAsymptotic + +def tripleDiscriminant (a b : ℕ) : ℕ := a*b*(b-a) + +lemma tripleDiscriminant_pos {a b : ℕ} (ha : 0 < a) (hab : a < b) : + 0 < tripleDiscriminant a b := + Nat.mul_pos (Nat.mul_pos ha (ha.trans hab)) (Nat.sub_pos_of_lt hab) + +lemma tripleRootCount_of_not_dvd {a b p : ℕ} (hab : a < b) (hp : p.Prime) + (hd : ¬p ∣ tripleDiscriminant a b) : tripleRootCount p a b = 3 := by + let _ : Fact p.Prime := ⟨hp⟩ + have ha : ¬p ∣ a := fun h => hd (dvd_mul_of_dvd_left (dvd_mul_of_dvd_left h b) (b-a)) + have hb : ¬p ∣ b := fun h => hd (dvd_mul_of_dvd_left (dvd_mul_of_dvd_right h a) (b-a)) + have hdiff : ¬p ∣ b-a := fun h => hd (dvd_mul_of_dvd_right h (a*b)) + have hneq : (a:ZMod p) ≠ b := by + intro he + apply hdiff + apply (ZMod.natCast_eq_zero_iff (b-a) p).mp + rw [Nat.cast_sub hab.le,he,sub_self] + rw [tripleRootCount_eq_card] + exact tripleSieveRoots_card_eq_three p a b ha hb hneq + +lemma tripleRootCount_bounds (a b p : ℕ) (hp : p.Prime) : + 1 ≤ tripleRootCount p a b ∧ tripleRootCount p a b ≤ 3 := by + let _ : Fact p.Prime := ⟨hp⟩ + rw [tripleRootCount_eq_card] + exact ⟨Finset.card_pos.mpr ⟨0,zero_mem_tripleSieveRoots p a b⟩,tripleSieveRoots_card_le p a b⟩ + +lemma tripleSieveWeight_euler_factor {a b p : ℕ} (hab : a < b) (hp : p.Prime) + (hp3 : 3 < p) : ((p:ℝ)/(p-1))^3 ≤ + (1+tripleSieveWeight a b p)* + (if p ∣ tripleDiscriminant a b then ((p:ℝ)/(p-1))^2 else 1) := by + have hpR : (3:ℝ) < p := by exact_mod_cast hp3 + have hb := tripleRootCount_bounds a b p hp + have hk1 : (1:ℝ) ≤ tripleRootCount p a b := by exact_mod_cast hb.1 + have hk3 : (tripleRootCount p a b:ℝ) ≤ 3 := by exact_mod_cast hb.2 + have he : 1+tripleSieveWeight a b p = (p:ℝ)/(p-tripleRootCount p a b) := by + rw [tripleSieveWeight,tripleSieveDensity_prime a b p hp] + field_simp [show (p:ℝ)-(tripleRootCount p a b:ℝ) ≠ 0 by linarith] + ring + rw [he] + split_ifs with hd + · have hsingle : (p:ℝ)/(p-1) ≤ (p:ℝ)/(p-tripleRootCount p a b) := by + apply div_le_div_of_nonneg_left (by linarith) (by linarith) + linarith + have hh := mul_le_mul_of_nonneg_right hsingle (sq_nonneg ((p:ℝ)/(p-1))) + nlinarith + · rw [tripleRootCount_of_not_dvd hab hp hd,mul_one] + norm_num only [Nat.cast_ofNat] + rw [div_pow] + apply (div_le_div_iff₀ (pow_pos (by linarith : (0:ℝ) < p-1) 3) (by linarith)).mpr + nlinarith + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TripleEulerProduct.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TripleEulerProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..a72ac15f54a1ce4ebb825d57b13b38eb772812d6 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TripleEulerProduct.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.TotientAsymptotic.TripleDiscriminant +import OAI.NumberTheory.TotientAsymptotic.SieveEulerProduct + +namespace OAI + +/-! The dimension-three lower bound for the collision sieve's Euler product. -/ +noncomputable section +open scoped BigOperators +namespace TotientAsymptotic + +lemma tripleEulerProduct_eq (z : ℕ) (hz : 3 ≤ z) : + primeEulerProduct z = 3*∏ p ∈ tripleSievePrimes z,(p:ℝ)/(p-1) := by + classical + have hthree : 3 ∈ oddSievePrimes z := by norm_num [mem_oddSievePrimes,hz] + have hs : tripleSievePrimes z = (oddSievePrimes z).erase 3 := by + ext p + simp only [mem_tripleSievePrimes,mem_oddSievePrimes,Finset.mem_erase] + constructor + · rintro ⟨hpz,hpp,hp3⟩ + exact ⟨by omega,hpz,hpp,by omega⟩ + · rintro ⟨hp3,hpz,hpp,hp2⟩ + have hp := hpp.two_le + exact ⟨hpz,hpp,by omega⟩ + rw [oddEulerProduct_eq z (by omega),hs,← Finset.mul_prod_erase _ _ hthree] + norm_num + ring + +lemma tripleEulerProduct_log_lower (z : ℕ) (hz : 3 ≤ z) : + Real.log z/3 ≤ ∏ p ∈ tripleSievePrimes z,(p:ℝ)/(p-1) := by + have h := primeEulerProduct_log_lower z + rw [tripleEulerProduct_eq z hz] at h + linarith + +lemma triple_exceptional_product_le_totient {D : ℕ} (hD : 0 < D) (z : ℕ) : + (∏ p ∈ tripleSievePrimes z,if p ∣ D then ((p:ℝ)/(p-1))^2 else 1) ≤ + ((D:ℝ)/D.totient)^2 := by + classical + have hp : (∏ p ∈ (tripleSievePrimes z).filter (fun p => p ∣ D),(p:ℝ)/(p-1)) ≤ + (D:ℝ)/D.totient := by + rw [totient_ratio_product hD] + apply Finset.prod_le_prod_of_subset_of_one_le₀ + · intro p hp + obtain ⟨hp,hd⟩ := Finset.mem_filter.mp hp + exact Nat.mem_primeFactors.mpr ⟨(mem_tripleSievePrimes.mp hp).2.1,hd,hD.ne'⟩ + · intro p hp + have hpp := (mem_tripleSievePrimes.mp (Finset.mem_filter.mp hp).1).2.1 + have hp1 : (1:ℝ) < p := by exact_mod_cast hpp.one_lt + exact div_nonneg (Nat.cast_nonneg _) (by linarith) + · intro p hp _ + have hp1 : (1:ℝ) < p := by exact_mod_cast (Nat.prime_of_mem_primeFactors hp).one_lt + apply (le_div_iff₀ (by linarith : (0:ℝ) < p-1)).mpr + linarith + rw [← Finset.prod_filter,Finset.prod_pow] + apply pow_le_pow_left₀ _ hp 2 + apply Finset.prod_nonneg + intro p hp + have hp1 : (1:ℝ) < p := by + exact_mod_cast (mem_tripleSievePrimes.mp (Finset.mem_filter.mp hp).1).2.1.one_lt + exact div_nonneg (Nat.cast_nonneg _) (by linarith) + +lemma tripleSieveEulerProduct_lower {a b : ℕ} (ha : 0 < a) (hab : a < b) + (z : ℕ) (hz : 3 ≤ z) : + (Real.log z)^3/27 ≤ (∏ p ∈ tripleSievePrimes z,(1+tripleSieveWeight a b p))* + ((tripleDiscriminant a b:ℝ)/(tripleDiscriminant a b).totient)^2 := by + have hfactor : (∏ p ∈ tripleSievePrimes z,(p:ℝ)/(p-1))^3 ≤ + (∏ p ∈ tripleSievePrimes z,(1+tripleSieveWeight a b p))* + (∏ p ∈ tripleSievePrimes z,if p ∣ tripleDiscriminant a b then ((p:ℝ)/(p-1))^2 else 1) := by + rw [← Finset.prod_pow,← Finset.prod_mul_distrib] + apply Finset.prod_le_prod₀ + · intro p hp + have hpR : (3:ℝ) < p := by exact_mod_cast (mem_tripleSievePrimes.mp hp).2.2 + exact pow_nonneg (div_nonneg (Nat.cast_nonneg _) (by linarith)) 3 + · intro p hp + exact tripleSieveWeight_euler_factor hab (mem_tripleSievePrimes.mp hp).2.1 + (mem_tripleSievePrimes.mp hp).2.2 + have hp : 0 ≤ ∏ p ∈ tripleSievePrimes z,(1+tripleSieveWeight a b p) := + Finset.prod_nonneg (fun p hp => by have := tripleSieveWeight_nonneg a b hp; linarith) + have he := mul_le_mul_of_nonneg_left + (triple_exceptional_product_le_totient (tripleDiscriminant_pos ha hab) z) hp + have hl := pow_le_pow_left₀ (show 0 ≤ Real.log z/3 by + have hz1 : (1:ℝ) ≤ z := by exact_mod_cast (show 1 ≤ z by omega) + exact div_nonneg (Real.log_nonneg hz1) (by norm_num)) + (tripleEulerProduct_log_lower z hz) 3 + calc + _ = (Real.log z/3)^3 := by ring + _ ≤ _ := hl + _ ≤ _ := hfactor.trans he + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TriplePrimeBound.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TriplePrimeBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..9f12812f03df0f06d0e9efe6a1c8afb6e0bf073e --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TriplePrimeBound.lean @@ -0,0 +1,39 @@ +import OAI.NumberTheory.TotientAsymptotic.TripleEulerProduct +import OAI.NumberTheory.TotientAsymptotic.TripleSieveError + +namespace OAI + +/-! Elimination of Selberg's auxiliary quantities in the three-form bound. -/ +noncomputable section +open scoped BigOperators +open SelbergSieve +namespace TotientAsymptotic + +lemma triplePrimeTuples_log_bound {a b : ℕ} (ha : 0 < a) (hab : a < b) (X z : ℕ) + (y : ℝ) (hy : 1 < y) (hz : 3 ≤ z) + (hscale : 12*Real.log 4*(2+Real.log z) ≤ Real.log y) : + ((triplePrimeTuples a b X z).card:ℝ) ≤ + 54*X*((tripleDiscriminant a b:ℝ)/(tripleDiscriminant a b).totient)^2/(Real.log z)^3+2*y^3 := by + let s := triplePrimeSieve a b X z y hy.le + let P := ∏ p ∈ tripleSievePrimes z,(1+tripleSieveWeight a b p) + let R : ℝ := ((tripleDiscriminant a b:ℝ)/(tripleDiscriminant a b).totient)^2 + have hR : 0 ≤ R := sq_nonneg _ + have hD : 0 < selbergBoundingSum s := selbergBoundingSum_pos s + have hlog : 0 < Real.log z := Real.log_pos (by exact_mod_cast (show 1 < z by omega)) + have hP : P/2 ≤ selbergBoundingSum s := + tripleSieveBoundingSum_lower a b X z y hy (by omega) hscale + have hprod : (Real.log z)^3/27 ≤ P*R := tripleSieveEulerProduct_lower ha hab z hz + have hden : (Real.log z)^3 ≤ 54*selbergBoundingSum s*R := by + have hh := mul_le_mul_of_nonneg_right hP hR + nlinarith + have hmain : (X:ℝ)/selbergBoundingSum s ≤ 54*X*R/(Real.log z)^3 := by + apply (div_le_div_iff₀ hD (pow_pos hlog 3)).mpr + have hh := mul_le_mul_of_nonneg_left hden (Nat.cast_nonneg X : (0:ℝ) ≤ X) + nlinarith + exact (triplePrimeTuples_bound a b X z y hy.le).trans (add_le_add hmain le_rfl) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCRT.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCRT.lean new file mode 100644 index 0000000000000000000000000000000000000000..17dc4af80979cf5e2c934294a2209ccc5331343c --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCRT.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.TotientAsymptotic.TripleSieveRoots +import OAI.NumberTheory.TotientAsymptotic.PeriodicSieveCount + +namespace OAI + +/-! Exact CRT and interval discrepancies for the three-form collision sieve. -/ +noncomputable section +namespace TotientAsymptotic + +def tripleSievePolynomial (a b q : ℕ) : ℕ := q*(a*q+1)*(b*q+1) + +def tripleRootCount (d a b : ℕ) : ℕ := + Nat.card {r : ZMod d // r*((a:ZMod d)*r+1)*((b:ZMod d)*r+1)=0} + +lemma tripleRootCount_eq_card (d a b : ℕ) [NeZero d] : + tripleRootCount d a b = (tripleSieveRoots d a b).card := by + rw [tripleRootCount,Nat.card_eq_fintype_card,Fintype.card_subtype] + rfl + +lemma tripleRootCount_mul {m n : ℕ} (hm : m ≠ 0) (hn : n ≠ 0) + (hcop : m.Coprime n) (a b : ℕ) : + tripleRootCount (m*n) a b = tripleRootCount m a b*tripleRootCount n a b := by + let _ : NeZero m := ⟨hm⟩ + let _ : NeZero n := ⟨hn⟩ + let e := ZMod.chineseRemainder hcop + have he (r : ZMod (m*n)) : r*((a:ZMod (m*n))*r+1)*((b:ZMod (m*n))*r+1)=0 ↔ + (e r).1*((a:ZMod m)*(e r).1+1)*((b:ZMod m)*(e r).1+1)=0 ∧ + (e r).2*((a:ZMod n)*(e r).2+1)*((b:ZMod n)*(e r).2+1)=0 := by + calc + _ ↔ e (r*((a:ZMod (m*n))*r+1)*((b:ZMod (m*n))*r+1))=0 := e.map_eq_zero_iff.symm + _ ↔ _ := by + simp only [map_mul,map_add,map_natCast,map_one,Prod.ext_iff] + rfl + let ep : {r : ZMod (m*n) // r*((a:ZMod (m*n))*r+1)*((b:ZMod (m*n))*r+1)=0} ≃ + {r : ZMod m × ZMod n // + r.1*((a:ZMod m)*r.1+1)*((b:ZMod m)*r.1+1)=0 ∧ + r.2*((a:ZMod n)*r.2+1)*((b:ZMod n)*r.2+1)=0} := + e.toEquiv.subtypeEquiv he + let ee := ep.trans (Equiv.subtypeProdEquivProd + (p := fun r : ZMod m => r*((a:ZMod m)*r+1)*((b:ZMod m)*r+1)=0) + (q := fun r : ZMod n => r*((a:ZMod n)*r+1)*((b:ZMod n)*r+1)=0)) + unfold tripleRootCount + rw [Nat.card_eq_fintype_card,Nat.card_eq_fintype_card,Nat.card_eq_fintype_card] + exact (Fintype.card_congr ee).trans (Fintype.card_prod _ _) + +lemma tripleRootCount_eq_count (d a b : ℕ) (hd : 0 < d) : + tripleRootCount d a b = Nat.count (fun q => d ∣ tripleSievePolynomial a b q) d := by + let _ : NeZero d := ⟨hd.ne'⟩ + let e : {q : ℕ // q ⟨q.val,by + have hh := (ZMod.natCast_eq_zero_iff (tripleSievePolynomial a b q.val) d).mpr q.property.2 + simpa only [tripleSievePolynomial,Nat.cast_mul,Nat.cast_add,Nat.cast_one] using hh⟩ + invFun := fun r => ⟨r.val.val,ZMod.val_lt r.val,by + apply (ZMod.natCast_eq_zero_iff (tripleSievePolynomial a b r.val.val) d).mp + simpa only [tripleSievePolynomial,Nat.cast_mul,Nat.cast_add,Nat.cast_one, + ZMod.natCast_zmod_val] using r.property⟩ + left_inv := fun q => by apply Subtype.ext; exact ZMod.val_natCast_of_lt q.property.1 + right_inv := fun r => by apply Subtype.ext; exact ZMod.natCast_zmod_val r.val } + let _ : Fintype {q : ℕ // q d ∣ tripleSievePolynomial a b q) d + rw [Nat.count_eq_card_fintype] + exact (Nat.card_congr e).symm.trans Nat.card_eq_fintype_card + +lemma tripleSievePolynomial_mod (a b d q : ℕ) : + tripleSievePolynomial a b q % d = tripleSievePolynomial a b (q%d) % d := by + simp [tripleSievePolynomial,Nat.add_mod,Nat.mul_mod] + +lemma tripleSieve_count_error (a b d : ℕ) (hd : 0 < d) (N : ℕ) : + |(Nat.count (fun q => d ∣ tripleSievePolynomial a b q) N:ℝ)- + (N:ℝ)/d*(tripleRootCount d a b:ℝ)| ≤ d := by + rw [tripleRootCount_eq_count d a b hd] + apply count_periodic_error d hd + intro q + simp only [Nat.dvd_iff_mod_eq_zero,tripleSievePolynomial_mod a b d q] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCount.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..d01e4509d84f42fd5a6fc5b0c18bd2b2aa38ea04 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCount.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.TotientAsymptotic.TripleDensity + +namespace OAI + +/-! The actual simultaneous primes counted by the three-form sieve. -/ +noncomputable section +open scoped BigOperators +open BoundingSieve SelbergSieve +namespace TotientAsymptotic + +def triplePrimeTuples (a b X z : ℕ) : Finset ℕ := + (Finset.Icc 1 X).filter (fun q => q.Prime ∧ (a*q+1).Prime ∧ (b*q+1).Prime ∧ + z < q ∧ z < a*q+1 ∧ z < b*q+1) + +lemma triplePrimeTuples_coprime {a b X z q : ℕ} (hq : q ∈ triplePrimeTuples a b X z) : + (∏ p ∈ tripleSievePrimes z,p).Coprime (tripleSievePolynomial a b q) := by + obtain ⟨_,hq,ha,hb,hzq,hza,hzb⟩ := Finset.mem_filter.mp hq + apply Nat.coprime_of_dvd + intro p hp hpd hpv + have hpz := (mem_tripleSievePrimes.mp (mem_tripleSievePrimes_of_dvd hp hpd)).1 + change p ∣ q*(a*q+1)*(b*q+1) at hpv + rcases hp.dvd_mul.mp hpv with hqa|hb' + · rcases hp.dvd_mul.mp hqa with hq'|ha' + · have he := (Nat.prime_dvd_prime_iff_eq hp hq).mp hq' + omega + · have he := (Nat.prime_dvd_prime_iff_eq hp ha).mp ha' + omega + · have he := (Nat.prime_dvd_prime_iff_eq hp hb).mp hb' + omega + +lemma triplePrimeTuples_le_sifted (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) : + ((triplePrimeTuples a b X z).card:ℝ) ≤ + siftedSum (s := (triplePrimeSieve a b X z y hy).toBoundingSieve) := by + let f := tripleSievePolynomial a b + have hinj := (tripleSievePolynomial_strictMono a b).injective + have hsubset : (triplePrimeTuples a b X z).image f ⊆ + ((Finset.Icc 1 X).image f).filter + (fun n => (∏ p ∈ tripleSievePrimes z,p).Coprime n) := by + intro n hn + obtain ⟨q,hq,rfl⟩ := Finset.mem_image.mp hn + exact Finset.mem_filter.mpr ⟨Finset.mem_image.mpr ⟨q,(Finset.mem_filter.mp hq).1,rfl⟩, + triplePrimeTuples_coprime hq⟩ + have hh := Finset.card_le_card hsubset + rw [Finset.card_image_of_injective _ hinj] at hh + have he : siftedSum (s := (triplePrimeSieve a b X z y hy).toBoundingSieve) = + (((Finset.Icc 1 X).image f).filter + (fun n => (∏ p ∈ tripleSievePrimes z,p).Coprime n)).card := by + change (∑ d ∈ (Finset.Icc 1 X).image f, + if (∏ p ∈ tripleSievePrimes z,p).Coprime d then (1:ℝ) else 0) = _ + rw [← Finset.sum_filter] + simp + rw [he] + exact_mod_cast hh + +lemma triplePrimeSieve_multSum (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) (d : ℕ) : + multSum (s := (triplePrimeSieve a b X z y hy).toBoundingSieve) d = + (((Finset.Icc 1 X).filter (fun q => d ∣ tripleSievePolynomial a b q)).card:ℝ) := by + simp only [multSum,triplePrimeSieve] + rw [Finset.sum_image] + · simp only [Finset.sum_boole] + · exact fun r _ s _ h => (tripleSievePolynomial_strictMono _ _).injective h + +lemma triplePrimeSieve_rem_le (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) {d : ℕ} + (hd : Squarefree d) : + |rem (s := (triplePrimeSieve a b X z y hy).toBoundingSieve) d| ≤ d+1 := by + rw [rem,triplePrimeSieve_multSum] + change |(((Finset.Icc 1 X).filter (fun q => d ∣ tripleSievePolynomial a b q)).card:ℝ)- + tripleSieveDensity a b d*(X:ℝ)| ≤ d+1 + have he : (X:ℝ)/d*(tripleRootCount d a b:ℝ) = tripleSieveDensity a b d*(X:ℝ) := by + rw [tripleRootCount_density a b d hd] + field_simp [show (d:ℝ) ≠ 0 by exact_mod_cast hd.ne_zero] + rw [← he] + calc + _ ≤ |(((Finset.Icc 1 X).filter (fun q => d ∣ tripleSievePolynomial a b q)).card:ℝ)- + (Nat.count (fun q => d ∣ tripleSievePolynomial a b q) X:ℝ)|+ + |(Nat.count (fun q => d ∣ tripleSievePolynomial a b q) X:ℝ)- + (X:ℝ)/d*(tripleRootCount d a b:ℝ)| := abs_sub_le _ _ _ + _ ≤ 1+d := add_le_add (interval_count_discrepancy _ X) + (tripleSieve_count_error a b d (Nat.pos_of_ne_zero hd.ne_zero) X) + _ = _ := by ring + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCutoff.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e7fcd71b7418b30b90261a7053f01f3de09da69 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCutoff.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.TotientAsymptotic.SieveCutoff + +namespace OAI + +/-! The existing small-power cutoff also supports sieve dimension three. -/ +noncomputable section +namespace TotientAsymptotic + +lemma tripleSieveCutoff_three {L : ℝ} (hL : 512*Real.log 4 ≤ L) : + 3 ≤ shiftedPrimeCutoff L := by + have hc : 0 < Real.log (4:ℝ) := Real.log_pos (by norm_num) + have hz := shiftedPrimeCutoff_bounds hL + have hlow : (2:ℝ) ≤ L/(256*Real.log 4) := (le_div_iff₀ (by positivity)).mpr (by linarith) + have hp : (0:ℝ) < shiftedPrimeCutoff L := by exact_mod_cast (show 0 < shiftedPrimeCutoff L by omega) + have hh := Real.log_le_sub_one_of_pos hp + have hthree : (3:ℝ) ≤ shiftedPrimeCutoff L := by linarith [hz.2.1] + exact_mod_cast hthree + +lemma tripleSieveCutoff_scale {L : ℝ} (hL : 512*Real.log 4 ≤ L) : + 12*Real.log 4*(2+Real.log (shiftedPrimeCutoff L)) ≤ Real.log (Real.exp (L/4)) := by + have hc : 0 < Real.log (4:ℝ) := Real.log_pos (by norm_num) + have hh := (shiftedPrimeCutoff_bounds hL).2.2.1 + have hm := mul_le_mul_of_nonneg_left hh (show 0 ≤ 12*Real.log 4 by positivity) + have he : 12*Real.log 4*(L/(128*Real.log 4))=3*L/32 := by field_simp; ring + rw [he] at hm + rw [Real.log_exp] + nlinarith + +lemma tripleSieveCutoff_error {L : ℝ} (hL : 512*Real.log 4 ≤ L) : + (shiftedPrimeCutoff L:ℝ)+2*(Real.exp (L/4))^3 ≤ 1152*Real.exp L/L^3 := by + have hc : 0 < Real.log (4:ℝ) := Real.log_pos (by norm_num) + have hL0 : 0 < L := by nlinarith + have he : (Real.exp (L/4))^3 = Real.exp (3*L/4) := by + rw [← Real.exp_nat_mul]; congr 1; ring + have hcube := Real.pow_div_factorial_le_exp (L/4) (show 0 ≤ L/4 by positivity) 3 + norm_num only [Nat.factorial] at hcube + have hsmall : L^3 ≤ 384*Real.exp (L/4) := by nlinarith + have hm := mul_le_mul_of_nonneg_right hsmall (Real.exp_pos (3*L/4)).le + have hsum : Real.exp (L/4)*Real.exp (3*L/4)=Real.exp L := by + rw [← Real.exp_add]; congr 1; ring + have hbound : 3*Real.exp (3*L/4) ≤ 1152*Real.exp L/L^3 := by + apply (le_div_iff₀ (pow_pos hL0 3)).mpr + rw [mul_assoc,hsum] at hm + nlinarith + rw [he] + exact (by linarith [(shiftedPrimeCutoff_bounds hL).2.2.2] : + (shiftedPrimeCutoff L:ℝ)+2*Real.exp (3*L/4) ≤ 3*Real.exp (3*L/4)).trans hbound + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveDenominator.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveDenominator.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2c33e7ca050bd80a49dbe63e835b7876d090a7d --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveDenominator.lean @@ -0,0 +1,145 @@ +import OAI.NumberTheory.TotientAsymptotic.TripleSieveModel +import OAI.NumberTheory.TotientAsymptotic.FiniteSieveMass +import OAI.NumberTheory.TotientAsymptotic.MertensLogMass + +namespace OAI + +/-! A finite Euler-product lower bound for the concrete Selberg denominator. -/ +noncomputable section +open scoped BigOperators +open BoundingSieve SelbergSieve +namespace TotientAsymptotic + +def tripleSieveWeight (a b p : ℕ) : ℝ := + tripleSieveDensity a b p / (1-tripleSieveDensity a b p) + +lemma tripleSieveWeight_nonneg (a b : ℕ) {z p : ℕ} (hp : p ∈ tripleSievePrimes z) : + 0 ≤ tripleSieveWeight a b p := by + obtain ⟨_,hpp,hp2⟩ := mem_tripleSievePrimes.mp hp + exact div_nonneg (tripleSieveDensity_positive a b p hpp).le + (sub_pos.mpr (tripleSieveDensity_lt_one a b p hpp hp2)).le + +lemma tripleSieveWeight_moment (a b : ℕ) {z p : ℕ} (hp : p ∈ tripleSievePrimes z) : + tripleSieveWeight a b p * Real.log p / (1+tripleSieveWeight a b p) = + tripleSieveDensity a b p * Real.log p := by + obtain ⟨_,hpp,hp2⟩ := mem_tripleSievePrimes.mp hp + have hn : 1-tripleSieveDensity a b p ≠ 0 := + (sub_pos.mpr (tripleSieveDensity_lt_one a b p hpp hp2)).ne' + have hn' : 1+tripleSieveWeight a b p ≠ 0 := by + have := tripleSieveWeight_nonneg a b hp + linarith + unfold tripleSieveWeight + field_simp + ring + +lemma tripleSieve_moment_le (a b z : ℕ) (hz : 2 ≤ z) : + (∑ p ∈ tripleSievePrimes z, + tripleSieveWeight a b p * Real.log p / (1+tripleSieveWeight a b p)) ≤ + 3*Real.log 4*(2+Real.log z) := by + have hpoint (p : ℕ) (hp : p ∈ tripleSievePrimes z) : + tripleSieveWeight a b p * Real.log p / (1+tripleSieveWeight a b p) ≤ + 3*(Real.log p/(p:ℝ)) := by + obtain ⟨_,hpp,_⟩ := mem_tripleSievePrimes.mp hp + rw [tripleSieveWeight_moment a b hp,tripleSieveDensity_prime a b p hpp] + let _ : Fact p.Prime := ⟨hpp⟩ + rw [tripleRootCount_eq_card] + have hc : ((tripleSieveRoots p a b).card:ℝ) ≤ 3 := by + exact_mod_cast tripleSieveRoots_card_le p a b + have hp0 : (0:ℝ) < p := by exact_mod_cast hpp.pos + have hl : 0 ≤ Real.log p := Real.log_nonneg (by exact_mod_cast hpp.one_lt.le) + have hh := mul_le_mul_of_nonneg_right hc (div_nonneg hl hp0.le) + convert hh using 1 + ring + + calc + _ ≤ ∑ p ∈ tripleSievePrimes z,3*(Real.log p/(p:ℝ)) := Finset.sum_le_sum hpoint + _ ≤ ∑ p ∈ (Finset.Icc 2 z).filter Nat.Prime,3*(Real.log p/(p:ℝ)) := by + apply Finset.sum_le_sum_of_subset_of_nonneg + · intro p hp + obtain ⟨hpz,hpp,_⟩ := mem_tripleSievePrimes.mp hp + exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr ⟨hpp.two_le,hpz⟩,hpp⟩ + · intro p hp _ + have hpp := (Finset.mem_filter.mp hp).2 + exact mul_nonneg (by norm_num) (div_nonneg + (Real.log_nonneg (by exact_mod_cast hpp.one_lt.le)) (Nat.cast_nonneg _)) + _ ≤ _ := by + rw [← Finset.mul_sum] + nlinarith [prime_log_mass_le z hz] + +lemma tripleSieveTerms_prod (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) + (T : Finset ℕ) (hT : T ⊆ tripleSievePrimes z) : + selbergTerms (triplePrimeSieve a b X z y hy).toBoundingSieve (∏ p ∈ T,p) = + ∏ p ∈ T,tripleSieveWeight a b p := by + rw [(selbergTerms_mult _).map_prod_of_prime T + (fun p hp => (mem_tripleSievePrimes.mp (hT hp)).2.1)] + apply Finset.prod_congr rfl + intro p hp + have hpp := (mem_tripleSievePrimes.mp (hT hp)).2.1 + rw [SelbergSieve.selbergTerms_apply] + simp only [hpp.primeFactors,Finset.prod_singleton] + change tripleSieveDensity a b p * (1/(1-tripleSieveDensity a b p)) = _ + simp [tripleSieveWeight,div_eq_mul_inv] + +lemma tripleSieveBoundingSum_powerset (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) : + selbergBoundingSum (triplePrimeSieve a b X z y hy) = + ∑ T ∈ (tripleSievePrimes z).powerset, + if ((∏ p ∈ T,p : ℕ):ℝ)^2 ≤ y then ∏ p ∈ T,tripleSieveWeight a b p else 0 := by + classical + have hsq := tripleSievePrimes_squarefree z + unfold selbergBoundingSum + change (∑ d ∈ (∏ p ∈ tripleSievePrimes z,p).divisors, + if (d:ℝ)^2 ≤ y then selbergTerms (triplePrimeSieve a b X z y hy).toBoundingSieve d else 0) = _ + rw [← Nat.divisors_filter_squarefree_of_squarefree hsq, + Nat.sum_divisors_filter_squarefree hsq.ne_zero,Nat.factors_eq] + simp only [List.toFinset_coe,Finset.prod_val] + change (∑ T ∈ (∏ p ∈ tripleSievePrimes z,p).primeFactors.powerset, + if ((∏ p ∈ T,p : ℕ):ℝ)^2 ≤ y then + selbergTerms (triplePrimeSieve a b X z y hy).toBoundingSieve (∏ p ∈ T,p) else 0) = _ + rw [Nat.primeFactors_prod (fun p hp => (mem_tripleSievePrimes.mp hp).2.1)] + apply Finset.sum_congr rfl + intro T hT + rw [tripleSieveTerms_prod a b X z y hy T (Finset.mem_powerset.mp hT)] + +/-- The logarithmic first moment confines at least half of the Euler product to +integers within the square-root cutoff used by Selberg's denominator. -/ +theorem tripleSieveBoundingSum_lower (a b X z : ℕ) (y : ℝ) (hy : 1 < y) + (hz : 2 ≤ z) (hscale : 12*Real.log 4*(2+Real.log z) ≤ Real.log y) : + (∏ p ∈ tripleSievePrimes z,(1+tripleSieveWeight a b p))/2 ≤ + selbergBoundingSum (triplePrimeSieve a b X z y hy.le) := by + classical + have hlogy : 0 < Real.log y := Real.log_pos hy + have hl : 0 < Real.log y / 2 := by positivity + have hm : (∑ p ∈ tripleSievePrimes z, + tripleSieveWeight a b p * Real.log p / (1+tripleSieveWeight a b p)) ≤ + (Real.log y/2)/2 := by + nlinarith [tripleSieve_moment_le a b z hz] + have hh := subset_weight_below_half (tripleSievePrimes z) (tripleSieveWeight a b) + (fun p => Real.log p) (fun p hp => tripleSieveWeight_nonneg a b hp) + (fun p hp => Real.log_nonneg (by + exact_mod_cast (mem_tripleSievePrimes.mp hp).2.1.one_lt.le)) hl hm + apply hh.trans + rw [tripleSieveBoundingSum_powerset] + apply Finset.sum_le_sum + intro T hT + have hTp := Finset.mem_powerset.mp hT + have hprimes : ∀ p ∈ T,p.Prime := fun p hp => (mem_tripleSievePrimes.mp (hTp hp)).2.1 + have hpos : (0:ℝ) < (∏ p ∈ T,p : ℕ) := by + exact_mod_cast Finset.prod_pos (fun p hp => (hprimes p hp).pos) + have hlog : Real.log ((∏ p ∈ T,p : ℕ):ℝ) = ∑ p ∈ T,Real.log p := by + rw [Nat.cast_prod,Real.log_prod (fun p hp => by exact_mod_cast (hprimes p hp).ne_zero)] + split_ifs with hsmall hcut hcut + · exact le_rfl + · exfalso + apply hcut + apply (Real.log_le_log_iff (sq_pos_of_pos hpos) (by linarith : 0 tripleSieveWeight_nonneg a b (hTp hp)) + · exact le_rfl + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveError.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveError.lean new file mode 100644 index 0000000000000000000000000000000000000000..a1315a284be36e0fe020a976e617967855ff938b --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveError.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.TotientAsymptotic.TripleSieveCount + +namespace OAI + +/-! A polynomial bound for the complete error term of the concrete Selberg sieve. -/ +noncomputable section +open scoped BigOperators +open BoundingSieve SelbergSieve +namespace TotientAsymptotic + +lemma triple_sieve_divisor_weight {z d : ℕ} (hd : d ∣ ∏ p ∈ tripleSievePrimes z,p) : + (3:ℕ)^ArithmeticFunction.cardDistinctFactors d ≤ d := by + have hsq := (tripleSievePrimes_squarefree z).squarefree_of_dvd hd + have hlen : ArithmeticFunction.cardDistinctFactors d ≤ d.primeFactorsList.length := + d.primeFactorsList.dedup_sublist.length_le + calc + _ ≤ 3^d.primeFactorsList.length := Nat.pow_le_pow_right (by norm_num) hlen + _ ≤ d.primeFactorsList.prod := List.pow_length_le_prod _ 3 (by + intro p hp + have hprime := Nat.prime_of_mem_primeFactorsList hp + have hmem := mem_tripleSievePrimes_of_dvd hprime ((Nat.dvd_of_mem_primeFactorsList hp).trans hd) + have hh := mem_tripleSievePrimes.mp hmem + exact hh.2.2.le) + _ = d := Nat.prod_primeFactorsList hsq.ne_zero + +lemma triplePrimeSieve_error_sum (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) : + (∑ d ∈ (∏ p ∈ tripleSievePrimes z,p).divisors, + if (d:ℝ) ≤ y then (3:ℝ)^ArithmeticFunction.cardDistinctFactors d* + |rem (s := (triplePrimeSieve a b X z y hy).toBoundingSieve) d| else 0) ≤ 2*y^3 := by + classical + let P : ℕ := ∏ p ∈ tripleSievePrimes z,p + let T : Finset ℕ := P.divisors.filter (fun d : ℕ => (d:ℝ) ≤ y) + have hP := tripleSievePrimes_squarefree z + have hT (d : ℕ) (hd : d∈T) : d∣P ∧ 1≤d ∧ (d:ℝ)≤y := by + obtain ⟨hd,hy⟩ := Finset.mem_filter.mp hd + obtain ⟨hd,hP0⟩ := Nat.mem_divisors.mp hd + have h0 : d≠0 := by + intro h + subst d + exact hP0 (zero_dvd_iff.mp hd) + exact ⟨hd,Nat.one_le_iff_ne_zero.mpr h0,hy⟩ + have hcard : (T.card:ℝ) ≤ y := by + have hsub : T ⊆ Finset.Icc 1 ⌊y⌋₊ := by + intro d hd + have hh := hT d hd + exact Finset.mem_Icc.mpr ⟨hh.2.1,Nat.le_floor hh.2.2⟩ + have hh := Finset.card_le_card hsub + have hc : (T.card:ℝ) ≤ ⌊y⌋₊ := by exact_mod_cast (by simpa using hh : T.card ≤ ⌊y⌋₊) + exact hc.trans (Nat.floor_le (by linarith)) + rw [← Finset.sum_filter] + change (∑ d ∈ T,(3:ℝ)^ArithmeticFunction.cardDistinctFactors d* + |rem (s := (triplePrimeSieve a b X z y hy).toBoundingSieve) d|) ≤ _ + calc + _ ≤ ∑ _d ∈ T,2*y^2 := by + apply Finset.sum_le_sum + intro d hd + obtain ⟨hd,h1,hdy⟩ := hT d hd + have hweight : (3:ℝ)^ArithmeticFunction.cardDistinctFactors d ≤ d := by + exact_mod_cast triple_sieve_divisor_weight hd + have hrem := triplePrimeSieve_rem_le a b X z y hy (hP.squarefree_of_dvd hd) + have hdR : (1:ℝ)≤d := by exact_mod_cast h1 + have hh := mul_le_mul hweight hrem (abs_nonneg _) (by positivity : (0:ℝ)≤d) + nlinarith + _ = (T.card:ℝ)*(2*y^2) := by simp + _ ≤ y*(2*y^2) := mul_le_mul_of_nonneg_right hcard (by positivity) + _ = _ := by ring + +/-- All arithmetic remainders in the three-linear-form sieve are now eliminated. -/ +theorem triplePrimeTuples_bound (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) : + ((triplePrimeTuples a b X z).card:ℝ) ≤ + X/selbergBoundingSum (triplePrimeSieve a b X z y hy)+2*y^3 := + (triplePrimeTuples_le_sifted a b X z y hy).trans + ((selberg_bound_simple (triplePrimeSieve a b X z y hy)).trans + (add_le_add le_rfl (triplePrimeSieve_error_sum a b X z y hy))) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveModel.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa87cf98e071e65b4964eb11ff81f95eac6b9e9b --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveModel.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.TotientAsymptotic.TripleSieveCRT +import PrimeNumberTheoremAnd.Mathlib.NumberTheory.Sieve.Selberg + +namespace OAI + +/-! Concrete Selberg sieve for q, aq+1 and bq+1. -/ +noncomputable section +open scoped BigOperators +namespace TotientAsymptotic + +def tripleSievePrimes (z : ℕ) : Finset ℕ := (Nat.primesLE z).filter (fun p => 3 < p) + +lemma mem_tripleSievePrimes {z p : ℕ} : + p ∈ tripleSievePrimes z ↔ p ≤ z ∧ p.Prime ∧ 3 < p := by + simp [tripleSievePrimes,Nat.mem_primesLE,and_assoc] + +lemma tripleSievePrimes_squarefree (z : ℕ) : Squarefree (∏ p ∈ tripleSievePrimes z,p) := by + apply Finset.squarefree_prod_of_pairwise_isCoprime + · intro p hp q hq hpq + apply Nat.coprime_iff_isRelPrime.mp + have hpp := (mem_tripleSievePrimes.mp hp).2.1 + have hqp := (mem_tripleSievePrimes.mp hq).2.1 + exact hpp.coprime_iff_not_dvd.mpr (fun hd => hpq ((Nat.prime_dvd_prime_iff_eq hpp hqp).mp hd)) + · intro p hp + exact (mem_tripleSievePrimes.mp hp).2.1.squarefree + +lemma mem_tripleSievePrimes_of_dvd {z p : ℕ} (hp : p.Prime) + (hd : p ∣ ∏ q ∈ tripleSievePrimes z,q) : p ∈ tripleSievePrimes z := by + obtain ⟨q,hq,hdq⟩ := hp.prime.exists_mem_finset_dvd hd + have he := (Nat.prime_dvd_prime_iff_eq hp (mem_tripleSievePrimes.mp hq).2.1).mp hdq + simpa only [he] using hq + +def tripleSieveDensity (a b : ℕ) : ArithmeticFunction ℝ := + ArithmeticFunction.prodPrimeFactors (fun p => (tripleRootCount p a b:ℝ)/p) + +lemma tripleSieveDensity_prime (a b p : ℕ) (hp : p.Prime) : + tripleSieveDensity a b p = (tripleRootCount p a b:ℝ)/p := by + simp [tripleSieveDensity,ArithmeticFunction.prodPrimeFactors_apply hp.ne_zero,hp.primeFactors] + +lemma tripleSieveDensity_positive (a b p : ℕ) (hp : p.Prime) : + 0 < tripleSieveDensity a b p := by + let _ : Fact p.Prime := ⟨hp⟩ + rw [tripleSieveDensity_prime a b p hp,tripleRootCount_eq_card] + have hc : 0 < (tripleSieveRoots p a b).card := + Finset.card_pos.mpr ⟨0,zero_mem_tripleSieveRoots p a b⟩ + exact div_pos (by exact_mod_cast hc) (by exact_mod_cast hp.pos) + +lemma tripleSieveDensity_lt_one (a b p : ℕ) (hp : p.Prime) (hp3 : 3 < p) : + tripleSieveDensity a b p < 1 := by + let _ : Fact p.Prime := ⟨hp⟩ + rw [tripleSieveDensity_prime a b p hp,tripleRootCount_eq_card] + apply (div_lt_one (by exact_mod_cast hp.pos)).mpr + exact_mod_cast (tripleSieveRoots_card_le p a b).trans_lt hp3 + +lemma tripleSievePolynomial_strictMono (a b : ℕ) : StrictMono (tripleSievePolynomial a b) := by + intro q r hqr + have ha : a*q+1 ≤ a*r+1 := Nat.add_le_add_right (Nat.mul_le_mul_left a hqr.le) 1 + have hb : b*q+1 ≤ b*r+1 := Nat.add_le_add_right (Nat.mul_le_mul_left b hqr.le) 1 + have hp : 0 < (a*r+1)*(b*r+1) := Nat.mul_pos (by omega) (by omega) + calc + tripleSievePolynomial a b q = q*((a*q+1)*(b*q+1)) := by unfold tripleSievePolynomial; ring + _ ≤ q*((a*r+1)*(b*r+1)) := Nat.mul_le_mul_left q (Nat.mul_le_mul ha hb) + _ < r*((a*r+1)*(b*r+1)) := Nat.mul_lt_mul_of_pos_right hqr hp + _ = tripleSievePolynomial a b r := by unfold tripleSievePolynomial; ring + +def triplePrimeSieve (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) : SelbergSieve where + support := (Finset.Icc 1 X).image (tripleSievePolynomial a b) + prodPrimes := ∏ p ∈ tripleSievePrimes z,p + prodPrimes_squarefree := tripleSievePrimes_squarefree z + weights := fun _ => 1 + weights_nonneg := fun _ => zero_le_one + totalMass := X + nu := tripleSieveDensity a b + nu_mult := ArithmeticFunction.IsMultiplicative.prodPrimeFactors _ + nu_pos_of_prime := fun p hp _ => tripleSieveDensity_positive a b p hp + nu_lt_one_of_prime := fun p hp hd => tripleSieveDensity_lt_one a b p hp + (mem_tripleSievePrimes.mp (mem_tripleSievePrimes_of_dvd hp hd)).2.2 + level := y + one_le_level := hy + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveRoots.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveRoots.lean new file mode 100644 index 0000000000000000000000000000000000000000..f89eff82cb9d0d095ff4af41f62cdb750ee2e23f --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveRoots.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.TotientAsymptotic.ShiftedSieveRoots + +namespace OAI + +/-! The local three-linear-form sieve in Ford's collision argument. -/ +noncomputable section +namespace TotientAsymptotic + +def tripleSieveRoots (p a b : ℕ) [NeZero p] : Finset (ZMod p) := + Finset.univ.filter (fun r => r*((a:ZMod p)*r+1)*((b:ZMod p)*r+1)=0) + +lemma tripleSieveRoots_eq_union (p a b : ℕ) [Fact p.Prime] : + tripleSieveRoots p a b = shiftedSieveRoots p a ∪ shiftedSieveRoots p b := by + ext r + simp only [tripleSieveRoots,shiftedSieveRoots,Finset.mem_filter,Finset.mem_univ, + true_and,Finset.mem_union,mul_eq_zero] + tauto + +lemma zero_mem_tripleSieveRoots (p a b : ℕ) [NeZero p] : + (0:ZMod p) ∈ tripleSieveRoots p a b := by simp [tripleSieveRoots] + +lemma tripleSieveRoots_card_le (p a b : ℕ) [Fact p.Prime] : + (tripleSieveRoots p a b).card ≤ 3 := by + have hcard := Finset.card_union_add_card_inter (shiftedSieveRoots p a) (shiftedSieveRoots p b) + have hint : 1 ≤ (shiftedSieveRoots p a ∩ shiftedSieveRoots p b).card := by + apply Finset.card_pos.mpr + exact ⟨0,by simp [shiftedSieveRoots]⟩ + rw [shiftedSieveRoots_card,shiftedSieveRoots_card] at hcard + rw [tripleSieveRoots_eq_union] + split_ifs at hcard <;> omega + +lemma tripleSieveRoots_card_eq_three (p a b : ℕ) [Fact p.Prime] + (ha : ¬p ∣ a) (hb : ¬p ∣ b) (hab : (a:ZMod p) ≠ b) : + (tripleSieveRoots p a b).card = 3 := by + have ha0 : (a:ZMod p) ≠ 0 := (ZMod.natCast_eq_zero_iff a p).not.mpr ha + have hb0 : (b:ZMod p) ≠ 0 := (ZMod.natCast_eq_zero_iff b p).not.mpr hb + have hinv : -(a:ZMod p)⁻¹ ≠ -(b:ZMod p)⁻¹ := by + intro h + apply hab + exact inv_injective (neg_injective h) + rw [tripleSieveRoots_eq_union,shiftedSieveRoots_of_not_dvd p a ha, + shiftedSieveRoots_of_not_dvd p b hb] + have he : ({0,-(a:ZMod p)⁻¹} ∪ {0,-(b:ZMod p)⁻¹} : Finset (ZMod p)) = + {0,-(a:ZMod p)⁻¹,-(b:ZMod p)⁻¹} := by ext r; simp + rw [he] + simp [Finset.card_insert_of_notMem,ha0,hb0,hinv] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TruncatedConcentration.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TruncatedConcentration.lean new file mode 100644 index 0000000000000000000000000000000000000000..c96501aae6d8244bada64638598ca76c9c243bee --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TruncatedConcentration.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.TotientAsymptotic.CenterComparison + +namespace OAI + +/-! Concentration at the full-scale bands after truncating the simplex. -/ + +noncomputable section +open MeasureTheory + +namespace TotientAsymptotic + +def fullSimplexCenter (m : ℕ) (B : ℝ) (k : ℕ) : ℝ := + B*rho^k*((m-k : ℕ) : ℝ)/m + +def coarseCoordinateBad (m : ℕ) (B : ℝ) {N : ℕ} (i : Fin N) : Set (Fin N → ℝ) := + {u | u i < (95/100 : ℝ)*fullSimplexCenter m B (i.val+1) ∨ + (105/100 : ℝ)*fullSimplexCenter m B (i.val+1) < u i} + +theorem truncated_simplex_concentration (hford : FordCoordinateConcentrationInput) : + ∃ C c : ℝ, ∃ N₀ : ℕ, 0 < C ∧ 0 < c ∧ + ∀ N ≥ N₀, ∀ (m q : ℕ) (B : ℝ), 0 < B → m-q=N+2 → + ∀ i : Fin (N+2), i.val < N → 100*q ≤ m-(i.val+1) → + (volume (prefixRegion (N+2) B 0 0 ∩ coarseCoordinateBad m B i)).toReal ≤ + C*Real.exp (-c*(N+2-(i.val+1) : ℕ))*(volume (prefixRegion (N+2) B 0 0)).toReal := by + obtain ⟨C, c, N₀, hC, hc, hconc⟩ := simplex_coordinate_concentration hford + refine ⟨C, c, N₀, hC, hc, ?_⟩ + intro N hN m q B hB hdim i hi hsmall + have hqm : q < m := by omega + have hik : i.val+1 ≤ m-q := by omega + have him : i.val+1 < m := by omega + have hmn : (m : ℝ) ≠ 0 := by exact_mod_cast (show m ≠ 0 by omega) + have hS : 0 < B*rho^(i.val+1) := mul_pos hB (pow_pos rho_pos _) + have hb : 0 < fullSimplexCenter m B (i.val+1) := by + unfold fullSimplexCenter + exact div_pos (mul_pos hS (Nat.cast_pos.mpr (Nat.sub_pos_of_lt him))) + (Nat.cast_pos.mpr (by omega)) + have hcenter : fordSimplexCenter N B i = + (B*rho^(i.val+1))*((N+2-(i.val+1) : ℕ) : ℝ)/(N+2) := by + unfold fordSimplexCenter + rw [Nat.cast_sub (by omega : i.val+1 ≤ N+2)] + push_cast + field_simp + have hcompare := truncated_center_close hS.le hqm hik hsmall + rw [hdim] at hcompare + simp only [Nat.cast_add, Nat.cast_ofNat] at hcompare + rw [← hcenter] at hcompare + change (99/100 : ℝ)*fullSimplexCenter m B (i.val+1) ≤ fordSimplexCenter N B i ∧ + fordSimplexCenter N B i ≤ fullSimplexCenter m B (i.val+1) at hcompare + have hbad : coarseCoordinateBad m B i ⊆ fordCoordinateBad N B i := by + intro u hu + apply outside_band_implies_deviation hb + (by nlinarith [hcompare.1]) (by nlinarith [hcompare.2]) hu + have hfin : volume (prefixRegion (N+2) B 0 0 ∩ fordCoordinateBad N B i) ≠ ⊤ := + ne_top_of_le_ne_top (prefixRegion_volume_ne_top (by omega) B) + (measure_mono Set.inter_subset_left) + exact (ENNReal.toReal_mono hfin (measure_mono (Set.inter_subset_inter_right _ hbad))).trans + (hconc N hN B hB i hi) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TupleCandidate.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TupleCandidate.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd16852a514185dd96dd678459e5a9eae9ee57b4 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TupleCandidate.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.TotientAsymptotic.PrefixPreimage +import OAI.NumberTheory.TotientAsymptotic.TailBelowPrefix + +namespace OAI + +noncomputable section +open scoped BigOperators Topology +open Filter + +namespace TotientAsymptotic + +lemma remainderTail_dvd_suffix {x : ℝ} {H : ℕ} (η : RemainderDatum (L x H)) + (hRL : R x H ≤ L x H) : remainderTail x H η ∣ suffixPreimage η 0 := by + have he : suffixPreimage η 0 = remainderTail x H η * + ∏ i ∈ Finset.Icc 1 (R x H), remainderPrime η i := by + unfold suffixPreimage remainderTail + rw [prod_Icc_split_at (Nat.zero_le (R x H)) hRL] + simp only [Nat.zero_add] + ring + rw [he] + exact dvd_mul_right _ _ + +lemma basic_tail_lt_all_tuple_primes : ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, + ∀ p : ℕ, p.Prime → x^(9/10 : ℝ) ≤ p → + ∀ η : RemainderDatum (L x H), IsBasicRemainder x H η → + ∀ i, remainderTail x H η < tuplePrimes (witnessTuple p η) i := by + filter_upwards [basic_tail_lt_last_prefix,eventually_ge_atTop 2, + P_tendsto.eventually (eventually_ge_atTop 1)] with H hlast hH hP + filter_upwards [theta_eventually_mem,m_tendsto.eventually (eventually_gt_atTop H), + basic_remainder_subpower H (show (0 : ℝ)<1/10 by norm_num), + eventually_gt_atTop (1 : ℝ)] with x hs hm hsub hx1 + intro p hp hpl η hη i + have hPH := P_lt_self hH + have hRL : R x H < L x H := by unfold R L; omega + have hLm : L x H < m x := by unfold L; omega + have hRpos : 0 < R x H := by unfold R; omega + refine Fin.cases ?_ (fun j => ?_) i + · change remainderTail x H η < p + have hwle : remainderTail x H η ≤ suffixPreimage η 0 := + Nat.le_of_dvd (suffixPreimage_pos hη) (remainderTail_dvd_suffix η hRL.le) + have hsmall := (show (remainderTail x H η : ℝ) ≤ suffixPreimage η 0 by exact_mod_cast hwle).trans (hsub η hη) + exact_mod_cast hsmall.trans_lt ((Real.rpow_lt_rpow_of_exponent_lt hx1 + (show (1/10 : ℝ)<9/10 by norm_num)).trans_le hpl) + · change remainderTail x H η < remainderPrime η (j.val+1) + have hj : j.val+1 ≤ R x H := by have := j.isLt; omega + have hl := hlast x hs hm η hη + rcases lt_or_eq_of_le hj with hj | hj + · exact hl.trans (basic_remainder_prime_strictAnti hη + (Finset.mem_Icc.mpr ⟨by omega,hj.le.trans hRL.le⟩) + (Finset.mem_Icc.mpr ⟨hRpos,hRL.le⟩) hj (hj.trans hRL |>.trans hLm)) + · simpa only [hj] using hl + +/-- Every basic tuple has the candidate obtained by replacing its arithmetic +tail by the least inverse image of the same tail totient. -/ +theorem basic_tuple_candidate_realizes : ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, + ∀ t : ℝ, ∀ τ : TotientTuple (R x H), IsBasicTuple x H t τ → + (tupleLeastCandidate τ).totient=tupleValue τ := by + filter_upwards [basic_tail_lt_all_tuple_primes,eventually_tail_cut_separated] + with H hsmall hH + obtain ⟨hP,hcuts⟩ := hH + have hPH : P H < H := by omega + filter_upwards [hsmall,basic_head_coprime H,m_tendsto.eventually (eventually_ge_atTop H)] + with x hsmall hc hm + intro t τ hτ + obtain ⟨η,hη,he⟩ := (isPrefixDatum_iff x H τ.tail).mp hτ.2.2.1 + have hτe : witnessTuple τ.head η=τ := by + cases τ + simpa only [witnessTuple,TotientTuple.mk.injEq,true_and] using he + have hRL : R x H < L x H := by unfold R L; omega + apply tuple_candidate_realizes (w := remainderTail x H η) hPH.le hτ (suffixPreimage_pos (i := R x H) hη) + · exact congrArg PrefixDatum.d he + · intro i + rw [← hτe] + exact hsmall _ hτ.1 hτ.2.1 η hη i + · rw [← hτe,← wholePreimage_prefix_split _ _ hRL.le] + exact wholePreimage_totient hτ.1 hη (by unfold L; omega) hRL + (hc _ hτ.1 hτ.2.1 η hη) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TupleCoefficient.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TupleCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f56641ae68be508027a44a25066d6fc985a91ce --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TupleCoefficient.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.TotientAsymptotic.TupleMassApproximation +import OAI.NumberTheory.TotientAsymptotic.MassVolumeApproximation + +namespace OAI + +/-! The actual tuple count approximates the finite arithmetic coefficient. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter + +namespace TotientAsymptotic + +def tupleNormalization (x : ℝ) : ℝ := x/Real.log x*G x (m x) + +lemma tupleNormalization_pos {x : ℝ} (hx : 1 < x) (hB : 0 < B x) : + 0 < tupleNormalization x := + mul_pos (div_pos (zero_lt_one.trans hx) (Real.log_pos hx)) (G_pos hB _) + +/-- The largest-prime summation error tends to zero for each fixed cutoff, +uniformly over all bounded weights and all comparable endpoints. -/ +theorem tuple_mass_normalized_approximation (hpnt : PrimeNumberTheoremInput) + (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) (hmertens : MertensProductInput) + {a : ℝ} (ha : 0 < a) : + ∀ᶠ H : ℕ in atTop, ∀ ε : ℝ, 0 < ε → ∀ᶠ x : ℝ in atTop, + ∀ t : ℝ, a*x ≤ t → t ≤ x → ∀ f : ℝ → ℝ, (∀ r, 0 ≤ f r ∧ f r ≤ 1) → + |weightedTupleCount x H t f/tupleNormalization x-(t/x)*(M x H f/G x (m x))| ≤ ε := by + obtain ⟨C,hC,hupper⟩ := mass_upper hbox hren hmertens + filter_upwards [hupper, eventually_ge_atTop 2, + P_tendsto.eventually (eventually_ge_atTop 1)] with H hH hH2 hP + let C₀ := C*Real.exp ((4*(lam/rho))*cofactorScale H) + have hC₀ : 0 < C₀ := mul_pos hC (Real.exp_pos _) + intro ε hε + filter_upwards [weighted_tuple_mass_relative hpnt ha (P_lt_self hH2) hP (div_pos hε hC₀), + hH, eventually_gt_atTop (1 : ℝ), + B_tendsto.eventually (eventually_gt_atTop (0 : ℝ))] with x herr hmass hx hB + intro t ht htx f hf + have hnorm := tupleNormalization_pos hx hB + have hG := G_pos hB (m x) + have ht0 : 0 < t := (mul_pos ha (zero_lt_one.trans hx)).trans_le ht + have hlog := Real.log_pos hx + have heq : weightedTupleCount x H t f/tupleNormalization x-(t/x)*(M x H f/G x (m x)) = + (weightedTupleCount x H t f-(t/Real.log x)*M x H f)/tupleNormalization x := by + unfold tupleNormalization + field_simp + rw [heq, abs_div, abs_of_pos hnorm] + apply (div_le_iff₀ hnorm).mpr + apply (herr t ht htx f hf).trans + have hm : M x H (fun _ => 1) ≤ C₀*G x (m x) := hmass _ (fun _ => le_rfl) + calc + (ε/C₀)*(t/Real.log x)*M x H (fun _ => 1) ≤ + (ε/C₀)*(t/Real.log x)*(C₀*G x (m x)) := + mul_le_mul_of_nonneg_left hm (by positivity) + _ = ε*(t/Real.log x)*G x (m x) := by field_simp + _ ≤ ε*tupleNormalization x := by + unfold tupleNormalization + simpa only [mul_assoc] using mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left (div_le_div_of_nonneg_right htx hlog.le) hε.le) hG.le + +/-- Combining the proved prime summation with the proved mass/volume bridge +leaves only the distinct-value/collision argument. This is a theorem about +actual tuples, not a published hypothesis. -/ +theorem tuple_finite_coefficient_approximation (hpnt : PrimeNumberTheoremInput) + (hbox : FordUnitPrimeBoxInput) (hmertens : MertensProductInput) + (hren : FordRenewalInput) (hford : FordCoordinateConcentrationInput) + {a : ℝ} (ha : 0 < a) : + ∃ δ : ℕ → ℝ, Tendsto δ atTop (nhds 0) ∧ + ∀ᶠ H : ℕ in atTop, ∀ f : ℝ → ℝ, (∀ r, 0 ≤ f r ∧ f r ≤ 1) → + ∀ ε : ℝ, 0 < ε → ∀ᶠ x : ℝ in atTop, ∀ t : ℝ, a*x ≤ t → t ≤ x → + |weightedTupleCount x H t f/tupleNormalization x-(t/x)*AH H f (theta x)| ≤ δ H+ε := by + obtain ⟨δ,hδ,hmass⟩ := mass_finite_coefficient_approximation hbox hmertens hren hford + refine ⟨fun H => |δ H|, by simpa using hδ.abs, ?_⟩ + filter_upwards [hmass, tuple_mass_normalized_approximation hpnt hbox hren hmertens ha] with H hH htuple + intro f hf ε hε + filter_upwards [hH f hf (ε/2) (by positivity), htuple (ε/2) (by positivity), + eventually_gt_atTop (1 : ℝ)] with x hx htup hx1 + intro t ht htx + have ht0 : 0 ≤ t/x := div_nonneg ((mul_pos ha (zero_lt_one.trans hx1)).trans_le ht).le + (zero_lt_one.trans hx1).le + have ht1 : t/x ≤ 1 := (div_le_one (zero_lt_one.trans hx1)).mpr htx + calc + _ ≤ |weightedTupleCount x H t f/tupleNormalization x-(t/x)*(M x H f/G x (m x))|+ + |(t/x)*(M x H f/G x (m x))-(t/x)*AH H f (theta x)| := abs_sub_le _ _ _ + _ ≤ ε/2+(δ H+ε/2) := by + apply add_le_add (htup t ht htx f hf) + rw [← mul_sub, abs_mul, abs_of_nonneg ht0] + exact (mul_le_of_le_one_left (abs_nonneg _) ht1).trans hx + _ ≤ |δ H|+ε := by linarith [le_abs_self (δ H)] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TupleCounting.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TupleCounting.lean new file mode 100644 index 0000000000000000000000000000000000000000..be6f93a33a10ce62c77ad8112e51bb25c0fb94a5 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TupleCounting.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.TotientAsymptotic.CollisionTuples +import OAI.NumberTheory.TotientAsymptotic.CollisionIndices + +namespace OAI + +/-! The finite set of distinct arithmetic tuples used in the collision count. -/ + +noncomputable section +open scoped BigOperators +attribute [local instance] Classical.propDecidable + +namespace TotientAsymptotic + +lemma basic_tuple_head_bound {x t : ℝ} {H : ℕ} {τ : TotientTuple (R x H)} + (hPH : P H ≤ H) (hτ : IsBasicTuple x H t τ) : τ.head < ⌊t⌋₊+2 := by + have hpos := basic_prefix_data_positive hPH hτ.2.2.1 + have hd : 0 < τ.tail.d*∏ i, (τ.tail.primes i-1) := by + apply Nat.mul_pos hpos.1 + exact Finset.prod_pos (fun i _ => Nat.sub_pos_of_lt (hpos.2 i).one_lt) + have hv : tupleValue τ = (τ.head-1)*(τ.tail.d*∏ i, (τ.tail.primes i-1)) := by + unfold tupleValue tuplePrimes + rw [Fin.prod_univ_succ] + simp only [Fin.cons_zero, Fin.cons_succ] + ring + have hl : τ.head-1 ≤ tupleValue τ := by rw [hv]; nlinarith + have hfloor : τ.head-1 ≤ ⌊t⌋₊ := Nat.le_floor ((by exact_mod_cast hl : ((τ.head-1 : ℕ) : ℝ) ≤ tupleValue τ).trans hτ.2.2.2) + omega + +def tupleFinset (x : ℝ) (H : ℕ) (t : ℝ) : Finset (TotientTuple (R x H)) := by + classical + exact (((Finset.range (⌊t⌋₊+2)) ×ˢ prefixDataFinset x H).image + (fun p => TotientTuple.mk p.1 p.2)).filter (IsBasicTuple x H t) + +lemma mem_tupleFinset {x t : ℝ} {H : ℕ} {τ : TotientTuple (R x H)} + (hPH : P H ≤ H) : τ ∈ tupleFinset x H t ↔ IsBasicTuple x H t τ := by + classical + constructor + · exact fun ht => (Finset.mem_filter.mp ht).2 + · intro ht + apply Finset.mem_filter.mpr + refine ⟨?_, ht⟩ + apply Finset.mem_image.mpr + exact ⟨(τ.head, τ.tail), Finset.mem_product.mpr + ⟨Finset.mem_range.mpr (basic_tuple_head_bound hPH ht), mem_prefixDataFinset.mpr ht.2.2.1⟩, rfl⟩ + +/-- The tuple fiber over a fixed tail is exactly the allowed largest-prime +interval. The prime number theorem is applied to this finite set later. -/ +lemma tuple_fiber_card (x : ℝ) (H : ℕ) (t : ℝ) (ζ : PrefixDatum (R x H)) : + ((tupleFinset x H t).filter (fun τ : TotientTuple (R x H) => τ.tail = ζ)).card = + if IsPrefixDatum x H ζ then + ((Finset.range (⌊t⌋₊+2)).filter (fun p : ℕ => p.Prime ∧ x^(9/10 : ℝ) ≤ p ∧ + (tupleValue (TotientTuple.mk p ζ) : ℝ) ≤ t)).card + else 0 := by + classical + by_cases hζ : IsPrefixDatum x H ζ + · rw [ite_eq_left hζ] + apply Finset.card_bij (fun τ _ => τ.head) + · intro τ hτ + obtain ⟨hτ, ht⟩ := Finset.mem_filter.mp hτ + obtain ⟨hu, hb⟩ := Finset.mem_filter.mp hτ + obtain ⟨p, hp, he⟩ := Finset.mem_image.mp hu + have hpr : τ.head ∈ Finset.range (⌊t⌋₊+2) := by + rw [← he] + exact (Finset.mem_product.mp hp).1 + exact Finset.mem_filter.mpr ⟨hpr, hb.1, hb.2.1, by simpa [← ht] using hb.2.2.2⟩ + · intro τ hτ σ hσ hh + have ht := (Finset.mem_filter.mp hτ).2 + have hs := (Finset.mem_filter.mp hσ).2 + cases τ + cases σ + simp_all + · intro p hp + obtain ⟨hr, hprime, hlo, hval⟩ := Finset.mem_filter.mp hp + refine ⟨⟨p, ζ⟩, Finset.mem_filter.mpr ⟨?_, rfl⟩, rfl⟩ + apply Finset.mem_filter.mpr + refine ⟨?_, hprime, hlo, hζ, hval⟩ + exact Finset.mem_image.mpr ⟨(p, ζ), Finset.mem_product.mpr + ⟨hr, mem_prefixDataFinset.mpr hζ⟩, rfl⟩ + · rw [ite_eq_right hζ] + apply Finset.card_eq_zero.mpr + apply Finset.eq_empty_iff_forall_notMem.mpr + intro τ hτ + obtain ⟨hτ, ht⟩ := Finset.mem_filter.mp hτ + have hb := (Finset.mem_filter.mp hτ).2.2.2.1 + exact hζ (ht ▸ hb) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TupleMassApproximation.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TupleMassApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..a839a83e9b997f836c47bd58e304948f8174a5df --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TupleMassApproximation.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.TotientAsymptotic.LowerPrimeCutoff +import OAI.NumberTheory.TotientAsymptotic.MassUpper + +namespace OAI + +/-! Largest-prime summation over the actual finite tuple set, with all weights. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter +attribute [local instance] Classical.propDecidable + +namespace TotientAsymptotic + +def weightedTupleCount (x : ℝ) (H : ℕ) (t : ℝ) (f : ℝ → ℝ) : ℝ := + ∑ τ ∈ tupleFinset x H t, f ((ell τ.tail.d : ℝ)/τ.tail.d) + +lemma weightedTupleCount_eq_fibers {x t : ℝ} {H : ℕ} (hPH : P H ≤ H) + (f : ℝ → ℝ) : + weightedTupleCount x H t f = ∑ ζ ∈ prefixDataFinset x H, + f ((ell ζ.d : ℝ)/ζ.d)*((tupleFinset x H t).filter (fun τ => τ.tail=ζ)).card := by + have hmap : ∀ τ ∈ tupleFinset x H t, τ.tail ∈ prefixDataFinset x H := by + intro τ hτ + exact mem_prefixDataFinset.mpr ((mem_tupleFinset hPH).mp hτ).2.2.1 + have he := Finset.sum_fiberwise_of_maps_to' hmap + (fun ζ : PrefixDatum (R x H) => f ((ell ζ.d : ℝ)/ζ.d)) + rw [weightedTupleCount, ← he] + apply Finset.sum_congr rfl + intro ζ _ + simp [mul_comm] + +/-- Relative error in largest-prime summation, uniformly over all bounded +weights and all endpoints in a fixed interval `[a*x,x]`. -/ +theorem weighted_tuple_mass_relative (hpnt : PrimeNumberTheoremInput) + {a : ℝ} (ha : 0 < a) {H : ℕ} (hPH : P H < H) (hP : 1 ≤ P H) + {ε : ℝ} (hε : 0 < ε) : + ∀ᶠ x : ℝ in atTop, ∀ t : ℝ, a*x ≤ t → t ≤ x → + ∀ f : ℝ → ℝ, (∀ r, 0 ≤ f r ∧ f r ≤ 1) → + |weightedTupleCount x H t f-(t/Real.log x)*M x H f| ≤ + ε*(t/Real.log x)*M x H (fun _ => 1) := by + filter_upwards [shifted_prime_uniform_asymptotic hpnt ha hε, + basic_prefix_denominator_log_small hPH hP, eventually_gt_atTop (1 : ℝ)] with x hp hs hx + intro t ht htx f hf + have ht0 : 0 < t := (mul_pos ha (zero_lt_one.trans hx)).trans_le ht + rw [weightedTupleCount_eq_fibers hPH.le, mass_eq_sum_prefixData, mass_eq_sum_prefixData, + Finset.mul_sum, Finset.mul_sum, ← Finset.sum_sub_distrib] + apply (Finset.abs_sum_le_sum_abs _ _).trans + apply Finset.sum_le_sum + intro ζ hζ + have hz := mem_prefixDataFinset.mp hζ + rw [tuple_fiber_eq_shiftedPrimeSet hPH.le ht0.le hz] + have hD := basic_prefix_denominator_pos hPH.le hz + have hc := hp (prefixDenominator ζ) hD (hs ζ hz) t ht htx + have hD0 : (prefixDenominator ζ : ℝ) ≠ 0 := by exact_mod_cast hD.ne' + have hden : (ζ.d : ℝ)*∏ i, (ζ.primes i-1 : ℕ) = prefixDenominator ζ := by + simp only [prefixDenominator, Nat.cast_mul, Nat.cast_prod] + rw [hden] + have he : f ((ell ζ.d : ℝ)/ζ.d)*(↑(shiftedPrimeSet x t (prefixDenominator ζ)).card : ℝ)- + t/Real.log x*(f ((ell ζ.d : ℝ)/ζ.d)/(prefixDenominator ζ : ℝ)) = + f ((ell ζ.d : ℝ)/ζ.d)*((↑(shiftedPrimeSet x t (prefixDenominator ζ)).card : ℝ)- + t/((prefixDenominator ζ : ℝ)*Real.log x)) := by ring + rw [he, abs_mul, abs_of_nonneg (hf _).1] + calc + _ ≤ f ((ell ζ.d : ℝ)/ζ.d)*(ε*(t/((prefixDenominator ζ : ℝ)*Real.log x))) := + mul_le_mul_of_nonneg_left hc (hf _).1 + _ ≤ ε*(t/((prefixDenominator ζ : ℝ)*Real.log x)) := + mul_le_of_le_one_left + (mul_nonneg hε.le (div_nonneg ht0.le (mul_nonneg + (Nat.cast_nonneg _) (Real.log_pos hx).le))) (hf _).2 + _ = _ := by field_simp + +lemma weightedTupleCount_one (x t : ℝ) (H : ℕ) : + weightedTupleCount x H t (fun _ => 1) = (tupleFinset x H t).card := by + simp [weightedTupleCount] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TupleMassBound.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TupleMassBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..f26281582077e38879bb589a37deac3a6a94c350 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TupleMassBound.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.TotientAsymptotic.LargestPrimeCount + +namespace OAI + +/-! Tuple counts controlled by arithmetic mass. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter +attribute [local instance] Classical.propDecidable + +namespace TotientAsymptotic + +lemma tupleValue_eq_head {R : ℕ} (p : ℕ) (ζ : PrefixDatum R) : + tupleValue (TotientTuple.mk p ζ) = (p-1)*(ζ.d*∏ i, (ζ.primes i-1)) := by + unfold tupleValue tuplePrimes + rw [Fin.prod_univ_succ] + simp only [Fin.cons_zero, Fin.cons_succ] + ring + +lemma basic_prefix_denominator_pos {x : ℝ} {H : ℕ} {ζ : PrefixDatum (R x H)} + (hPH : P H ≤ H) (hζ : IsPrefixDatum x H ζ) : + 0 < ζ.d*∏ i, (ζ.primes i-1) := by + have hp := basic_prefix_data_positive hPH hζ + exact Nat.mul_pos hp.1 (Finset.prod_pos (fun i _ => Nat.sub_pos_of_lt (hp.2 i).one_lt)) + +lemma tupleFinset_card_eq_sum_fibers {x t : ℝ} {H : ℕ} (hPH : P H ≤ H) : + (tupleFinset x H t).card = ∑ ζ ∈ prefixDataFinset x H, + ((tupleFinset x H t).filter (fun τ => τ.tail = ζ)).card := by + rw [Finset.sum_card_fiberwise_eq_card_filter (tupleFinset x H t) + (prefixDataFinset x H) TotientTuple.tail] + congr 1 + symm + apply Finset.filter_eq_self.mpr + intro τ hτ + exact mem_prefixDataFinset.mpr ((mem_tupleFinset hPH).mp hτ).2.2.1 + +/-- Uniform at both common endpoints: an arbitrary smaller endpoint can only +reduce the largest-prime fibers. -/ +theorem tuple_count_le_mass : ∀ᶠ x : ℝ in atTop, ∀ H : ℕ, P H ≤ H → + ∀ t : ℝ, t ≤ x → ( (tupleFinset x H t).card : ℝ) ≤ + (10*x/Real.log x)*M x H (fun _ => 1) := by + filter_upwards [largest_prime_count_upper, eventually_gt_atTop (1 : ℝ)] with x hx hx1 + intro H hPH t ht + rw [tupleFinset_card_eq_sum_fibers hPH, Nat.cast_sum, mass_eq_sum_prefixData, Finset.mul_sum] + apply Finset.sum_le_sum + intro ζ hζ + have hz := mem_prefixDataFinset.mp hζ + rw [tuple_fiber_card, ite_eq_left hz] + let D := ζ.d*∏ i, (ζ.primes i-1) + let Q := (Finset.range (⌊t⌋₊+2)).filter (fun p : ℕ => p.Prime ∧ x^(9/10 : ℝ) ≤ p ∧ + (tupleValue (TotientTuple.mk p ζ) : ℝ) ≤ t) + have hD : 0 < D := basic_prefix_denominator_pos hPH hz + have hb := hx D hD Q (by + intro p hp + obtain ⟨_, hprime, hlo, hval⟩ := Finset.mem_filter.mp hp + refine ⟨hprime, hlo, ?_⟩ + rw [tupleValue_eq_head] at hval + exact hval.trans ht) + change (Q.card : ℝ) ≤ _ + apply hb.trans_eq + dsimp [D] + push_cast + field_simp + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TupleRecovery.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TupleRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..1cc6854b6baf337e8df681126fa37bd3bef3ab6d --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TupleRecovery.lean @@ -0,0 +1,145 @@ +import OAI.NumberTheory.TotientAsymptotic.Basic + +namespace OAI + +/-! +The prime-occurrence allocation bound in equations (residual-factorization) +and (tuple-recovery-cost). Repeated prime factors are counted with multiplicity. +-/ + +open scoped BigOperators + +namespace TotientAsymptotic + +private lemma prod_update_div {ι : Type*} [Fintype ι] [DecidableEq ι] + (f : ι → ℕ) (i : ι) {p : ℕ} (hp : p ∣ f i) : + (∏ j, Function.update f i (f i / p) j) = (∏ j, f j) / p := by + rw [Finset.prod_update_of_mem (Finset.mem_univ i)] + rw [← Finset.mul_prod_erase Finset.univ f (Finset.mem_univ i)] + rw [Finset.sdiff_singleton_eq_erase] + simpa [Nat.mul_comm] using (Nat.mul_div_assoc (∏ j ∈ Finset.univ.erase i, f j) hp).symm + +private lemma update_div_injOn {ι : Type*} [Fintype ι] [DecidableEq ι] + (S : Finset (ι → ℕ)) (i : ι) (p : ℕ) + (hS : ∀ f ∈ S, p ∣ f i) : + Set.InjOn (fun (f : ι → ℕ) => Function.update f i (f i / p)) (↑S : Set (ι → ℕ)) := by + intro f hf f' hf' he + funext j + by_cases hji : j = i + · subst j + have hh := congrFun he i + simp only [Function.update_self] at hh + calc + f i = (f i / p) * p := (Nat.div_mul_cancel (hS f hf)).symm + _ = (f' i / p) * p := congrArg (fun t => t*p) hh + _ = f' i := Nat.div_mul_cancel (hS f' hf') + · simpa [Function.update_of_ne hji] using congrFun he j + +/-- Ordered factorizations into `k` labeled slots are bounded by assigning each +prime occurrence to a slot. The finite set may contain any chosen restrictions. -/ +theorem ordered_factorizations_card_le {ι : Type*} [Fintype ι] [DecidableEq ι] + (n : ℕ) (hn : 0 < n) (T : Finset (ι → ℕ)) + (hT : ∀ f ∈ T, ∏ i, f i = n) : + T.card ≤ (Fintype.card ι)^n.primeFactorsList.length := by + classical + induction n using Nat.strong_induction_on generalizing T with + | h n ih => + by_cases hn1 : n = 1 + · subst n + have hf (f : ι → ℕ) (hf : f ∈ T) (i : ι) : f i = 1 := by + apply Nat.dvd_one.mp + rw [← hT f hf] + exact Finset.dvd_prod_of_mem f (Finset.mem_univ i) + have hc : T.card ≤ 1 := Finset.card_le_one.mpr (fun f hff f' hff' => + funext (fun i => (hf f hff i).trans (hf f' hff' i).symm)) + simpa using hc + · obtain ⟨p, hp, hpn⟩ := Nat.exists_prime_and_dvd hn1 + have hquot : 0 < n/p := Nat.div_pos (Nat.le_of_dvd hn hpn) hp.pos + have hlt : n/p < n := Nat.div_lt_self hn hp.one_lt + let S : ι → Finset (ι → ℕ) := fun i => T.filter (fun f => p ∣ f i) + let U : ι → Finset (ι → ℕ) := fun i => + (S i).image (fun f => Function.update f i (f i/p)) + have hU (i : ι) : (U i).card ≤ (Fintype.card ι)^(n/p).primeFactorsList.length := by + apply ih (n/p) hlt hquot (U i) + intro f hf + obtain ⟨f', hf', rfl⟩ := Finset.mem_image.mp hf + have hf'' := Finset.mem_filter.mp hf' + rw [prod_update_div f' i hf''.2, hT f' hf''.1] + have hS (i : ι) : (S i).card = (U i).card := by + symm + apply Finset.card_image_of_injOn + exact update_div_injOn (S i) i p (fun f hf => (Finset.mem_filter.mp hf).2) + have hcover : T ⊆ Finset.univ.biUnion S := by + intro f hf + have hdiv : p ∣ ∏ i, f i := by rw [hT f hf]; exact hpn + obtain ⟨i, _, hi⟩ := (hp.prime.dvd_finsetProd_iff f).mp hdiv + exact Finset.mem_biUnion.mpr ⟨i, Finset.mem_univ i, Finset.mem_filter.mpr ⟨hf, hi⟩⟩ + have hlength : n.primeFactorsList.length = 1+(n/p).primeFactorsList.length := by + have hprod : p*(n/p) = n := Nat.mul_div_cancel' hpn + have hperm := Nat.perm_primeFactorsList_mul hp.ne_zero hquot.ne' + rw [hprod, Nat.primeFactorsList_prime hp] at hperm + simpa [Nat.add_comm] using hperm.length_eq + calc + T.card ≤ (Finset.univ.biUnion S).card := Finset.card_le_card hcover + _ ≤ ∑ i, (S i).card := Finset.card_biUnion_le + _ = ∑ i, (U i).card := Finset.sum_congr rfl (fun i _ => hS i) + _ ≤ ∑ _i : ι, (Fintype.card ι)^(n/p).primeFactorsList.length := + Finset.sum_le_sum (fun i _ => hU i) + _ = (Fintype.card ι)^n.primeFactorsList.length := by + rw [hlength, pow_add] + simp + +/-- The two residual factorizations in an ordered collision pair have the +product of the two prime-occurrence bounds, including repeated factors. -/ +theorem ordered_factorization_pairs_card_le {ι κ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] + (n m : ℕ) (hn : 0 < n) (hm : 0 < m) + (T : Finset (ι → ℕ)) (U : Finset (κ → ℕ)) + (hT : ∀ f ∈ T, ∏ i, f i = n) (hU : ∀ f ∈ U, ∏ i, f i = m) : + (T ×ˢ U).card ≤ (Fintype.card ι)^n.primeFactorsList.length * + (Fintype.card κ)^m.primeFactorsList.length := by + rw [Finset.card_product] + exact Nat.mul_le_mul (ordered_factorizations_card_le n hn T hT) + (ordered_factorizations_card_le m hm U hU) + +def prefixDatumEncoding {n : ℕ} (t : PrefixDatum n) : Fin (n+1) → ℕ := + Fin.cons t.d (fun i => t.primes i-1) + +lemma prefixDatumEncoding_injOn {n : ℕ} (T : Finset (PrefixDatum n)) + (hT : ∀ t ∈ T, ∀ i, 1 ≤ t.primes i) : + Set.InjOn prefixDatumEncoding (↑T : Set (PrefixDatum n)) := by + intro t ht u hu he + have hd : t.d = u.d := by + have h := congrFun he 0 + simpa [prefixDatumEncoding] using h + have hp : t.primes = u.primes := by + funext i + have h := congrFun he i.succ + simp only [prefixDatumEncoding, Fin.cons_succ] at h + have ht1 := hT t ht i + have hu1 := hT u hu i + omega + cases t + cases u + simp_all + +/-- Concrete tuple data inside a residual totient are bounded by the ordered +factorization estimate. The tail totient is a separate, final factor. -/ +theorem prefixData_card_le {n D : ℕ} (hD : 0 < D) (T : Finset (PrefixDatum n)) + (hp : ∀ t ∈ T, ∀ i, 1 ≤ t.primes i) + (hprod : ∀ t ∈ T, t.d * (∏ i, (t.primes i-1)) = D) : + T.card ≤ (n+1)^D.primeFactorsList.length := by + classical + let E := T.image prefixDatumEncoding + have hE : ∀ f ∈ E, ∏ i, f i = D := by + intro f hf + obtain ⟨t, ht, rfl⟩ := Finset.mem_image.mp hf + simpa only [prefixDatumEncoding, Fin.prod_univ_succ, Fin.cons_zero, Fin.cons_succ] + using hprod t ht + have hcard : E.card = T.card := Finset.card_image_of_injOn (prefixDatumEncoding_injOn T hp) + have h := ordered_factorizations_card_le D hD E hE + simpa only [hcard, Fintype.card_fin] using h + +end TotientAsymptotic + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TupleSuffix.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TupleSuffix.lean new file mode 100644 index 0000000000000000000000000000000000000000..c25ae73f2faa3af6394d369279e714d21cfd5f5a --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TupleSuffix.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.TotientAsymptotic.CollisionClassData + +namespace OAI + +/-! Actual tuple suffixes, with the common prefix removed exactly once. -/ + +noncomputable section + +namespace TotientAsymptotic + +def tupleSuffix {R : ℕ} (τ : TotientTuple R) (i : ℕ) : PrefixDatum (R+1-i) where + primes := fun j => tuplePrimes τ ⟨i+j.val,by have := j.isLt; omega⟩ + d := τ.tail.d + +def pairSuffix {R : ℕ} (q : TotientTuple R × TotientTuple R) (i : ℕ) : + PrefixDatum (R+1-i) × PrefixDatum (R+1-i) := (tupleSuffix q.1 i,tupleSuffix q.2 i) + +lemma chosen_whole_prime {x t : ℝ} {H j : ℕ} {τ : TotientTuple (R x H)} + (hτ : IsBasicTuple x H t τ) (hj : j ≤ R x H) : + wholeWitnessPrime τ.head (chosenRemainder x H τ.tail) j = + tuplePrimes τ ⟨j,by omega⟩ := by + have he := wholeWitnessPrime_tuple (p := τ.head) + (η := chosenRemainder x H τ.tail) ⟨j,by omega⟩ + rw [chosenRemainder_tuple hτ] at he + exact he + +/-- Comparison primes and residual tuples recover only the suffix being +counted; the earlier common prefix is irrelevant to this reconstruction. -/ +theorem tupleSuffix_recovered {x t : ℝ} {H i k : ℕ} + {τ σ : TotientTuple (R x H)} (hτ : IsBasicTuple x H t τ) (hσ : IsBasicTuple x H t σ) + (hL : L x H < m x) (hkL : k < L x H) (hiR : i ≤ R x H) + (hknown : ∀ r ∈ Finset.Icc i k, + wholeWitnessPrime τ.head (chosenRemainder x H τ.tail) r = + wholeWitnessPrime σ.head (chosenRemainder x H σ.tail) r) + (hdata : residualTupleData (chosenRemainder x H τ.tail) k = + residualTupleData (chosenRemainder x H σ.tail) k) : + tupleSuffix τ i=tupleSuffix σ i := by + let η := chosenRemainder x H τ.tail + let ξ := chosenRemainder x H σ.tail + have hη : IsBasicRemainder x H η := (chosenRemainder_spec hτ.2.2.1).1 + have hξ : IsBasicRemainder x H ξ := (chosenRemainder_spec hσ.2.2.1).1 + have hps := congrArg PrefixDatum.primes hdata + have hds := congrArg PrefixDatum.d hdata + have hp : (tupleSuffix τ i).primes=(tupleSuffix σ i).primes := by + funext j + have hj : i+j.val ≤ R x H := by have := j.isLt; omega + change tuplePrimes τ ⟨i+j.val,by omega⟩=tuplePrimes σ ⟨i+j.val,by omega⟩ + rw [← chosen_whole_prime hτ hj,← chosen_whole_prime hσ hj] + by_cases hr : i+j.val ≤ k + · exact hknown _ (Finset.mem_Icc.mpr ⟨by omega,hr⟩) + · let l : Fin (R x H-k) := ⟨i+j.val-k-1,by omega⟩ + have he := congrFun hps l + change remainderPrime η (k+l.val+1)=remainderPrime ξ (k+l.val+1) at he + have hidx : k+l.val+1=i+j.val := by dsimp [l]; omega + rw [hidx] at he + simpa only [wholeWitnessPrime,ite_eq_right (by omega : i+j.val ≠ 0)] using he + have ht : (tupleSuffix τ i).d=(tupleSuffix σ i).d := by + have htailτ : (remainderTail x H η).totient=τ.tail.d := + congrArg PrefixDatum.d (chosenRemainder_spec hτ.2.2.1).2 + have htailσ : (remainderTail x H ξ).totient=σ.tail.d := + congrArg PrefixDatum.d (chosenRemainder_spec hσ.2.2.1).2 + change τ.tail.d=σ.tail.d + rw [← htailτ,← htailσ] + by_cases hk : k ≤ R x H + · simpa only [residualTupleData,ite_eq_left hk] using hds + · have hd : (suffixPreimage η k).totient=(suffixPreimage ξ k).totient := by + simpa only [residualTupleData,ite_eq_right hk] using hds + rw [← suffixPreimage_at_R η,← suffixPreimage_at_R ξ, + basic_suffix_totient_split hη hL (by omega : R x H ≤ k) hkL, + basic_suffix_totient_split hξ hL (by omega : R x H ≤ k) hkL,hd] + congr 1 + apply Finset.prod_congr rfl + intro r hr + have hr' := Finset.mem_Icc.mp hr + have he := hknown r (Finset.mem_Icc.mpr ⟨by omega,hr'.2⟩) + have hprime : remainderPrime η r=remainderPrime ξ r := by + simpa only [wholeWitnessPrime,ite_eq_right (by omega : r ≠ 0)] using he + exact congrArg (fun n : ℕ => n-1) hprime + exact congrArg₂ PrefixDatum.mk hp ht + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TupleTotients.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TupleTotients.lean new file mode 100644 index 0000000000000000000000000000000000000000..04d306b4b12d54573b064171f54e4378eee39153 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TupleTotients.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.TotientAsymptotic.CollisionHeadSize +import OAI.NumberTheory.TotientAsymptotic.GoodDiscard +import OAI.NumberTheory.TotientAsymptotic.FiniteMap + +namespace OAI + +/-! Actual arithmetic realization of tuples and the finite-map comparison. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter +attribute [local instance] Classical.propDecidable + +namespace TotientAsymptotic + +def wholePreimage {x : ℝ} {H : ℕ} (p : ℕ) (η : RemainderDatum (L x H)) : ℕ := + p * suffixPreimage η 0 + +lemma basic_head_coprime (H : ℕ) : ∀ᶠ x : ℝ in atTop, + ∀ p : ℕ, p.Prime → x^(9/10 : ℝ) ≤ p → + ∀ η : RemainderDatum (L x H), IsBasicRemainder x H η → + p.Coprime (suffixPreimage η 0) := by + filter_upwards [basic_remainder_subpower H (show (0 : ℝ)<1/10 by norm_num), + eventually_gt_atTop (1 : ℝ)] with x hx hx1 + intro p hp hpl η hη + apply hp.coprime_iff_not_dvd.mpr + intro hd + have hle := Nat.le_of_dvd (suffixPreimage_pos hη (i := 0)) hd + have hsmall := (hx η hη).trans_lt + (Real.rpow_lt_rpow_of_exponent_lt hx1 (by norm_num : (1/10 : ℝ)<9/10)) + exact (not_lt_of_ge (show (p : ℝ) ≤ suffixPreimage η 0 by exact_mod_cast hle)) + (hsmall.trans_le hpl) + +lemma wholePreimage_totient {x : ℝ} {H p : ℕ} + {η : RemainderDatum (L x H)} (hp : p.Prime) (hη : IsBasicRemainder x H η) + (hL : L x H < m x) (hR : R x H < L x H) + (hcop : p.Coprime (suffixPreimage η 0)) : + (wholePreimage p η).totient = tupleValue (witnessTuple p η) := by + rw [wholePreimage, Nat.totient_mul hcop, Nat.totient_prime hp, + witness_tuple_value_at_cut hη hL hR (Nat.zero_lt_of_lt hR)] + simp only [Finset.Icc_self, Finset.prod_singleton, wholeWitnessPrime, ite_true] + ring + +lemma basic_tuple_isTotient : ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, + ∀ t : ℝ, ∀ τ : TotientTuple (R x H), IsBasicTuple x H t τ → IsTotient (tupleValue τ) := by + filter_upwards [eventually_tail_cut_separated] with H hH + obtain ⟨hPH,hP⟩ := hH + filter_upwards [basic_head_coprime H,m_tendsto.eventually (eventually_ge_atTop H)] with x hx hm + intro t τ hτ + obtain ⟨η,hη,he⟩ := (isPrefixDatum_iff x H τ.tail).mp hτ.2.2.1 + have hw : witnessTuple τ.head η=τ := by + cases τ + simpa only [witnessTuple,TotientTuple.mk.injEq,true_and] using he + have hL : L x H < m x := by unfold L; omega + have hR : R x H < L x H := by unfold R L; omega + refine ⟨wholePreimage τ.head η,Nat.mul_pos hτ.1.pos (suffixPreimage_pos hη),?_⟩ + rw [wholePreimage_totient hτ.1 hη hL hR (hx τ.head hτ.1 hτ.2.1 η hη),hw] + +def totientValues (t : ℝ) : Finset ℕ := (Finset.Icc 1 ⌊t⌋₊).filter IsTotient + +def uncoveredValues (x : ℝ) (H : ℕ) (t : ℝ) : Finset ℕ := + totientValues t \ (tupleFinset x H t).image tupleValue + +lemma card_totientValues (t : ℝ) : ((totientValues t).card : ℝ)=V t := rfl + +lemma basic_tuple_mem_values {x t : ℝ} {H : ℕ} {τ : TotientTuple (R x H)} + (hPH : P H ≤ H) (hτ : IsBasicTuple x H t τ) (hval : IsTotient (tupleValue τ)) : + tupleValue τ ∈ totientValues t := by + exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr + ⟨basic_tuple_value_pos hPH hτ,Nat.le_floor hτ.2.2.2⟩,hval⟩ + +lemma good_collision_count_eq {x t : ℝ} {H : ℕ} + (hmap : ∀ τ ∈ goodTupleFinset x H t, tupleValue τ ∈ totientValues t) : + FiniteMap.collisionCount (goodTupleFinset x H t) (totientValues t) tupleValue = + (goodCollisionPairs x H t).card := by + classical + rw [FiniteMap.collisionCount_eq_ordered_pairs _ _ _ hmap] + congr 1 + ext q + simp only [Finset.mem_filter,Finset.mem_offDiag,goodCollisionPairs,Finset.mem_product] + tauto + +/-- Both errors are for concrete finite sets: actual bad tuples and actual +uncovered totient values. The coverage error will be bounded by extraction. -/ +theorem tuple_value_comparison : ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, ∀ t : ℝ, + -((uncoveredValues x H t).card : ℝ) ≤ ((tupleFinset x H t).card : ℝ)-V t ∧ + ((tupleFinset x H t).card : ℝ)-V t ≤ + (badTupleFinset x H t).card+((goodCollisionPairs x H t).card : ℝ)/2 := by + filter_upwards [basic_tuple_isTotient,eventually_ge_atTop 2] with H hreal hH + filter_upwards [hreal] with x hx + intro t + have hPH := (P_lt_self hH).le + have hmap : ∀ τ ∈ tupleFinset x H t, tupleValue τ ∈ totientValues t := by + intro τ hτ + have hb := (mem_tupleFinset hPH).mp hτ + exact basic_tuple_mem_values hPH hb (hx t τ hb) + have hg : goodTupleFinset x H t ⊆ tupleFinset x H t := Finset.filter_subset _ _ + have hpart : tupleFinset x H t=goodTupleFinset x H t ∪ badTupleFinset x H t := by + exact (Finset.union_sdiff_of_subset hg).symm + have hdis : Disjoint (goodTupleFinset x H t) (badTupleFinset x H t) := + Finset.disjoint_left.mpr (fun _ h₁ h₂ => (Finset.mem_sdiff.mp h₂).2 h₁) + have hc := FiniteMap.counting (tupleFinset x H t) (goodTupleFinset x H t) + (badTupleFinset x H t) (totientValues t) (uncoveredValues x H t) tupleValue + hpart hdis hmap (Finset.sdiff_subset) (by + intro v hv + by_contra hn + exact (Finset.mem_sdiff.mp hv).2 (Finset.mem_sdiff.mpr ⟨(Finset.mem_sdiff.mp hv).1,hn⟩)) + rw [good_collision_count_eq (fun τ hτ => hmap τ (hg hτ))] at hc + exact ⟨hc.1,hc.2.1⟩ + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TwoBandCount.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TwoBandCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fdce5a34c71d84f3934c567549caaf02a73c8da --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TwoBandCount.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.TotientAsymptotic.FordNormalCount + +namespace OAI + +/-! The two-coordinate upper estimate needed to start Ford's counting bootstrap. -/ +noncomputable section +open scoped BigOperators +namespace TotientAsymptotic + +def twoBandCutoffs (S z w : ℕ) (j : ℕ) : ℕ := if j=0 then z else if j=1 then w else S + +lemma two_band_exponent_le {S z w : ℕ} (hS : 2 ≤ S) (hSw : S ≤ w) (hwz : w ≤ z) + (hBS : 0 ≤ B S) (D : ℝ) : + -(∑ j ∈ Finset.range 2,a (j+1)*B (twoBandCutoffs S z w j))+ + (1-countBandWeight 3)*B S+normalBandError S D 2 (twoBandCutoffs S z w) ≤ + -a 1*B z-a 2*B w+4*B S+5*D+8*Real.sqrt (B S*B z) := by + have hw1 : (1:ℝ) < w := by exact_mod_cast (show 1 < w by omega) + have hz1 : (1:ℝ) < z := by exact_mod_cast (show 1 < z by omega) + have hB : B w ≤ B z := Real.log_le_log (Real.log_pos hw1) + (Real.log_le_log (by linarith) (by exact_mod_cast hwz)) + have hroot : Real.sqrt (B S*B w) ≤ Real.sqrt (B S*B z) := + Real.sqrt_le_sqrt (mul_le_mul_of_nonneg_left hB hBS) + have hlog2 : Real.log (2:ℝ) ≤ 1 := by + have hh := Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2) + norm_num at hh + exact hh + have hlog3 : Real.log (3:ℝ) ≤ 2 := by + have hh := Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<3) + norm_num at hh + exact hh + have hlog3non : 0 ≤ Real.log (3:ℝ) := Real.log_nonneg (by norm_num) + have hterm := mul_le_mul_of_nonneg_right hlog3 hBS + have h2 := mul_le_mul_of_nonneg_right hlog2 (Real.sqrt_nonneg (B S*B z)) + have h3 := mul_le_mul_of_nonneg_right hlog3 (Real.sqrt_nonneg (B S*B z)) + have hm := mul_le_mul_of_nonneg_left hroot hlog3non + simp only [Finset.sum_range_succ,Finset.sum_range_zero,zero_add,normalBandError, + twoBandCutoffs,countBandWeight] at * + norm_num at * + nlinarith only [hterm,h2,h3,hm] + +theorem ford_two_band_count : ∃ C D : ℝ,0 < C ∧ 0 < D ∧ + ∀ S X z w : ℕ,2 ≤ S → S ≤ w → w ≤ z → 0 ≤ B S → 1 ≤ B X → + Real.log z ≤ Real.log X/(20*B X) → ∀ Q : Finset ℕ, + (∀ v ∈ Q,∃ n : ℕ,0 < n ∧ n.totient=v ∧ v ≤ X ∧ + (v.primeFactorsList.length:ℝ) ≤ 5*B X ∧ SquarefreeAbove v S ∧ SquarefreeAbove n S ∧ + (∀ p ∈ n.primeFactors,IsNormalPrime S p) ∧ + 3 ≤ n.primeFactorsList.length ∧ z < fordPrime n 1 ∧ w < fordPrime n 2) → + (Q.card:ℝ) ≤ C*X*Real.exp (-a 1*B z-a 2*B w+4*B S+5*D+8*Real.sqrt (B S*B z)) := by + obtain ⟨C,D,hC,hD,hbound⟩ := ford_normal_value_count + refine ⟨C,D,hC,hD,?_⟩ + intro S X z w hS hSw hwz hBS hBX hcut Q hQ + have hY : ∀ j < 2,twoBandCutoffs S z w (j+1) ≤ twoBandCutoffs S z w j := by + intro j hj + interval_cases j + · simpa [twoBandCutoffs] using hwz + · simpa [twoBandCutoffs] using hSw + have hb := hbound S X z 2 (twoBandCutoffs S z w) hS (hSw.trans hwz) + (by simp [twoBandCutoffs]) (by simp [twoBandCutoffs]) hBX hcut hY Q (by + intro v hv + obtain ⟨n,hn,hφ,hvX,hΩ,hsqv,hsqn,hnorm,hlen,hp1,hp2⟩ := hQ v hv + refine ⟨n,hn,hφ,hvX,hΩ,hsqv,hsqn,hnorm,?_⟩ + intro j + fin_cases j <;> norm_num [twoBandCutoffs] <;> omega) + have he := Real.exp_le_exp.mpr (two_band_exponent_le hS hSw hwz hBS D) + exact hb.trans (mul_le_mul_of_nonneg_left he (by positivity)) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TwoBandUnionCount.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TwoBandUnionCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..96859b584ddabacf96087798acffb50661838825 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TwoBandUnionCount.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TotientAsymptotic.TwoBandCount +import OAI.NumberTheory.TotientAsymptotic.RegularValueCount + +namespace OAI + +/-! Sum the two-band estimate over a finite grid of actual cutoff pairs. -/ +noncomputable section +open scoped BigOperators +attribute [local instance] Classical.propDecidable +namespace TotientAsymptotic + +theorem two_band_union_count : ∃ C D : ℝ,0 < C ∧ 0 < D ∧ + ∀ S X : ℕ,2 ≤ S → 0 ≤ B S → 1 ≤ B X → ∀ H T : ℝ, + ∀ P : Finset (ℕ×ℕ), + (∀ q ∈ P,S ≤ q.2 ∧ q.2 ≤ q.1 ∧ B q.1 ≤ H ∧ + Real.log q.1 ≤ Real.log X/(20*B X) ∧ T ≤ a 1*B q.1+a 2*B q.2) → + ∀ Q : Finset ℕ, + (∀ v ∈ Q,v ≤ X ∧ CountingRegular S X v ∧ + ∃ n : ℕ,0 < n ∧ n.totient=v ∧ 3 ≤ n.primeFactorsList.length ∧ + ∃ q ∈ P,q.1 < fordPrime n 1 ∧ q.2 < fordPrime n 2) → + (Q.card:ℝ) ≤ C*X*P.card*Real.exp (-T+4*B S+5*D+8*Real.sqrt (B S*H)) := by + obtain ⟨C,D,hC,hD,hbound⟩ := ford_two_band_count + refine ⟨C,D,hC,hD,?_⟩ + intro S X hS hBS hBX H T P hP Q hQ + let F := fun q : ℕ×ℕ => Q.filter (fun v => ∃ n : ℕ,0 < n ∧ n.totient=v ∧ + 3 ≤ n.primeFactorsList.length ∧ q.1 < fordPrime n 1 ∧ q.2 < fordPrime n 2) + have hcover : Q ⊆ P.biUnion F := by + intro v hv + obtain ⟨hvX,hreg,n,hn,hφ,hlen,q,hq,hq1,hq2⟩ := hQ v hv + exact Finset.mem_biUnion.mpr ⟨q,hq,Finset.mem_filter.mpr ⟨hv,n,hn,hφ,hlen,hq1,hq2⟩⟩ + have hcell (q : ℕ×ℕ) (hq : q ∈ P) : + ((F q).card:ℝ) ≤ C*X*Real.exp (-T+4*B S+5*D+8*Real.sqrt (B S*H)) := by + obtain ⟨hSq,horder,hBH,hlog,hT⟩ := hP q hq + have hh := hbound S X q.1 q.2 hS hSq horder hBS hBX hlog (F q) (by + intro v hv + obtain ⟨hv,n,hn,hφ,hlen,hq1,hq2⟩ := Finset.mem_filter.mp hv + obtain ⟨hvX,hreg,_⟩ := hQ v hv + have hr := hreg.2.2 n hn hφ + exact ⟨n,hn,hφ,hvX,hreg.1,hreg.2.1,hr.1,hr.2,hlen,hq1,hq2⟩) + have hsqrt : Real.sqrt (B S*B q.1) ≤ Real.sqrt (B S*H) := + Real.sqrt_le_sqrt (mul_le_mul_of_nonneg_left hBH hBS) + apply hh.trans + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply Real.exp_le_exp.mpr + linarith + calc + _ ≤ ((P.biUnion F).card:ℝ) := Nat.cast_le.mpr (Finset.card_le_card hcover) + _ ≤ ∑ q ∈ P,((F q).card:ℝ) := by + exact_mod_cast (Finset.card_biUnion_le : (P.biUnion F).card ≤ ∑ q ∈ P,(F q).card) + _ ≤ ∑ _q ∈ P,C*X*Real.exp (-T+4*B S+5*D+8*Real.sqrt (B S*H)) := Finset.sum_le_sum hcell + _ = _ := by simp only [Finset.sum_const,nsmul_eq_mul]; ring + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TwoCoordinateCount.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TwoCoordinateCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..c2d7defcd310df091f40dce08a7524491ea2eadc --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TwoCoordinateCount.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.TotientAsymptotic.TwoCoordinateGrid +import OAI.NumberTheory.TotientAsymptotic.TwoBandUnionCount + +namespace OAI + +/-! The two-coordinate instance of Ford Lemma 4.2, before absorbing errors. -/ +noncomputable section +open scoped BigOperators +attribute [local instance] Classical.propDecidable +namespace TotientAsymptotic + +def coordinateCutoffPairs (S K : ℕ) (T : ℝ) : Finset (ℕ×ℕ) := + (((Finset.Icc 2 K).product (Finset.Icc 2 K)).image + (fun q : ℕ×ℕ => (loglogCutoff q.1,loglogCutoff q.2))).filter + (fun q => S ≤ q.2 ∧ q.2 ≤ q.1 ∧ T ≤ a 1*B q.1+a 2*B q.2) + +lemma coordinateCutoffPairs_card (S K : ℕ) (T : ℝ) : + (coordinateCutoffPairs S K T).card ≤ (K+1)^2 := by + have hI : (Finset.Icc 2 K).card ≤ K+1 := by simp; omega + calc + _ ≤ (((Finset.Icc 2 K).product (Finset.Icc 2 K)).image + (fun q : ℕ×ℕ => (loglogCutoff q.1,loglogCutoff q.2))).card := Finset.card_filter_le _ _ + _ ≤ ((Finset.Icc 2 K).product (Finset.Icc 2 K)).card := Finset.card_image_le + _ = (Finset.Icc 2 K).card*(Finset.Icc 2 K).card := Finset.card_product _ _ + _ ≤ (K+1)^2 := by nlinarith + +lemma coordinateCutoffPairs_data {S K : ℕ} {T : ℝ} {q : ℕ×ℕ} + (hq : q ∈ coordinateCutoffPairs S K T) : + S ≤ q.2 ∧ q.2 ≤ q.1 ∧ B q.1 ≤ K ∧ Real.log q.1 ≤ Real.exp K ∧ + T ≤ a 1*B q.1+a 2*B q.2 := by + obtain ⟨hq,hS,horder,hT⟩ := Finset.mem_filter.mp hq + obtain ⟨ij,hij,rfl⟩ := Finset.mem_image.mp hq + obtain ⟨hi,hj⟩ := Finset.mem_product.mp hij + have hi' := Finset.mem_Icc.mp hi + have hb := loglogCutoff_bounds (by exact_mod_cast hi'.1 : (2:ℝ) ≤ ij.1) + exact ⟨hS,horder,hb.2.2.1.trans (by exact_mod_cast hi'.2), + hb.2.2.2.trans (Real.exp_le_exp.mpr (by exact_mod_cast hi'.2)),hT⟩ + +/-- Every counted value has some violating preimage. Its regularity controls +all preimages, allowing the actual witness to supply the grid cell. -/ +theorem two_coordinate_violation_count : ∃ C D : ℝ,0 < C ∧ 0 < D ∧ + ∀ (X K L : ℕ) (ω : ℝ),4 ≤ X → 12 ≤ B X → 0 ≤ ω → 2 ≤ L → L ≤ K → + (L:ℝ)+2 ≤ B X/2 → (K:ℝ) ≤ B X+2 → + Real.exp K ≤ Real.log X/(20*B X) → ∀ Q : Finset ℕ, + (∀ v ∈ Q,v ≤ X ∧ CountingRegular (loglogCutoff L) X v ∧ + ∃ n : ℕ,0 < n ∧ n.totient=v ∧ + (1+ω)*B X < a 1*fordPrimeCoordinate n 1+a 2*fordPrimeCoordinate n 2) → + (Q.card:ℝ) ≤ C*X*(K+1:ℕ)^2* + Real.exp (-(1+ω)*B X+(3/2:ℝ)*(B X+5-K)+4*B (loglogCutoff L)+5*D+ + 8*Real.sqrt (B (loglogCutoff L)*K)) := by + obtain ⟨C,D,hC,hD,hbound⟩ := two_band_union_count + refine ⟨C,D,hC,hD,?_⟩ + intro X K L ω hX hBX hω hL hLK hLB hKB hcut Q hQ + let S := loglogCutoff L + let T := (1+ω)*B X-(3/2:ℝ)*(B X+5-K) + let P := coordinateCutoffPairs S K T + have hS := loglogCutoff_bounds (by exact_mod_cast hL : (2:ℝ) ≤ L) + have hBS : 0 ≤ B S := by + have hLR : (2:ℝ) ≤ L := by exact_mod_cast hL + linarith only [hS.2.1,hLR] + have hpdata (q : ℕ×ℕ) (hq : q ∈ P) : S ≤ q.2 ∧ q.2 ≤ q.1 ∧ B q.1 ≤ (K:ℝ) ∧ + Real.log q.1 ≤ Real.log X/(20*B X) ∧ T ≤ a 1*B q.1+a 2*B q.2 := by + obtain ⟨h1,h2,h3,h4,h5⟩ := coordinateCutoffPairs_data hq + exact ⟨h1,h2,h3,h4.trans hcut,h5⟩ + have hcoverage (v : ℕ) (hv : v ∈ Q) : v ≤ X ∧ CountingRegular S X v ∧ + ∃ n : ℕ,0 < n ∧ n.totient=v ∧ 3 ≤ n.primeFactorsList.length ∧ + ∃ q ∈ P,q.1 < fordPrime n 1 ∧ q.2 < fordPrime n 2 := by + obtain ⟨hvX,hreg,n,hn,hφ,hbad⟩ := hQ v hv + have hφX : (n.totient:ℝ) ≤ X := by rw [hφ]; exact_mod_cast hvX + have hg := two_coordinate_grid (by exact_mod_cast hX : (4:ℝ) ≤ X) hBX hω hn hφX hbad + (hL.trans hLK) hKB hLK hLB + dsimp only at hg + obtain ⟨hlen,hi2,hiK,hj2,hjK,hSj,hji,hip,hjp,hBi,hlogi,hT⟩ := hg + let i := cappedLoglogIndex K (B (fordPrime n 1)) + let j := cappedLoglogIndex K (B (fordPrime n 2)) + refine ⟨hvX,hreg,n,hn,hφ,hlen,(loglogCutoff i,loglogCutoff j),?_,hip,hjp⟩ + refine Finset.mem_filter.mpr ⟨?_,hSj,hji,hT⟩ + apply Finset.mem_image.mpr + exact ⟨(i,j),Finset.mem_product.mpr ⟨Finset.mem_Icc.mpr ⟨hi2,hiK⟩, + Finset.mem_Icc.mpr ⟨hj2,hjK⟩⟩,rfl⟩ + have hb := hbound S X hS.1 hBS (by linarith) K T P hpdata Q hcoverage + have hcard : (P.card:ℝ) ≤ ((K+1:ℕ)^2:ℝ) := by exact_mod_cast coordinateCutoffPairs_card S K T + calc + _ ≤ C*X*P.card*Real.exp (-T+4*B S+5*D+8*Real.sqrt (B S*K)) := hb + _ ≤ C*X*((K+1:ℕ)^2:ℝ)*Real.exp (-T+4*B S+5*D+8*Real.sqrt (B S*K)) := by + apply mul_le_mul_of_nonneg_right _ (Real.exp_pos _).le + exact mul_le_mul_of_nonneg_left hcard (by positivity) + _ = _ := by dsimp [T,S]; congr 1; congr 1; ring + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TwoCoordinateGrid.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TwoCoordinateGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..12f9a2d936afca957b9f1c92aa11c095996a8f02 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TwoCoordinateGrid.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TotientAsymptotic.CappedLoglogGrid +import OAI.NumberTheory.TotientAsymptotic.FordCoordinateBounds + +namespace OAI + +/-! Extract two admissible integer cutoffs from a violating actual preimage. -/ +noncomputable section +namespace TotientAsymptotic + +lemma two_coordinate_grid {x ω : ℝ} {n K L : ℕ} (hx : 4 ≤ x) + (hBx : 12 ≤ B x) (hω : 0 ≤ ω) (hn : 0 < n) (hφ : (n.totient:ℝ) ≤ x) + (hbad : (1+ω)*B x < a 1*fordPrimeCoordinate n 1+a 2*fordPrimeCoordinate n 2) + (hK : 2 ≤ K) (hKU : (K:ℝ) ≤ B x+2) (hLK : L ≤ K) + (hL : (L:ℝ)+2 ≤ B x/2) : + let i := cappedLoglogIndex K (B (fordPrime n 1)) + let j := cappedLoglogIndex K (B (fordPrime n 2)) + 3 ≤ n.primeFactorsList.length ∧ 2 ≤ i ∧ i ≤ K ∧ 2 ≤ j ∧ j ≤ K ∧ + loglogCutoff L ≤ loglogCutoff j ∧ loglogCutoff j ≤ loglogCutoff i ∧ + loglogCutoff i < fordPrime n 1 ∧ loglogCutoff j < fordPrime n 2 ∧ + B (loglogCutoff i) ≤ K ∧ Real.log (loglogCutoff i) ≤ Real.exp K ∧ + (1+ω)*B x-(3/2:ℝ)*(B x+5-K) ≤ + a 1*B (loglogCutoff i)+a 2*B (loglogCutoff j) := by + obtain ⟨hraw2,hlen⟩ := two_coordinate_failure_large_second hx hBx hω hn hφ hbad + have hp1 := fordPrime_prime (n:=n) (i:=1) (by omega) + have hp2 := fordPrime_prime (n:=n) (i:=2) (by omega) + have horder : fordPrime n 2 ≤ fordPrime n 1 := fordPrime_antitone (by omega) (by omega) (by norm_num) + have hBord : B (fordPrime n 2) ≤ B (fordPrime n 1) := + Real.log_le_log (Real.log_pos (by exact_mod_cast hp2.one_lt)) + (Real.log_le_log (by exact_mod_cast hp2.pos) (by exact_mod_cast horder)) + change 4 < B (fordPrime n 2) at hraw2 + have hraw1 : 0 ≤ B (fordPrime n 1) := by linarith + have hc1 : fordPrimeCoordinate n 1=B (fordPrime n 1) := max_eq_right hraw1 + have hc2 : fordPrimeCoordinate n 2=B (fordPrime n 2) := max_eq_right (show 0 ≤ B (fordPrime n 2) by linarith) + have hb1 := (ford_coordinate_upper hx hn hφ 1) + have hb2 := (ford_coordinate_upper hx hn hφ 2) + rw [hc1] at hb1 + rw [hc2] at hb2 + have hi := capped_loglog_prime hK hKU hp1.one_lt (by linarith) hb1 + have hj := capped_loglog_prime hK hKU hp2.one_lt hraw2.le hb2 + dsimp only at hi hj ⊢ + have hLraw : (L:ℝ)+1 ≤ B (fordPrime n 2) := by + have hh := two_coordinate_failure_second_lower hx (by linarith) hω hn hφ hbad + rw [hc2] at hh + linarith + have hLj := cappedLoglogIndex_lower hLK hLraw + have hji := cappedLoglogIndex_mono K hBord + refine ⟨hlen,hi.1,hi.2.1,hj.1,hj.2.1,loglogCutoff_mono (by exact_mod_cast hLj), + loglogCutoff_mono (by exact_mod_cast hji),hi.2.2.1,hj.2.2.1,hi.2.2.2.2.1,hi.2.2.2.2.2,?_⟩ + obtain ⟨ha1,ha1',ha2,ha2'⟩ := first_two_a_bounds + have hpos : 0 ≤ B x+5-K := by linarith + have ha : a 1+a 2 ≤ (3/2:ℝ) := by linarith + have hcost := mul_le_mul_of_nonneg_right ha hpos + have hm1 := mul_le_mul_of_nonneg_left hi.2.2.2.1 ha1.le + have hm2 := mul_le_mul_of_nonneg_left hj.2.2.2.1 ha2.le + rw [hc1,hc2] at hbad + nlinarith only [hbad,hm1,hm2,hcost] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TwoExceptionalPrimeLayer.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TwoExceptionalPrimeLayer.lean new file mode 100644 index 0000000000000000000000000000000000000000..75cee6ce8661076dacdcb655481d9510153bbe2d --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TwoExceptionalPrimeLayer.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.TotientAsymptotic.RestrictedPrimeLayer + +namespace OAI + +/-! Two distinct restricted coordinates in the short suffix. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter + +namespace TotientAsymptotic + +lemma prime_mass_two_exceptions {N n : ℕ} (hn : n ≤ N) (Q : Finset (Fin N → ℕ)) + (j k : Fin (N-n)) (hjk : j ≠ k) (U V W : Finset ℕ) + (hU : ∀ p ∈ Q, ∀ l, primeFinal p n l ∈ U) + (hV : ∀ p ∈ Q, primeFinal p n j ∈ V) + (hW : ∀ p ∈ Q, primeFinal p n k ∈ W) : + (∑ p ∈ Q, reciprocalShiftWeight p) ≤ + (∑ p ∈ Q.image (fun p => primeInitial p n hn), reciprocalShiftWeight p)* + (∑ q ∈ V, ((q-1 : ℕ) : ℝ)⁻¹)*(∑ q ∈ W, ((q-1 : ℕ) : ℝ)⁻¹)* + (∑ q ∈ U, ((q-1 : ℕ) : ℝ)⁻¹)^(N-n-2) := by + classical + let F := fun l : Fin (N-n) => ∑ q ∈ (if l=j then V else if l=k then W else U), ((q-1 : ℕ) : ℝ)⁻¹ + have hh := prime_mass_split hn Q (fun l => if l=j then V else if l=k then W else U) (by + intro p hp l + split_ifs with hj hk + · subst l; exact hV p hp + · subst l; exact hW p hp + · exact hU p hp l) + have hjmem : j ∈ (Finset.univ : Finset (Fin (N-n))) := Finset.mem_univ j + have hkmem : k ∈ (Finset.univ : Finset (Fin (N-n))).erase j := by simp [Ne.symm hjk] + have he : (∏ l, F l) = + (∑ q ∈ V, ((q-1 : ℕ) : ℝ)⁻¹)*(∑ q ∈ W, ((q-1 : ℕ) : ℝ)⁻¹)* + (∑ q ∈ U, ((q-1 : ℕ) : ℝ)⁻¹)^(N-n-2) := by + rw [← Finset.mul_prod_erase _ _ hjmem,← Finset.mul_prod_erase _ _ hkmem] + have hr : (∏ l ∈ ((Finset.univ : Finset (Fin (N-n))).erase j).erase k, F l) = + (∑ q ∈ U, ((q-1 : ℕ) : ℝ)⁻¹)^(N-n-2) := by + calc + _ = ∏ _l ∈ ((Finset.univ : Finset (Fin (N-n))).erase j).erase k, + ∑ q ∈ U, ((q-1 : ℕ) : ℝ)⁻¹ := by + apply Finset.prod_congr rfl + intro l hl + have hlk := (Finset.mem_erase.mp hl).1 + have hlj := (Finset.mem_erase.mp (Finset.mem_erase.mp hl).2).1 + simp only [F,ite_eq_right hlj,ite_eq_right hlk] + _ = _ := by simp [Finset.card_erase_of_mem hkmem,Nat.sub_sub] + rw [hr] + simp only [F,ite_true,ite_eq_right (Ne.symm hjk)] + ring + change _ ≤ _*(∏ l, F l) at hh + rw [he] at hh + simpa only [mul_assoc] using hh + +lemma restricted_two_prime_layer_mass (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) : + ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, + ∀ (S : Finset (RemainderDatum (L x H))) (n j k : ℕ), + n ≤ R x H → n < j → j ≤ L x H → n < k → k ≤ L x H → j ≠ k → + ∀ U V W : Finset ℕ, + (∀ η ∈ S, IsBasicRemainder x H η) → + (∀ η ∈ S, ∀ l ∈ Finset.Icc (n+1) (L x H), remainderPrime η l ∈ U) → + (∀ η ∈ S, remainderPrime η j ∈ V) → (∀ η ∈ S, remainderPrime η k ∈ W) → + (∑ η ∈ S, remainderReciprocalWeight η) ≤ + (∑ a ∈ Finset.Icc 1 (tailCofactorBound H), (a.totient : ℝ)⁻¹)*G x (m x)* + (∑ q ∈ V, ((q-1 : ℕ) : ℝ)⁻¹)*(∑ q ∈ W, ((q-1 : ℕ) : ℝ)⁻¹)* + (∑ q ∈ U, ((q-1 : ℕ) : ℝ)⁻¹)^(L x H-n-2) := by + filter_upwards [basic_prime_initial_mass hbox hren,eventually_ge_atTop 2] with H hpre hH + filter_upwards [hpre,theta_eventually_mem,m_tendsto.eventually (eventually_ge_atTop H)] with x hp hs hHm + intro S n j k hn hj hjL hk hkL hjk U V W hS hU hV hW + have hPH := P_lt_self hH + have hnL : n ≤ L x H := by omega + let Q := S.image RemainderDatum.primes + have hQ : Q ⊆ fullPrimeTuples x H := by + intro p hp + obtain ⟨η,hη,rfl⟩ := Finset.mem_image.mp hp + exact Finset.mem_image.mpr ⟨η,mem_basicRemainderFinset.mpr (hS η hη),rfl⟩ + let j' : Fin (L x H-n) := ⟨j-(n+1),by omega⟩ + let k' : Fin (L x H-n) := ⟨k-(n+1),by omega⟩ + have hj' : n+j'.val+1=j := by dsimp [j']; omega + have hk' : n+k'.val+1=k := by dsimp [k']; omega + have hjk' : j' ≠ k' := by intro h; have hh := congrArg Fin.val h; dsimp [j',k'] at hh; omega + have hall : ∀ p ∈ Q, ∀ l, primeFinal p n l ∈ U := by + intro p hp l + obtain ⟨η,hη,rfl⟩ := Finset.mem_image.mp hp + rw [primeFinal_remainder] + exact hU η hη _ (Finset.mem_Icc.mpr ⟨by omega,by have := l.isLt; omega⟩) + have hbadV : ∀ p ∈ Q, primeFinal p n j' ∈ V := by + intro p hp + obtain ⟨η,hη,rfl⟩ := Finset.mem_image.mp hp + rw [primeFinal_remainder,hj'] + exact hV η hη + have hbadW : ∀ p ∈ Q, primeFinal p n k' ∈ W := by + intro p hp + obtain ⟨η,hη,rfl⟩ := Finset.mem_image.mp hp + rw [primeFinal_remainder,hk'] + exact hW η hη + have hm := prime_mass_two_exceptions hnL Q j' k' hjk' U V W hall hbadV hbadW + have hb := hp n hn hnL Q hQ + have hw : 0 ≤ ∑ a ∈ Finset.Icc 1 (tailCofactorBound H), (a.totient : ℝ)⁻¹ := by positivity + calc + _ ≤ (∑ a ∈ Finset.Icc 1 (tailCofactorBound H), (a.totient : ℝ)⁻¹)* + ∑ p ∈ Q, reciprocalShiftWeight p := restricted_remainder_weight hPH hHm hs S hS + _ ≤ (∑ a ∈ Finset.Icc 1 (tailCofactorBound H), (a.totient : ℝ)⁻¹)* + ((∑ p ∈ Q.image (fun p => primeInitial p n hnL), reciprocalShiftWeight p)* + (∑ q ∈ V, ((q-1 : ℕ) : ℝ)⁻¹)*(∑ q ∈ W, ((q-1 : ℕ) : ℝ)⁻¹)* + (∑ q ∈ U, ((q-1 : ℕ) : ℝ)⁻¹)^(L x H-n-2)) := mul_le_mul_of_nonneg_left hm hw + _ ≤ _ := by + have hnonneg : 0 ≤ (∑ q ∈ V, ((q-1 : ℕ) : ℝ)⁻¹)*(∑ q ∈ W, ((q-1 : ℕ) : ℝ)⁻¹)* + (∑ q ∈ U, ((q-1 : ℕ) : ℝ)⁻¹)^(L x H-n-2) := by positivity + have hmul := mul_le_mul_of_nonneg_right hb hnonneg + simpa only [mul_assoc] using mul_le_mul_of_nonneg_left hmul hw + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/TwoPrimeResidualMass.lean b/lean/OAI/NumberTheory/TotientAsymptotic/TwoPrimeResidualMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..daf39e2c5a1f2ea13be097854580a1f8e57cf242 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/TwoPrimeResidualMass.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.TotientAsymptotic.FordCofactorStep +import OAI.NumberTheory.TotientAsymptotic.NormalityGridMass +import OAI.NumberTheory.TotientAsymptotic.TotientCountingEnvelope +import OAI.NumberTheory.TotientAsymptotic.PrimeReciprocalBound +import OAI.NumberTheory.TotientAsymptotic.MertensProduct + +namespace OAI + +/-! Residual values after one prime extension and their reciprocal mass. -/ +noncomputable section +open scoped BigOperators +namespace TotientAsymptotic + +def singlePrimeExtensions (P M : Finset ℕ) : Finset ℕ := + M ∪ M.biUnion (fun m => P.biUnion (fun p => {(p-1)*m,p*m})) + +lemma singlePrimeExtensions_pos {P M : Finset ℕ} + (hP : ∀ p ∈ P,p.Prime) (hM : ∀ m ∈ M,0 < m) : + ∀ d ∈ singlePrimeExtensions P M,0 < d := by + classical + intro d hd + rcases Finset.mem_union.mp hd with hd|hd + · exact hM d hd + · obtain ⟨m,hm,p,hp,hd⟩ := by + simpa only [Finset.mem_biUnion] using hd + have hp2 := (hP p hp).two_le + simp only [Finset.mem_insert,Finset.mem_singleton] at hd + rcases hd with rfl|rfl <;> exact Nat.mul_pos (by omega) (hM m hm) + +lemma singlePrimeExtensions_mass (P M : Finset ℕ) (hP : ∀ p ∈ P,p.Prime) : + (∑ d ∈ singlePrimeExtensions P M,(d:ℝ)⁻¹) ≤ + (1+2*∑ p ∈ P,((p-1:ℕ):ℝ)⁻¹)*(∑ m ∈ M,(m:ℝ)⁻¹) := by + classical + have hpair (m p : ℕ) (hp : p ∈ P) : + (∑ d ∈ ({(p-1)*m,p*m}:Finset ℕ),(d:ℝ)⁻¹) ≤ + 2*((p-1:ℕ):ℝ)⁻¹*(m:ℝ)⁻¹ := by + have hh : (∑ d ∈ ({(p-1)*m,p*m}:Finset ℕ),(d:ℝ)⁻¹) ≤ + (((p-1)*m:ℕ):ℝ)⁻¹+((p*m:ℕ):ℝ)⁻¹ := by + by_cases he : (p-1)*m=p*m + · simp only [he,Finset.insert_eq_of_mem (Finset.mem_singleton_self _),Finset.sum_singleton] + have hi : (0:ℝ) ≤ ((p*m:ℕ):ℝ)⁻¹ := by positivity + linarith + · rw [Finset.sum_pair he] + have hp0 : 0 < p-1 := by have := (hP p hp).two_le; omega + have hp' : (p:ℝ)⁻¹ ≤ ((p-1:ℕ):ℝ)⁻¹ := + inv_anti₀ (by exact_mod_cast hp0) (by exact_mod_cast Nat.sub_le p 1) + simp only [Nat.cast_mul,mul_inv_rev] at hh + have hm0 : 0 ≤ (m:ℝ)⁻¹ := inv_nonneg.mpr (Nat.cast_nonneg _) + nlinarith only [hh,mul_le_mul_of_nonneg_left hp' hm0] + have hmass : (∑ d ∈ M.biUnion (fun m => P.biUnion (fun p => {(p-1)*m,p*m})),(d:ℝ)⁻¹) ≤ + (2*∑ p ∈ P,((p-1:ℕ):ℝ)⁻¹)*(∑ m ∈ M,(m:ℝ)⁻¹) := by + calc + _ ≤ ∑ m ∈ M,∑ d ∈ P.biUnion (fun p => {(p-1)*m,p*m}),(d:ℝ)⁻¹ := + reciprocal_sum_biUnion_le _ _ + _ ≤ ∑ m ∈ M,∑ p ∈ P,2*((p-1:ℕ):ℝ)⁻¹*(m:ℝ)⁻¹ := by + apply Finset.sum_le_sum + intro m _ + exact (reciprocal_sum_biUnion_le _ _).trans (Finset.sum_le_sum (hpair m)) + _ = _ := by + simp only [← Finset.sum_mul,← Finset.mul_sum] + have hu := Finset.sum_union_inter (s₁:=M) + (s₂:=M.biUnion (fun m => P.biUnion (fun p => {(p-1)*m,p*m}))) + (f:=fun d : ℕ => (d:ℝ)⁻¹) + have hn : 0 ≤ ∑ d ∈ M ∩ M.biUnion (fun m => P.biUnion (fun p => {(p-1)*m,p*m})),(d:ℝ)⁻¹ := + Finset.sum_nonneg (fun d _ => inv_nonneg.mpr (Nat.cast_nonneg _)) + unfold singlePrimeExtensions + nlinarith only [hu,hmass,hn] + +lemma cofactor_singlePrimeExtensions {n k : ℕ} {P M : Finset ℕ} + (hM : (fordCofactor n (k+1)).totient ∈ M) + (hP : (fordPrime n k).Prime → fordPrime n k ∈ P) : + (fordCofactor n k).totient ∈ singlePrimeExtensions P M := by + classical + rcases fordCofactor_totient_cases n k with he|⟨hp,he⟩ + · exact Finset.mem_union_left _ (he ▸ hM) + · apply Finset.mem_union_right + apply Finset.mem_biUnion.mpr + refine ⟨(fordCofactor n (k+1)).totient,hM,?_⟩ + apply Finset.mem_biUnion.mpr + refine ⟨fordPrime n k,hP hp,?_⟩ + simpa only [Finset.mem_insert,Finset.mem_singleton] using he + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedCube.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedCube.lean new file mode 100644 index 0000000000000000000000000000000000000000..78800278b201578f734f57cc1ae62d0568e77779 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedCube.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.TotientAsymptotic.SimplexScaling +import OAI.NumberTheory.TotientAsymptotic.CubeBoundary + +namespace OAI + +/-! Unit boxes around a simplex prefix, without coordinate-band hypotheses. -/ +noncomputable section +open scoped BigOperators +open MeasureTheory +namespace TotientAsymptotic + +def prefixCubeCost (N : ℕ) : ℝ := + (N:ℝ)^2 + ∑ i : Fin N, g (i.val+1)*((N-i.val:ℕ):ℝ)^2 + +lemma prefixCubeCost_nonneg (N : ℕ) : 0 ≤ prefixCubeCost N := by + exact add_nonneg (sq_nonneg _) (Finset.sum_nonneg (fun i _ => + mul_nonneg (g_pos _).le (sq_nonneg _))) + +lemma prefixRegion_unit_cube {N : ℕ} {B : ℝ} {u v : Fin N → ℝ} + (hu : u ∈ prefixRegion N B 0 0) (hd : ∀ i, |u i-v i| ≤ 1) : + v ∈ prefixRegion N (B+(N:ℝ)^2) 0 + (fun i => -((N-i.val:ℕ):ℝ)^2) := by + refine ⟨fun i => ?_, ?_⟩ + · have hh := (le_abs_self _).trans (prefixLinear_cube_error u v hd i) + have hi := hu.1 i + change 0 ≤ prefixLinear N u i at hi + linarith + · have hh := (neg_le_abs _).trans (prefixBudget_cube_error u v hd) + have hi := hu.2 + simp only [sub_zero] at hi ⊢ + linarith + +lemma simplexScale_unit_distance {N : ℕ} {κ u v : Fin N → ℝ} + (hκ : ∀ i, 1 ≤ κ i) (hd : ∀ i, |u i-v i| ≤ 1) : + ∀ i, |simplexScale κ u i-simplexScale κ v i| ≤ 1 := by + intro i + simp only [simplexScale_apply, ← sub_div, abs_div, abs_of_pos (zero_lt_one.trans_le (hκ i))] + exact (div_le_iff₀ (zero_lt_one.trans_le (hκ i))).mpr (by + simpa only [one_mul] using (hd i).trans (hκ i)) + +/-- Diagonal normalization followed by additive cube error does not require +lower coordinate bands. The error is the exact renewal-weighted sum. -/ +theorem unbanded_grid_volume_bound {N : ℕ} (hN : 0 < N) + (B β₀ : ℝ) (β κ : Fin N → ℝ) (K : Finset (Fin N → ℕ)) + (hB : 0 ≤ B) (hβ₀ : 0 < β₀) (hβ : ∀ i, 0 < β i) + (hκ : ∀ i, 1 ≤ κ i) (htop : ∀ i, β₀ ≤ κ i) + (hstep : ∀ i j, i < j → β i*κ i ≤ κ j) + (hK : ∀ b ∈ K, ∃ u ∈ unitGridCell b, u ∈ enlargedSimplex N B β₀ β) : + (K.card:ℝ) ≤ (∏ i, κ i)* + ((B+prefixCubeCost N)^N/((N.factorial:ℝ)*∏ i : Fin N, g (i.val+1))) := by + let S := prefixRegion N (B+(N:ℝ)^2) 0 (fun i => -((N-i.val:ℕ):ℝ)^2) + have hκpos (i) : 0 < κ i := zero_lt_one.trans_le (hκ i) + have hp : 0 < ∏ i, κ i := Finset.prod_pos (fun i _ => hκpos i) + have hd : LinearMap.det (simplexScale κ) ≠ 0 := by + rw [simplexScale_det] + exact inv_ne_zero hp.ne' + have hsub : gridRegion K ⊆ (simplexScale κ) ⁻¹' S := by + intro v hv + obtain ⟨b,hv⟩ := Set.mem_iUnion.mp hv + obtain ⟨hb,hvb⟩ := Set.mem_iUnion.mp hv + obtain ⟨u,hub,hu⟩ := hK b hb + exact prefixRegion_unit_cube + (enlargedSimplex_mapsTo hβ₀ hβ hκpos htop hstep hu) + (simplexScale_unit_distance hκ (unitGridCell_coordinate_distance hub hvb)) + have hvol : volume (gridRegion K) ≤ ENNReal.ofReal (∏ i, κ i)*volume S := by + apply (measure_mono hsub).trans_eq + rw [← Measure.map_apply (simplexScale κ).continuous_of_finiteDimensional.measurable + (measurableSet_prefixRegion _ _ _ _), + Real.map_linearMap_volume_pi_eq_smul_volume_pi hd, simplexScale_det, + inv_inv, abs_of_pos hp, Measure.smul_apply, smul_eq_mul] + have he : B+(N:ℝ)^2-0-(∑ i : Fin N, g (i.val+1)*(-((N-i.val:ℕ):ℝ)^2)) = + B+prefixCubeCost N := by + simp only [prefixCubeCost, mul_neg, Finset.sum_neg_distrib] + ring + have hn : 0 ≤ B+prefixCubeCost N := add_nonneg hB (prefixCubeCost_nonneg N) + change volume (gridRegion K) ≤ ENNReal.ofReal (∏ i, κ i)* + volume (prefixRegion N (B+(N:ℝ)^2) 0 (fun i => -((N-i.val:ℕ):ℝ)^2)) at hvol + rw [volume_prefixRegion_explicit N hN, he, max_eq_left hn, + ← ENNReal.ofReal_mul hp.le] at hvol + have hh := ENNReal.toReal_mono ENNReal.ofReal_ne_top hvol + have hnresult : 0 ≤ (∏ i, κ i)*((B+prefixCubeCost N)^N/ + ((N.factorial:ℝ)*∏ i : Fin N, g (i.val+1))) := + mul_nonneg hp.le (div_nonneg (pow_nonneg hn _) + (mul_nonneg (Nat.cast_nonneg _) (Finset.prod_nonneg (fun i _ => (g_pos _).le)))) + simpa only [gridRegion_volume_real, ENNReal.toReal_ofReal hnresult] using hh + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedCubeCost.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedCubeCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ba52d350ef50952d073160d361861045f867e57 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedCubeCost.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.TotientAsymptotic.UnbandedCube +import OAI.NumberTheory.TotientAsymptotic.RenewalInput +import OAI.NumberTheory.TotientAsymptotic.RenewalLower +import OAI.NumberTheory.TotientAsymptotic.UniformPrefactor + +namespace OAI + +/-! The additive unit-box cost is uniformly comparable to one renewal coefficient. -/ +noncomputable section +open scoped BigOperators Topology +open Filter +namespace TotientAsymptotic + +lemma summable_shifted_square_geometric : + Summable (fun n : ℕ => ((n:ℝ)+1)^2*rho^n) := by + have hr : ‖rho‖ < 1 := by simpa only [Real.norm_eq_abs, abs_of_pos rho_pos] using rho_lt_one + have h2 := summable_pow_mul_geometric_of_norm_lt_one 2 hr + have h1 := summable_pow_mul_geometric_of_norm_lt_one 1 hr + have h0 := summable_geometric_of_lt_one rho_pos.le rho_lt_one + convert (h2.add (h1.mul_left 2)).add h0 using 1 + ext n + simp only [pow_one] + ring + +theorem prefixCubeCost_normalized_bound : ∃ C : ℝ, 0 < C ∧ + ∀ N : ℕ, prefixCubeCost N*rho^N ≤ C := by + obtain ⟨K,hK,hg⟩ := (normalizedRenewal_properties fordRenewalInput).2 + let S := ∑' n : ℕ, ((n:ℝ)+1)^2*rho^n + have hS : 0 < S := by + have hh := summable_shifted_square_geometric.le_tsum 0 + (fun _ _ => mul_nonneg (sq_nonneg _) (pow_nonneg rho_pos.le _)) + norm_num at hh + exact lt_of_lt_of_le (by norm_num : (0:ℝ)<1) hh + refine ⟨(1+K)*S, mul_pos (by linarith) hS, fun N => ?_⟩ + have hfirst : (N:ℝ)^2*rho^N ≤ S := by + apply le_trans _ (summable_shifted_square_geometric.le_tsum N + (fun _ _ => mul_nonneg (sq_nonneg _) (pow_nonneg rho_pos.le _))) + apply mul_le_mul_of_nonneg_right _ (pow_nonneg rho_pos.le _) + nlinarith [Nat.cast_nonneg N (α:=ℝ)] + have hsum : (∑ i : Fin N, g (i.val+1)*((N-i.val:ℕ):ℝ)^2)*rho^N ≤ K*S := by + rw [Finset.sum_mul] + calc + _ ≤ ∑ i : Fin N, K*(((N-i.val-1:ℕ):ℝ)+1)^2*rho^(N-i.val-1) := by + apply Finset.sum_le_sum + intro i _ + have hi : i.val+1+(N-i.val-1)=N := by omega + have he : ((N-i.val:ℕ):ℝ)=((N-i.val-1:ℕ):ℝ)+1 := by + exact_mod_cast (show N-i.val=N-i.val-1+1 by omega) + have hh : g (i.val+1)*rho^(i.val+1) ≤ K := by + have hh := hg (i.val+1) + rw [Real.norm_eq_abs, abs_of_pos (normalizedRenewal_pos _)] at hh + exact hh + have hm := mul_le_mul_of_nonneg_right hh + (show 0 ≤ (((N-i.val-1:ℕ):ℝ)+1)^2*rho^(N-i.val-1) by exact mul_nonneg (sq_nonneg _) (pow_nonneg rho_pos.le _)) + have hp : rho^N = rho^(i.val+1)*rho^(N-i.val-1) := by + rw [← pow_add, hi] + rw [hp, he] + nlinarith only [hm] + _ = K*∑ j ∈ Finset.range N, ((j:ℝ)+1)^2*rho^j := by + rw [Finset.mul_sum] + apply Finset.sum_bij (fun i _ => N-i.val-1) + · intro i _ + exact Finset.mem_range.mpr (by omega) + · intro i _ j _ hij + apply Fin.ext + have := i.isLt + have := j.isLt + omega + · intro j hj + have hj := Finset.mem_range.mp hj + exact ⟨⟨N-j-1,by omega⟩,Finset.mem_univ _,by simp only; omega⟩ + · intro i _ + ring + _ ≤ K*S := mul_le_mul_of_nonneg_left + (summable_shifted_square_geometric.sum_le_tsum _ + (fun _ _ => mul_nonneg (sq_nonneg _) (pow_nonneg rho_pos.le _))) hK + unfold prefixCubeCost + rw [add_mul] + nlinarith only [hfirst,hsum] + +/-- For prefixes ending `H` coordinates before the natural dimension, the +unit-box enlargement has a uniformly bounded relative volume cost. -/ +theorem prefixCubeCost_relative_bound : ∃ C : ℝ, 0 < C ∧ + ∀ᶠ x : ℝ in atTop, ∀ N ≤ m x, + (N:ℝ)*prefixCubeCost N/B x ≤ C*rho^(m x-N) := by + obtain ⟨A,hA,ha⟩ := prefixCubeCost_normalized_bound + refine ⟨2*A/lam, div_pos (mul_pos (by norm_num) hA) lam_pos, ?_⟩ + filter_upwards [inverse_scale_bound, B_tendsto.eventually (eventually_gt_atTop (0:ℝ))] + with x hx hB + intro N hN + have hcost : prefixCubeCost N ≤ A/rho^N := + (le_div_iff₀ (pow_pos rho_pos N)).mpr (ha N) + have hNm : (N:ℝ) ≤ m x := by exact_mod_cast hN + have hp : rho^N*rho^(m x-N)=rho^(m x) := by + rw [← pow_add, Nat.add_sub_of_le hN] + calc + _ ≤ (m x:ℝ)*(A/rho^N)/B x := by + apply div_le_div_of_nonneg_right _ hB.le + exact mul_le_mul hNm hcost (prefixCubeCost_nonneg N) (Nat.cast_nonneg _) + _ = A*((m x:ℝ)/(B x*rho^(m x)))*rho^(m x-N) := by + rw [← hp] + field_simp [rho_pos.ne'] + _ ≤ A*(2/lam)*rho^(m x-N) := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hx hA.le) (pow_nonneg rho_pos.le _) + _ = _ := by ring + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedEnlargementLower.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedEnlargementLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f6b6c62b1827e01296149ca95306b2a62b1701f --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedEnlargementLower.lean @@ -0,0 +1,50 @@ +import OAI.NumberTheory.TotientAsymptotic.UnbandedPrefixLower +import OAI.NumberTheory.TotientAsymptotic.EnlargementTail + +namespace OAI + +/-! A uniform linear envelope for Ford's reverse-indexed enlarged prefixes. -/ +noncomputable section +open scoped BigOperators +namespace TotientAsymptotic + +theorem reverse_enlarged_linear_lower : ∃ c : ℝ, 0 < c ∧ + ∀ m N : ℕ, N ≤ m → ∀ B : ℝ, ∀ u : Fin N → ℝ, + u ∈ enlargedSimplex N B (1+simplexBoxError 0 m) + (fun i => 1+simplexBoxError 0 (m-(i.val+1))) → + (∀ i, i.val+1=N → (1/100:ℝ) ≤ u i) → ∀ i, c*(N-i.val:ℕ) ≤ u i := by + obtain ⟨d,hd,hlower⟩ := enlarged_prefix_linear_lower + let E := Real.exp (∑' n : ℕ, (n:ℝ)*simplexBoxError 0 n) + have hE : 0 < E := Real.exp_pos _ + refine ⟨d/(100*E),div_pos hd (mul_pos (by norm_num) hE),?_⟩ + intro m N hNm B u hu hlast + cases N with + | zero => intro i; exact Fin.elim0 i + | succ N => + let β : ℕ → ℝ := fun r => 1+simplexBoxError 0 (m-r) + let κ : Fin (N+1) → ℝ := enlargementScale β + have hβ (r) : 1 ≤ β r := by + dsimp [β] + linarith [simplexBoxError_nonneg (by norm_num : (0:ℝ) ≤ 0) (m-r)] + have hκ (i) : 1 ≤ κ i ∧ κ i ≤ E := by + refine ⟨(hβ 0).trans (enlargementScale_top hβ i),?_⟩ + have hh := reverse_enlargement_coordinate (m:=m) (H:=0) (Nat.zero_le m) + (simplexBoxError 0) (simplexBoxError_nonneg (by norm_num)) + (summable_simplexBoxError_weighted 0) i (by have := i.isLt; omega) + simpa only [Nat.zero_add] using hh + have hh := hlower hE (zero_lt_one.trans_le (hβ 0)) + (fun i => zero_lt_one.trans_le (hβ (i.val+1))) hκ + (enlargementScale_top hβ) (enlargementScale_step hβ) + (enlargedSimplex_mul_const hu (by norm_num : (0:ℝ) ≤ 100)) + (by have ht := hlast (Fin.last N) (by simp); linarith) + intro i + have hi := hh i + calc + _ = (d/E*((N+1-i.val:ℕ):ℝ))/100 := by ring + _ ≤ u i := (div_le_iff₀ (by norm_num : (0:ℝ)<100)).mpr (by linarith only [hi]) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedGridVolume.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedGridVolume.lean new file mode 100644 index 0000000000000000000000000000000000000000..703e9d7c8440c973172791af0970e362dca84145 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedGridVolume.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TotientAsymptotic.UnbandedCubeCost +import OAI.NumberTheory.TotientAsymptotic.EnlargementTail +import OAI.NumberTheory.TotientAsymptotic.MassMajorant + +namespace OAI + +/-! A uniform volume bound for unbanded enlarged prime-prefix grids. -/ +noncomputable section +open scoped BigOperators Topology +open Filter +namespace TotientAsymptotic + +lemma add_pow_le_exp_ratio {B D : ℝ} (hB : 0 < B) (hD : 0 ≤ D) (N : ℕ) : + (B+D)^N ≤ Real.exp ((N:ℝ)*D/B)*B^N := by + have hbase : 1+D/B ≤ Real.exp (D/B) := by + simpa only [add_comm] using Real.add_one_le_exp (D/B) + have hpow := pow_le_pow_left₀ (by positivity : 0 ≤ 1+D/B) hbase N + have he : B+D=(1+D/B)*B := by field_simp + rw [he,mul_pow] + apply (mul_le_mul_of_nonneg_right hpow (pow_nonneg hB.le N)).trans_eq + rw [← Real.exp_nat_mul] + congr 2 + ring + +theorem unbanded_grid_uniform_volume : ∃ C : ℝ, 0 < C ∧ + ∀ᶠ x : ℝ in atTop, ∀ H : ℕ, H < m x → + ∀ K : Finset (Fin (m x-H) → ℕ), + (∀ b ∈ K, ∃ u ∈ unitGridCell b, + u ∈ enlargedSimplex (m x-H) (B x) + (1+simplexBoxError 0 (m x)) + (fun i => 1+simplexBoxError 0 (m x-(i.val+1)))) → + (K.card:ℝ) ≤ C*G x (m x-H) := by + obtain ⟨A,hA,hcost⟩ := prefixCubeCost_relative_bound + let E := Real.exp (simplexBoxTail 0 0) + refine ⟨E*Real.exp A, mul_pos (Real.exp_pos _) (Real.exp_pos _), ?_⟩ + filter_upwards [hcost,B_tendsto.eventually (eventually_gt_atTop (0:ℝ))] with x hx hB + intro H hH K hK + let β : ℕ → ℝ := fun r => 1+simplexBoxError 0 (m x-r) + have hβ (r) : 1 ≤ β r := by + dsimp [β] + linarith [simplexBoxError_nonneg (by norm_num : (0:ℝ) ≤ 0) (m x-r)] + let κ : Fin (m x-H) → ℝ := enlargementScale β + have hκ (i) : 1 ≤ κ i := (hβ 0).trans (enlargementScale_top hβ i) + have hvol := unbanded_grid_volume_bound (Nat.sub_pos_of_lt hH) (B x) (β 0) + (fun i => β (i.val+1)) κ K hB.le (zero_lt_one.trans_le (hβ 0)) + (fun i => zero_lt_one.trans_le (hβ (i.val+1))) hκ + (enlargementScale_top hβ) (enlargementScale_step hβ) hK + have hj : (∏ i, κ i) ≤ E := by + have hh := enlargement_jacobian_bound (N:=m x-H) hβ + have ht := reverse_perturbation_sum_le (Nat.le_of_lt hH) + (simplexBoxError 0) (simplexBoxError_nonneg (by norm_num)) + (summable_simplexBoxError_weighted 0) + have ht0 : (∑' n : ℕ, ((H+n:ℕ):ℝ)*simplexBoxError 0 (H+n)) ≤ + ∑' n : ℕ, (n:ℝ)*simplexBoxError 0 n := by + have hs := summable_simplexBoxError_weighted 0 + have he := hs.sum_add_tsum_nat_add H + have hn : 0 ≤ ∑ n ∈ Finset.range H, (n:ℝ)*simplexBoxError 0 n := + Finset.sum_nonneg (fun n _ => mul_nonneg (Nat.cast_nonneg n) + (simplexBoxError_nonneg (by norm_num) n)) + have hh : (∑' n : ℕ, ((n+H:ℕ):ℝ)*simplexBoxError 0 (n+H)) ≤ + ∑' n : ℕ, (n:ℝ)*simplexBoxError 0 n := by linarith only [he,hn] + simpa only [Nat.add_comm] using hh + apply hh.trans + apply Real.exp_le_exp.mpr + simp only [β,add_sub_cancel_left] + rw [simplexBoxTail_eq_tsum] + simpa only [Nat.zero_add] using ht.trans ht0 + have hratio : ((m x-H:ℕ):ℝ)*prefixCubeCost (m x-H)/B x ≤ A := by + exact (hx _ (Nat.sub_le _ _)).trans + (mul_le_of_le_one_right hA.le (pow_le_one₀ rho_pos.le rho_lt_one.le)) + have hden : 0 < ((m x-H).factorial:ℝ)*∏ i : Fin (m x-H), g (i.val+1) := + mul_pos (by positivity) (Finset.prod_pos (fun i _ => g_pos _)) + calc + _ ≤ (∏ i,κ i)*((B x+prefixCubeCost (m x-H))^(m x-H)/ + (((m x-H).factorial:ℝ)*∏ i : Fin (m x-H), g (i.val+1))) := hvol + _ ≤ E*(Real.exp A*(B x)^(m x-H)/ + (((m x-H).factorial:ℝ)*∏ i : Fin (m x-H), g (i.val+1))) := by + apply mul_le_mul hj _ + (div_nonneg (pow_nonneg (add_nonneg hB.le (prefixCubeCost_nonneg _)) _) hden.le) + (Real.exp_pos _).le + apply div_le_div_of_nonneg_right _ hden.le + exact (add_pow_le_exp_ratio hB (prefixCubeCost_nonneg _) _).trans + (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr hratio) (pow_nonneg hB.le _)) + _ = E*Real.exp A*G x (m x-H) := by + rw [G,prod_fin_shifted (m x-H) g] + ring + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedLower.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..b02d9c32d36f912731826ac4bf1767ea4c1afe38 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedLower.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.TotientAsymptotic.RegionLower +import OAI.NumberTheory.TotientAsymptotic.TailRenewal + +namespace OAI + +/-! Uniform scaled lower coordinates for the unbanded witness regions. -/ + +noncomputable section +open scoped BigOperators + +namespace TotientAsymptotic + +/-- The first retained tail prime forces every continuous prefix coordinate +above a fixed multiple of `H rho^(-h)`. This is the lower bound needed when +thickening tail boxes after removing the prefix bands. -/ +theorem tailPrefixRegion_scaled_lower (hford : FordRenewalInput) : + ∃ c : ℝ, 0 < c ∧ ∀ {x s : ℝ} {H : ℕ} {η : TailDatum H}, + 0 ≤ s → IsWitness H s η → P H < H → H ≤ m x → + ∀ {u : Fin (R x H) → ℝ}, u ∈ tailPrefixRegion x H η → + ∀ i, c*(H-1 : ℕ) ≤ rho^(m x-(i.val+1))*u i := by + obtain ⟨c, hc, hg⟩ := renewal_uniform_lower hford + refine ⟨(9/10 : ℝ)*c*lam, mul_pos (mul_pos (by norm_num) hc) lam_pos, ?_⟩ + intro x s H η hs hη hPH hHm u hu i + have hlast : H-1 ∈ Finset.Ico (P H) H := Finset.mem_Ico.mpr (by omega) + have ht := (hη.2.2.1 (H-1) hlast).2.1 + have hα := alpha_ge_lam hs + have hT : (9/10 : ℝ)*lam*(H-1 : ℕ)*(rho^(H-1))⁻¹ ≤ tailLog η (H-1) := by + apply le_trans _ ht + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hα (by norm_num)) + (Nat.cast_nonneg _)) (inv_pos.mpr (pow_pos rho_pos _)).le + have hu' := tailPrefixRegion_terminal_lower hη hPH hHm hu i + have hn : (R x H-i.val)+(H-1) = m x-(i.val+1) := by + have := i.isLt + unfold R at * + omega + have hp : rho^(m x-(i.val+1)) = rho^(R x H-i.val)*rho^(H-1) := by + rw [← pow_add, hn] + calc + _ = rho^(m x-(i.val+1))* + ((c*(rho^(R x H-i.val))⁻¹)* + ((9/10 : ℝ)*lam*(H-1 : ℕ)*(rho^(H-1))⁻¹)) := by + rw [hp] + field_simp [rho_pos.ne'] + _ ≤ rho^(m x-(i.val+1))*(g (R x H-i.val)*tailLog η (H-1)) := by + apply mul_le_mul_of_nonneg_left _ (pow_pos rho_pos _).le + exact mul_le_mul (hg _) hT (by have := lam_pos; have := rho_pos; positivity) (g_pos _).le + _ ≤ _ := mul_le_mul_of_nonneg_left hu' (pow_pos rho_pos _).le + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedPrefixLower.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedPrefixLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..b54fc44492f2c86221c3d03f5cbf9ad291a7843e --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedPrefixLower.lean @@ -0,0 +1,122 @@ +import OAI.NumberTheory.TotientAsymptotic.FordSimplexEmbedding +import OAI.NumberTheory.TotientAsymptotic.RenewalInput +import OAI.NumberTheory.TotientAsymptotic.SimplexScaling + +namespace OAI + +/-! Terminal lower bounds for finite unbanded simplex prefixes. -/ +noncomputable section +open scoped BigOperators +namespace TotientAsymptotic + +lemma enlargedSimplex_mul_const {N : ℕ} {B β₀ c : ℝ} {β u : Fin N → ℝ} + (hu : u ∈ enlargedSimplex N B β₀ β) (hc : 0 ≤ c) : + (fun i => c*u i) ∈ enlargedSimplex N (c*B) β₀ β := by + refine ⟨fun i => mul_nonneg hc (hu.1 i),?_,?_⟩ + · intro i + calc + _ = c*∑ j : Fin N, if i < j then a (j.val-i.val)*u j else 0 := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + split_ifs <;> ring + _ ≤ c*(β i*u i) := mul_le_mul_of_nonneg_left (hu.2.1 i) hc + _ = _ := by ring + · calc + _ = c*∑ i : Fin N, a (i.val+1)*u i := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + _ ≤ c*(β₀*B) := mul_le_mul_of_nonneg_left hu.2.2 hc + _ = _ := by ring + +lemma prefixRegion_last_lower {N : ℕ} {B : ℝ} {u : Fin (N+1) → ℝ} + (hu : u ∈ prefixRegion (N+1) B 0 0) (i : Fin (N+1)) : + g (N-i.val)*u (Fin.last N) ≤ u i := by + let v : ℕ → ℝ := fun j => if hj : j < N+1 then u ⟨j,hj⟩ else 0 + have hv (j) (hj : j < N+1) : v j = u ⟨j,hj⟩ := by simp only [v,dite_eq_left hj] + have hs (j : ℕ) (hj : j < N) : + (∑ r ∈ Finset.Icc (j+1) N, a (r-j)*v r) ≤ v j := by + have hh := hu.1 ⟨j,by omega⟩ + rw [prefixLinear_apply] at hh + have he : (∑ r : Fin (N+1), if (⟨j,by omega⟩:Fin (N+1)) < r then + a (r.val-j)*u r else 0) = + ∑ r ∈ Finset.Icc (j+1) N, a (r-j)*v r := by + have hv' : (∑ r : Fin (N+1), if j < r.val then a (r.val-j)*u r else 0) = + ∑ r : Fin (N+1), if j < r.val then a (r.val-j)*v r.val else 0 := by + apply Finset.sum_congr rfl + intro r _ + rw [hv r.val r.isLt] + change (∑ r : Fin (N+1), if j < r.val then a (r.val-j)*u r else 0) = _ + rw [hv',Fin.sum_univ_eq_sum_range + (fun r => if j < r then a (r-j)*v r else 0), ← Finset.sum_filter] + congr 1 + ext r + simp only [Finset.mem_filter,Finset.mem_range,Finset.mem_Icc] + omega + rw [he] at hh + rw [hv j (by omega)] + change 0 ≤ u ⟨j,by omega⟩-_ at hh + linarith + have hh := renewal_prefix_lower N v hs (show i.val ≤ N by omega) + simpa only [hv N (by omega),hv i.val i.isLt,Fin.eta,Fin.last] using hh + +lemma renewal_linear_lower : ∃ c : ℝ, 0 < c ∧ ∀ n : ℕ, c*((n:ℝ)+1) ≤ g n := by + obtain ⟨d,hd,hg⟩ := renewal_uniform_lower fordRenewalInput + let r := min 1 (rho⁻¹-1) + have hrpos : 0 < r := lt_min (by norm_num) (by + have hh : 1 < rho⁻¹ := (one_lt_inv₀ rho_pos).mpr rho_lt_one + linarith) + refine ⟨d*r,mul_pos hd hrpos,fun n => ?_⟩ + have hp := one_add_mul_sub_le_pow (show (-1:ℝ) ≤ rho⁻¹ from (by norm_num : (-1:ℝ) ≤ 0).trans (inv_pos.mpr rho_pos).le) n + have hr1 : r ≤ 1 := min_le_left _ _ + have hr2 : r ≤ rho⁻¹-1 := min_le_right _ _ + have hn := mul_le_mul_of_nonneg_left hr2 (Nat.cast_nonneg n (α:=ℝ)) + have hh : r*((n:ℝ)+1) ≤ (rho^n)⁻¹ := by + rw [← inv_pow] + nlinarith only [hr1,hn,hp] + calc + _ = d*(r*((n:ℝ)+1)) := by ring + _ ≤ d*(rho^n)⁻¹ := mul_le_mul_of_nonneg_left hh hd.le + _ ≤ g n := hg n + +/-- The linear lower envelope survives every bounded diagonal enlargement. -/ +theorem enlarged_prefix_linear_lower : ∃ d : ℝ, 0 < d ∧ + ∀ {N : ℕ} {B β₀ K : ℝ} {β κ u : Fin (N+1) → ℝ}, + 0 < K → 0 < β₀ → (∀ i, 0 < β i) → + (∀ i, 1 ≤ κ i ∧ κ i ≤ K) → + (∀ i, β₀ ≤ κ i) → (∀ i j, i < j → β i*κ i ≤ κ j) → + u ∈ enlargedSimplex (N+1) B β₀ β → 1 ≤ u (Fin.last N) → + ∀ i, d/K*((N+1-i.val:ℕ):ℝ) ≤ u i := by + obtain ⟨d,hd,hg⟩ := renewal_linear_lower + refine ⟨d,hd,?_⟩ + intro N B β₀ K β κ u hK hβ₀ hβ hκ htop hstep hu hlast i + have hκpos (j) : 0 < κ j := zero_lt_one.trans_le (hκ j).1 + have hv := enlargedSimplex_mapsTo hβ₀ hβ hκpos htop hstep hu + have hterminal : 1/K ≤ simplexScale κ u (Fin.last N) := by + rw [simplexScale_apply] + calc + _ ≤ 1/κ (Fin.last N) := div_le_div_of_nonneg_left (by norm_num) + (hκpos _) (hκ _).2 + _ ≤ _ := div_le_div_of_nonneg_right hlast (hκpos _).le + have hrec := prefixRegion_last_lower hv i + have huupper : simplexScale κ u i ≤ u i := by + rw [simplexScale_apply] + exact div_le_self (hu.1 i) (hκ i).1 + have hN : ((N+1-i.val:ℕ):ℝ)=((N-i.val:ℕ):ℝ)+1 := by + exact_mod_cast (show N+1-i.val=(N-i.val)+1 by have := i.isLt; omega) + calc + _ = (d*((N-i.val:ℕ):ℝ)+d)*(1/K) := by rw [hN]; ring + _ ≤ g (N-i.val)*(1/K) := mul_le_mul_of_nonneg_right + (by simpa only [mul_add,mul_one] using hg (N-i.val)) (by positivity) + _ ≤ g (N-i.val)*simplexScale κ u (Fin.last N) := + mul_le_mul_of_nonneg_left hterminal (g_pos _).le + _ ≤ simplexScale κ u i := hrec + _ ≤ u i := huupper + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedPrimeGrid.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedPrimeGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..1251e15663b3f2171d36a840f1ac3638db79e045 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedPrimeGrid.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.TotientAsymptotic.UnbandedCube +import OAI.NumberTheory.TotientAsymptotic.PrimeBoxGeometry + +namespace OAI + +/-! Prime mass in arbitrary nonnegative prefix regions. -/ +noncomputable section +open scoped BigOperators +open MeasureTheory +namespace TotientAsymptotic + +def tupleUnitGrid {N : ℕ} (Q : Finset (Fin N → ℕ)) : Finset (Fin N → ℕ) := + Q.image (fun p i => ⌊primePrefixCoord p i⌋₊+1) + +lemma tupleUnitGrid_cell {N : ℕ} {p : Fin N → ℕ} + (hp : ∀ i, 0 ≤ primePrefixCoord p i) : + primePrefixCoord p ∈ unitGridCell (fun i => ⌊primePrefixCoord p i⌋₊+1) := by + intro i _ + simp only [Nat.cast_add, Nat.cast_one, add_sub_cancel_right] + exact ⟨Nat.floor_le (hp i), Nat.lt_floor_add_one _⟩ + +lemma tupleUnitGrid_cover {N : ℕ} {Q : Finset (Fin N → ℕ)} + (hp : ∀ p ∈ Q, ∀ i, (p i).Prime ∧ 0 ≤ primePrefixCoord p i) : + Q ⊆ gridPrimeTuples (tupleUnitGrid Q) := by + intro p hpQ + apply Finset.mem_biUnion.mpr + refine ⟨(fun i => ⌊primePrefixCoord p i⌋₊+1), Finset.mem_image.mpr ⟨p,hpQ,rfl⟩, ?_⟩ + exact mem_primeBoxTuples_iff.mpr ⟨fun i => (hp p hpQ i).1, + tupleUnitGrid_cell (fun i => (hp p hpQ i).2)⟩ + +lemma tupleUnitGrid_positive {N : ℕ} {Q : Finset (Fin N → ℕ)} + {b : Fin N → ℕ} (hb : b ∈ tupleUnitGrid Q) (i : Fin N) : 1 ≤ b i := by + obtain ⟨p,_,rfl⟩ := Finset.mem_image.mp hb + simp only + omega + +lemma sum_exp_neg_linear_prefix {N : ℕ} {c : ℝ} (hc : 0 < c) + (b : Fin N → ℕ) (hb : ∀ i, c*(N-i.val:ℕ) ≤ (b i:ℝ)) : + (∑ i, Real.exp (-(b i:ℝ))) ≤ (1-Real.exp (-c))⁻¹ := by + let q := Real.exp (-c) + have hq0 : 0 ≤ q := (Real.exp_pos _).le + have hq1 : q < 1 := Real.exp_lt_one_iff.mpr (by linarith) + have hs := summable_geometric_of_lt_one hq0 hq1 + calc + _ ≤ ∑ i : Fin N, q^(N-i.val-1) := by + apply Finset.sum_le_sum + intro i _ + dsimp [q] + rw [← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + have hh : ((N-i.val-1:ℕ):ℝ) ≤ (N-i.val:ℕ) := by + exact_mod_cast Nat.sub_le (N-i.val) 1 + have := mul_le_mul_of_nonneg_left hh hc.le + linarith [hb i] + _ = ∑ j ∈ Finset.range N, q^j := by + apply Finset.sum_bij (fun i _ => N-i.val-1) + · intro i _ + exact Finset.mem_range.mpr (by omega) + · intro i _ j _ hij + apply Fin.ext + have := i.isLt + have := j.isLt + omega + · intro j hj + have hj := Finset.mem_range.mp hj + exact ⟨⟨N-j-1,by omega⟩,Finset.mem_univ _,by simp only; omega⟩ + · intro i _ + rfl + _ ≤ ∑' j : ℕ, q^j := hs.sum_le_tsum _ (fun _ _ => pow_nonneg hq0 _) + _ = _ := tsum_geometric_of_lt_one hq0 hq1 + +/-- A linear lower envelope is enough for a dimension-independent prime +mass factor; no concentration or band assumption is used. -/ +theorem unbanded_prime_mass_bound (hford : FordUnitPrimeBoxInput) : + ∃ C : ℝ, 0 < C ∧ ∀ {N : ℕ} (Q : Finset (Fin N → ℕ)) (c A : ℝ), + 0 < c → + (∀ p ∈ Q, ∀ i, (p i).Prime ∧ c*(N-i.val:ℕ) ≤ primePrefixCoord p i) → + ((tupleUnitGrid Q).card:ℝ) ≤ A → + (∑ p ∈ Q, reciprocalShiftWeight p) ≤ Real.exp (C*(1-Real.exp (-c))⁻¹)*A := by + obtain ⟨C,hC,hgrid⟩ := grid_prime_mass_error_of_sum hford + refine ⟨C,hC,?_⟩ + intro N Q c A hc hQ hA + have hp (p) (hpQ : p ∈ Q) (i) : (p i).Prime ∧ 0 ≤ primePrefixCoord p i := + ⟨(hQ p hpQ i).1, (mul_nonneg hc.le (Nat.cast_nonneg _)).trans (hQ p hpQ i).2⟩ + have he (b) (hb : b ∈ tupleUnitGrid Q) : + (∑ i, Real.exp (-(b i:ℝ))) ≤ (1-Real.exp (-c))⁻¹ := by + apply sum_exp_neg_linear_prefix hc b + obtain ⟨p,hpQ,rfl⟩ := Finset.mem_image.mp hb + intro i + exact (hQ p hpQ i).2.trans (by + simpa only [Nat.cast_add, Nat.cast_one] using (Nat.lt_floor_add_one (primePrefixCoord p i)).le) + have hh := (le_abs_self _).trans (hgrid (tupleUnitGrid Q) _ + (fun b hb i => tupleUnitGrid_positive hb i) he) + calc + _ ≤ gridPrimeMass (tupleUnitGrid Q) := + Finset.sum_le_sum_of_subset_of_nonneg (tupleUnitGrid_cover hp) + (fun p _ _ => reciprocalShiftWeight_nonneg p) + _ ≤ Real.exp (C*(1-Real.exp (-c))⁻¹)*(tupleUnitGrid Q).card := by + nlinarith only [hh] + _ ≤ _ := mul_le_mul_of_nonneg_left hA (Real.exp_pos _).le + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedSimplexMass.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedSimplexMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ec30e6985fa8f1e6eecd77fda9a56d5d59ca837 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedSimplexMass.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.TotientAsymptotic.UnbandedPrimeGrid +import OAI.NumberTheory.TotientAsymptotic.UnbandedGridVolume +import OAI.NumberTheory.TotientAsymptotic.UnbandedEnlargementLower +import OAI.NumberTheory.TotientAsymptotic.PrimeBoxInput + +namespace OAI + +/-! The prime-prefix mass bound used before the first failed simplex row. -/ +noncomputable section +open scoped BigOperators Topology +open Filter +namespace TotientAsymptotic + +theorem unbanded_simplex_prime_mass : ∃ C : ℝ, 0 < C ∧ + ∀ᶠ x : ℝ in atTop, ∀ H : ℕ, H < m x → + ∀ Q : Finset (Fin (m x-H) → ℕ), + (∀ p ∈ Q, (∀ i, (p i).Prime) ∧ + primePrefixCoord p ∈ enlargedSimplex (m x-H) (B x) + (1+simplexBoxError 0 (m x)) + (fun i => 1+simplexBoxError 0 (m x-(i.val+1))) ∧ + (∀ i, i.val+1=m x-H → (1/100:ℝ) ≤ primePrefixCoord p i)) → + (∑ p ∈ Q, reciprocalShiftWeight p) ≤ C*G x (m x-H) := by + obtain ⟨A,hA,hvolume⟩ := unbanded_grid_uniform_volume + obtain ⟨c,hc,hlower⟩ := reverse_enlarged_linear_lower + obtain ⟨D,hD,hmass⟩ := unbanded_prime_mass_bound fordUnitPrimeBoxInput + refine ⟨Real.exp (D*(1-Real.exp (-c))⁻¹)*A, + mul_pos (Real.exp_pos _) hA, ?_⟩ + filter_upwards [hvolume] with x hx + intro H hH Q hQ + have hcoords (p) (hp : p ∈ Q) : + ∀ i, c*(m x-H-i.val:ℕ) ≤ primePrefixCoord p i := + hlower (m x) (m x-H) (Nat.sub_le _ _) (B x) (primePrefixCoord p) + (hQ p hp).2.1 (hQ p hp).2.2 + have hcard : ((tupleUnitGrid Q).card:ℝ) ≤ A*G x (m x-H) := by + apply hx H hH + intro b hb + obtain ⟨p,hp,rfl⟩ := Finset.mem_image.mp hb + refine ⟨primePrefixCoord p,tupleUnitGrid_cell (fun i => ?_),(hQ p hp).2.1⟩ + exact (mul_nonneg hc.le (Nat.cast_nonneg _)).trans (hcoords p hp i) + have hh := hmass Q c (A*G x (m x-H)) hc + (fun p hp i => ⟨(hQ p hp).1 i,hcoords p hp i⟩) hcard + simpa only [mul_assoc] using hh + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedTerminalCube.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedTerminalCube.lean new file mode 100644 index 0000000000000000000000000000000000000000..fd1a2162ac060bb63945e405fecad26f1918062a --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UnbandedTerminalCube.lean @@ -0,0 +1,103 @@ +import OAI.NumberTheory.TotientAsymptotic.UnbandedCube +import OAI.NumberTheory.TotientAsymptotic.PrefixTerminalVolume +import OAI.NumberTheory.TotientAsymptotic.SimplexTerminalCap + +namespace OAI + +/-! A terminal lower bound survives unit-box thickening with its exact cost. -/ +noncomputable section +open scoped BigOperators +open MeasureTheory +namespace TotientAsymptotic + +theorem unbanded_grid_terminal_volume_bound (N : ℕ) + (B β₀ t : ℝ) (β κ : Fin (N+1) → ℝ) (K : Finset (Fin (N+1) → ℕ)) + (hβ₀ : 0 < β₀) (hβ : ∀ i,0 < β i) (ht : 0 ≤ t) + (hκ : ∀ i,1 ≤ κ i) (htop : ∀ i,β₀ ≤ κ i) + (hstep : ∀ i j,i < j → β i*κ i ≤ κ j) + (hK : ∀ b ∈ K,∃ u ∈ unitGridCell b, + u ∈ enlargedSimplex (N+1) B β₀ β ∧ t ≤ u (Fin.last N)) : + (K.card:ℝ) ≤ (∏ i,κ i)* + ((max (B+prefixCubeCost (N+1)-g (N+1)*(t/κ (Fin.last N))) 0)^(N+1)/ + (((N+1).factorial:ℝ)*∏ i : Fin (N+1),g (i.val+1))) := by + let C : Fin (N+1) → ℝ := fun i => -((N+1-i.val:ℕ):ℝ)^2 + let S := prefixRegion (N+1) (B+(N+1:ℝ)^2) 0 C ∩ + {u | t/κ (Fin.last N)-1 ≤ u (Fin.last N)} + have hκpos (i) : 0 < κ i := zero_lt_one.trans_le (hκ i) + have hp : 0 < ∏ i,κ i := Finset.prod_pos (fun i _ => hκpos i) + have hd : LinearMap.det (simplexScale κ)≠0 := by + rw [simplexScale_det] + exact inv_ne_zero hp.ne' + have hsub : gridRegion K ⊆ simplexScale κ ⁻¹' S := by + intro v hv + obtain ⟨b,hv⟩ := Set.mem_iUnion.mp hv + obtain ⟨hb,hvb⟩ := Set.mem_iUnion.mp hv + obtain ⟨u,hub,hu,hterminal⟩ := hK b hb + have hdist := simplexScale_unit_distance hκ (unitGridCell_coordinate_distance hub hvb) + refine ⟨?_,?_⟩ + · simpa only [Nat.cast_add,Nat.cast_one,C] using prefixRegion_unit_cube + (enlargedSimplex_mapsTo hβ₀ hβ hκpos htop hstep hu) hdist + · have ht' := div_le_div_of_nonneg_right hterminal (hκpos (Fin.last N)).le + have hd' := (abs_le.mp (hdist (Fin.last N))).2 + rw [simplexScale_apply] at hd' + change t/κ (Fin.last N)-1 ≤ simplexScale κ v (Fin.last N) + linarith only [ht',hd'] + have hS : MeasurableSet S := + (measurableSet_prefixRegion _ _ _ _).inter + (measurableSet_le measurable_const (measurable_pi_apply _)) + have hvol : volume (gridRegion K) ≤ ENNReal.ofReal (∏ i,κ i)*volume S := by + apply (measure_mono hsub).trans_eq + rw [← Measure.map_apply (simplexScale κ).continuous_of_finiteDimensional.measurable hS, + Real.map_linearMap_volume_pi_eq_smul_volume_pi hd,simplexScale_det, + inv_inv,abs_of_pos hp,Measure.smul_apply,smul_eq_mul] + have hC : C (Fin.last N)= -1 := by simp [C] + have hthreshold : C (Fin.last N) ≤ t/κ (Fin.last N)-1 := by + rw [hC] + have hh := div_nonneg ht (hκpos (Fin.last N)).le + linarith only [hh] + have hformula := volume_prefixRegion_terminal N (B+(N+1:ℝ)^2) 0 C hthreshold + have hbudget : B+(N+1:ℝ)^2-0-(∑ i : Fin (N+1),g (i.val+1)*C i)- + g (N+1)*(t/κ (Fin.last N)-1-C (Fin.last N))= + B+prefixCubeCost (N+1)-g (N+1)*(t/κ (Fin.last N)) := by + rw [hC] + simp only [C,prefixCubeCost,mul_neg,Finset.sum_neg_distrib,Nat.cast_add,Nat.cast_one] + ring + rw [hbudget] at hformula + change volume (gridRegion K) ≤ ENNReal.ofReal (∏ i,κ i)* + volume (prefixRegion (N+1) (B+(N+1:ℝ)^2) 0 C ∩ + {u | t/κ (Fin.last N)-1 ≤ u (Fin.last N)}) at hvol + rw [hformula,← ENNReal.ofReal_mul hp.le] at hvol + have hh := ENNReal.toReal_mono ENNReal.ofReal_ne_top hvol + have hden : 0 ≤ (((N+1).factorial:ℝ)*∏ i : Fin (N+1),g (i.val+1)) := + mul_nonneg (Nat.cast_nonneg _) (Finset.prod_nonneg (fun i _ => (g_pos _).le)) + have hnresult : 0 ≤ (∏ i,κ i)* + ((max (B+prefixCubeCost (N+1)-g (N+1)*(t/κ (Fin.last N))) 0)^(N+1)/ + (((N+1).factorial:ℝ)*∏ i : Fin (N+1),g (i.val+1))) := + mul_nonneg hp.le (div_nonneg (pow_nonneg (le_max_right _ _) _) hden) + simpa only [gridRegion_volume_real,ENNReal.toReal_ofReal hnresult] using hh + +theorem unbanded_grid_terminal_exponential (N : ℕ) + (B β₀ t : ℝ) (β κ : Fin (N+1) → ℝ) (K : Finset (Fin (N+1) → ℕ)) + (hB : 0 < B) (hβ₀ : 0 < β₀) (hβ : ∀ i,0 < β i) (ht : 0 ≤ t) + (hκ : ∀ i,1 ≤ κ i) (htop : ∀ i,β₀ ≤ κ i) + (hstep : ∀ i j,i < j → β i*κ i ≤ κ j) + (hK : ∀ b ∈ K,∃ u ∈ unitGridCell b, + u ∈ enlargedSimplex (N+1) B β₀ β ∧ t ≤ u (Fin.last N)) : + (K.card:ℝ) ≤ (∏ i,κ i)* + (Real.exp (-((N+1:ℕ):ℝ)*(g (N+1)*(t/κ (Fin.last N)))/ + (B+prefixCubeCost (N+1)))* + (B+prefixCubeCost (N+1))^(N+1)/ + (((N+1).factorial:ℝ)*∏ i : Fin (N+1),g (i.val+1))) := by + apply (unbanded_grid_terminal_volume_bound N B β₀ t β κ K hβ₀ hβ ht hκ htop hstep hK).trans + apply mul_le_mul_of_nonneg_left _ (Finset.prod_nonneg (fun i _ => (hκ i).trans' zero_le_one)) + apply div_le_div_of_nonneg_right _ + (mul_nonneg (Nat.cast_nonneg _) (Finset.prod_nonneg (fun i _ => (g_pos _).le))) + exact simplex_positive_part_power_bound + (add_pos_of_pos_of_nonneg hB (prefixCubeCost_nonneg _)) + (mul_nonneg (g_pos _).le (div_nonneg ht (zero_le_one.trans (hκ _)))) (by omega) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UnconditionalMain.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UnconditionalMain.lean new file mode 100644 index 0000000000000000000000000000000000000000..60225f2c27398c81d0f330b12ff88393cdf63cc5 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UnconditionalMain.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.TotientAsymptotic.FordInputs +import OAI.NumberTheory.TotientAsymptotic.PPTFixedBandLimit + +namespace OAI + +/-! Asymptotic counting and least-preimage interval theorems. -/ +noncomputable section +open scoped Topology +open Filter +namespace TotientAsymptotic + +theorem totient_asymptotic_formula + : + TendstoUniformlyOn (fun H => AH H (fun _ => 1)) (A (fun _ => 1)) + atTop (Set.Ico (0 : ℝ) 1) ∧ + (∃ cMinus cPlus : ℝ, 0 < cMinus ∧ ∀ s ∈ Set.Ico (0 : ℝ) 1, + cMinus ≤ A (fun _ => 1) s ∧ A (fun _ => 1) s ≤ cPlus) ∧ + Tendsto (fun x => V x/mainTerm x) atTop (nhds 1) ∧ + ∀ c : ℝ, 0 < c → Tendsto (fun x => V (c*x)/V x) atTop (nhds c) := + conditional_main_theorem_of_structure fordScaleBounds extractedStructureInput primeNumberTheoremInput fordUnitPrimeBoxInput + fordRenewalInput mertensProductInput fordLemma26Input fordLemma51Input fordCoordinateConcentrationInput + +theorem weighted_totient_asymptotic + (k : ℕ) (hk : 1≤k) : + TendstoUniformlyOn (fun H => AH H (fk k)) (A (fk k)) atTop (Set.Ico (0 : ℝ) 1) ∧ + Tendsto (fun x => normalizedCount (N k) x-A (fk k) (theta x)) atTop (nhds 0) ∧ + ((∃ d : ℕ, IsTotient d ∧ k*d N k x/(tupleNormalization x*A (fk k) (theta x))) atTop (nhds 1) ∧ + ∀ᶠ x : ℝ in atTop, (cMinus/cPlus)*V x≤N k x ∧ N k x≤V x) ∧ + ((¬∃ d : ℕ, IsTotient d ∧ k*d 1) s := + AH_nonneg H hs (fun _ => 1) (fun _ _ => ⟨zero_le_one, le_rfl⟩) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UniformNonNormalCount.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UniformNonNormalCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..9fda2cf83abf7cef22afcc35d26a6f2997e8e30d --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UniformNonNormalCount.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.TotientAsymptotic.SqrtCountingCutoff + +namespace OAI + +/-! Uniform form of the non-normal-prime value exception. -/ +noncomputable section +open scoped BigOperators +namespace TotientAsymptotic + +theorem uniform_non_normal_value_count : ∃ C : ℝ,0 < C ∧ + ∀ (S x : ℝ) (J : ℕ),2 < S → 0 ≤ B S → 256 ≤ x → 1 ≤ J → + x ≤ (2:ℝ)^J → ∀ Q : Finset ℕ, + (∀ v ∈ Q,∃ n p : ℕ,0 < n ∧ n.totient=v ∧ p.Prime ∧ p ∣ n ∧ + (v:ℝ) ≤ x ∧ ¬IsNormalPrime S p) → + (Q.card:ℝ) ≤ C*dyadicTotientEnvelope J*x/Real.log x* + (B (2*x))^5*(1+Real.log J)*(Real.log S)^(-1/6:ℝ) := by + obtain ⟨C,D,hC,hD,hcount⟩ := non_normal_value_count_split + refine ⟨C+5*D,by positivity,?_⟩ + intro S x J hS hBS hx hJ hxJ Q hQ + let N := ⌊Real.sqrt x⌋₊ + let L := Nat.clog 2 N + have hcut := sqrt_counting_cutoff hx + have hN : 4 ≤ N := hcut.1 + have hNR : (1:ℝ) ≤ N := by exact_mod_cast (show 1 ≤ N by omega) + have hNx : (N:ℝ) ≤ x := by nlinarith only [hcut.2.1,hNR] + have hNJ : N ≤ 2^J := by exact_mod_cast hNx.trans hxJ + have hLJ : L ≤ J := (Nat.clog_le_iff_le_pow (by norm_num : 1 < 2)).mpr hNJ + have hb := dyadic_nat_bounds (show 1 < N by omega) + have hL1 : 1 ≤ L := hb.1 + have hLlog : 1+Real.log L ≤ 1+Real.log J := by + exact add_le_add le_rfl (Real.log_le_log (by exact_mod_cast (show 0 < L by omega)) + (by exact_mod_cast hLJ)) + have hLlog0 : 0 ≤ 1+Real.log L := by + have hh := Real.log_nonneg (show (1:ℝ) ≤ L by exact_mod_cast hL1) + linarith + have hJlog1 : 1 ≤ 1+Real.log J := by + have hh := Real.log_nonneg (show (1:ℝ) ≤ J by exact_mod_cast hJ) + linarith + have hpow2x : (2:ℝ)^L ≤ 2*x := by nlinarith only [hb.2.1,hNx] + have hBsmall0 : 0 ≤ B ((2:ℝ)^L) := by + have h4 : 4 ≤ (2:ℕ)^L := hN.trans (Nat.le_pow_clog (by norm_num : 1 < 2) N) + have hh := (doubleLog_nat_pos h4).le + simpa only [Nat.cast_pow,Nat.cast_ofNat] using hh + have hB : B ((2:ℝ)^L) ≤ B (2*x) := by + have hp : (1:ℝ) < 2^L := by + have h4 : 4 ≤ (2:ℕ)^L := hN.trans (Nat.le_pow_clog (by norm_num : 1 < 2) N) + exact_mod_cast (show 1 < (2:ℕ)^L by omega) + exact Real.log_le_log (Real.log_pos hp) (Real.log_le_log (by positivity) hpow2x) + have hB0 : 0 ≤ B (2*x) := hBsmall0.trans hB + have hmass : (B ((2:ℝ)^L))^5*(1+Real.log L) ≤ (B (2*x))^5*(1+Real.log J) := + mul_le_mul (pow_le_pow_left₀ hBsmall0 hB 5) hLlog hLlog0 (pow_nonneg hB0 _) + have hE1 : 1 ≤ dyadicTotientEnvelope J := dyadicTotientEnvelope_one_le J + have hE0 : 0 ≤ dyadicTotientEnvelope J := by linarith + have hlogx : 0 < Real.log x := Real.log_pos (by linarith) + have hlogS : 0 < Real.log S := Real.log_pos (by linarith) + have hsn : 0 ≤ (Real.log S)^(-1/6:ℝ) := Real.rpow_nonneg hlogS.le _ + have hlarge : 1+4*dyadicTotientEnvelope J*(1+Real.log J) ≤ + 5*dyadicTotientEnvelope J*(1+Real.log J) := by + have hh := mul_le_mul hE1 hJlog1 (by norm_num) hE0 + nlinarith only [hh] + have hs : C*dyadicTotientEnvelope J*x/Real.log x* + (B ((2:ℝ)^L))^5*(1+Real.log L)*(Real.log S)^(-1/6:ℝ) ≤ + C*dyadicTotientEnvelope J*x/Real.log x* + (B (2*x))^5*(1+Real.log J)*(Real.log S)^(-1/6:ℝ) := by + have hh := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hmass (show 0 ≤ C*dyadicTotientEnvelope J*x/Real.log x by positivity)) hsn + convert hh using 1 <;> ring + have hl : (D*x/Real.log x*(B (2*x))^5*(Real.log S)^(-1/6:ℝ))* + (1+4*dyadicTotientEnvelope J*(1+Real.log J)) ≤ + (5*D)*dyadicTotientEnvelope J*x/Real.log x*(B (2*x))^5*(1+Real.log J)*(Real.log S)^(-1/6:ℝ) := by + have hh := mul_le_mul_of_nonneg_left hlarge + (show 0 ≤ D*x/Real.log x*(B (2*x))^5*(Real.log S)^(-1/6:ℝ) by positivity) + convert hh using 1 + ring + have hc := hcount S x N J hS hBS hN (by linarith) hcut.2.1 hcut.2.2 hJ hxJ Q hQ + exact hc.trans ((add_le_add hs hl).trans_eq (by ring)) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UniformPrefactor.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UniformPrefactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..46abeedbc8dede074e5cfa056ce9591ba93351c8 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UniformPrefactor.lean @@ -0,0 +1,119 @@ +import OAI.NumberTheory.TotientAsymptotic.Prefactor + +namespace OAI + +/-! A simultaneous bound for all projected prefix volumes. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter + +namespace TotientAsymptotic + +lemma inverse_scale_eq {x : ℝ} (hB : 1 < B x) (hm : 0 < m x) : + (m x : ℝ)/(B x*rho^(m x)) = (alpha (theta x)*bandCenterRatio x)⁻¹ := by + rw [alpha_theta_eq hB] + unfold bandCenterRatio + field_simp [(Real.log_pos hB).ne', (zero_lt_one.trans hB).ne', + lam_pos.ne', Nat.cast_ne_zero.mpr hm.ne', rho_pos.ne'] + +lemma inverse_scale_bound : ∀ᶠ x : ℝ in atTop, + (m x : ℝ)/(B x*rho^(m x)) ≤ 2/lam := by + filter_upwards [theta_eventually_mem, + B_tendsto.eventually (eventually_gt_atTop (1 : ℝ)), + m_tendsto.eventually (eventually_gt_atTop 0), + bandCenterRatio_tendsto.eventually + (eventually_gt_nhds (show (1/2 : ℝ) < 1 by norm_num))] with x hx hB hm hv + rw [inverse_scale_eq hB hm] + have ha := alpha_ge_lam hx.1 + have hprod : lam/2 ≤ alpha (theta x)*bandCenterRatio x := by + nlinarith [lam_pos, alpha_pos (theta x)] + calc + _ ≤ (lam/2)⁻¹ := inv_anti₀ (div_pos lam_pos (by norm_num)) hprod + _ = _ := by ring + +lemma uniform_step_bound (hford : FordRenewalInput) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ x : ℝ in atTop, ∀ i ≤ m x, + ((m x-i : ℕ) : ℝ)*g (m x-i)/B x ≤ C*rho^i := by + obtain ⟨_, K, hK, hg⟩ := normalizedRenewal_properties hford + let C := 2*(K+1)/lam + refine ⟨C, div_pos (mul_pos (by norm_num) (by linarith)) lam_pos, ?_⟩ + filter_upwards [inverse_scale_bound, + B_tendsto.eventually (eventually_gt_atTop (0 : ℝ))] with x hx hB + intro i hi + have hgn : g (m x-i)*rho^(m x-i) ≤ K+1 := by + have hh := hg (m x-i) + change |g (m x-i)*rho^(m x-i)| ≤ K at hh + exact (le_abs_self _).trans (hh.trans (by linarith)) + have hg' : g (m x-i) ≤ (K+1)/rho^(m x-i) := + (le_div_iff₀ (pow_pos rho_pos _)).mpr hgn + have hm' : ((m x-i : ℕ) : ℝ) ≤ m x := by exact_mod_cast Nat.sub_le (m x) i + have hpow : rho^(m x-i)*rho^i = rho^(m x) := by + rw [← pow_add, Nat.sub_add_cancel hi] + calc + _ ≤ (m x : ℝ)*((K+1)/rho^(m x-i))/B x := by + apply div_le_div_of_nonneg_right _ hB.le + exact mul_le_mul hm' hg' (g_pos _).le (Nat.cast_nonneg _) + _ = ((K+1)*((m x : ℝ)/(B x*rho^(m x))))*rho^i := by + rw [← hpow] + field_simp [rho_pos.ne'] + _ ≤ ((K+1)*(2/lam))*rho^i := + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hx (by linarith)) + (pow_nonneg rho_pos.le _) + _ = C*rho^i := by dsimp [C]; ring + +/-- Ford's bounded renewal error yields the manuscript's simultaneous +projected-volume majorant, including prefixes whose length moves with `x`. -/ +theorem uniform_projected_volume_bound (hford : FordRenewalInput) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ x : ℝ in atTop, ∀ H ≤ m x, + G x (m x-H)/G x (m x) ≤ C^H*rho^(H*(H-1)/2) := by + obtain ⟨C, hC, hstep⟩ := uniform_step_bound hford + refine ⟨C, hC, ?_⟩ + filter_upwards [hstep, B_tendsto.eventually (eventually_gt_atTop (0 : ℝ))] + with x hx hB + intro H hH + rw [G_sub_eq_product hB (m x) H hH, mul_div_cancel_left₀ _ (G_pos hB _).ne'] + calc + _ ≤ ∏ i ∈ Finset.range H, C*rho^i := by + apply Finset.prod_le_prod₀ + · intro i hi + exact div_nonneg (mul_nonneg (Nat.cast_nonneg _) (g_pos _).le) hB.le + · intro i hi + exact hx i (by have := Finset.mem_range.mp hi; omega) + _ = _ := by + rw [Finset.prod_mul_distrib, Finset.prod_const, Finset.card_range, + Finset.prod_pow_eq_pow_sum, Finset.sum_range_id] + +def projectedEnvelope (C : ℝ) (H : ℕ) : ℝ := C^H*rho^(H*(H-1)/2) + +lemma summable_projectedEnvelope {C : ℝ} (hC : 0 < C) : + Summable (projectedEnvelope C) := by + have hh : Tendsto (fun n : ℕ => C*rho^n) atTop (nhds 0) := by + simpa using (tendsto_pow_atTop_nhds_zero_of_lt_one rho_pos.le rho_lt_one).const_mul C + obtain ⟨K, hK⟩ := eventually_atTop.mp + (hh.eventually (eventually_lt_nhds (show (0 : ℝ) < 1 by norm_num))) + let q := C*rho^K + have hq : 0 < q := mul_pos hC (pow_pos rho_pos _) + have hq1 : q < 1 := hK K le_rfl + have hg : Summable (fun n : ℕ => q^n) := + summable_geometric_of_lt_one hq.le hq1 + apply hg.of_norm_bounded_eventually_nat + filter_upwards [eventually_ge_atTop (2*K+1)] with n hn + have htri : K*n ≤ n*(n-1)/2 := by + have hn' : 2*K ≤ n-1 := by omega + have hm := Nat.mul_le_mul_left n hn' + apply (Nat.le_div_iff_mul_le (by norm_num : 0 < 2)).mpr + nlinarith + unfold projectedEnvelope + rw [Real.norm_eq_abs, abs_of_pos + (mul_pos (pow_pos hC _) (pow_pos rho_pos _))] + calc + _ ≤ C^n*rho^(K*n) := mul_le_mul_of_nonneg_left + (pow_le_pow_of_le_one rho_pos.le rho_lt_one.le htri) (pow_pos hC _).le + _ = q^n := by rw [pow_mul, mul_pow] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UniformPrimePairBound.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UniformPrimePairBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbb57fb1e515b65ec149d81f7c15f759caab9c70 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UniformPrimePairBound.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.TotientAsymptotic.AllShiftedPrimePairs +import OAI.NumberTheory.TotientAsymptotic.SieveCutoff + +namespace OAI + +/-! A uniform elementary upper-bound sieve for q and bq+1. -/ +noncomputable section +open scoped BigOperators +namespace TotientAsymptotic + +lemma allShiftedPrimePairs_large_bound {b X : ℕ} (hb : 0 hn (Set.mem_iUnion.mpr ⟨η, Set.mem_iUnion.mpr ⟨hη, ht⟩⟩)⟩ + exact measureReal_mono hsub (ne_top_of_le_ne_top (prefixBandRegion_volume_ne_top x H) + (measure_mono (fun _ hu => hu.1.2))) + +/-- Removing all retained `xi` factors in the actual witness unions has a +vanishing normalized error for every weight between zero and one. -/ +theorem weighted_union_perturbation_removal (hbox : FordUnitPrimeBoxInput) + (hmertens : MertensProductInput) (hren : FordRenewalInput) : + ∃ ε : ℕ → ℝ, Tendsto ε atTop (nhds 0) ∧ + ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, + ∀ f : ℝ → ℝ, (∀ r, 0 ≤ f r ∧ f r ≤ 1) → + (∑ d ∈ Finset.Icc 1 (tailValueBound H), f ((ell d : ℝ)/d)/d * + volume.real ((⋃ η ∈ witnessFinset H (theta x) d, + perturbedTailPrefixRegion x H η ∩ prefixBandRegion x H) \ + (⋃ η ∈ witnessFinset H (theta x) d, tailPrefixRegion x H η)))/G x (m x) ≤ ε H := by + obtain ⟨ε, hε, hbound⟩ := witness_perturbation_removal hbox hmertens hren + refine ⟨ε, hε, ?_⟩ + filter_upwards [hbound] with H hH + filter_upwards [hH, theta_eventually_mem, + B_tendsto.eventually (eventually_gt_atTop (0 : ℝ))] with x hx hs hB + intro f hf + apply le_trans _ (hx (activeWitnesses H (theta x)) + (fun η hη => (mem_activeWitnesses hs).mp hη)) + apply div_le_div_of_nonneg_right _ (G_pos hB _).le + rw [← weighted_witness_fibers hs] + apply Finset.sum_le_sum + intro d hd + have hd0 : (0 : ℝ) < d := by exact_mod_cast (Finset.mem_Icc.mp hd).1 + have hw : 0 ≤ f ((ell d : ℝ)/d)/d := div_nonneg (hf _).1 hd0.le + have hw' : f ((ell d : ℝ)/d)/d ≤ (d : ℝ)⁻¹ := by + simpa only [one_div] using div_le_div_of_nonneg_right (hf _).2 hd0.le + exact (mul_le_mul_of_nonneg_left (union_perturbation_loss_bound d) hw).trans + (mul_le_mul_of_nonneg_right hw' (Finset.sum_nonneg (fun _ _ => measureReal_nonneg))) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UnionVolume.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UnionVolume.lean new file mode 100644 index 0000000000000000000000000000000000000000..36b3e6f3ca365a95cffde5a8271cdc5c764b2a99 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UnionVolume.lean @@ -0,0 +1,167 @@ +import OAI.NumberTheory.TotientAsymptotic.FiniteCoefficient + +namespace OAI + +/-! The exact union-volume coefficient and its finite-tail limit. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter MeasureTheory +attribute [local instance] Classical.propDecidable + +namespace TotientAsymptotic + +def witnessFinset (H : ℕ) (s : ℝ) (d : ℕ) : Finset (TailDatum H) := + (allTailData H).filter (fun η => η ∈ witnesses H s d) + +lemma mem_witnessFinset {H : ℕ} {s : ℝ} {d : ℕ} {η : TailDatum H} + (hs : s ∈ Set.Ico (0 : ℝ) 1) : + η ∈ witnessFinset H s d ↔ η ∈ witnesses H s d := by + simp only [witnessFinset, Finset.mem_filter] + exact ⟨And.right, fun h => ⟨witness_mem_allTailData hs h.1, h⟩⟩ + +lemma measurableSet_tailPrefixRegion (x : ℝ) (H : ℕ) (η : TailDatum H) : + MeasurableSet (tailPrefixRegion x H η) := by + unfold tailPrefixRegion + rw [prefixRegion_eq_simplex_preimage] + exact (prefixAffine_preserves_volume _ _).measurable + (measurableSet_weightedSimplex _ _) + +lemma volume_tailPrefixRegion_ne_top {x : ℝ} {H : ℕ} (hR : 0 < R x H) + (η : TailDatum H) : volume (tailPrefixRegion x H η) ≠ ⊤ := by + unfold tailPrefixRegion + rw [volume_prefixRegion_explicit _ hR] + exact ENNReal.ofReal_ne_top + +def unionVolumeCoefficient (H : ℕ) (f : ℝ → ℝ) (x : ℝ) : ℝ := + ∑ d ∈ Finset.Icc 1 (tailValueBound H), + if IsTotient d then f ((ell d : ℝ)/d)/d * + (volume (⋃ η ∈ witnessFinset H (theta x) d, tailPrefixRegion x H η)).toReal / + G x (m x) + else 0 + +lemma subset_witnessFinset {H : ℕ} {s : ℝ} {d : ℕ} (hs : s ∈ Set.Ico (0 : ℝ) 1) + (T : Finset (TailDatum H)) : + T ⊆ witnessFinset H s d ↔ (↑T : Set (TailDatum H)) ⊆ witnesses H s d := by + exact ⟨fun h η hη => (mem_witnessFinset hs).mp (h hη), + fun h η hη => (mem_witnessFinset hs).mpr (h hη)⟩ + +lemma union_volume_inclusion_exclusion {x : ℝ} {H : ℕ} {s : ℝ} + (hs : s ∈ Set.Ico (0 : ℝ) 1) (hR : 0 < R x H) (d : ℕ) : + (volume (⋃ η ∈ witnessFinset H s d, tailPrefixRegion x H η)).toReal = + ∑ T ∈ nonemptyTailSubsets H, + if (↑T : Set (TailDatum H)) ⊆ witnesses H s d then + (-1 : ℝ)^(T.card-1) * (volume (tailIntersection x H T)).toReal else 0 := by + rw [show (volume (⋃ η ∈ witnessFinset H s d, tailPrefixRegion x H η)).toReal = + volume.real (⋃ η ∈ witnessFinset H s d, tailPrefixRegion x H η) from rfl, + measureReal_biUnion_eq_sum_powerset + (fun η _ => measurableSet_tailPrefixRegion x H η) + (fun η _ => volume_tailPrefixRegion_ne_top hR η)] + let W := (witnessFinset H s d).powerset.filter Finset.Nonempty + have hsub : W ⊆ nonemptyTailSubsets H := by + intro T hT + obtain ⟨hTW, hne⟩ := Finset.mem_filter.mp hT + refine Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr ?_, hne⟩ + exact (Finset.mem_powerset.mp hTW).trans (Finset.filter_subset _ _) + calc + _ = ∑ T ∈ W, if (↑T : Set (TailDatum H)) ⊆ witnesses H s d then + (-1 : ℝ)^(T.card-1)*(volume (tailIntersection x H T)).toReal else 0 := by + apply Finset.sum_congr rfl + intro T hT + obtain ⟨hTW, hne⟩ := Finset.mem_filter.mp hT + rw [ite_eq_left ((subset_witnessFinset hs T).mp (Finset.mem_powerset.mp hTW))] + have hc : T.card+1 = T.card-1+2 := by + have := Finset.card_pos.mpr hne + omega + rw [hc, pow_add] + norm_num + change (volume (⋂ i ∈ T, tailPrefixRegion x H i)).toReal = _ + congr 2 + ext u + simp [tailIntersection] + _ = _ := Finset.sum_subset hsub (by + intro T hT hnot + rw [ite_eq_right] + intro hW + exact hnot (Finset.mem_filter.mpr + ⟨Finset.mem_powerset.mpr ((subset_witnessFinset hs T).mpr hW), + (Finset.mem_filter.mp hT).2⟩)) + +lemma unionVolumeCoefficient_eq {x : ℝ} {H : ℕ} (f : ℝ → ℝ) + (hs : theta x ∈ Set.Ico (0 : ℝ) 1) (hR : 0 < R x H) : + unionVolumeCoefficient H f x = finiteTailCoefficient H f (theta x) + (fun T => (volume (tailIntersection x H T)).toReal/G x (m x)) := by + unfold unionVolumeCoefficient finiteTailCoefficient + apply Finset.sum_congr rfl + intro d hd + split_ifs with hdt + · rw [union_volume_inclusion_exclusion hs hR d, mul_div_assoc] + congr 1 + rw [Finset.sum_div] + apply Finset.sum_congr rfl + intro T hT + split_ifs <;> ring + · rfl + +lemma tendsto_ite_zero {ι : Type*} {l : Filter ι} (p : ι → Prop) (F : ι → ℝ) + (hF : Tendsto F l (nhds 0)) : + Tendsto (fun x => if p x then F x else 0) l (nhds 0) := by + apply squeeze_zero_norm' (a := fun x => ‖F x‖) + · exact Eventually.of_forall (fun x => by split_ifs <;> simp) + · simpa using hF.norm + +theorem unionVolumeCoefficient_limit (hford : FordRenewalInput) (H : ℕ) + (f : ℝ → ℝ) : + Tendsto (fun x => unionVolumeCoefficient H f x-AH H f (theta x)) atTop (nhds 0) := by + let E : ℕ → Finset (TailDatum H) → ℝ → ℝ := fun d T x => + if IsTotient d then + if (↑T : Set (TailDatum H)) ⊆ witnesses H (theta x) d then + f ((ell d : ℝ)/d)/d * (-1 : ℝ)^(T.card-1) * + ((volume (tailIntersection x H T)).toReal/G x (m x)-intersectionWeight (theta x) T) + else 0 + else 0 + have he (d : ℕ) (T : Finset (TailDatum H)) (hT : T ∈ nonemptyTailSubsets H) : + Tendsto (E d T) atTop (nhds 0) := by + by_cases hd : IsTotient d + · by_cases hadm : ∃ s ∈ Set.Ico (0 : ℝ) 1, ∀ η ∈ T, IsWitness H s η + · obtain ⟨s, hs, hTs⟩ := hadm + have hh := (normalized_intersection_volume_limit hford T + (Finset.mem_filter.mp hT).2 hTs).const_mul + (f ((ell d : ℝ)/d)/d * (-1 : ℝ)^(T.card-1)) + simpa only [E, ite_eq_left hd] using tendsto_ite_zero + (fun x => (↑T : Set (TailDatum H)) ⊆ witnesses H (theta x) d) _ + (by simpa using hh) + · apply tendsto_const_nhds.congr' + filter_upwards [theta_eventually_mem] with x hx + dsimp [E] + rw [ite_eq_left hd, ite_eq_right] + intro hsub + exact hadm ⟨theta x, hx, fun η hη => (hsub hη).1⟩ + · simpa only [E, ite_eq_right hd] using (tendsto_const_nhds (x := (0 : ℝ))) + have hh := tendsto_finsetSum (Finset.Icc 1 (tailValueBound H)) + (fun d _ => tendsto_finsetSum (nonemptyTailSubsets H) (he d)) + simp only [Finset.sum_const_zero] at hh + apply hh.congr' + filter_upwards [theta_eventually_mem, + m_tendsto.eventually (eventually_gt_atTop H)] with x hx hm + rw [unionVolumeCoefficient_eq f hx (by dsimp [R]; omega), + AH_eq_finiteTailCoefficient H f hx] + unfold finiteTailCoefficient + rw [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro d hd + by_cases hdt : IsTotient d + · simp only [ite_eq_left hdt] + rw [← mul_sub, ← Finset.sum_sub_distrib, Finset.mul_sum] + apply Finset.sum_congr rfl + intro T hT + dsimp [E] + rw [ite_eq_left hdt] + split_ifs <;> ring + · simp only [E, ite_eq_right hdt, sub_self, Finset.sum_const_zero] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UniquePrefix.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UniquePrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f947b17847f100ec65af0a10a5428138d4f265c --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UniquePrefix.lean @@ -0,0 +1,108 @@ +import OAI.NumberTheory.TotientAsymptotic.BasicExceptionCount +import OAI.NumberTheory.TotientAsymptotic.PrefixPreimage + +namespace OAI + +noncomputable section +open scoped BigOperators Topology Classical +open Filter + +namespace TotientAsymptotic + +def exceptionalTotients (x : ℝ) (H : ℕ) : Finset ℕ := + totientValues x ∩ basicExceptionValues x H + +def nonuniqueValues (x : ℝ) (H : ℕ) : Finset ℕ := + FiniteMap.badValues (goodTupleFinset x H x) (badTupleFinset x H x) + (totientValues x) (exceptionalTotients x H) tupleValue + +def discardedTuples (x : ℝ) (H : ℕ) : Finset (TotientTuple (R x H)) := + FiniteMap.badPreimages (tupleFinset x H x) (goodTupleFinset x H x) + (badTupleFinset x H x) (totientValues x) (exceptionalTotients x H) tupleValue + +lemma unique_prefix_finite_comparison : ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, + ((nonuniqueValues x H).card : ℝ) ≤ (basicExceptionValues x H).card+ + (badTupleFinset x H x).card+((goodCollisionPairs x H x).card : ℝ)/2 ∧ + ((discardedTuples x H).card : ℝ) ≤ (basicExceptionValues x H).card+ + 2*(badTupleFinset x H x).card+(goodCollisionPairs x H x).card ∧ + Set.BijOn (fun τ : TotientTuple (R x H) => tupleValue τ) (↑(tupleFinset x H x \ discardedTuples x H)) + (↑(totientValues x \ nonuniqueValues x H)) := by + filter_upwards [basic_tuple_isTotient,eventually_ge_atTop 2, + P_tendsto.eventually (eventually_ge_atTop 1)] with H hreal hH hP + filter_upwards [hreal,uncovered_values_subset (P_lt_self hH) hP] with x hx hcover + have hPH := (P_lt_self hH).le + have hmap : ∀ τ ∈ tupleFinset x H x, tupleValue τ ∈ totientValues x := by + intro τ hτ + have hb := (mem_tupleFinset hPH).mp hτ + exact basic_tuple_mem_values hPH hb (hx x τ hb) + have hg : goodTupleFinset x H x ⊆ tupleFinset x H x := Finset.filter_subset _ _ + have hpart : tupleFinset x H x=goodTupleFinset x H x ∪ badTupleFinset x H x := + (Finset.union_sdiff_of_subset hg).symm + have hdis : Disjoint (goodTupleFinset x H x) (badTupleFinset x H x) := + Finset.disjoint_left.mpr (fun _ h₁ h₂ => (Finset.mem_sdiff.mp h₂).2 h₁) + have hcov : totientValues x \ exceptionalTotients x H ⊆ (tupleFinset x H x).image tupleValue := by + intro v hv + obtain ⟨hv,he⟩ := Finset.mem_sdiff.mp hv + by_contra hn + have hexc := hcover x le_rfl (Finset.mem_sdiff.mpr ⟨hv,hn⟩) + exact he (Finset.mem_inter.mpr ⟨hv,hexc⟩) + have hc := FiniteMap.counting (tupleFinset x H x) (goodTupleFinset x H x) + (badTupleFinset x H x) (totientValues x) (exceptionalTotients x H) tupleValue + hpart hdis hmap Finset.inter_subset_left hcov + rw [good_collision_count_eq (fun τ hτ => hmap τ (hg hτ))] at hc + have he : ((exceptionalTotients x H).card : ℝ) ≤ (basicExceptionValues x H).card := by + exact_mod_cast Finset.card_le_card (show exceptionalTotients x H ⊆ basicExceptionValues x H from Finset.inter_subset_right) + exact ⟨hc.2.2.1.trans (by linarith),hc.2.2.2.1.trans (by linarith),hc.2.2.2.2⟩ + +/-- All inverse images of an ordinary value have the same displayed prime +prefix. This uses all-preimage extraction, not merely existence of a witness. -/ +lemma common_prefix_inverse_fiber {H : ℕ} (hPH : P H < H) (hP : 1 ≤ P H) : + ∀ᶠ x : ℝ in atTop, + ∀ τ ∈ tupleFinset x H x \ discardedTuples x H, + (Set.InjOn (fun σ : TotientTuple (R x H) => tupleValue σ) (↑(tupleFinset x H x \ discardedTuples x H))) → + tupleValue τ ∈ totientValues x \ nonuniqueValues x H → + ∀ n : ℕ, 0 < n → n.totient=tupleValue τ → + ∃ w : ℕ, 0 < w ∧ w.totient=τ.tail.d ∧ n=tuplePrimeProduct τ*w := by + filter_upwards [all_preimages_tuple_value hPH hP,all_preimages_basic hPH hP, + m_tendsto.eventually (eventually_ge_atTop H)] with x hval hbasic hm + intro τ hτ hinj hv n hn hnv + have hE : tupleValue τ ∉ basicExceptionValues x H := by + intro he + apply (Finset.mem_sdiff.mp hv).2 + apply Finset.mem_union_left + apply Finset.mem_union_left + exact Finset.mem_inter.mpr ⟨(Finset.mem_sdiff.mp hv).1,he⟩ + have hσ := hval _ (Finset.mem_sdiff.mp hv).1 hE n hn hnv + have hσout : witnessTuple (fordPrime n 0) (fordRemainder x H n) ∈ + tupleFinset x H x \ discardedTuples x H := by + apply Finset.mem_sdiff.mpr + refine ⟨hσ.1,?_⟩ + intro h + have hb := (Finset.mem_filter.mp h).2 + rw [hσ.2] at hb + exact (Finset.mem_sdiff.mp hv).2 hb + have heq := hinj hσout hτ hσ.2 + obtain ⟨hbt,hfact⟩ := hbasic _ (Finset.mem_sdiff.mp hv).1 hE n hn hnv + have hη : IsBasicRemainder x H (fordRemainder x H n) := by + have hsout : tupleValue τ ∉ preimageExceptionValues x (extractedStructureCondition x (P H)) := by + intro h + exact hE (Finset.mem_union_left _ (Finset.mem_union_left _ h)) + have hs := (outside_preimageExceptions_iff (Finset.mem_filter.mp (Finset.mem_sdiff.mp hv).1).1).mp hsout n hn hnv + have ha : Real.log (fordCofactor n (L x H+1) : ℝ) ≤ Real.exp (2*bandScale x (L x H)) := by + apply le_of_not_gt + intro h + exact hE (Finset.mem_union_right _ (Finset.mem_union_right _ + (Finset.mem_filter.mpr ⟨(Finset.mem_sdiff.mp hv).1,n,hn,hnv,hs,hbt.2.1,h⟩))) + exact fordRemainder_basic (by unfold L; omega) hs ha + refine ⟨remainderTail x H (fordRemainder x H n),suffixPreimage_pos (i := R x H) hη,?_,?_⟩ + · have hh := congrArg (fun σ : TotientTuple (R x H) => σ.tail.d) heq + exact hh + · calc + n = wholePreimage (fordPrime n 0) (fordRemainder x H n) := hfact.symm + _ = _ := by rw [wholePreimage_prefix_split _ _ (by unfold R L; omega),heq] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UniqueValueNegligible.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UniqueValueNegligible.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2cdfb264b154d0b0e623161d27d334fc5d9aa5b --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UniqueValueNegligible.lean @@ -0,0 +1,37 @@ +import OAI.NumberTheory.TotientAsymptotic.CandidateComparison + +namespace OAI + +noncomputable section +open scoped Topology +open Filter +namespace TotientAsymptotic + +lemma nonunique_values_negligible (hscale : FordScaleBounds) + (hstruct : ExtractedStructureInput) + (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) (hmertens : MertensProductInput) + (h26 : FordLemma26Input) (h51 : FordLemma51Input) : + ∃ δ : ℕ → ℝ, Tendsto δ atTop (nhds 0) ∧ + ∀ᶠ H : ℕ in atTop, ∀ ε : ℝ, 0<ε → ∀ᶠ x : ℝ in atTop, + ((nonuniqueValues x H).card : ℝ) ≤ (δ H+ε)*tupleNormalization x := by + obtain ⟨δe,hδe,he⟩ := basic_exception_values_negligible hscale hstruct hbox hren hmertens + obtain ⟨δd,hδd,hd⟩ := bad_tuple_discard hbox hren hmertens h26 + obtain ⟨δc,hδc,hc⟩ := good_collision_count h51 hmertens hbox hren + refine ⟨fun H => |δe H|+|δd H|+|δc H|,by simpa using (hδe.abs.add hδd.abs).add hδc.abs,?_⟩ + filter_upwards [he,hd,hc,unique_prefix_finite_comparison] with H he hd hc hf + intro ε hε + filter_upwards [he ε hε,hd,hc,hf,scale_eventually_pos] with x he hd hc hf hN + have he' : ((basicExceptionValues x H).card : ℝ)≤(|δe H|+ε)*tupleNormalization x := + he.trans (mul_le_mul_of_nonneg_right (by linarith [le_abs_self (δe H)]) hN.le) + have hd' : ((badTupleFinset x H x).card : ℝ)≤|δd H| *tupleNormalization x := + (hd x le_rfl).trans (mul_le_mul_of_nonneg_right (le_abs_self _) hN.le) + have hc' : ((goodCollisionPairs x H x).card : ℝ)≤|δc H| *tupleNormalization x := + (hc x le_rfl).trans (mul_le_mul_of_nonneg_right (le_abs_self _) hN.le) + have hc0 : (0 : ℝ)≤(goodCollisionPairs x H x).card := Nat.cast_nonneg _ + nlinarith [hf.1] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UntruncatedCount.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UntruncatedCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..675dd115ad5e59b148d74d9e2d7e28ba3d1c2293 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UntruncatedCount.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TotientAsymptotic.UntruncatedRemainder +import OAI.NumberTheory.TotientAsymptotic.LargestPrimeCount + +namespace OAI + +noncomputable section +open scoped BigOperators Topology Classical +open Filter + +namespace TotientAsymptotic + +lemma untruncated_totient_lower {x : ℝ} {H p : ℕ} {η : RemainderDatum (L x H)} + (hη : IsUntruncatedRemainder x H η) (hp : p.Prime) : + (p-1)*(η.cofactor.totient*∏ i : Fin (L x H), (η.primes i-1)) ≤ + (wholePreimage p η).totient := by + have hprime (i : Fin (L x H)) : (η.primes i).Prime := by + have hh := (hη.2.1.2.1 (i.val+1) (Finset.mem_Icc.mpr + ⟨by omega,by have := i.isLt; omega⟩)).1 + simpa [primeOnly,remainderPrime,i.isLt] using hh + have htail := totient_prime_product_lower Finset.univ η.primes η.cofactor (fun i _ => hprime i) + have he : suffixPreimage η 0=η.cofactor*∏ i, η.primes i := by + unfold suffixPreimage + rw [← prod_fin_shifted (L x H) (remainderPrime η)] + congr 1 + apply Finset.prod_congr rfl + intro i _ + simp [remainderPrime,i.isLt] + rw [wholePreimage,he] + calc + _ ≤ (p-1)*(η.cofactor*∏ i, η.primes i).totient := Nat.mul_le_mul_left _ htail + _ = p.totient*(η.cofactor*∏ i, η.primes i).totient := by rw [Nat.totient_prime hp] + _ ≤ _ := Nat.totient_super_multiplicative _ _ + +/-- Count any finite family before truncating its smooth cofactor. The +largest-prime count is uniform in both the cofactor and the prime vector. -/ +theorem untruncated_witness_count : ∀ᶠ x : ℝ in atTop, ∀ H : ℕ, + ∀ S : Finset (RemainderDatum (L x H) × ℕ), + (∀ q ∈ S, IsUntruncatedRemainder x H q.1 ∧ q.2.Prime ∧ + x^(9/10 : ℝ) ≤ q.2 ∧ ((wholePreimage q.2 q.1).totient : ℝ) ≤ x) → + (S.card : ℝ) ≤ (10*x/Real.log x)* + ∑ η ∈ S.image Prod.fst, (η.cofactor.totient : ℝ)⁻¹*reciprocalShiftWeight η.primes := by + classical + filter_upwards [largest_prime_count_upper] with x hx + intro H S hS + let E := S.image Prod.fst + have he : (S.card : ℝ)=∑ η ∈ E, ((S.filter (fun q => q.1=η)).card : ℝ) := by + rw [← Nat.cast_sum] + congr 1 + rw [Finset.sum_card_fiberwise_eq_card_filter S E Prod.fst] + congr 1 + exact (Finset.filter_eq_self.mpr (fun q hq => Finset.mem_image.mpr ⟨q,hq,rfl⟩)).symm + rw [he,Finset.mul_sum] + apply Finset.sum_le_sum + intro η hη + obtain ⟨q,hq,hqη⟩ := Finset.mem_image.mp hη + have hηb : IsUntruncatedRemainder x H η := hqη ▸ (hS q hq).1 + let D := η.cofactor.totient*∏ i, (η.primes i-1) + have hD : 0 < D := by + apply Nat.mul_pos (Nat.totient_pos.mpr hηb.1) + apply Finset.prod_pos + intro i _ + have hp := (hηb.2.1.2.1 (i.val+1) (Finset.mem_Icc.mpr + ⟨by omega,by have := i.isLt; omega⟩)).1 + have hp' : (η.primes i).Prime := by simpa [primeOnly,remainderPrime,i.isLt] using hp + exact Nat.sub_pos_of_lt hp'.one_lt + let Q := (S.filter (fun q => q.1=η)).image Prod.snd + have hcard : (S.filter (fun q => q.1=η)).card=Q.card := by + symm + apply Finset.card_image_of_injOn + intro a ha b hb heq + exact Prod.ext ((Finset.mem_filter.mp ha).2.trans (Finset.mem_filter.mp hb).2.symm) heq + rw [hcard] + have hb := hx D hD Q (by + intro p hp + obtain ⟨q,hq,rfl⟩ := Finset.mem_image.mp hp + obtain ⟨hq,heq⟩ := Finset.mem_filter.mp hq + obtain ⟨hη',hp,hmin,hval⟩ := hS q hq + refine ⟨hp,hmin,?_⟩ + have hlower := untruncated_totient_lower hη' hp + rw [heq] at hlower + have hh : (((q.2-1)*D : ℕ) : ℝ) ≤ (wholePreimage q.2 η).totient := by exact_mod_cast hlower + exact hh.trans (by simpa only [heq] using hval)) + apply hb.trans_eq + dsimp [D] + simp only [reciprocalShiftWeight,Nat.cast_mul,Nat.cast_prod] + field_simp + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UntruncatedMass.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UntruncatedMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..e01fc05ab2c9cd20a8f54b7174497f84d9bd6b0f --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UntruncatedMass.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.TotientAsymptotic.UntruncatedCount +import OAI.NumberTheory.TotientAsymptotic.SmoothCutoffTail +import OAI.NumberTheory.TotientAsymptotic.MassUpper + +namespace OAI + +noncomputable section +open scoped BigOperators Topology +open Filter + +namespace TotientAsymptotic + +lemma full_prime_mass_le_G (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) : + ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, + (∑ p ∈ fullPrimeTuples x H, reciprocalShiftWeight p) ≤ G x (m x) := by + obtain ⟨C,hC,hprime⟩ := full_prime_mass_bound hbox + obtain ⟨K,hK,hproj⟩ := uniform_projected_volume_bound hren + have hcut := ((tendsto_natCast_atTop_atTop.comp P_tendsto).const_mul_atTop lam_pos).eventually + (eventually_ge_atTop (4 : ℝ)) + filter_upwards [hcut,(fullPrimeFactor_tendsto C hK).eventually (eventually_lt_nhds (by norm_num : (0 : ℝ)<1)), + eventually_ge_atTop 2] with H hc hf hH + filter_upwards [theta_eventually_mem,B_tendsto.eventually (eventually_gt_atTop (0 : ℝ)), + inverse_scale_bound,hproj,m_tendsto.eventually (eventually_ge_atTop H)] with x hs hB hscale hp hm + have hPH := P_lt_self hH + have hL : 0 ?_) (tendsto_natCast_atTop_atTop.comp P_tendsto) + have hh : 1 ≤ (rho^(P H))⁻¹ := (one_le_inv₀ (pow_pos rho_pos _)).mpr + (pow_le_one₀ rho_pos.le rho_lt_one.le) + exact le_mul_of_one_le_right (Nat.cast_nonneg _) hh + +lemma terminal_band_lower {x : ℝ} {H : ℕ} (hs : 0 ≤ theta x) (hm : P H ≤ m x) : + lam*cofactorScale H ≤ bandScale x (L x H) := by + have he : m x-L x H=P H := by unfold L; omega + simp only [bandScale,he,cofactorScale] + simpa only [mul_assoc] using + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right (alpha_ge_lam hs) (Nat.cast_nonneg (P H))) + (inv_nonneg.mpr (pow_pos rho_pos (P H)).le) + +lemma untruncated_cofactor_smooth {x : ℝ} {H : ℕ} {η : RemainderDatum (L x H)} + (hL : 0 (η.cofactor,η.primes) + have hinj : Function.Injective F := by + intro η ξ h + cases η + cases ξ + simpa only [F,Prod.mk.injEq,RemainderDatum.mk.injEq,and_comm] using h + have he : (∑ η ∈ S, (η.cofactor.totient : ℝ)⁻¹*reciprocalShiftWeight η.primes)= + ∑ z ∈ S.image F, (z.1.totient : ℝ)⁻¹*reciprocalShiftWeight z.2 := by + rw [Finset.sum_image (fun η _ ξ _ hh => hinj hh)] + rw [he] + have hsub : S.image F ⊆ S.image RemainderDatum.cofactor ×ˢ fullPrimeTuples x H := by + intro z hz + obtain ⟨η,hη,rfl⟩ := Finset.mem_image.mp hz + exact Finset.mem_product.mpr ⟨Finset.mem_image.mpr ⟨η,hη,rfl⟩,untruncated_prime_mem (hS η hη)⟩ + calc + _ ≤ ∑ z ∈ S.image RemainderDatum.cofactor ×ˢ fullPrimeTuples x H, + (z.1.totient : ℝ)⁻¹*reciprocalShiftWeight z.2 := + Finset.sum_le_sum_of_subset_of_nonneg hsub + (fun z _ _ => mul_nonneg (by positivity) (reciprocalShiftWeight_nonneg z.2)) + _ = _ := by rw [Finset.sum_product]; simp only [← Finset.mul_sum,← Finset.sum_mul] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/UntruncatedRemainder.lean b/lean/OAI/NumberTheory/TotientAsymptotic/UntruncatedRemainder.lean new file mode 100644 index 0000000000000000000000000000000000000000..847ff3657dd0cbcee1f2690ce1e25556da423c92 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/UntruncatedRemainder.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.TotientAsymptotic.StructuredRemainder +import OAI.NumberTheory.TotientAsymptotic.FullPrimeGrid + +namespace OAI + +noncomputable section +open scoped BigOperators + +namespace TotientAsymptotic + +def primeOnly {J : ℕ} (η : RemainderDatum J) : RemainderDatum J := ⟨η.primes,1⟩ + +def IsUntruncatedRemainder (x : ℝ) (H : ℕ) (η : RemainderDatum (L x H)) : Prop := + 0 < η.cofactor ∧ IsBasicRemainder x H (primeOnly η) ∧ + largestPrimeFactor η.cofactor ≤ remainderPrime η (L x H) + +lemma primeOnly_prime {J : ℕ} (η : RemainderDatum J) (i : ℕ) : + remainderPrime (primeOnly η) i=remainderPrime η i := rfl + +lemma primeOnly_coord {J : ℕ} (η : RemainderDatum J) (x : ℝ) (i : ℕ) : + remainderCoord x (primeOnly η) i=remainderCoord x η i := rfl + +lemma untruncated_basic {x : ℝ} {H : ℕ} {η : RemainderDatum (L x H)} + (hη : IsUntruncatedRemainder x H η) + (hs : Real.log (η.cofactor : ℝ) ≤ Real.exp (2*bandScale x (L x H))) : + IsBasicRemainder x H η := + ⟨hη.1,hη.2.1.2.1,hη.2.1.2.2.1,hη.2.2,hs⟩ + +lemma untruncated_prime_mem {x : ℝ} {H : ℕ} {η : RemainderDatum (L x H)} + (hη : IsUntruncatedRemainder x H η) : η.primes ∈ fullPrimeTuples x H := by + exact Finset.mem_image.mpr ⟨primeOnly η,mem_basicRemainderFinset.mpr hη.2.1,rfl⟩ + +lemma fordRemainder_untruncated {x : ℝ} {H n : ℕ} (hL : 0 < L x H) + (hstruct : extractedStructureCondition x (P H) n) : + IsUntruncatedRemainder x H (fordRemainder x H n) := by + have hlast : 0 < primeDoubleLog n (L x H) := lt_trans (by norm_num) hstruct.2.1 + have hindex := fordPrime_index_of_doubleLog_pos hlast + refine ⟨fordCofactor_pos _ _,⟨by norm_num [primeOnly],?_,?_,?_,?_⟩,?_⟩ + · intro i hi + change (remainderPrime (fordRemainder x H n) i).Prime ∧ _ + rw [fordRemainder_prime hi] + have hcoord := fordRemainder_coord (n := n) (Finset.mem_Icc.mp hi).2 + have hi0 : i ≠ 0 := by have := (Finset.mem_Icc.mp hi).1; omega + have hcoord' : remainderCoord x (primeOnly (fordRemainder x H n)) i=primeDoubleLog n i := by + simpa only [primeOnly_coord,rawSimplexCoordinate,ite_eq_right hi0] using hcoord + rw [hcoord'] + exact ⟨fordPrime_prime (by have := (Finset.mem_Icc.mp hi).2; omega),hstruct.1 i hi⟩ + · intro i hi + have hiL := (Finset.mem_Icc.mp hi).2 + rw [primeOnly_coord,fordRemainder_coord hiL] + by_cases he : i=L x H + · subst i + rw [ite_eq_left rfl] + have hempty : Finset.Icc (L x H+1) (L x H)=∅ := by simp + rw [hempty,Finset.sum_empty,one_mul] + simpa only [rawSimplexCoordinate,ite_eq_right (Nat.ne_of_gt hL)] using hlast.le + · rw [ite_eq_right he] + convert hstruct.2.2 i (Finset.mem_Ico.mpr ⟨Nat.zero_le _,by unfold L at *; omega⟩) using 1 + apply Finset.sum_congr rfl + intro r hr + rw [primeOnly_coord,fordRemainder_coord (Finset.mem_Icc.mp hr).2] + · change largestPrimeFactor 1 ≤ remainderPrime (fordRemainder x H n) (L x H) + rw [fordRemainder_prime (Finset.mem_Icc.mpr ⟨hL,le_rfl⟩)] + simpa [largestPrimeFactor] using (fordPrime_prime hindex).one_lt.le + · simpa only [primeOnly,Nat.cast_one,Real.log_one] using + (Real.exp_pos (2*bandScale x (L x H))).le + · change largestPrimeFactor (fordCofactor n (L x H+1)) ≤ _ + rw [fordRemainder_prime (Finset.mem_Icc.mpr ⟨hL,le_rfl⟩)] + exact fordCofactor_largest hindex + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/ValueComparison.lean b/lean/OAI/NumberTheory/TotientAsymptotic/ValueComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b8e391a40f9739b06dac6260d2cc17edd11876d --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/ValueComparison.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.TotientAsymptotic.ValueCoverage +import OAI.NumberTheory.TotientAsymptotic.ValueLower + +namespace OAI + +noncomputable section +open scoped BigOperators Topology Classical +open Filter + +namespace TotientAsymptotic + +theorem value_tuple_comparison (hscale : FordScaleBounds) + (hstruct : ExtractedStructureInput) + (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) (hmertens : MertensProductInput) + (h26 : FordLemma26Input) (h51 : FordLemma51Input) : + ∃ δ : ℕ → ℝ, Tendsto δ atTop (nhds 0) ∧ + ∀ᶠ H : ℕ in atTop, ∀ ε : ℝ, 0<ε → ∀ᶠ x : ℝ in atTop, ∀ t ≤ x, + |((tupleFinset x H t).card : ℝ)-V t| ≤ (δ H+ε)*tupleNormalization x := by + obtain ⟨δ₁,hd₁,h₁⟩ := tuple_excess_negligible hbox hren hmertens h26 h51 + obtain ⟨δ₂,hd₂,h₂⟩ := uncovered_values_negligible hscale hstruct hbox hren hmertens + refine ⟨fun H => |δ₁ H|+|δ₂ H|,by simpa using hd₁.abs.add hd₂.abs,?_⟩ + filter_upwards [h₁,h₂,tuple_value_comparison] with H h1 h2 hc + intro ε hε + filter_upwards [h1,h2 ε hε,hc,scale_eventually_pos] with x h1 h2 hc hN + intro t ht + have ha : δ₁ H ≤ |δ₁ H|+|δ₂ H|+ε := by linarith [le_abs_self (δ₁ H),abs_nonneg (δ₂ H)] + have hb : δ₂ H+ε ≤ |δ₁ H|+|δ₂ H|+ε := by linarith [le_abs_self (δ₂ H),abs_nonneg (δ₁ H)] + apply abs_le.mpr + constructor + · have hh := (h2 t ht).trans (mul_le_mul_of_nonneg_right hb hN.le) + linarith [(hc t).1] + · exact (h1 t ht).trans (mul_le_mul_of_nonneg_right ha hN.le) + +/-- The complete downstream comparison between actual distinct values and +finite arithmetic coefficients, uniformly over comparable endpoints. -/ +theorem value_finite_coefficient_approximation (hscale : FordScaleBounds) + (hstruct : ExtractedStructureInput) (hpnt : PrimeNumberTheoremInput) + (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) (hmertens : MertensProductInput) + (h26 : FordLemma26Input) (h51 : FordLemma51Input) (hconc : FordCoordinateConcentrationInput) + {a : ℝ} (ha : 0 1) (theta x)| ≤ δ H+ε := by + obtain ⟨δ₁,hd₁,h₁⟩ := value_tuple_comparison hscale hstruct hbox hren hmertens h26 h51 + obtain ⟨δ₂,hd₂,h₂⟩ := tuple_finite_coefficient_approximation hpnt hbox hmertens hren hconc ha + refine ⟨fun H => δ₁ H+δ₂ H,by simpa using hd₁.add hd₂,?_⟩ + filter_upwards [h₁,h₂] with H h1 h2 + intro ε hε + filter_upwards [h1 (ε/2) (by positivity),h2 (fun _ => 1) (fun _ => ⟨zero_le_one,le_rfl⟩) + (ε/2) (by positivity),scale_eventually_pos] with x hv ht hN + intro t hat htx + change 0 < tupleNormalization x at hN + have hc : |V t/tupleNormalization x-((tupleFinset x H t).card : ℝ)/tupleNormalization x| ≤ δ₁ H+ε/2 := by + rw [← sub_div,abs_div,abs_of_pos hN,abs_sub_comm] + exact (div_le_iff₀ hN).mpr (hv t htx) + have hp := ht t hat htx + rw [weightedTupleCount_one] at hp + exact (abs_sub_le _ _ _).trans ((add_le_add hc hp).trans_eq (by ring)) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/ValueCoverage.lean b/lean/OAI/NumberTheory/TotientAsymptotic/ValueCoverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..713e05a1eba36c12851caa30831ca2ecd3e32dfa --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/ValueCoverage.lean @@ -0,0 +1,43 @@ +import OAI.NumberTheory.TotientAsymptotic.BasicCoverage +import OAI.NumberTheory.TotientAsymptotic.PPTStructureInput + +namespace OAI + +noncomputable section +open scoped BigOperators Topology Classical +open Filter + +namespace TotientAsymptotic + +/-- All uncovered values are controlled by the published Ford extraction +and the independently proved cofactor and elementary exclusions. -/ +theorem uncovered_values_negligible (_hscale : FordScaleBounds) + (hstruct : ExtractedStructureInput) + (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) (hmertens : MertensProductInput) : + ∃ δ : ℕ → ℝ, Tendsto δ atTop (nhds 0) ∧ + ∀ᶠ H : ℕ in atTop, ∀ ε : ℝ, 0<ε → ∀ᶠ x : ℝ in atTop, ∀ t ≤ x, + ((uncoveredValues x H t).card : ℝ) ≤ (δ H+ε)*tupleNormalization x := by + obtain ⟨δs,hδs,hstructure⟩ := hstruct + obtain ⟨δc,hδc,hcof⟩ := cofactor_exception_count hbox hren hmertens + let δ := fun H => δs (P H)+δc H + refine ⟨δ,by simpa only [δ,Function.comp_def,zero_add] using (hδs.comp P_tendsto).add hδc,?_⟩ + filter_upwards [hcof,eventually_ge_atTop 2,P_tendsto.eventually (eventually_ge_atTop 1)] with H hcof hH hP + intro ε hε + filter_upwards [hcof,hstructure (P H) (ε/3) (by positivity),uncovered_values_subset (P_lt_self hH) hP, + small_values_negligible hren (show 0<ε/3 by positivity), + omega_values_negligible hmertens hren (show 0<ε/3 by positivity), + scale_eventually_pos,m_tendsto.eventually (eventually_gt_atTop (P H))] with x hcf he hsub hsmall hω _hn _hm + intro t ht + have hcard := (Finset.card_le_card (hsub t ht)).trans + ((Finset.card_union_le _ _).trans (Nat.add_le_add (Finset.card_union_le _ _) (Finset.card_union_le _ _))) + have hcardR : ((uncoveredValues x H t).card : ℝ) ≤ + ((preimageExceptionValues x (extractedStructureCondition x (P H))).card+(smallValues x).card)+ + ((largeOmegaValues x).card+(cofactorExceptionValues x H).card) := by exact_mod_cast hcard + change ((preimageExceptionValues x (extractedStructureCondition x (P H))).card : ℝ) ≤ _ at he + exact hcardR.trans ((add_le_add (add_le_add he hsmall) (add_le_add hω hcf)).trans_eq (by unfold δ; ring)) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/ValueLower.lean b/lean/OAI/NumberTheory/TotientAsymptotic/ValueLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d3375f24248e00c30a5e8e9c3304cbdba8e7bbb --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/ValueLower.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TotientAsymptotic.TupleTotients +import OAI.NumberTheory.TotientAsymptotic.TupleCoefficient + +namespace OAI + +noncomputable section +open scoped BigOperators Topology +open Filter + +namespace TotientAsymptotic + +/-- The actual count can exceed the number of represented values only by +the discarded tuples and the collision error, both already proved small. -/ +theorem tuple_excess_negligible (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) + (hmertens : MertensProductInput) (h26 : FordLemma26Input) (h51 : FordLemma51Input) : + ∃ δ : ℕ → ℝ, Tendsto δ atTop (nhds 0) ∧ + ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, ∀ t ≤ x, + ((tupleFinset x H t).card : ℝ)-V t ≤ δ H*tupleNormalization x := by + obtain ⟨δ₁,hd₁,h₁⟩ := bad_tuple_discard hbox hren hmertens h26 + obtain ⟨δ₂,hd₂,h₂⟩ := good_collision_count h51 hmertens hbox hren + refine ⟨fun H => δ₁ H+δ₂ H/2,by simpa using hd₁.add (hd₂.div_const 2),?_⟩ + filter_upwards [h₁,h₂,tuple_value_comparison] with H h1 h2 hcomp + filter_upwards [h1,h2,hcomp] with x h1 h2 hc + intro t ht + have h := add_le_add (h1 t ht) (div_le_div_of_nonneg_right (h2 t ht) (by norm_num : (0 : ℝ) ≤ 2)) + exact (hc t).2.trans (h.trans_eq (by unfold tupleNormalization; ring)) + +/-- The lower half of the main count comparison follows from actual collision +and discard bounds, with no exceptional-value coverage premise. -/ +theorem normalized_value_coefficient_lower (hpnt : PrimeNumberTheoremInput) + (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) (hmertens : MertensProductInput) + (h26 : FordLemma26Input) (h51 : FordLemma51Input) (hconc : FordCoordinateConcentrationInput) : + ∃ δ : ℕ → ℝ, Tendsto δ atTop (nhds 0) ∧ + ∀ᶠ H : ℕ in atTop, ∀ ε : ℝ, 0 < ε → ∀ᶠ x : ℝ in atTop, + AH H (fun _ => 1) (theta x)-δ H-ε ≤ normalizedCount V x := by + obtain ⟨δ₁,hd₁,h₁⟩ := tuple_excess_negligible hbox hren hmertens h26 h51 + obtain ⟨δ₂,hd₂,h₂⟩ := tuple_finite_coefficient_approximation hpnt hbox hmertens hren hconc + (a := 1) (by norm_num) + refine ⟨fun H => δ₁ H+δ₂ H,by simpa using hd₁.add hd₂,?_⟩ + filter_upwards [h₁,h₂] with H h1 h2 + intro ε hε + filter_upwards [h1,h2 (fun _ => 1) (fun _ => ⟨zero_le_one,le_rfl⟩) ε hε, + scale_eventually_pos,eventually_gt_atTop (1 : ℝ)] with x h1 h2 hnorm hx + have ht := h2 x (by simp) le_rfl + rw [weightedTupleCount_one,div_self (ne_of_gt (zero_lt_one.trans hx)),one_mul] at ht + have he := (div_le_iff₀ hnorm).mpr (h1 x le_rfl) + rw [sub_div] at he + change ((tupleFinset x H x).card : ℝ)/tupleNormalization x-V x/tupleNormalization x ≤ δ₁ H at he + have hlo := (abs_le.mp ht).1 + change _ ≤ V x/tupleNormalization x + linarith + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/ValueMass.lean b/lean/OAI/NumberTheory/TotientAsymptotic/ValueMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4c4dfbffc4f90eee1451aa71391b014ffa16c49 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/ValueMass.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.TotientAsymptotic.ValueComparison +import OAI.NumberTheory.TotientAsymptotic.Scaling + +namespace OAI + +noncomputable section +open scoped Topology +open Filter + +namespace TotientAsymptotic + +/-- Actual distinct values and the common-endpoint arithmetic mass. -/ +theorem value_mass_approximation (hscale : FordScaleBounds) + (hstruct : ExtractedStructureInput) (hpnt : PrimeNumberTheoremInput) + (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) (hmertens : MertensProductInput) + (h26 : FordLemma26Input) (h51 : FordLemma51Input) {a : ℝ} (ha : 0 < a) : + ∃ δ : ℕ → ℝ, Tendsto δ atTop (nhds 0) ∧ + ∀ᶠ H : ℕ in atTop, ∀ ε : ℝ, 0 < ε → ∀ᶠ x : ℝ in atTop, + ∀ t : ℝ, a*x ≤ t → t ≤ x → + |V t/tupleNormalization x-(t/x)*(M x H (fun _ => 1)/G x (m x))| ≤ δ H+ε := by + obtain ⟨δ,hδ,hv⟩ := value_tuple_comparison hscale hstruct hbox hren hmertens h26 h51 + refine ⟨δ,hδ,?_⟩ + filter_upwards [hv,tuple_mass_normalized_approximation hpnt hbox hren hmertens ha] with H hV hM + intro ε hε + filter_upwards [hV (ε/2) (by positivity),hM (ε/2) (by positivity),scale_eventually_pos] + with x hV hM hN + intro t ht htx + change 0 < tupleNormalization x at hN + have he : |V t/tupleNormalization x-((tupleFinset x H t).card : ℝ)/tupleNormalization x| ≤ δ H+ε/2 := by + rw [← sub_div,abs_div,abs_of_pos hN,abs_sub_comm] + exact (div_le_iff₀ hN).mpr (hV t htx) + have hm := hM t ht htx (fun _ => 1) (fun _ => ⟨zero_le_one,le_rfl⟩) + rw [weightedTupleCount_one] at hm + exact (abs_sub_le _ _ _).trans ((add_le_add he hm).trans_eq (by ring)) + +lemma massError_eq_normalized {x t : ℝ} (H : ℕ) (hx : x ≠ 0) (ht : t ≠ 0) : + massError x H t = (x/t)*(V t/tupleNormalization x- + (t/x)*(M x H (fun _ => 1)/G x (m x))) := by + unfold massError tupleNormalization + field_simp + +/-- The common-endpoint estimate is proved from published inputs, rather than +assumed as an internal comparison. -/ +theorem common_endpoint_comparison (hscale : FordScaleBounds) + (hstruct : ExtractedStructureInput) (hpnt : PrimeNumberTheoremInput) + (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) (hmertens : MertensProductInput) + (h26 : FordLemma26Input) (h51 : FordLemma51Input) {c : ℝ} (hc : 1 ≤ c) : + CommonEndpointComparison c := by + have hc0 : 0 < c := zero_lt_one.trans_le hc + obtain ⟨δ,hδ,happ⟩ := value_mass_approximation hscale hstruct hpnt hbox hren hmertens h26 h51 + (a := 1/c) (by positivity) + intro ε hε + have he : ∀ᶠ H : ℕ in atTop, δ H < ε/(2*c) := + hδ.eventually (eventually_lt_nhds (by positivity)) + obtain ⟨H,hH,hδH⟩ := (happ.and he).exists + refine ⟨H,?_⟩ + filter_upwards [hH (ε/(2*c)) (by positivity),eventually_gt_atTop (0 : ℝ)] with x hx hx0 + have hcx : x/c ≤ x := div_le_self hx0.le hc + have h1 := hx x (by simpa [div_eq_mul_inv,mul_comm] using hcx) le_rfl + have h2 := hx (x/c) (by simp [div_eq_mul_inv,mul_comm]) hcx + have heps : δ H+ε/(2*c) ≤ ε/c := by + calc + δ H+ε/(2*c) ≤ ε/(2*c)+ε/(2*c) := by + simpa only [add_comm] using add_le_add_right hδH.le (ε/(2*c)) + _ = ε/c := by ring + have hs : δ H+ε/(2*c) ≤ ε := heps.trans (div_le_self hε.le hc) + constructor + · rw [massError_eq_normalized H hx0.ne' hx0.ne',div_self hx0.ne',one_mul] + simpa only [div_self hx0.ne',one_mul] using h1.trans hs + · rw [massError_eq_normalized H hx0.ne' (div_pos hx0 hc0).ne', + show x/(x/c)=c by field_simp,abs_mul,abs_of_pos hc0] + exact (mul_le_mul_of_nonneg_left (h2.trans heps) hc0.le).trans_eq (by field_simp) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/ValueOmega.lean b/lean/OAI/NumberTheory/TotientAsymptotic/ValueOmega.lean new file mode 100644 index 0000000000000000000000000000000000000000..092abdae1aa602cc9b9ace1663c111e9038c03b9 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/ValueOmega.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.TotientAsymptotic.PreimageOmega +import OAI.NumberTheory.TotientAsymptotic.BandComparison + +namespace OAI + +noncomputable section +open scoped BigOperators Topology +open Filter +attribute [local instance] Classical.propDecidable + +namespace TotientAsymptotic + +def largeOmegaValues (x : ℝ) : Finset ℕ := + (Finset.Icc 1 ⌊x⌋₊).filter (fun n => 20*B x < (n.primeFactorsList.length : ℝ)) + +/-- A deliberately coarse factor-count cutoff still has vanishing relative +cost and supplies the head-prime lower bound in every remaining preimage. -/ +theorem large_omega_value_count (hmertens : MertensProductInput) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ x : ℝ in atTop, + ((largeOmegaValues x).card : ℝ) ≤ (C/Real.log x)*(x/Real.log x) := by + obtain ⟨D,hD,hprod⟩ := hmertens + refine ⟨D^3,by positivity,?_⟩ + filter_upwards [eventually_ge_atTop (3 : ℝ),B_tendsto.eventually (eventually_ge_atTop (0 : ℝ))] + with x hx hB + have hx0 : 0 < x := by linarith + have hx1 : 1 < x := by linarith + have hlog := Real.log_pos hx1 + have hN : 2 ≤ ⌊x⌋₊ := (Nat.le_floor_iff hx0.le).mpr (by norm_num; linarith) + have hQ (n : ℕ) (hn : n ∈ largeOmegaValues x) : + 0 < n ∧ n ≤ ⌊x⌋₊ ∧ 20*B x ≤ (n.primeFactorsList.length : ℝ) := by + obtain ⟨hi,hh⟩ := Finset.mem_filter.mp hn + exact ⟨(Finset.mem_Icc.mp hi).1,(Finset.mem_Icc.mp hi).2,hh.le⟩ + have hcount : ((largeOmegaValues x).card : ℝ) ≤ x*∑ n ∈ largeOmegaValues x, (n : ℝ)⁻¹ := by + rw [Finset.mul_sum] + calc + _ = ∑ _n ∈ largeOmegaValues x, (1 : ℝ) := by simp + _ ≤ _ := by + apply Finset.sum_le_sum + intro n hn + have hn0 : (0 : ℝ) volume_tailPrefixRegion_ne_top hR η) + +lemma perturbedWitnessUnion_volume_ne_top (x : ℝ) (H d : ℕ) : + volume (perturbedWitnessUnion x H d) ≠ ⊤ := by + apply ne_top_of_le_ne_top (prefixBandRegion_volume_ne_top x H) + apply measure_mono + intro u hu + obtain ⟨η, hη⟩ := Set.mem_iUnion.mp hu + obtain ⟨_, hu⟩ := Set.mem_iUnion.mp hη + exact hu.2 + +lemma exactWitnessUnion_empty_of_not_totient {x : ℝ} {H d : ℕ} + (hs : theta x ∈ Set.Ico (0 : ℝ) 1) (hd : ¬ IsTotient d) : + exactWitnessUnion x H d = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + intro u hu + obtain ⟨η, hη⟩ := Set.mem_iUnion.mp hu + obtain ⟨hη, _⟩ := Set.mem_iUnion.mp hη + have hw := (mem_witnessFinset hs).mp hη + exact hd ⟨w η, witness_w_pos hw.1, hw.2⟩ + +lemma unionVolumeCoefficient_mul_G {x : ℝ} {H : ℕ} + (hB : 0 < B x) (hs : theta x ∈ Set.Ico (0 : ℝ) 1) (f : ℝ → ℝ) : + unionVolumeCoefficient H f x*G x (m x) = + ∑ d ∈ Finset.Icc 1 (tailValueBound H), + f ((ell d : ℝ)/d)/d*volume.real (exactWitnessUnion x H d) := by + unfold unionVolumeCoefficient + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro d _ + by_cases hd : IsTotient d + · rw [ite_eq_left hd, div_mul_cancel₀ _ (G_pos hB _).ne'] + rfl + · rw [ite_eq_right hd, zero_mul, exactWitnessUnion_empty_of_not_totient hs hd] + simp + +lemma perturbed_exact_volume_difference {x : ℝ} {H : ℕ} (hB : 0 ≤ B x) + (hR : 0 < R x H) (d : ℕ) : + |volume.real (perturbedWitnessUnion x H d)-volume.real (exactWitnessUnion x H d)| ≤ + volume.real (perturbedWitnessUnion x H d \ exactWitnessUnion x H d)+ + volume.real (exactWitnessUnion x H d \ prefixBandRegion x H) := by + have hfinite := exactWitnessUnion_volume_ne_top hR d + have hsub : exactWitnessUnion x H d \ perturbedWitnessUnion x H d ⊆ + exactWitnessUnion x H d \ prefixBandRegion x H := by + rintro u ⟨hu, hn⟩ + refine ⟨hu, ?_⟩ + intro hb + obtain ⟨η, hη⟩ := Set.mem_iUnion.mp hu + obtain ⟨hη, hu⟩ := Set.mem_iUnion.mp hη + exact hn (Set.mem_iUnion.mpr ⟨η, Set.mem_iUnion.mpr + ⟨hη, banded_tailRegion_subset_perturbed η hB ⟨hu, hb⟩, hb⟩⟩) + have hfinDiff : volume (exactWitnessUnion x H d \ prefixBandRegion x H) ≠ ⊤ := + ne_top_of_le_ne_top hfinite (measure_mono Set.sdiff_subset) + have hh := (le_measureReal_sdiff (μ := volume) (s₁ := exactWitnessUnion x H d) + (perturbedWitnessUnion_volume_ne_top x H d)).trans (measureReal_mono hsub hfinDiff) + have ha := le_measureReal_sdiff (μ := volume) (s₁ := perturbedWitnessUnion x H d) hfinite + rw [abs_le] + constructor <;> linarith [show 0 ≤ volume.real + (perturbedWitnessUnion x H d \ exactWitnessUnion x H d) from measureReal_nonneg, + show 0 ≤ volume.real (exactWitnessUnion x H d \ prefixBandRegion x H) from measureReal_nonneg] + +/-- The geometric approximation to the exact coefficient. Only the +prime-grid-to-volume step remains in the mass approximation after this. -/ +theorem banded_volume_coefficient_approximation (hbox : FordUnitPrimeBoxInput) + (hmertens : MertensProductInput) (hren : FordRenewalInput) + (hford : FordCoordinateConcentrationInput) : + ∃ ε : ℕ → ℝ, Tendsto ε atTop (nhds 0) ∧ + ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, + ∀ f : ℝ → ℝ, (∀ r, 0 ≤ f r ∧ f r ≤ 1) → + |bandedVolumeMass x H f/G x (m x)-unionVolumeCoefficient H f x| ≤ ε H := by + obtain ⟨ε, hε, hp⟩ := weighted_union_perturbation_removal hbox hmertens hren + obtain ⟨δ, hδ, hb⟩ := weighted_union_band_removal hbox hmertens hren hford + refine ⟨fun H => ε H+δ H, by simpa using hε.add hδ, ?_⟩ + filter_upwards [hp, hb] with H hHp hHb + filter_upwards [hHp, hHb, theta_eventually_mem, + B_tendsto.eventually (eventually_gt_atTop (0 : ℝ)), + m_tendsto.eventually (eventually_gt_atTop H)] with x hxp hxb hs hB hm + intro f hf + have hR : 0 < R x H := by unfold R; omega + have heq : bandedVolumeMass x H f-unionVolumeCoefficient H f x*G x (m x) = + ∑ d ∈ Finset.Icc 1 (tailValueBound H), f ((ell d : ℝ)/d)/d* + (volume.real (perturbedWitnessUnion x H d)-volume.real (exactWitnessUnion x H d)) := by + rw [unionVolumeCoefficient_mul_G hB hs, bandedVolumeMass, ← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro d _ + rw [bandedWitnessRegion_eq hs] + change _*volume.real _-_*volume.real _ = _ + ring + have habs : |bandedVolumeMass x H f-unionVolumeCoefficient H f x*G x (m x)| ≤ + (∑ d ∈ Finset.Icc 1 (tailValueBound H), f ((ell d : ℝ)/d)/d* + volume.real (perturbedWitnessUnion x H d \ exactWitnessUnion x H d))+ + (∑ d ∈ Finset.Icc 1 (tailValueBound H), f ((ell d : ℝ)/d)/d* + volume.real (exactWitnessUnion x H d \ prefixBandRegion x H)) := by + rw [heq, ← Finset.sum_add_distrib] + apply (Finset.abs_sum_le_sum_abs _ _).trans + apply Finset.sum_le_sum + intro d hd + have hw : 0 ≤ f ((ell d : ℝ)/d)/d := div_nonneg (hf _).1 (Nat.cast_nonneg _) + rw [abs_mul, abs_of_nonneg hw, ← mul_add] + exact mul_le_mul_of_nonneg_left (perturbed_exact_volume_difference hB.le hR d) hw + have htotal := add_le_add (hxp f hf) (hxb f hf) + rw [← add_div] at htotal + calc + _ = |bandedVolumeMass x H f-unionVolumeCoefficient H f x*G x (m x)|/G x (m x) := by + have hq : bandedVolumeMass x H f/G x (m x)-unionVolumeCoefficient H f x = + (bandedVolumeMass x H f-unionVolumeCoefficient H f x*G x (m x))/G x (m x) := by + rw [sub_div, mul_div_cancel_right₀ _ (G_pos hB _).ne'] + rw [hq, abs_div, abs_of_pos (G_pos hB _)] + _ ≤ _ := div_le_div_of_nonneg_right habs (G_pos hB _).le + _ ≤ ε H+δ H := htotal + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/WeightPerturbation.lean b/lean/OAI/NumberTheory/TotientAsymptotic/WeightPerturbation.lean new file mode 100644 index 0000000000000000000000000000000000000000..c0f916956e12b12b9bdab72f6e3b2a8e892cf7d3 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/WeightPerturbation.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.TotientAsymptotic.Arithmetic + +namespace OAI + +noncomputable section +open scoped BigOperators +namespace TotientAsymptotic + +lemma one_sub_prod_le_sum {ι : Type*} (S : Finset ι) (a : ι → ℝ) + (ha : ∀ i ∈ S, 0 ≤ a i ∧ a i ≤ 1) : + 1-∏ i ∈ S, a i ≤ ∑ i ∈ S, (1-a i) := by + classical + induction S using Finset.induction_on with + | empty => simp + | @insert i S hi ih => + have hai := ha i (Finset.mem_insert_self _ _) + have hS : ∀ j ∈ S, 0 ≤ a j ∧ a j ≤ 1 := fun j hj => ha j (Finset.mem_insert_of_mem hj) + have hp0 : 0 ≤ ∏ j ∈ S, a j := Finset.prod_nonneg (fun j hj => (hS j hj).1) + have hp1 : ∏ j ∈ S, a j ≤ 1 := + Finset.prod_le_one₀ (fun j hj => (hS j hj).1) (fun j hj => (hS j hj).2) + rw [Finset.prod_insert hi,Finset.sum_insert hi] + have hh := ih hS + nlinarith [mul_nonneg (sub_nonneg.mpr hai.2) (sub_nonneg.mpr hp1)] + +lemma min_one_lipschitz (u v : ℝ) : |min 1 u-min 1 v| ≤ |u-v| := by + simpa only [sub_self,abs_zero,max_eq_right (abs_nonneg (u-v))] using + abs_min_sub_min_le_max (1 : ℝ) u 1 v + +/-- A bounded additive perturbation is valid even when the original weight +vanishes, including the boundary r=k. -/ +lemma fk_reciprocal_lipschitz (k : ℕ) {r q : ℝ} (hr : 1 ≤ r) + (_hq : 0 < q) (hq1 : q ≤ 1) : + |fk k (r/q)-fk k r| ≤ (2*(k : ℝ)+1)*(1-q) := by + have hr0 : 0 < r := zero_lt_one.trans_le hr + have hdiff (c : ℝ) (hc : 0 ≤ c) : + |c/(r/q)-c/r| = c*(1-q)/r := by + have he : c/(r/q)-c/r=-(c*(1-q)/r) := by field_simp; ring + rw [he,abs_neg,abs_of_nonneg (by positivity)] + unfold fk + calc + _ = |(min 1 ((k+1 : ℝ)/(r/q))-min 1 ((k+1 : ℝ)/r))- + (min 1 ((k : ℝ)/(r/q))-min 1 ((k : ℝ)/r))| := by congr 1; ring + _ ≤ |min 1 ((k+1 : ℝ)/(r/q))-min 1 ((k+1 : ℝ)/r)|+ + |min 1 ((k : ℝ)/(r/q))-min 1 ((k : ℝ)/r)| := abs_sub _ _ + _ ≤ |(k+1 : ℝ)/(r/q)-(k+1 : ℝ)/r|+|(k : ℝ)/(r/q)-(k : ℝ)/r| := + add_le_add (min_one_lipschitz _ _) (min_one_lipschitz _ _) + _ = (2*(k : ℝ)+1)*(1-q)/r := by + rw [hdiff _ (by positivity),hdiff _ (Nat.cast_nonneg k)] + ring + _ ≤ _ := div_le_self (by positivity) hr + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/WeightedCoefficient.lean b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f581bbbdff58ef7816ecb1b4b93066f4b135425 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedCoefficient.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.TotientAsymptotic.WeightedMass + +namespace OAI + +noncomputable section +open scoped Topology +open Filter +namespace TotientAsymptotic + +/-- The weighted mass comparison includes every exceptional value and tuple. -/ +theorem weighted_value_mass_approximation (hscale : FordScaleBounds) + (hstruct : ExtractedStructureInput) (hpnt : PrimeNumberTheoremInput) + (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) (hmertens : MertensProductInput) + (h26 : FordLemma26Input) (h51 : FordLemma51Input) (k : ℕ) (hk : 1 ≤ k) : + ∃ δ : ℕ → ℝ, Tendsto δ atTop (nhds 0) ∧ + ∀ᶠ H : ℕ in atTop, ∀ ε : ℝ, 0 < ε → ∀ᶠ x : ℝ in atTop, + |normalizedCount (N k) x-M x H (fk k)/G x (m x)| ≤ δ H+ε := by + obtain ⟨δv,hδv,hv⟩ := candidate_value_comparison hscale hstruct hbox hren hmertens h26 h51 + obtain ⟨δm,hδm,hm⟩ := candidate_mass_normalized hpnt hbox hren hmertens k hk + refine ⟨fun H => δv H+δm H,by simpa using hδv.add hδm,?_⟩ + filter_upwards [hv,hm] with H hv hm + intro ε hε + filter_upwards [hv (ε/2) (by positivity),hm (ε/2) (by positivity),scale_eventually_pos] + with x hv hm hN + change 0 < tupleNormalization x at hN + have he : |normalizedCount (N k) x-((candidateTuples x H k).card : ℝ)/tupleNormalization x| ≤ δv H+ε/2 := by + change |N k x/tupleNormalization x-_| ≤ _ + rw [← sub_div,abs_div,abs_of_pos hN,abs_sub_comm] + exact (div_le_iff₀ hN).mpr (hv k) + exact (abs_sub_le _ _ _).trans ((add_le_add he hm).trans_eq (by ring)) + +theorem weighted_value_coefficient_approximation (hscale : FordScaleBounds) + (hstruct : ExtractedStructureInput) (hpnt : PrimeNumberTheoremInput) + (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) (hmertens : MertensProductInput) + (h26 : FordLemma26Input) (h51 : FordLemma51Input) (hconc : FordCoordinateConcentrationInput) + (k : ℕ) (hk : 1 ≤ k) : + ∃ δ : ℕ → ℝ, Tendsto δ atTop (nhds 0) ∧ + ∀ᶠ H : ℕ in atTop, ∀ ε : ℝ, 0 < ε → ∀ᶠ x : ℝ in atTop, + |normalizedCount (N k) x-AH H (fk k) (theta x)| ≤ δ H+ε := by + obtain ⟨δv,hδv,hv⟩ := weighted_value_mass_approximation hscale hstruct hpnt hbox hren hmertens h26 h51 k hk + obtain ⟨δm,hδm,hm⟩ := mass_finite_coefficient_approximation hbox hmertens hren hconc + refine ⟨fun H => δv H+δm H,by simpa using hδv.add hδm,?_⟩ + let f : ℝ → ℝ := fun r => fk k (max r 0) + have hf : ∀ r, 0 ≤ f r ∧ f r ≤ 1 := fun r => + ⟨fk_nonneg k (le_max_right _ _),fk_le_one k (le_max_right _ _)⟩ + have hsame (d : ℕ) : f ((ell d : ℝ)/d)=fk k ((ell d : ℝ)/d) := by + dsimp [f] + rw [max_eq_left (div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _))] + have hmass (x : ℝ) (H : ℕ) : M x H f=M x H (fk k) := by + simp only [mass_eq_prefix_denominators,hsame] + have hcoeff (H : ℕ) (s : ℝ) : AH H f s=AH H (fk k) s := by + unfold AH + simp only [hsame] + filter_upwards [hv,hm] with H hv hm + intro ε hε + filter_upwards [hv (ε/2) (by positivity),hm f hf (ε/2) (by positivity)] with x hv hm + rw [hmass,hcoeff] at hm + exact (abs_sub_le _ _ _).trans ((add_le_add hv hm).trans_eq (by ring)) + +/-- The additive weighted asymptotic and its uniform arithmetic coefficient. -/ +theorem conditional_companion_additive (hscale : FordScaleBounds) + (hstruct : ExtractedStructureInput) (hpnt : PrimeNumberTheoremInput) + (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) (hmertens : MertensProductInput) + (h26 : FordLemma26Input) (h51 : FordLemma51Input) (hconc : FordCoordinateConcentrationInput) + (k : ℕ) (hk : 1 ≤ k) : + TendstoUniformlyOn (fun H => AH H (fk k)) (A (fk k)) atTop (Set.Ico (0 : ℝ) 1) ∧ + Tendsto (fun x => normalizedCount (N k) x-A (fk k) (theta x)) atTop (nhds 0) := by + obtain ⟨δ,hδ,happ⟩ := weighted_value_coefficient_approximation hscale hstruct hpnt + hbox hren hmertens h26 h51 hconc k hk + apply coefficient_convergence_from_phase_comparison + intro ε hε + have he : ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, + |normalizedCount (N k) x-AH H (fk k) (theta x)| ≤ ε := by + filter_upwards [happ,hδ.eventually (eventually_lt_nhds (show (0 : ℝ)<ε/2 by positivity))] + with H hH hδH + filter_upwards [hH (ε/2) (by positivity)] with x hx + exact hx.trans (by linarith) + exact eventually_atTop.mp he + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/WeightedFiber.lean b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedFiber.lean new file mode 100644 index 0000000000000000000000000000000000000000..72162e786475662f2e0ad5181891b6e3fd2e7f61 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedFiber.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TotientAsymptotic.CandidateComparison +import OAI.NumberTheory.TotientAsymptotic.WeightedPrimeWindow +import OAI.NumberTheory.TotientAsymptotic.WeightPerturbation + +namespace OAI + +noncomputable section +open scoped BigOperators Topology Classical +open Filter +namespace TotientAsymptotic + +def prefixCandidateFactor {r : ℕ} (ζ : PrefixDatum r) : ℕ := + ell ζ.d*∏ i, ζ.primes i + +lemma tupleLeastCandidate_eq_head {r p : ℕ} (ζ : PrefixDatum r) : + tupleLeastCandidate (TotientTuple.mk p ζ)=p*prefixCandidateFactor ζ := by + simp only [tupleLeastCandidate,tuplePrimeProduct,tuplePrimes,Fin.prod_univ_succ, + Fin.cons_zero,Fin.cons_succ,prefixCandidateFactor] + ring + +def candidatePrimeSet (x : ℝ) (H k : ℕ) (ζ : PrefixDatum (R x H)) : Finset ℕ := + (shiftedPrimeSet x x (prefixDenominator ζ)).filter (fun p : ℕ => + (k : ℝ)*x < (p*prefixCandidateFactor ζ : ℕ) ∧ + (p*prefixCandidateFactor ζ : ℕ) ≤ (k+1 : ℝ)*x) + +lemma candidate_fiber_card {x : ℝ} {H k : ℕ} (hPH : P H ≤ H) (hx : 0 ≤ x) + {ζ : PrefixDatum (R x H)} (hζ : IsPrefixDatum x H ζ) : + ((candidateTuples x H k).filter (fun τ => τ.tail=ζ)).card=(candidatePrimeSet x H k ζ).card := by + apply Finset.card_bij (fun τ _ => τ.head) + · intro τ hτ + obtain ⟨hτ,htail⟩ := Finset.mem_filter.mp hτ + obtain ⟨hb,hw⟩ := Finset.mem_filter.mp hτ + have hb := (mem_tupleFinset hPH).mp hb + apply Finset.mem_filter.mpr + constructor + · apply (mem_shiftedPrimeSet hx (basic_prefix_denominator_pos hPH hζ)).mpr + refine ⟨hb.1,hb.2.1,?_⟩ + have hv := hb.2.2.2 + change ((tupleValue (TotientTuple.mk τ.head τ.tail) : ℕ) : ℝ) ≤ x at hv + rw [tupleValue_eq_head,htail] at hv + exact hv + · have he : τ=TotientTuple.mk τ.head ζ := by cases τ; simp_all + rw [he] at hw + simpa only [candidateInWindow,tupleLeastCandidate_eq_head] using hw + · intro τ hτ σ hσ he + have ht := (Finset.mem_filter.mp hτ).2 + have hs := (Finset.mem_filter.mp hσ).2 + cases τ + cases σ + simp_all + · intro p hp + obtain ⟨hp,hw⟩ := Finset.mem_filter.mp hp + obtain ⟨hp,hlo,hval⟩ := (mem_shiftedPrimeSet hx (basic_prefix_denominator_pos hPH hζ)).mp hp + refine ⟨⟨p,ζ⟩,Finset.mem_filter.mpr ⟨?_,rfl⟩,rfl⟩ + apply Finset.mem_filter.mpr + constructor + · apply (mem_tupleFinset hPH).mpr + refine ⟨hp,hlo,hζ,?_⟩ + simpa only [tupleValue_eq_head,prefixDenominator] using hval + · simpa only [candidateInWindow,tupleLeastCandidate_eq_head] using hw + +lemma candidate_count_eq_prime_fibers {x : ℝ} {H k : ℕ} (hPH : P H ≤ H) (hx : 0 ≤ x) : + ((candidateTuples x H k).card : ℝ)= + ∑ ζ ∈ prefixDataFinset x H, ((candidatePrimeSet x H k ζ).card : ℝ) := by + have hmap : ∀ τ ∈ candidateTuples x H k, τ.tail ∈ prefixDataFinset x H := by + intro τ hτ + exact mem_prefixDataFinset.mpr ((mem_tupleFinset hPH).mp (Finset.mem_filter.mp hτ).1).2.2.1 + have he := Finset.sum_card_fiberwise_eq_card_filter (candidateTuples x H k) (prefixDataFinset x H) TotientTuple.tail + rw [Finset.filter_eq_self.mpr hmap] at he + rw [← he,Nat.cast_sum] + apply Finset.sum_congr rfl + intro ζ hζ + rw [candidate_fiber_card hPH hx (mem_prefixDataFinset.mp hζ)] + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/WeightedFiniteMap.lean b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedFiniteMap.lean new file mode 100644 index 0000000000000000000000000000000000000000..c147e9d5dbacca03eda74d8782bdf4420fa89e90 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedFiniteMap.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.TotientAsymptotic.FilteredComparison +import Mathlib.Algebra.Order.BigOperators.Group.Finset + +namespace OAI + +noncomputable section +open scoped BigOperators Classical +namespace TotientAsymptotic.FiniteMap + +/-- A positive weight on all ordinary representatives converts a count of +values into a lower bound for the weighted representation count. -/ +lemma weighted_lower {α β : Type*} [DecidableEq α] [DecidableEq β] + (T D : Finset α) (W E U : Finset β) (F : α → β) (w : α → ℝ) (c : ℝ) + (hc : 0≤c) (hU : U⊆W) (hbij : Set.BijOn F (↑(T\D)) (↑(W\E))) + (hw : ∀ t∈T, 0≤w t) + (hweight : ∀ t∈T\D, F t∈U → c≤w t) : + c*((U.card : ℝ)-E.card) ≤ ∑ t∈T, w t := by + let S := (T\D).filter (fun t => F t∈U) + have hcard : S.card=(U\E).card := by + apply Finset.card_bij (fun t _ => F t) + · intro t ht + obtain ⟨ht,hU⟩ := Finset.mem_filter.mp ht + exact Finset.mem_sdiff.mpr ⟨hU,(Finset.mem_sdiff.mp (hbij.1 ht)).2⟩ + · intro t ht s hs he + exact hbij.2.1 (Finset.mem_filter.mp ht).1 (Finset.mem_filter.mp hs).1 he + · intro v hv + obtain ⟨t,ht,he⟩ := hbij.2.2 (Finset.mem_sdiff.mpr ⟨hU (Finset.mem_sdiff.mp hv).1,(Finset.mem_sdiff.mp hv).2⟩) + refine ⟨t,Finset.mem_filter.mpr ⟨ht,?_⟩,he⟩ + exact he ▸ (Finset.mem_sdiff.mp hv).1 + have hs : S⊆T := fun _ ht => (Finset.mem_sdiff.mp (Finset.mem_filter.mp ht).1).1 + have hce : (U.card : ℝ)-E.card≤(S.card : ℝ) := by + have he := Finset.card_sdiff_add_card_inter U E + have hle := Finset.card_le_card (show U∩E⊆E from Finset.inter_subset_right) + have her : ((U\E).card : ℝ)+(U∩E).card=U.card := by exact_mod_cast he + have hler : ((U∩E).card : ℝ)≤E.card := by exact_mod_cast hle + rw [hcard] + linarith + calc + c*((U.card : ℝ)-E.card) ≤ c*(S.card : ℝ) := mul_le_mul_of_nonneg_left hce hc + _ = ∑ t∈S, c := by simp [mul_comm] + _ ≤ ∑ t∈S, w t := Finset.sum_le_sum (fun t ht => hweight t (Finset.mem_filter.mp ht).1 (Finset.mem_filter.mp ht).2) + _ ≤ ∑ t∈T, w t := Finset.sum_le_sum_of_subset_of_nonneg hs (fun t ht _ => hw t ht) + +end TotientAsymptotic.FiniteMap + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/WeightedIntervalGeometry.lean b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedIntervalGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..f00906fd46f5bdf4db8ea5e519109a6a24158924 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedIntervalGeometry.lean @@ -0,0 +1,49 @@ +import OAI.NumberTheory.TotientAsymptotic.WeightPerturbation + +namespace OAI + +noncomputable section +namespace TotientAsymptotic + +lemma intervalLength_lipschitz {l u v : ℝ} (huv : v ≤ u) (hvu : u ≤ v+1) : + |(u-min l u)-(v-min l v)| ≤ 1 := by + by_cases hlv : l ≤ v + · rw [min_eq_left hlv,min_eq_left (hlv.trans huv)] + rw [abs_of_nonneg (by linarith)] + linarith + · have hvl := (not_le.mp hlv).le + rw [min_eq_right hvl] + by_cases hlu : l ≤ u + · rw [min_eq_left hlu,abs_of_nonneg (by linarith)] + linarith + · rw [min_eq_right (not_le.mp hlu).le] + norm_num + +lemma shifted_interval_length {T U r : ℝ} (hT : 0 < T) (hU : 0 ≤ U) + (_hr : 0 < r) (he : U=T/r) (k : ℕ) : + |(min (T+1) ((k+1 : ℝ)*U)-min ((k : ℝ)*U) (min (T+1) ((k+1 : ℝ)*U)))- + T*fk k r| ≤ 1 := by + have hlc : (k : ℝ)*U ≤ (k+1 : ℝ)*U := by nlinarith + have hm : min ((k : ℝ)*U) (min T ((k+1 : ℝ)*U)) = min T ((k : ℝ)*U) := by + rw [← min_assoc,min_comm ((k : ℝ)*U) T,min_assoc,min_eq_left hlc] + have hf : T*fk k r=min T ((k+1 : ℝ)*U)-min T ((k : ℝ)*U) := by + rw [fk,mul_sub,mul_min_of_nonneg _ _ hT.le,mul_min_of_nonneg _ _ hT.le] + rw [mul_one] + rw [he] + congr 2 <;> ring + have hlow : min T ((k+1 : ℝ)*U) ≤ min (T+1) ((k+1 : ℝ)*U) := + min_le_min_right _ (by linarith) + have hhigh : min (T+1) ((k+1 : ℝ)*U) ≤ min T ((k+1 : ℝ)*U)+1 := by + by_cases hc : T ≤ (k+1 : ℝ)*U + · rw [min_eq_left hc] + exact min_le_left _ _ + · rw [min_eq_right (not_le.mp hc).le] + exact (min_le_right _ _).trans (by linarith) + rw [hf,← hm] + exact intervalLength_lipschitz hlow hhigh + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/WeightedMass.lean b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..a081bbda836f724f4e5f578a0341b6f9612ffc9b --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedMass.lean @@ -0,0 +1,130 @@ +import OAI.NumberTheory.TotientAsymptotic.WeightedPrimeCount +import OAI.NumberTheory.TotientAsymptotic.PrefixWeight +import OAI.NumberTheory.TotientAsymptotic.TupleCoefficient + +namespace OAI + +noncomputable section +open scoped BigOperators Topology Classical +open Filter +namespace TotientAsymptotic + +def candidateMass (x : ℝ) (H k : ℕ) : ℝ := + ∑ ζ ∈ prefixDataFinset x H, + fk k ((prefixCandidateFactor ζ : ℝ)/prefixDenominator ζ)/(prefixDenominator ζ : ℝ) + +lemma mass_eq_prefix_denominators (x : ℝ) (H : ℕ) (f : ℝ → ℝ) : + M x H f = ∑ ζ ∈ prefixDataFinset x H, + f ((ell ζ.d : ℝ)/ζ.d)/(prefixDenominator ζ : ℝ) := by + rw [mass_eq_sum_prefixData] + simp only [prefixDenominator,Nat.cast_mul,Nat.cast_prod] + +lemma candidate_mass_perturbation : ∀ᶠ H : ℕ in atTop, + ∀ x : ℝ, 0 ≤ theta x → H ≤ m x → ∀ k : ℕ, + |candidateMass x H k-M x H (fk k)| ≤ + ((2*(k : ℝ)+1)*prefixReciprocalError H)*M x H (fun _ => 1) := by + filter_upwards [prefix_weight_error,eventually_ge_atTop 2] with H he hH + intro x hs hm k + rw [candidateMass,mass_eq_prefix_denominators,mass_eq_prefix_denominators, + ← Finset.sum_sub_distrib,Finset.mul_sum] + apply (Finset.abs_sum_le_sum_abs _ _).trans + apply Finset.sum_le_sum + intro ζ hζ + have hz := mem_prefixDataFinset.mp hζ + have hd : (0 : ℝ) < prefixDenominator ζ := by + exact_mod_cast basic_prefix_denominator_pos (P_lt_self hH).le hz + rw [← sub_div,abs_div,abs_of_pos hd] + exact (div_le_div_of_nonneg_right (he x hs hm k ζ hz) hd.le).trans_eq (by ring) + +/-- Summation of the actual least-preimage prime intervals, before replacing +its prefix ratio by the tail ratio. -/ +theorem candidate_prime_mass_relative (hpnt : PrimeNumberTheoremInput) : + ∀ᶠ H : ℕ in atTop, ∀ ε : ℝ, 0 < ε → ∀ᶠ x : ℝ in atTop, + ∀ k : ℕ, 1 ≤ k → + |((candidateTuples x H k).card : ℝ)-(x/Real.log x)*candidateMass x H k| ≤ + ε*(x/Real.log x)*M x H (fun _ => 1) := by + filter_upwards [prefix_candidate_ratio_bounds,eventually_ge_atTop 2, + P_tendsto.eventually (eventually_ge_atTop 1)] with H hratio hH hP + intro ε hε + let C : ℝ := max 1 (2*tailValueBound H) + filter_upwards [weighted_prime_count hpnt (C := C) (le_max_left _ _) hε, + basic_prefix_denominator_log_small (P_lt_self hH) hP, + theta_eventually_mem,m_tendsto.eventually (eventually_ge_atTop H), + eventually_gt_atTop (1 : ℝ)] with x hcount hlog hs hm hx + intro k hk + rw [candidate_count_eq_prime_fibers (P_lt_self hH).le (zero_lt_one.trans hx).le, + candidateMass,mass_eq_prefix_denominators,Finset.mul_sum,Finset.mul_sum,← Finset.sum_sub_distrib] + apply (Finset.abs_sum_le_sum_abs _ _).trans + apply Finset.sum_le_sum + intro ζ hζ + have hz := mem_prefixDataFinset.mp hζ + have hd := basic_prefix_denominator_pos (P_lt_self hH).le hz + have hdR : (0 : ℝ) < prefixDenominator ζ := by exact_mod_cast hd + obtain ⟨hlo,hhi⟩ := hratio x hs hm ζ hz + have hDA : prefixDenominator ζ ≤ prefixCandidateFactor ζ := by + exact_mod_cast (one_le_div hdR).mp hlo + have hAC : (prefixCandidateFactor ζ : ℝ) ≤ C*prefixDenominator ζ := + (div_le_iff₀ hdR).mp (hhi.trans (le_max_right _ _)) + have hc := hcount k (prefixDenominator ζ) (prefixCandidateFactor ζ) hk hd hDA hAC (hlog ζ hz) + change |((candidatePrimeSet x H k ζ).card : ℝ)-_| ≤ _ + change |((intervalHeads x k (prefixDenominator ζ) (prefixCandidateFactor ζ)).card : ℝ)-_| ≤ _ + have heq : (x/Real.log x)*(fk k ((prefixCandidateFactor ζ : ℝ)/prefixDenominator ζ)/ + (prefixDenominator ζ : ℝ))= + (x/(prefixDenominator ζ*Real.log x))*fk k ((prefixCandidateFactor ζ : ℝ)/prefixDenominator ζ) := by ring + rw [heq] + convert hc using 1 + ring + +/-- The weighted counting error vanishes with the discrete tail cutoff. -/ +theorem candidate_mass_normalized (hpnt : PrimeNumberTheoremInput) + (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) (hmertens : MertensProductInput) + (k : ℕ) (hk : 1 ≤ k) : + ∃ δ : ℕ → ℝ, Tendsto δ atTop (nhds 0) ∧ + ∀ᶠ H : ℕ in atTop, ∀ ε : ℝ, 0 < ε → ∀ᶠ x : ℝ in atTop, + |((candidateTuples x H k).card : ℝ)/tupleNormalization x- + M x H (fk k)/G x (m x)| ≤ δ H+ε := by + obtain ⟨C,hC,hupper⟩ := mass_upper hbox hren hmertens + let K := fun H => C*Real.exp ((4*(lam/rho))*cofactorScale H) + let δ := fun H => (2*(k : ℝ)+1)*K H*prefixReciprocalError H + have hK (H : ℕ) : 0 < K H := mul_pos hC (Real.exp_pos _) + refine ⟨δ,?_,?_⟩ + · have ht := (weighted_prefixReciprocalError_tendsto (4*(lam/rho))).const_mul ((2*(k : ℝ)+1)*C) + simp only [mul_zero] at ht + convert ht using 1 + ext H + dsimp [δ,K] + ring + filter_upwards [candidate_prime_mass_relative hpnt,candidate_mass_perturbation,hupper] + with H hprime hpert hupper + intro ε hε + filter_upwards [hprime (ε/K H) (div_pos hε (hK H)),hupper,theta_eventually_mem, + m_tendsto.eventually (eventually_ge_atTop H),eventually_gt_atTop (1 : ℝ), + B_tendsto.eventually (eventually_gt_atTop (0 : ℝ))] with x hp hu hs hm hx hB + have hG := G_pos hB (m x) + have ht : 0 < x/Real.log x := div_pos (zero_lt_one.trans hx) (Real.log_pos hx) + have hN := tupleNormalization_pos hx hB + have hM : M x H (fun _ => 1) ≤ K H*G x (m x) := hu _ (fun _ => le_rfl) + have he : |((candidateTuples x H k).card : ℝ)/tupleNormalization x- + candidateMass x H k/G x (m x)| ≤ ε := by + rw [show ((candidateTuples x H k).card : ℝ)/tupleNormalization x-candidateMass x H k/G x (m x)= + (((candidateTuples x H k).card : ℝ)-(x/Real.log x)*candidateMass x H k)/tupleNormalization x by + unfold tupleNormalization; field_simp [(Real.log_pos hx).ne',hG.ne'], + abs_div,abs_of_pos hN] + apply (div_le_iff₀ hN).mpr + calc + _ ≤ (ε/K H)*(x/Real.log x)*M x H (fun _ => 1) := hp k hk + _ ≤ (ε/K H)*(x/Real.log x)*(K H*G x (m x)) := + mul_le_mul_of_nonneg_left hM (by positivity) + _ = ε*tupleNormalization x := by unfold tupleNormalization; field_simp [(hK H).ne'] + have hmerr : |candidateMass x H k/G x (m x)-M x H (fk k)/G x (m x)| ≤ δ H := by + rw [← sub_div,abs_div,abs_of_pos hG] + apply (div_le_iff₀ hG).mpr + exact (hpert x hs.1 hm k).trans ((mul_le_mul_of_nonneg_left hM + (mul_nonneg (by positivity) (prefixReciprocalError_nonneg H))).trans_eq (by dsimp [δ]; ring)) + exact (abs_sub_le _ _ _).trans ((add_le_add he hmerr).trans_eq (add_comm _ _)) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/WeightedPrimeCount.lean b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedPrimeCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..e88f176e0f08889241247e429ed16da80819c4d1 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedPrimeCount.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.TotientAsymptotic.WeightedPrimeSet + +namespace OAI + +noncomputable section +open scoped Topology +open Filter +namespace TotientAsymptotic + +lemma weighted_endpoint_bounds {x D A C : ℝ} {k : ℕ} + (hx : 0 < x) (hD : 0 < D) (hDA : D ≤ A) (hC : 1 ≤ C) (hAC : A ≤ C*D) + (hT : 1 ≤ x/D) (hk : 1 ≤ k) : + (1/C)*x/D ≤ (k : ℝ)*x/A ∧ + (1/C)*x/D ≤ min (1+x/D) ((k+1 : ℝ)*x/A) ∧ + min (1+x/D) ((k+1 : ℝ)*x/A) ≤ 2*x/D := by + have hA : 0 < A := hD.trans_le hDA + have hC0 : 0 < C := zero_lt_one.trans_le hC + have hb : (1/C)*x/D ≤ x/A := by + have hh := div_le_div_of_nonneg_left hx.le hA hAC + convert hh using 1 + ring + have hkR : (1 : ℝ) ≤ k := by exact_mod_cast hk + have hp : (1/C)*x/D ≤ x/D := by + have hi : 1/C ≤ (1 : ℝ) := (div_le_one hC0).mpr hC + calc + (1/C)*x/D = (1/C)*(x/D) := by ring + _ ≤ 1*(x/D) := mul_le_mul_of_nonneg_right hi (div_pos hx hD).le + _ = x/D := one_mul _ + refine ⟨hb.trans ?_,le_min (hp.trans (by linarith)) (hb.trans ?_),?_⟩ + · exact div_le_div_of_nonneg_right (by nlinarith) hA.le + · exact div_le_div_of_nonneg_right (by nlinarith) hA.le + · apply (min_le_left _ _).trans + rw [show 2*x/D=2*(x/D) by ring] + linarith + +/-- Ordinary PNT at two long-scale endpoints suffices, uniformly for all +allowed integers A,D. The estimate remains additive for empty intervals. -/ +theorem weighted_prime_count (hpnt : PrimeNumberTheoremInput) + {C ε : ℝ} (hC : 1 ≤ C) (hε : 0 < ε) : + ∀ᶠ x : ℝ in atTop, ∀ k D A : ℕ, 1 ≤ k → 0 < D → D ≤ A → + (A : ℝ) ≤ C*D → Real.log (D : ℝ) ≤ (Real.log x)^(4/5 : ℝ) → + |((intervalHeads x k D A).card : ℝ)- + (x/(D*Real.log x))*fk k ((A : ℝ)/D)| ≤ ε*(x/(D*Real.log x)) := by + have hC0 : 0 < C := zero_lt_one.trans_le hC + filter_upwards [prime_interval_uniform hpnt (a := 1/C) (by positivity) + (b := 2) (by norm_num) (show 0 < ε/3 by positivity), + lower_prime_cutoff_negligible (a := 1) (by norm_num) (show 0 < ε/3 by positivity), + small_denominator_window (a := 1) (by norm_num) (δ := 1/4) (by norm_num) le_rfl, + eventually_gt_atTop (Real.exp 1)] with x hint hcut hwindow hx + intro k D A hk hD hDA hAC hlogD + have he1 : (1 : ℝ) < Real.exp 1 := Real.one_lt_exp_iff.mpr (by norm_num) + have hx1 : 1 < x := he1.trans hx + have hx0 : 0 < x := zero_lt_one.trans hx1 + have hL : 0 < Real.log x := Real.log_pos hx1 + have hL1 : 1 ≤ Real.log x := (Real.le_log_iff_exp_le hx0).mpr hx.le + have hD1 : (1 : ℝ) ≤ D := by exact_mod_cast hD + have hD0 : (0 : ℝ) < D := by exact_mod_cast hD + have hDA' : (D : ℝ) ≤ A := by exact_mod_cast hDA + have hA0 : (0 : ℝ) < A := hD0.trans_le hDA' + let l : ℝ := (k : ℝ)*x/A + let u : ℝ := min (1+x/D) ((k+1 : ℝ)*x/A) + have hT : 1 ≤ x/D := (Real.one_le_rpow hx1.le (by norm_num : (0 : ℝ)≤1/2)).trans + (hwindow D x hD1 hlogD (by simp) le_rfl).1 + have hb := weighted_endpoint_bounds hx0 hD0 hDA' hC hAC hT hk + have hi := hint D l u hD1 hlogD hb.1 hb.2.1 hb.2.2 + have hc := (finite_prime_cutoff_error hx0.le (primeInterval l u)) + rw [← intervalHeads_eq_cutoff hx0.le hD (hD.trans_le hDA)] at hc + have hc' := hcut D x hD1 hlogD (by simp) + have hg := shifted_interval_length (div_pos hx0 hD0) (div_pos hx0 hA0).le + (div_pos hA0 hD0) (show x/(A : ℝ)=(x/D)/((A : ℝ)/D) by field_simp) k + have hg' : |(u-min l u)-(x/D)*fk k ((A : ℝ)/D)| ≤ 1 := by + simpa only [l,u,add_comm,mul_div_assoc] using hg + have he : |(u-min l u)/Real.log x-(x/(D*Real.log x))*fk k ((A : ℝ)/D)| ≤ 1/Real.log x := by + rw [show (u-min l u)/Real.log x-(x/(D*Real.log x))*fk k ((A : ℝ)/D)= + ((u-min l u)-(x/D)*fk k ((A : ℝ)/D))/Real.log x by ring,abs_div,abs_of_pos hL] + exact div_le_div_of_nonneg_right hg' hL.le + have hsmall : 1/Real.log x ≤ (ε/3)*(x/(D*Real.log x)) := by + exact ((div_le_one hL).mpr hL1).trans ((by linarith [Real.rpow_nonneg hx0.le (9/10 : ℝ)] : (1 : ℝ) ≤ x^(9/10 : ℝ)+1).trans hc') + calc + _ ≤ |((intervalHeads x k D A).card : ℝ)-(primeInterval l u).card|+ + |((primeInterval l u).card : ℝ)-(x/(D*Real.log x))*fk k ((A : ℝ)/D)| := abs_sub_le _ _ _ + _ ≤ (ε/3)*(x/(D*Real.log x))+ + (|(primeInterval l u).card-(u-min l u)/Real.log x|+ + |(u-min l u)/Real.log x-(x/(D*Real.log x))*fk k ((A : ℝ)/D)|) := + add_le_add (hc.trans hc') (abs_sub_le _ _ _) + _ ≤ (ε/3)*(x/(D*Real.log x))+ + ((ε/3)*(x/(D*Real.log x))+(ε/3)*(x/(D*Real.log x))) := by + apply add_le_add_right + apply add_le_add _ (he.trans hsmall) + convert hi using 1 + ring + _ = ε*(x/(D*Real.log x)) := by ring + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/WeightedPrimeSet.lean b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedPrimeSet.lean new file mode 100644 index 0000000000000000000000000000000000000000..54a3159feb29594387002ff13029d9c7c49be0e7 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedPrimeSet.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.TotientAsymptotic.PrimeInterval +import OAI.NumberTheory.TotientAsymptotic.LowerPrimeCutoff +import OAI.NumberTheory.TotientAsymptotic.WeightedIntervalGeometry + +namespace OAI + +noncomputable section +open scoped Topology Classical +open Filter +namespace TotientAsymptotic + +def intervalHeads (x : ℝ) (k D A : ℕ) : Finset ℕ := + (shiftedPrimeSet x x D).filter (fun p : ℕ => + (k : ℝ)*x < (p*A : ℕ) ∧ (p*A : ℕ) ≤ (k+1 : ℝ)*x) + +lemma mem_primeInterval {l u : ℝ} (hu : 0 ≤ u) (p : ℕ) : + p ∈ primeInterval l u ↔ p.Prime ∧ l < p ∧ (p : ℝ) ≤ u := by + simp only [primeInterval,Finset.mem_filter,Nat.mem_primesLE,Nat.le_floor_iff hu] + tauto + +lemma intervalHeads_eq_cutoff {x : ℝ} {k D A : ℕ} + (hx : 0 ≤ x) (hD : 0 < D) (hA : 0 < A) : + intervalHeads x k D A = + (primeInterval ((k : ℝ)*x/A) (min (1+x/D) ((k+1 : ℝ)*x/A))).filter + (fun p : ℕ => x^(9/10 : ℝ) ≤ p) := by + have hD0 : (0 : ℝ) < D := by exact_mod_cast hD + have hA0 : (0 : ℝ) < A := by exact_mod_cast hA + have hu : 0 ≤ min (1+x/D) ((k+1 : ℝ)*x/A) := le_min (by positivity) (by positivity) + ext p + rw [intervalHeads,Finset.mem_filter,Finset.mem_filter,mem_shiftedPrimeSet hx hD,mem_primeInterval hu] + by_cases hp : p.Prime + · simp only [hp,true_and] + have hv : (((p-1)*D : ℕ) : ℝ) ≤ x ↔ (p : ℝ) ≤ 1+x/D := by + rw [Nat.cast_mul,Nat.cast_sub hp.one_lt.le,Nat.cast_one] + rw [← le_div_iff₀ hD0] + constructor <;> intro h <;> linarith + simp only [Nat.cast_mul] at hv + simp only [hv,Nat.cast_mul,le_min_iff,div_lt_iff₀ hA0,le_div_iff₀ hA0] + tauto + · simp [hp] + +lemma finite_prime_cutoff_error {x : ℝ} (hx : 0 ≤ x) (S : Finset ℕ) : + |((S.filter (fun p : ℕ => x^(9/10 : ℝ) ≤ p)).card : ℝ)-S.card| ≤ x^(9/10 : ℝ)+1 := by + let E := S.filter (fun p : ℕ => ¬x^(9/10 : ℝ) ≤ p) + have he : E.card ≤ ⌊x^(9/10 : ℝ)⌋₊+1 := by + apply (Finset.card_le_card (t := Finset.range (⌊x^(9/10 : ℝ)⌋₊+1)) ?_).trans_eq (Finset.card_range _) + intro p hp + have ht := lt_of_not_ge (Finset.mem_filter.mp hp).2 + exact Finset.mem_range.mpr (Nat.lt_succ_of_le (Nat.le_floor ht.le)) + have hs := Finset.card_filter_add_card_filter_not (s := S) (fun p : ℕ => x^(9/10 : ℝ) ≤ p) + have hsR := congrArg (fun n : ℕ => (n : ℝ)) hs + rw [Nat.cast_add] at hsR + change ((S.filter (fun p : ℕ => x^(9/10 : ℝ) ≤ p)).card : ℝ)+(E.card : ℝ)=S.card at hsR + rw [show ((S.filter (fun p : ℕ => x^(9/10 : ℝ) ≤ p)).card : ℝ)-S.card=-(E.card : ℝ) by linarith, + abs_neg,abs_of_nonneg (Nat.cast_nonneg _)] + have heR : (E.card : ℝ) ≤ (⌊x^(9/10 : ℝ)⌋₊ : ℝ)+1 := by exact_mod_cast he + exact heR.trans (by linarith [Nat.floor_le (Real.rpow_nonneg hx (9/10 : ℝ))]) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/WeightedPrimeWindow.lean b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedPrimeWindow.lean new file mode 100644 index 0000000000000000000000000000000000000000..642b6c219f561f1f0f016a1560e2514f9b7ef8ef --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/WeightedPrimeWindow.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.TotientAsymptotic.PrimeWindow + +namespace OAI + +/-! Prime counts at both moving endpoints of the least-preimage interval. -/ + +noncomputable section +open scoped Topology +open Filter +namespace TotientAsymptotic + +theorem linear_prime_window (hpnt : PrimeNumberTheoremInput) + {a b ε : ℝ} (ha : 0 < a) (hb : 0 < b) (hε : 0 < ε) : + ∀ᶠ x : ℝ in atTop, ∀ D y : ℝ, 1 ≤ D → + Real.log D ≤ (Real.log x)^(4/5 : ℝ) → + a*x/D ≤ y → y ≤ b*x/D → + |(Nat.primeCounting ⌊y⌋₊ : ℝ)-y/Real.log x| ≤ ε*x/(D*Real.log x) := by + let δ := min (1/4 : ℝ) (ε/(6*b)) + have hδ : 0 < δ := lt_min (by norm_num) (by positivity) + have hδq : δ ≤ 1/4 := min_le_left _ _ + have hδb : 6*δ*b ≤ ε := by + have hh := (le_div_iff₀ (show 0 < 6*b by positivity)).mp (min_le_right (1/4 : ℝ) (ε/(6*b))) + nlinarith + have hlow : Tendsto (fun x : ℝ => (Real.log x)^(4/5 : ℝ)/Real.log x+ + (-Real.log a)/Real.log x) atTop (nhds 0) := by + simpa using subpower_log_ratio.add (tendsto_const_nhds.div_atTop Real.tendsto_log_atTop) + have hupp : Tendsto (fun x : ℝ => Real.log b/Real.log x) atTop (nhds 0) := + tendsto_const_nhds.div_atTop Real.tendsto_log_atTop + obtain ⟨Y,hY⟩ := eventually_atTop.mp (hpnt δ hδ) + filter_upwards [eventually_gt_atTop (1 : ℝ), + hlow.eventually (eventually_lt_nhds hδ),hupp.eventually (eventually_lt_nhds hδ), + (tendsto_rpow_atTop (by norm_num : (0 : ℝ)<1/2)).eventually (eventually_ge_atTop Y)] + with x hx hlo hup hYx + intro D y hD hlogD hylo hyhi + have hx0 : 0 < x := zero_lt_one.trans hx + have hL : 0 < Real.log x := Real.log_pos hx + have hD0 : 0 < D := zero_lt_one.trans_le hD + have hy0 : 0 < y := (div_pos (mul_pos ha hx0) hD0).trans_le hylo + have hloglo : (1-δ)*Real.log x ≤ Real.log y := by + have hh := (div_lt_iff₀ hL).mp (show ((Real.log x)^(4/5 : ℝ)-Real.log a)/Real.log x < δ by + convert hlo using 1; ring) + have ht := Real.log_le_log (div_pos (mul_pos ha hx0) hD0) hylo + rw [Real.log_div (mul_pos ha hx0).ne' hD0.ne',Real.log_mul ha.ne' hx0.ne'] at ht + linarith + have hloghi : Real.log y ≤ (1+δ)*Real.log x := by + have hxy : y ≤ b*x := hyhi.trans (div_le_self (mul_nonneg hb.le hx0.le) hD) + have ht := Real.log_le_log hy0 hxy + rw [Real.log_mul hb.ne' hx0.ne'] at ht + have hh := (div_lt_iff₀ hL).mp hup + linarith + have hroot : x^(1/2 : ℝ) ≤ y := by + rw [Real.rpow_def_of_pos hx0] + calc + _ ≤ Real.exp (Real.log y) := Real.exp_le_exp.mpr (by nlinarith) + _ = y := Real.exp_log hy0 + have hp := hY y (hYx.trans hroot) + have he := prime_count_change_scale hL hy0.le hδ.le hδq ⟨hloglo,hloghi⟩ + ⟨le_rfl,le_mul_of_one_le_left hy0.le (by linarith : 1 ≤ 1+δ)⟩ hp + apply he.trans + calc + 6*δ*(y/Real.log x) ≤ 6*δ*((b*x/D)/Real.log x) := + mul_le_mul_of_nonneg_left (div_le_div_of_nonneg_right hyhi hL.le) (by positivity) + _ = (6*δ*b)*x/(D*Real.log x) := by ring + _ ≤ ε*x/(D*Real.log x) := div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_right hδb hx0.le) (mul_nonneg hD0.le hL.le) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/WitnessAggregation.lean b/lean/OAI/NumberTheory/TotientAsymptotic/WitnessAggregation.lean new file mode 100644 index 0000000000000000000000000000000000000000..6fe24fcfc37bb2455ff09bd38e5cf8894ad2d992 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/WitnessAggregation.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.TotientAsymptotic.TailEncoding +import OAI.NumberTheory.TotientAsymptotic.TailBoxCoordinates + +namespace OAI + +/-! Full-dimensional aggregation of a finite witness family with fixed cofactor. -/ + +noncomputable section +open scoped BigOperators +open MeasureTheory +attribute [local instance] Classical.propDecidable + +namespace TotientAsymptotic + +def witnessPrimeRegion {H R : ℕ} (W : Finset (TailDatum H)) + (S : TailDatum H → Set (Fin R → ℝ)) (p : Fin (H-P H) → ℕ) : Set (Fin R → ℝ) := + ⋃ η ∈ W.filter (fun η => tailPrimeVector η=p), S η + +def witnessBoxRegion {H R : ℕ} (W : Finset (TailDatum H)) + (S : TailDatum H → Set (Fin R → ℝ)) (b : Fin (H-P H) → ℕ) : Set (Fin R → ℝ) := + ⋃ η ∈ W.filter (fun η => tailVector η ∈ unitGridCell b), S η + +lemma witnessPrimeRegion_eq {H R a : ℕ} {s : ℝ} (W : Finset (TailDatum H)) + (S : TailDatum H → Set (Fin R → ℝ)) + (hW : ∀ η ∈ W, IsWitness H s η) (hcof : ∀ η ∈ W, η.cofactor=a) + {η : TailDatum H} (hη : η ∈ W) : witnessPrimeRegion W S (tailPrimeVector η) = S η := by + ext u + simp only [witnessPrimeRegion, Set.mem_iUnion, Finset.mem_filter] + constructor + · rintro ⟨ξ, ⟨hξ, he⟩, hu⟩ + have hh : ξ=η := tailDatum_eq_of_primeVector (hW ξ hξ) (hW η hη) + ((hcof ξ hξ).trans (hcof η hη).symm) he + simpa only [hh] using hu + · intro hu + exact ⟨η, ⟨hη, rfl⟩, hu⟩ + +/-- Aggregation counts the prime mass of each tail box once. The bound has +no factor equal to the number of witnesses in the box. -/ +theorem witness_tail_box_aggregation {H R a : ℕ} {s : ℝ} + (W : Finset (TailDatum H)) (S : TailDatum H → Set (Fin R → ℝ)) + (K : Finset (Fin (H-P H) → ℕ)) (T : Set (Fin (R+(H-P H)) → ℝ)) (C : ℝ) + (hC : 0 ≤ C) (hW : ∀ η ∈ W, IsWitness H s η) (hcof : ∀ η ∈ W, η.cofactor=a) + (hS : ∀ η ∈ W, MeasurableSet (S η)) (hT : volume T ≠ ⊤) + (hcover : ∀ η ∈ W, tailPrimeVector η ∈ gridPrimeTuples K) + (hbox : ∀ b ∈ K, (∏ i, unitPrimeWeight (b i)) ≤ C) + (henclose : ∀ η ∈ W, ∀ b ∈ K, tailVector η ∈ unitGridCell b → + ∀ u ∈ S η, ∀ v ∈ unitGridCell b, joinCoordinates R (H-P H) (u,v) ∈ T) : + (∑ η ∈ W, reciprocalShiftWeight (tailPrimeVector η)*volume.real (S η)) ≤ C*volume.real T := by + classical + have hinj : Set.InjOn tailPrimeVector (↑W : Set (TailDatum H)) := by + intro η hη ξ hξ he + exact tailDatum_eq_of_primeVector (hW η hη) (hW ξ hξ) + ((hcof η hη).trans (hcof ξ hξ).symm) he + have heq : (∑ η ∈ W, reciprocalShiftWeight (tailPrimeVector η)*volume.real (S η)) = + ∑ p ∈ W.image tailPrimeVector, reciprocalShiftWeight p * + volume.real (witnessPrimeRegion W S p) := by + rw [Finset.sum_image hinj] + apply Finset.sum_congr rfl + intro η hη + rw [witnessPrimeRegion_eq W S hW hcof hη] + rw [heq] + have hsub : W.image tailPrimeVector ⊆ gridPrimeTuples K := by + intro p hp + obtain ⟨η, hη, rfl⟩ := Finset.mem_image.mp hp + exact hcover η hη + apply (Finset.sum_le_sum_of_subset_of_nonneg hsub (fun p _ _ => + mul_nonneg (reciprocalShiftWeight_nonneg p) measureReal_nonneg)).trans + apply tail_box_aggregation_enclosure K (witnessPrimeRegion W S) (witnessBoxRegion W S) T C hC + · intro b _ + exact (W.filter _).measurableSet_biUnion (fun η hη => hS η (Finset.mem_filter.mp hη).1) + · exact hT + · intro b _ p hp u hu + obtain ⟨η, hu⟩ := Set.mem_iUnion.mp hu + obtain ⟨hη, hu⟩ := Set.mem_iUnion.mp hu + obtain ⟨hη, he⟩ := Finset.mem_filter.mp hη + have hc : tailVector η ∈ unitGridCell b := by + rw [tailVector_eq_primeCoord, he] + exact (mem_primeBoxTuples_iff.mp hp).2 + exact Set.mem_iUnion.mpr ⟨η, Set.mem_iUnion.mpr ⟨Finset.mem_filter.mpr ⟨hη, hc⟩, hu⟩⟩ + · exact hbox + · intro z hz + obtain ⟨⟨u,v⟩, hz, rfl⟩ := hz + obtain ⟨b, hz⟩ := Set.mem_iUnion.mp hz + obtain ⟨hb, hu, hv⟩ := Set.mem_iUnion.mp hz + obtain ⟨η, hu⟩ := Set.mem_iUnion.mp hu + obtain ⟨hη, hu⟩ := Set.mem_iUnion.mp hu + obtain ⟨hη, hcell⟩ := Finset.mem_filter.mp hη + exact henclose η hη b hb hcell u hu v hv + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/WitnessCollision.lean b/lean/OAI/NumberTheory/TotientAsymptotic/WitnessCollision.lean new file mode 100644 index 0000000000000000000000000000000000000000..f5f987a98dfb06d64d9fc55e991d1f9c30551f36 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/WitnessCollision.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.TotientAsymptotic.CollisionTuples + +namespace OAI + +/-! Exact comparison data extracted from two basic witnesses for colliding tuples. -/ + +noncomputable section +open scoped BigOperators + +namespace TotientAsymptotic + +def wholeWitnessPrime {x : ℝ} {H : ℕ} (p : ℕ) (η : RemainderDatum (L x H)) + (i : ℕ) : ℕ := if i=0 then p else remainderPrime η i + +def witnessTuple {x : ℝ} {H : ℕ} (p : ℕ) (η : RemainderDatum (L x H)) : + TotientTuple (R x H) := ⟨p, prefixOfRemainder x H η⟩ + +lemma wholeWitness_shift_product {x : ℝ} {H k : ℕ} (p : ℕ) + (η : RemainderDatum (L x H)) : + (∏ r ∈ Finset.Icc 0 k, (wholeWitnessPrime p η r-1)) = + (p-1)*∏ r ∈ Finset.Icc 1 k, (remainderPrime η r-1) := by + have hsplit : Finset.Icc 0 k = insert 0 (Finset.Icc 1 k) := by + ext r + simp only [Finset.mem_Icc, Finset.mem_insert] + omega + rw [hsplit, Finset.prod_insert (by simp)] + simp only [wholeWitnessPrime, ite_true] + congr 1 + apply Finset.prod_congr rfl + intro r hr + rw [ite_eq_right (by have := (Finset.mem_Icc.mp hr).1; omega)] + +/-- Every valid cutoff gives the same integer value. No witness representative +is discarded from the tail totient. -/ +lemma witness_tuple_value_at_cut {x : ℝ} {H k : ℕ} {p : ℕ} + {η : RemainderDatum (L x H)} (hη : IsBasicRemainder x H η) + (hL : L x H < m x) (hR : R x H < L x H) (hk : k < L x H) : + tupleValue (witnessTuple p η) = (suffixPreimage η k).totient * + ∏ r ∈ Finset.Icc 0 k, (wholeWitnessPrime p η r-1) := by + have hRsplit := basic_suffix_totient_split hη hL (Nat.zero_le (R x H)) hR + have hksplit := basic_suffix_totient_split hη hL (Nat.zero_le k) hk + simp only [Nat.zero_add] at hRsplit hksplit + have hprod : (∏ i : Fin (R x H), (remainderPrime η (i.val+1)-1)) = + ∏ r ∈ Finset.Icc 1 (R x H), (remainderPrime η r-1) := + prod_fin_shifted (R x H) (fun r => (remainderPrime η r-1)) + unfold tupleValue witnessTuple tuplePrimes prefixOfRemainder + rw [Fin.prod_univ_succ] + simp only [Fin.cons_zero, Fin.cons_succ, hprod] + rw [← suffixPreimage_at_R η, wholeWitness_shift_product] + calc + _ = (p-1)*((suffixPreimage η (R x H)).totient* + ∏ r ∈ Finset.Icc 1 (R x H), (remainderPrime η r-1)) := by ring + _ = (p-1)*(suffixPreimage η 0).totient := by rw [hRsplit] + _ = _ := by rw [hksplit]; ring + +/-- Cancel all matched primes up to the cutoff, including the common prefix. +The first differing prime survives, and at most `k-i+1` indices survive. -/ +theorem witness_collision_cancel {x : ℝ} {H i k p q : ℕ} + {η ξ : RemainderDatum (L x H)} + (hη : IsBasicRemainder x H η) (hξ : IsBasicRemainder x H ξ) + (hp : p.Prime) (hL : L x H < m x) (hR : R x H < L x H) + (hk : k < L x H) (hik : i ≤ k) + (hv : tupleValue (witnessTuple p η) = tupleValue (witnessTuple q ξ)) + (hfirst : wholeWitnessPrime p η i ≠ wholeWitnessPrime q ξ i) + (hcommon : ∀ j < i, wholeWitnessPrime p η j = wholeWitnessPrime q ξ j) : + let I := (Finset.Icc 0 k).filter (fun j => wholeWitnessPrime p η j ≠ wholeWitnessPrime q ξ j) + (suffixPreimage η k).totient*(∏ j ∈ I, (wholeWitnessPrime p η j-1)) = + (suffixPreimage ξ k).totient*(∏ j ∈ I, (wholeWitnessPrime q ξ j-1)) ∧ + i ∈ I ∧ I.card ≤ k-i+1 := by + classical + dsimp only + have hval : (suffixPreimage η k).totient* + (∏ j ∈ Finset.Icc 0 k, (wholeWitnessPrime p η j-1)) = + (suffixPreimage ξ k).totient* + (∏ j ∈ Finset.Icc 0 k, (wholeWitnessPrime q ξ j-1)) := by + simpa only [witness_tuple_value_at_cut hη hL hR hk, + witness_tuple_value_at_cut hξ hL hR hk] using hv + refine ⟨cancel_equal_shifts _ _ _ _ _ ?_ hval, ?_, ?_⟩ + · intro j hj + by_cases hj0 : j=0 + · simp only [wholeWitnessPrime, hj0, ite_true] + exact hp.two_le + · simp only [wholeWitnessPrime, ite_eq_right hj0] + exact (hη.2.1 j (Finset.mem_Icc.mpr + ⟨by omega, (Finset.mem_Icc.mp hj).2.trans hk.le⟩)).1.two_le + · exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr ⟨Nat.zero_le _, hik⟩, hfirst⟩ + · have hsub : (Finset.Icc 0 k).filter + (fun j => wholeWitnessPrime p η j ≠ wholeWitnessPrime q ξ j) ⊆ Finset.Icc i k := by + intro j hj + obtain ⟨hj, hne⟩ := Finset.mem_filter.mp hj + refine Finset.mem_Icc.mpr ⟨?_, (Finset.mem_Icc.mp hj).2⟩ + by_contra! hh + exact hne (hcommon j hh) + have hh := Finset.card_le_card hsub + rw [Nat.card_Icc] at hh + omega + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/WitnessGrid.lean b/lean/OAI/NumberTheory/TotientAsymptotic/WitnessGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..394014c8349a24cfacb858dadcfc7e9d0a042036 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/WitnessGrid.lean @@ -0,0 +1,112 @@ +import OAI.NumberTheory.TotientAsymptotic.TailEncoding +import OAI.NumberTheory.TotientAsymptotic.BandPrimeError + +namespace OAI + +/-! Uniform prime mass for the boxes occupied by discrete witness tails. -/ + +noncomputable section +open scoped BigOperators + +namespace TotientAsymptotic + +def tailBoxIndex {H : ℕ} (η : TailDatum H) : Fin (H-P H) → ℕ := + fun i => ⌊tailVector η i⌋₊+1 + +def witnessGrid {H : ℕ} (W : Finset (TailDatum H)) : Finset (Fin (H-P H) → ℕ) := + W.image tailBoxIndex + +lemma tailVector_mem_box {H : ℕ} {s : ℝ} {η : TailDatum H} (hη : IsWitness H s η) : + tailVector η ∈ unitGridCell (tailBoxIndex η) := by + intro i _ + simp only [tailBoxIndex, Nat.cast_add, Nat.cast_one, add_sub_cancel_right] + exact ⟨Nat.floor_le (tailVector_nonneg hη i), Nat.lt_floor_add_one _⟩ + +lemma tailPrimeVector_mem_grid {H : ℕ} {s : ℝ} (W : Finset (TailDatum H)) + (hW : ∀ η ∈ W, IsWitness H s η) {η : TailDatum H} (hη : η ∈ W) : + tailPrimeVector η ∈ gridPrimeTuples (witnessGrid W) := by + apply mem_gridPrimeTuples_iff.mpr + refine ⟨tailPrimeVector_prime (hW η hη), ?_⟩ + rw [← tailVector_eq_primeCoord] + exact Set.mem_iUnion.mpr ⟨tailBoxIndex η, + Set.mem_iUnion.mpr ⟨Finset.mem_image.mpr ⟨η, hη, rfl⟩, tailVector_mem_box (hW η hη)⟩⟩ + +lemma tailBoxIndex_lower {H : ℕ} {s : ℝ} {η : TailDatum H} + (hs : 0 ≤ s) (hη : IsWitness H s η) (i : Fin (H-P H)) : + 1 ≤ tailBoxIndex η i ∧ (9/10 : ℝ)*lam*(H-1-i.val : ℕ) ≤ tailBoxIndex η i := by + refine ⟨by dsimp [tailBoxIndex]; omega, ?_⟩ + have hi : H-1-i.val ∈ Finset.Ico (P H) H := by + have := i.isLt + exact Finset.mem_Ico.mpr (by omega) + have hb := (hη.2.2.1 _ hi).2.1 + have hα := alpha_ge_lam hs + have hp : 1 ≤ (rho^(H-1-i.val))⁻¹ := + (one_le_inv₀ (pow_pos rho_pos _)).mpr (pow_le_one₀ rho_pos.le rho_lt_one.le) + have hl : (9/10 : ℝ)*lam*(H-1-i.val : ℕ) ≤ tailVector η i := by + apply le_trans _ hb + exact (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hα (by norm_num)) + (Nat.cast_nonneg _)).trans + (le_mul_of_one_le_right (by have := alpha_pos s; positivity : 0 ≤ (9/10 : ℝ)*alpha s*(H-1-i.val : ℕ)) hp) + exact hl.trans (tailVector_mem_box hη i (Set.mem_univ _)).2.le + +lemma witnessGrid_exp_sum {H : ℕ} {s : ℝ} (hs : 0 ≤ s) (hPH : P H ≤ H) + (W : Finset (TailDatum H)) (hW : ∀ η ∈ W, IsWitness H s η) + {b : Fin (H-P H) → ℕ} (hb : b ∈ witnessGrid W) : + (∑ i, Real.exp (-(b i : ℝ))) ≤ + (Real.exp (-(9/10 : ℝ)*lam))^(P H)/(1-Real.exp (-(9/10 : ℝ)*lam)) := by + obtain ⟨η, hη, rfl⟩ := Finset.mem_image.mp hb + let q := Real.exp (-(9/10 : ℝ)*lam) + have hq0 : 0 ≤ q := (Real.exp_pos _).le + have hq1 : q < 1 := by dsimp [q]; rw [Real.exp_lt_one_iff]; nlinarith [lam_pos] + have ht (i : Fin (H-P H)) : Real.exp (-(tailBoxIndex η i : ℝ)) ≤ q^(H-(i.val+1)) := by + dsimp [q] + rw [← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + have hl := (tailBoxIndex_lower hs (hW η hη) i).2 + have he : H-1-i.val=H-(i.val+1) := by omega + rw [he] at hl + nlinarith + apply (Finset.sum_le_sum (fun i _ => ht i)).trans + rw [sum_reverse_geometric hPH q] + have hg := summable_geometric_of_lt_one hq0 hq1 + calc + _ ≤ ∑' n : ℕ, q^(P H+n) := + (hg.comp_injective (fun _ _ h => Nat.add_left_cancel h)).sum_le_tsum _ + (fun _ _ => pow_nonneg hq0 _) + _ = _ := by + simp_rw [pow_add] + rw [tsum_mul_left, tsum_geometric_of_lt_one hq0 hq1] + rfl + +/-- The entire prime mass of any occupied tail box is bounded by an absolute +constant, independent of the number of tail coordinates and witnesses. -/ +theorem witnessGrid_prime_mass_bound (hford : FordUnitPrimeBoxInput) : + ∃ C : ℝ, 0 < C ∧ ∀ {H : ℕ} {s : ℝ}, 0 ≤ s → P H ≤ H → + ∀ W : Finset (TailDatum H), (∀ η ∈ W, IsWitness H s η) → + ∀ b ∈ witnessGrid W, (∏ i, unitPrimeWeight (b i)) ≤ C := by + obtain ⟨C, hC, hc⟩ := prime_unit_box_error hford + let q := Real.exp (-(9/10 : ℝ)*lam) + have hq0 : 0 ≤ q := (Real.exp_pos _).le + have hq1 : q < 1 := by dsimp [q]; rw [Real.exp_lt_one_iff]; nlinarith [lam_pos] + refine ⟨Real.exp (C/(1-q)), Real.exp_pos _, ?_⟩ + intro H s hs hPH W hW b hb + have hb1 : ∀ i, 1 ≤ b i := by + obtain ⟨η, hη, rfl⟩ := Finset.mem_image.mp hb + exact fun i => (tailBoxIndex_lower hs (hW η hη) i).1 + have he := hc Finset.univ b (fun i _ => hb1 i) + have hsum := witnessGrid_exp_sum hs hPH W hW hb + have hsum' : (∑ i, Real.exp (-(b i : ℝ))) ≤ 1/(1-q) := by + apply hsum.trans + exact div_le_div_of_nonneg_right (pow_le_one₀ hq0 hq1.le) (sub_pos.mpr hq1).le + have hh := (le_abs_self _).trans he + have he' : (∏ i, unitPrimeWeight (b i)) ≤ Real.exp (C*∑ i, Real.exp (-(b i : ℝ))) := by + linarith + apply he'.trans + apply Real.exp_le_exp.mpr + simpa only [mul_one_div] using mul_le_mul_of_nonneg_left hsum' hC.le + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/WitnessPrefix.lean b/lean/OAI/NumberTheory/TotientAsymptotic/WitnessPrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..689bcf143df5b1afd3b87172d31eeb0385c44819 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/WitnessPrefix.lean @@ -0,0 +1,166 @@ +import OAI.NumberTheory.TotientAsymptotic.RemainderSplit + +namespace OAI + +/-! The exact banded, perturbed regions represented by the arithmetic fibers. -/ + +noncomputable section +open scoped BigOperators + +namespace TotientAsymptotic + +def PrefixPrimeBands (x : ℝ) (H : ℕ) (p : Fin (R x H) → ℕ) : Prop := + ∀ i, (p i).Prime ∧ (9/10 : ℝ)*bandScale x (i.val+1) ≤ primePrefixCoord p i ∧ + primePrefixCoord p i ≤ (11/10 : ℝ)*bandScale x (i.val+1) + +lemma attachTail_prefix_coord {x : ℝ} {H : ℕ} (hPH : P H ≤ H) + (p : Fin (R x H) → ℕ) (η : TailDatum H) (i : Fin (R x H)) : + remainderCoord x (attachTail x H p η) (i.val+1) = primePrefixCoord p i := by + simp only [remainderCoord, Nat.add_one_ne_zero, ite_false, + attachTail_prefix hPH, primePrefixCoord] + +lemma attachTail_tail_prime {x s : ℝ} {H i : ℕ} (_hPH : P H < H) (_hHm : H ≤ m x) + (p : Fin (R x H) → ℕ) {η : TailDatum H} (_hη : IsWitness H s η) + (hi : i ∈ Finset.Icc (R x H+1) (L x H)) : + remainderPrime (attachTail x H p η) i = tailPrime η (m x-i) := by + have hi' := Finset.mem_Icc.mp hi + have hiL : i ∈ Finset.Icc 1 (L x H) := Finset.mem_Icc.mpr (by omega) + rw [remainderPrime_attachTail p η hiL, dite_eq_right (by omega)] + +lemma attachTail_tail_coord {x s : ℝ} {H i : ℕ} (hPH : P H < H) (hHm : H ≤ m x) + (p : Fin (R x H) → ℕ) {η : TailDatum H} (hη : IsWitness H s η) + (hi : i ∈ Finset.Icc (R x H+1) (L x H)) : + remainderCoord x (attachTail x H p η) i = tailLog η (m x-i) := by + have hi' := Finset.mem_Icc.mp hi + simp only [remainderCoord, ite_eq_right (by omega : i ≠ 0), + attachTail_tail_prime hPH hHm p hη hi, tailLog] + +lemma attachTail_tail_basic {x : ℝ} {H : ℕ} (hPH : P H < H) (hHm : H ≤ m x) + (p : Fin (R x H) → ℕ) {η : TailDatum H} (hη : IsWitness H (theta x) η) : + (∀ i ∈ Finset.Icc (R x H+1) (L x H), + (remainderPrime (attachTail x H p η) i).Prime ∧ + (9/10 : ℝ)*bandScale x i ≤ remainderCoord x (attachTail x H p η) i ∧ + remainderCoord x (attachTail x H p η) i ≤ (11/10 : ℝ)*bandScale x i) ∧ + (∀ i ∈ Finset.Icc (R x H+1) (L x H), + (∑ r ∈ Finset.Icc (i+1) (L x H), a (r-i)*remainderCoord x (attachTail x H p η) r) ≤ + (if i = L x H then 1 else xi x i)*remainderCoord x (attachTail x H p η) i) := by + have hh {i : ℕ} (hi : i ∈ Finset.Icc (R x H+1) (L x H)) : + m x-i ∈ Finset.Ico (P H) H := by + have hi' := Finset.mem_Icc.mp hi + apply Finset.mem_Ico.mpr + unfold R L at hi' + omega + have him {i : ℕ} (hi : i ∈ Finset.Icc (R x H+1) (L x H)) : i ≤ m x := + (Finset.mem_Icc.mp hi).2.trans (Nat.sub_le _ _) + constructor + · intro i hi + have hp := hη.2.2.1 (m x-i) (hh hi) + have hb : bandScale x i = alpha (theta x)*(m x-i : ℕ)*(rho^(m x-i))⁻¹ := rfl + rw [attachTail_tail_prime hPH hHm p hη hi, attachTail_tail_coord hPH hHm p hη hi, hb] + exact ⟨hp.1, by simpa only [mul_assoc] using hp.2.1, + by simpa only [mul_assoc] using hp.2.2.1⟩ + · intro i hi + have ht := hη.2.2.1 (m x-i) (hh hi) + have he := extractTail_threshold (attachTail x H p η) hHm + (Finset.mem_Ico.mp (hh hi)).1 (Finset.mem_Ico.mp (hh hi)).2.le + rw [extract_attachTail hPH hHm p hη, Nat.sub_sub_self (him hi)] at he + rw [← he, attachTail_tail_coord hPH hHm p hη hi] + by_cases hiL : i = L x H + · subst i + have hP : m x-L x H = P H := by unfold L; omega + simp only [ite_true, hP, Finset.Ico_self, Finset.sum_empty, one_mul] + have hp := hη.2.2.1 (P H) (Finset.mem_Ico.mpr ⟨le_rfl, hPH⟩) + have ha := alpha_pos (theta x) + have hr := pow_pos rho_pos (P H) + exact (by positivity : (0 : ℝ) ≤ (9/10 : ℝ)*alpha (theta x)*(P H)*(rho^(P H))⁻¹).trans hp.2.1 + · rw [ite_eq_right hiL] + exact ht.2.2.2 + +lemma attachTail_cofactor_basic {x : ℝ} {H : ℕ} (hPH : P H < H) (hHm : H ≤ m x) + (p : Fin (R x H) → ℕ) {η : TailDatum H} (hη : IsWitness H (theta x) η) : + largestPrimeFactor (attachTail x H p η).cofactor ≤ + remainderPrime (attachTail x H p η) (L x H) ∧ + Real.log ((attachTail x H p η).cofactor : ℝ) ≤ Real.exp (2*bandScale x (L x H)) := by + have hRL : R x H < L x H := by unfold R L; omega + have hLP : m x-L x H = P H := by unfold L; omega + have hi : L x H ∈ Finset.Icc (R x H+1) (L x H) := Finset.mem_Icc.mpr (by omega) + rw [attachTail_tail_prime hPH hHm p hη hi, hLP] + exact ⟨hη.2.2.2.1, by simpa only [attachTail, bandScale, hLP, mul_assoc] using hη.2.2.2.2⟩ + +lemma attachTail_prefix_sum {x s : ℝ} {H i : ℕ} (hPH : P H < H) (hHm : H ≤ m x) + (p : Fin (R x H) → ℕ) {η : TailDatum H} (hη : IsWitness H s η) (hi : i ≤ R x H) : + (∑ r ∈ Finset.Icc (i+1) (L x H), a (r-i)*remainderCoord x (attachTail x H p η) r) = + (∑ j : Fin (R x H), if i < j.val+1 then a (j.val+1-i)*primePrefixCoord p j else 0) + + D (m x-i) η := by + rw [remainder_sum_prefix_tail _ hPH.le hHm hi, extract_attachTail hPH hHm p hη] + simp only [attachTail_prefix_coord hPH.le] + +theorem basic_attach_iff_region {x : ℝ} {H : ℕ} (hPH : P H < H) (hHm : H ≤ m x) + (p : Fin (R x H) → ℕ) {η : TailDatum H} (hη : IsWitness H (theta x) η) : + IsBasicRemainder x H (attachTail x H p η) ↔ + PrefixPrimeBands x H p ∧ primePrefixCoord p ∈ perturbedTailPrefixRegion x H η := by + have hRL : R x H < L x H := by unfold R L; omega + constructor + · intro hb + constructor + · intro i + have hi : i.val+1 ∈ Finset.Icc 1 (L x H) := + Finset.mem_Icc.mpr ⟨by omega, by have := i.isLt; omega⟩ + simpa only [attachTail_prefix hPH.le, attachTail_prefix_coord hPH.le] using hb.2.1 _ hi + · have hh := basic_remainder_mem_perturbed hb hPH hHm + rw [extract_attachTail hPH hHm p hη] at hh + have he : (fun i : Fin (R x H) => remainderPrime (attachTail x H p η) (i.val+1)) = p := + funext (attachTail_prefix hPH.le p η) + rwa [he] at hh + · rintro ⟨hb, hu⟩ + have htail := attachTail_tail_basic hPH hHm p hη + refine ⟨hη.2.1, ?_, ?_, attachTail_cofactor_basic hPH hHm p hη⟩ + · intro i hi + have hi' := Finset.mem_Icc.mp hi + by_cases hiR : i ≤ R x H + · let j : Fin (R x H) := ⟨i-1, by omega⟩ + have he : j.val+1 = i := by dsimp [j]; omega + have hh := hb j + simpa only [← he, attachTail_prefix hPH.le, attachTail_prefix_coord hPH.le] using hh + · exact htail.1 i (Finset.mem_Icc.mpr (by omega)) + · intro i hi + have hi' := Finset.mem_Icc.mp hi + by_cases hiR : i ≤ R x H + · rw [attachTail_prefix_sum hPH hHm p hη hiR, + ite_eq_right (by omega : i ≠ L x H)] + by_cases hi0 : i = 0 + · subst i + simp only [Nat.zero_lt_succ, ite_true, Nat.sub_zero, remainderCoord, ite_true] + exact le_sub_iff_add_le.mp hu.2 + · let j : Fin (R x H) := ⟨i-1, by omega⟩ + have he : j.val+1 = i := by dsimp [j]; omega + rw [← he, attachTail_prefix_coord hPH.le] + have ht := hu.1 j + rw [prefixLinear_apply] at ht + have hs : (∑ k : Fin (R x H), if j.val+1 < k.val+1 then + a (k.val+1-(j.val+1))*primePrefixCoord p k else 0) = + ∑ k : Fin (R x H), if j < k then a (k.val-j.val)*primePrefixCoord p k else 0 := by + simp only [Nat.add_lt_add_iff_right, Nat.add_sub_add_right, Fin.lt_def] + rw [hs] + nlinarith + · exact htail.2 i (Finset.mem_Icc.mpr (by omega)) + +/-- Membership in the arithmetic fiber is precisely the banded union of the +manuscript's perturbed prefix regions. Witness multiplicities disappear. -/ +theorem prefixDatum_iff_banded_region {x : ℝ} {H d : ℕ} + (hPH : P H < H) (hHm : H ≤ m x) (p : Fin (R x H) → ℕ) : + IsPrefixDatum x H ⟨p,d⟩ ↔ PrefixPrimeBands x H p ∧ + ∃ η ∈ witnesses H (theta x) d, primePrefixCoord p ∈ perturbedTailPrefixRegion x H η := by + rw [prefixDatum_iff_attach_witness hPH hHm] + constructor + · rintro ⟨η, hη, hb⟩ + have hh := (basic_attach_iff_region hPH hHm p hη.1).mp hb + exact ⟨hh.1, η, hη, hh.2⟩ + · rintro ⟨hb, η, hη, hu⟩ + exact ⟨η, hη, (basic_attach_iff_region hPH hHm p hη.1).mpr ⟨hb, hu⟩⟩ + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientAsymptotic/WitnessUnionLoss.lean b/lean/OAI/NumberTheory/TotientAsymptotic/WitnessUnionLoss.lean new file mode 100644 index 0000000000000000000000000000000000000000..cada917444e9fb185f4fdd74546f8e7c3f48e09d --- /dev/null +++ b/lean/OAI/NumberTheory/TotientAsymptotic/WitnessUnionLoss.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.TotientAsymptotic.BandRemoval + +namespace OAI + +/-! Transfer of the band-removal estimate to the actual unions at each tail value. -/ + +noncomputable section +open scoped BigOperators Topology +open Filter MeasureTheory +attribute [local instance] Classical.propDecidable + +namespace TotientAsymptotic + +def activeWitnesses (H : ℕ) (s : ℝ) : Finset (TailDatum H) := + (allTailData H).filter (IsWitness H s) + +lemma mem_activeWitnesses {H : ℕ} {s : ℝ} {η : TailDatum H} + (hs : s ∈ Set.Ico (0 : ℝ) 1) : η ∈ activeWitnesses H s ↔ IsWitness H s η := by + simp only [activeWitnesses, Finset.mem_filter] + exact ⟨And.right, fun h => ⟨witness_mem_allTailData hs h, h⟩⟩ + +lemma sum_witness_fibers {H : ℕ} {s : ℝ} (hs : s ∈ Set.Ico (0 : ℝ) 1) + (F : TailDatum H → ℝ) : + (∑ d ∈ Finset.Icc 1 (tailValueBound H), ∑ η ∈ witnessFinset H s d, F η) = + ∑ η ∈ activeWitnesses H s, F η := by + have hmaps : ∀ η ∈ activeWitnesses H s, + (w η).totient ∈ Finset.Icc 1 (tailValueBound H) := by + intro η hη + have hw := (mem_activeWitnesses hs).mp hη + exact Finset.mem_Icc.mpr ⟨Nat.totient_pos.mpr (witness_w_pos hw), + witness_totient_bound hs η ⟨hw, rfl⟩⟩ + rw [← Finset.sum_fiberwise_of_maps_to hmaps] + apply Finset.sum_congr rfl + intro d _ + congr 1 + ext η + rw [mem_witnessFinset hs, Finset.mem_filter, mem_activeWitnesses hs] + rfl + +lemma weighted_witness_fibers {H : ℕ} {s : ℝ} (hs : s ∈ Set.Ico (0 : ℝ) 1) + (F : TailDatum H → ℝ) : + (∑ d ∈ Finset.Icc 1 (tailValueBound H), + (d : ℝ)⁻¹*∑ η ∈ witnessFinset H s d, F η) = + ∑ η ∈ activeWitnesses H s, ((w η).totient : ℝ)⁻¹*F η := by + rw [← sum_witness_fibers hs] + apply Finset.sum_congr rfl + intro d _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro η hη + rw [((mem_witnessFinset hs).mp hη).2] + +lemma union_band_loss_bound {H : ℕ} {x : ℝ} (d : ℕ) : + volume.real ((⋃ η ∈ witnessFinset H (theta x) d, tailPrefixRegion x H η) \ + prefixBandRegion x H) ≤ + ∑ η ∈ witnessFinset H (theta x) d, + volume.real (tailPrefixRegion x H η \ prefixBandRegion x H) := by + have he : ((⋃ η ∈ witnessFinset H (theta x) d, tailPrefixRegion x H η) \ + prefixBandRegion x H) = + ⋃ η ∈ witnessFinset H (theta x) d, + (tailPrefixRegion x H η \ prefixBandRegion x H) := by + ext u + simp only [Set.mem_sdiff, Set.mem_iUnion] + aesop + rw [he] + exact measureReal_biUnion_finset_le _ _ + +/-- The discarded volume in the coefficient's actual witness unions is +uniformly negligible for every weight between zero and one. -/ +theorem weighted_union_band_removal (hbox : FordUnitPrimeBoxInput) + (hmertens : MertensProductInput) (hren : FordRenewalInput) + (hford : FordCoordinateConcentrationInput) : + ∃ ε : ℕ → ℝ, Tendsto ε atTop (nhds 0) ∧ + ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, + ∀ f : ℝ → ℝ, (∀ r, 0 ≤ f r ∧ f r ≤ 1) → + (∑ d ∈ Finset.Icc 1 (tailValueBound H), f ((ell d : ℝ)/d)/d * + volume.real ((⋃ η ∈ witnessFinset H (theta x) d, tailPrefixRegion x H η) \ + prefixBandRegion x H))/G x (m x) ≤ ε H := by + obtain ⟨ε, hε, hbound⟩ := witness_band_removal hbox hmertens hren hford + refine ⟨ε, hε, ?_⟩ + filter_upwards [hbound] with H hH + filter_upwards [hH, theta_eventually_mem, + B_tendsto.eventually (eventually_gt_atTop (0 : ℝ))] with x hx hs hB + intro f hf + apply le_trans _ (hx (activeWitnesses H (theta x)) + (fun η hη => (mem_activeWitnesses hs).mp hη)) + apply div_le_div_of_nonneg_right _ (G_pos hB _).le + rw [← weighted_witness_fibers hs] + apply Finset.sum_le_sum + intro d hd + have hd0 : (0 : ℝ) < d := by exact_mod_cast (Finset.mem_Icc.mp hd).1 + have hw : 0 ≤ f ((ell d : ℝ)/d)/d := div_nonneg (hf _).1 hd0.le + have hw' : f ((ell d : ℝ)/d)/d ≤ (d : ℝ)⁻¹ := by + simpa only [one_div] using div_le_div_of_nonneg_right (hf _).2 hd0.le + exact (mul_le_mul_of_nonneg_left (union_band_loss_bound d) hw).trans + (mul_le_mul_of_nonneg_right hw' (Finset.sum_nonneg (fun _ _ => measureReal_nonneg))) + +end TotientAsymptotic + +end + +end OAI diff --git a/lean/OAI/NumberTheory/TotientFibers/FiniteFiber.lean b/lean/OAI/NumberTheory/TotientFibers/FiniteFiber.lean new file mode 100644 index 0000000000000000000000000000000000000000..217cfe4d7f9c39981eabe9bbeeb8458febb0fc76 --- /dev/null +++ b/lean/OAI/NumberTheory/TotientFibers/FiniteFiber.lean @@ -0,0 +1,312 @@ +import Mathlib + +namespace OAI + +open scoped BigOperators + +namespace TotientFibers + +def fiber (n : ℕ) : Set ℕ := {m : ℕ | 0 < m ∧ Nat.totient m = n} + +noncomputable def g (n : ℕ) : ℕ := (fiber n).ncard + +theorem preimage_le {m n : ℕ} (hm : 0 < m) (h : Nat.totient m = n) : + m ≤ n * ∏ p ∈ Finset.Icc 1 (n + 1), p := by + have hn : 0 < n := h ▸ Nat.totient_pos.mpr hm + have hs : m.primeFactors ⊆ Finset.Icc 1 (n + 1) := by + intro p hp + have hp' := Nat.prime_of_mem_primeFactors hp + have hd : p - 1 ∣ n := by + rw [← h, ← Nat.totient_prime hp'] + exact Nat.totient_dvd_of_dvd (Nat.dvd_of_mem_primeFactors hp) + have hle := Nat.le_of_dvd hn hd + exact Finset.mem_Icc.mpr ⟨hp'.one_le, by omega⟩ + calc + m ≤ m * ∏ p ∈ m.primeFactors, (p - 1) := by + apply Nat.le_mul_of_pos_right + exact Finset.prod_pos fun p hp => Nat.sub_pos_of_lt + (Nat.prime_of_mem_primeFactors hp).one_lt + _ = n * ∏ p ∈ m.primeFactors, p := by + rw [← h, Nat.totient_mul_prod_primeFactors] + _ ≤ n * ∏ p ∈ Finset.Icc 1 (n + 1), p := by + apply Nat.mul_le_mul_left + exact Finset.prod_le_prod_of_subset_of_one_le hs fun p hp _ => + (Finset.mem_Icc.mp hp).1 + +theorem fiber_finite (n : ℕ) : (fiber n).Finite := by + refine (Set.finite_Icc 1 (n * ∏ p ∈ Finset.Icc 1 (n + 1), p)).subset ?_ + intro m hm + exact ⟨hm.1, preimage_le hm.1 hm.2⟩ + +theorem card_le_g {n : ℕ} {s : Finset ℕ} + (hs : ∀ m ∈ s, 0 < m ∧ Nat.totient m = n) : s.card ≤ g n := by + rw [g, ← Set.ncard_coe_finset] + exact Set.ncard_le_ncard hs (fiber_finite n) + +theorem two_le_g_prime_pred {p : ℕ} (hp : p.Prime) (hp2 : p ≠ 2) : + 2 ≤ g (p - 1) := by + have hne : p ≠ 2 * p := by nlinarith [hp.pos] + have hcard : ({p, 2 * p} : Finset ℕ).card = 2 := by simp [hne] + rw [← hcard] + apply card_le_g + intro m hm + rcases Finset.mem_insert.mp hm with rfl | hm + · exact ⟨hp.pos, Nat.totient_prime hp⟩ + · have hm' := Finset.mem_singleton.mp hm + subst m + exact ⟨Nat.mul_pos (by decide) hp.pos, by rw [Nat.totient_two_mul_of_odd (hp.odd_of_ne_two hp2), + Nat.totient_prime hp]⟩ + +theorem totient_large_fibers_of_one_le {ε : ℝ} (hε : 1 ≤ ε) : + Set.Infinite {n : ℕ | 0 < n ∧ (n : ℝ) ^ (1 - ε) < (g n : ℝ)} := by + apply Set.infinite_of_forall_exists_gt + intro N + obtain ⟨p, hNp, hp⟩ := Nat.exists_infinite_primes (N + 3) + have hn : 0 < p - 1 := by omega + refine ⟨p - 1, ⟨hn, ?_⟩, by omega⟩ + have hg : 2 ≤ g (p - 1) := two_le_g_prime_pred hp (by omega) + have hn' : (1 : ℝ) ≤ (p - 1 : ℕ) := by exact_mod_cast hn + have hpow := Real.rpow_le_one_of_one_le_of_nonpos hn' (sub_nonpos.mpr hε) + have hg' : (2 : ℝ) ≤ g (p - 1) := by exact_mod_cast hg + linarith + +theorem infinite_of_unbounded_g {P : ℕ → Prop} + (h : ∀ B : ℕ, ∃ n : ℕ, 0 < n ∧ P n ∧ B < g n) : + Set.Infinite {n : ℕ | 0 < n ∧ P n} := by + apply Set.Infinite.of_image g + apply Set.infinite_of_forall_exists_gt + intro B + obtain ⟨n, hn, hPn, hBn⟩ := h B + exact ⟨g n, ⟨n, ⟨hn, hPn⟩, rfl⟩, hBn⟩ + +theorem factorization_le_log {n U : ℕ} (hn : 0 < n) (hU : n ≤ U) (p : ℕ) : + n.factorization p ≤ Nat.log 2 U := by + by_cases hp : p.Prime + · apply Nat.le_log_of_pow_le (by decide) + exact (Nat.pow_le_pow_left hp.two_le _).trans ((Nat.ordProj_le p hn.ne').trans hU) + · rw [Nat.factorization_eq_zero_of_not_prime n hp] + exact Nat.zero_le _ + +theorem card_le_of_smooth {S : Finset ℕ} {B U : ℕ} + (hpos : ∀ n ∈ S, 0 < n) (hbound : ∀ n ∈ S, n ≤ U) + (hsmooth : ∀ n ∈ S, ∀ p : ℕ, p.Prime → p ∣ n → p ≤ B) : + S.card ≤ (Nat.log 2 U + 1) ^ B := by + let E : ↥S → (↥(Finset.Icc 1 B) → Fin (Nat.log 2 U + 1)) := + fun n p => ⟨n.val.factorization p.val, + Nat.lt_succ_of_le (factorization_le_log (hpos n.val n.property) + (hbound n.val n.property) p.val)⟩ + have hinj : Function.Injective E := by + intro a b hab + apply Subtype.ext + apply Nat.eq_of_factorization_eq (hpos a.val a.property).ne' + (hpos b.val b.property).ne' + intro p + by_cases hp : p ∈ Finset.Icc 1 B + · exact congrArg Fin.val (congrFun hab ⟨p, hp⟩) + · have hz : ∀ n ∈ S, n.factorization p = 0 := by + intro n hn + by_cases hprime : p.Prime + · apply Nat.factorization_eq_zero_of_not_dvd + intro hd + exact hp (Finset.mem_Icc.mpr ⟨hprime.one_le, hsmooth n hn p hprime hd⟩) + · exact Nat.factorization_eq_zero_of_not_prime n hprime + rw [hz a.val a.property, hz b.val b.property] + have hcard := Nat.card_le_card_of_injective E hinj + rw [Nat.card_fun, Nat.card_fin] at hcard + simpa only [Nat.card_fun, Nat.card_fin, Nat.card_eq_fintype_card, Fintype.card_coe, + Nat.card_Icc, Nat.add_sub_cancel] using hcard + +theorem prime_prod_eq_iff {Q R : Finset ℕ} + (hQ : ∀ p ∈ Q, p.Prime) (hR : ∀ p ∈ R, p.Prime) : + (∏ p ∈ Q, p) = (∏ p ∈ R, p) ↔ Q = R := by + constructor + · intro h + have := congrArg Nat.primeFactors h + simpa only [Nat.primeFactors_prod hQ, Nat.primeFactors_prod hR] using this + · rintro rfl + rfl + +theorem totient_prime_prod {Q : Finset ℕ} (hQ : ∀ p ∈ Q, p.Prime) : + Nat.totient (∏ p ∈ Q, p) = ∏ p ∈ Q, (p - 1) := by + have hpos : 0 < ∏ p ∈ Q, p := Finset.prod_pos fun p hp => (hQ p hp).pos + apply Nat.mul_right_cancel hpos + simpa only [Nat.primeFactors_prod hQ, mul_comm] using + Nat.totient_mul_prod_primeFactors (∏ p ∈ Q, p) + +theorem finite_pigeonhole {P : Finset ℕ} {X B k : ℕ} {a : ℝ} + (hprime : ∀ p ∈ P, p.Prime) (hsize : ∀ p ∈ P, p ≤ X) + (hsmooth : ∀ p ∈ P, ∀ q : ℕ, q.Prime → q ∣ p - 1 → q ≤ B) + (ha : 0 ≤ a) + (hcount : ((Nat.log 2 (X ^ k) + 1 : ℕ) : ℝ) ^ B * a < (P.card.choose k : ℝ)) : + ∃ n : ℕ, 0 < n ∧ n ≤ X ^ k ∧ + (∀ q : ℕ, q.Prime → q ∣ n → q ≤ B) ∧ a < (g n : ℝ) := by + let S := (P.powersetCard k).image (fun Q => ∏ p ∈ Q, p) + let T := S.image Nat.totient + have hS : S.card = P.card.choose k := by + unfold S + rw [Finset.card_image_of_injOn, Finset.card_powersetCard] + intro Q hQ R hR hQR + exact (prime_prod_eq_iff + (fun p hp => hprime p ((Finset.mem_powersetCard.mp hQ).1 hp)) + (fun p hp => hprime p ((Finset.mem_powersetCard.mp hR).1 hp))).mp hQR + have hpos : ∀ m ∈ S, 0 < m := by + intro m hm + obtain ⟨Q, hQ, rfl⟩ := Finset.mem_image.mp hm + exact Finset.prod_pos fun p hp => (hprime p ((Finset.mem_powersetCard.mp hQ).1 hp)).pos + have hvalues : ∀ n ∈ T, 0 < n ∧ n ≤ X ^ k ∧ + (∀ q : ℕ, q.Prime → q ∣ n → q ≤ B) := by + intro n hn + obtain ⟨m, hm, rfl⟩ := Finset.mem_image.mp hn + have hmpos := hpos m hm + obtain ⟨Q, hQ, rfl⟩ := Finset.mem_image.mp hm + obtain ⟨hQP, hQk⟩ := Finset.mem_powersetCard.mp hQ + refine ⟨Nat.totient_pos.mpr hmpos, ?_, ?_⟩ + · calc + Nat.totient (∏ p ∈ Q, p) ≤ ∏ p ∈ Q, p := Nat.totient_le _ + _ ≤ X ^ Q.card := Finset.prod_le_pow_card _ _ _ fun p hp => hsize p (hQP hp) + _ = X ^ k := by rw [hQk] + · intro q hq hd + rw [totient_prime_prod (fun p hp => hprime p (hQP hp))] at hd + obtain ⟨p, hp, hdiv⟩ := (hq.prime.dvd_finsetProd_iff _).mp hd + exact hsmooth p (hQP hp) q hq hdiv + have hT : T.card ≤ (Nat.log 2 (X ^ k) + 1) ^ B := + card_le_of_smooth (fun n hn => (hvalues n hn).1) + (fun n hn => (hvalues n hn).2.1) (fun n hn => (hvalues n hn).2.2) + have hT' : (T.card : ℝ) ≤ ((Nat.log 2 (X ^ k) + 1 : ℕ) : ℝ) ^ B := by + exact_mod_cast hT + have havg : T.card • a < (S.card : ℝ) := by + rw [nsmul_eq_mul, hS] + exact (mul_le_mul_of_nonneg_right hT' ha).trans_lt hcount + obtain ⟨n, hn, han⟩ := Finset.exists_lt_card_fiber_of_nsmul_lt_card_of_maps_to + (fun m hm => Finset.mem_image_of_mem Nat.totient hm) havg + refine ⟨n, (hvalues n hn).1, (hvalues n hn).2.1, (hvalues n hn).2.2, ?_⟩ + have hgn : (S.filter (fun m => Nat.totient m = n)).card ≤ g n := by + apply card_le_g + intro m hm + obtain ⟨hmS, hmn⟩ := Finset.mem_filter.mp hm + exact ⟨hpos m hmS, hmn⟩ + exact han.trans_le (by exact_mod_cast hgn) + +theorem binomial_ge_ratio {M k : ℕ} (hkM : k ≤ M) : + ((M : ℝ) / k) ^ k ≤ (M.choose k : ℝ) := by + have hid : (∏ j ∈ Finset.range k, ((M - j : ℕ) : ℝ) / (k - j : ℕ)) = + (M.choose k : ℝ) := by + rw [Finset.prod_div_distrib, ← Nat.cast_prod, ← Nat.cast_prod, + ← Nat.descFactorial_eq_prod_range, ← Nat.descFactorial_eq_prod_range, + Nat.descFactorial_self, Nat.descFactorial_eq_factorial_mul_choose, Nat.cast_mul] + have hfact : (k.factorial : ℝ) ≠ 0 := by exact_mod_cast k.factorial_ne_zero + exact mul_div_cancel_left₀ _ hfact + calc + ((M : ℝ) / k) ^ k = ∏ j ∈ Finset.range k, ((M : ℝ) / k) := by simp [div_pow] + _ ≤ ∏ j ∈ Finset.range k, ((M - j : ℕ) : ℝ) / (k - j : ℕ) := by + apply Finset.prod_le_prod₀ (fun _ _ => div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) + intro j hj + have hjk : j < k := Finset.mem_range.mp hj + have hjM : j ≤ M := hjk.le.trans hkM + have hjk' : (j : ℝ) < k := by exact_mod_cast hjk + have hkM' : (k : ℝ) ≤ M := by exact_mod_cast hkM + have hkpos : (0 : ℝ) < k := by exact_mod_cast (Nat.zero_le j).trans_lt hjk + rw [Nat.cast_sub hjM, Nat.cast_sub hjk.le, div_le_div_iff₀ hkpos (sub_pos.mpr hjk')] + nlinarith [mul_nonneg (sub_nonneg.mpr hkM') (Nat.cast_nonneg j : (0 : ℝ) ≤ j)] + _ = (M.choose k : ℝ) := hid + +theorem logarithmic_count_bound {t a : ℕ} (ht : 5 ≤ t) (ha : a ≤ t) : + (Nat.log 2 ((t ^ a) ^ (t ^ 2)) + 1) ^ t ≤ t ^ (t ^ 2) := by + have htone : 1 ≤ t := by omega + have hpow : (t ^ a) ^ (t ^ 2) ≤ 2 ^ (t * (a * t ^ 2)) := by + calc + (t ^ a) ^ (t ^ 2) ≤ ((2 ^ t) ^ a) ^ (t ^ 2) := + Nat.pow_le_pow_left (Nat.pow_le_pow_left Nat.lt_two_pow_self.le a) _ + _ = 2 ^ (t * (a * t ^ 2)) := by rw [← pow_mul, ← pow_mul] + have hlog : Nat.log 2 ((t ^ a) ^ (t ^ 2)) ≤ t * (a * t ^ 2) := by + have := Nat.log_mono_right (b := 2) hpow + rwa [Nat.log_pow (by decide)] at this + have hexp : Nat.log 2 ((t ^ a) ^ (t ^ 2)) ≤ t ^ 4 := by + calc + Nat.log 2 ((t ^ a) ^ (t ^ 2)) ≤ t * (a * t ^ 2) := hlog + _ ≤ t * (t * t ^ 2) := Nat.mul_le_mul_left _ (Nat.mul_le_mul_right _ ha) + _ = t ^ 4 := by ring + have hbase : Nat.log 2 ((t ^ a) ^ (t ^ 2)) + 1 ≤ t ^ 5 := by + have hpos : 1 ≤ t ^ 4 := one_le_pow₀ htone + have htwo : 2 * t ^ 4 ≤ t * t ^ 4 := Nat.mul_le_mul_right _ (by omega : 2 ≤ t) + nlinarith [pow_succ t 4] + calc + (Nat.log 2 ((t ^ a) ^ (t ^ 2)) + 1) ^ t ≤ (t ^ 5) ^ t := Nat.pow_le_pow_left hbase _ + _ = t ^ (5 * t) := (pow_mul _ _ _).symm + _ ≤ t ^ (t ^ 2) := pow_le_pow_right₀ htone (by nlinarith) + +theorem finite_large_fiber {P : Finset ℕ} {t a : ℕ} + (ha : 5 ≤ a) (hat : a ≤ t) + (hprime : ∀ p ∈ P, p.Prime) (hsize : ∀ p ∈ P, p ≤ t ^ a) + (hsmooth : ∀ p ∈ P, ∀ q : ℕ, q.Prime → q ∣ p - 1 → q ≤ t) + (hcard : t ^ (a - 1) < P.card) : + ∃ n : ℕ, 0 < n ∧ n ≤ (t ^ a) ^ (t ^ 2) ∧ + t ^ ((a - 4) * t ^ 2) < g n := by + have ht : 5 ≤ t := ha.trans hat + have htone : 1 ≤ t := by omega + have htpos : 0 < t := by omega + have hkM : t ^ 2 ≤ P.card := + (pow_le_pow_right₀ htone (by omega : 2 ≤ a - 1)).trans hcard.le + have hratio : (t : ℝ) ^ (a - 3) < (P.card : ℝ) / (t ^ 2 : ℕ) := by + rw [lt_div_iff₀ (by positivity), Nat.cast_pow, ← pow_add, + show a - 3 + 2 = a - 1 by omega] + exact_mod_cast hcard + have hchoose : (t : ℝ) ^ ((a - 3) * t ^ 2) < (P.card.choose (t ^ 2) : ℝ) := by + rw [pow_mul] + exact (pow_lt_pow_left₀ hratio (by positivity) (by positivity)).trans_le + (binomial_ge_ratio hkM) + have hC : ((Nat.log 2 ((t ^ a) ^ (t ^ 2)) + 1 : ℕ) : ℝ) ^ t ≤ + (t : ℝ) ^ (t ^ 2) := by + exact_mod_cast logarithmic_count_bound ht hat + have hexp : t ^ 2 + (a - 4) * t ^ 2 = (a - 3) * t ^ 2 := by + rw [show a - 3 = a - 4 + 1 by omega] + ring + have hcount : ((Nat.log 2 ((t ^ a) ^ (t ^ 2)) + 1 : ℕ) : ℝ) ^ t * + (t : ℝ) ^ ((a - 4) * t ^ 2) < (P.card.choose (t ^ 2) : ℝ) := by + calc + _ ≤ (t : ℝ) ^ (t ^ 2) * (t : ℝ) ^ ((a - 4) * t ^ 2) := + mul_le_mul_of_nonneg_right hC (by positivity) + _ = (t : ℝ) ^ ((a - 3) * t ^ 2) := by rw [← pow_add, hexp] + _ < (P.card.choose (t ^ 2) : ℝ) := hchoose + obtain ⟨n, hn, hnb, _, hgn⟩ := finite_pigeonhole hprime hsize hsmooth (by positivity) hcount + exact ⟨n, hn, hnb, by exact_mod_cast hgn⟩ + +theorem finite_large_fiber_rpow {P : Finset ℕ} {t a : ℕ} {ε : ℝ} + (ha : 5 ≤ a) (hat : a ≤ t) (hε : ε ≤ 1) (haε : 4 ≤ (a : ℝ) * ε) + (hprime : ∀ p ∈ P, p.Prime) (hsize : ∀ p ∈ P, p ≤ t ^ a) + (hsmooth : ∀ p ∈ P, ∀ q : ℕ, q.Prime → q ∣ p - 1 → q ≤ t) + (hcard : t ^ (a - 1) < P.card) : + ∃ n : ℕ, 0 < n ∧ t < g n ∧ (n : ℝ) ^ (1 - ε) < (g n : ℝ) := by + obtain ⟨n, hn, hnb, hgn⟩ := finite_large_fiber ha hat hprime hsize hsmooth hcard + have htone : 1 ≤ t := by omega + have htpos : 0 < t := by omega + have hexp_pos : 1 ≤ (a - 4) * t ^ 2 := Nat.mul_pos + (by omega) (pow_pos htpos _) + have htg : t < g n := by + calc + t = t ^ 1 := (pow_one t).symm + _ ≤ t ^ ((a - 4) * t ^ 2) := pow_le_pow_right₀ htone hexp_pos + _ < g n := hgn + have ha4 : 4 ≤ a := by omega + have hexp : (a : ℝ) * (1 - ε) ≤ (a - 4 : ℕ) := by + rw [Nat.cast_sub ha4] + norm_num + nlinarith + have hexp' : ((a * t ^ 2 : ℕ) : ℝ) * (1 - ε) ≤ (((a - 4) * t ^ 2 : ℕ) : ℝ) := by + push_cast + have h := mul_le_mul_of_nonneg_right hexp (sq_nonneg (t : ℝ)) + nlinarith + have hnrpow : (n : ℝ) ^ (1 - ε) ≤ (t : ℝ) ^ ((a - 4) * t ^ 2) := by + calc + (n : ℝ) ^ (1 - ε) ≤ (((t ^ a) ^ (t ^ 2) : ℕ) : ℝ) ^ (1 - ε) := + Real.rpow_le_rpow (Nat.cast_nonneg _) (by exact_mod_cast hnb) (sub_nonneg.mpr hε) + _ = (t : ℝ) ^ (((a * t ^ 2 : ℕ) : ℝ) * (1 - ε)) := by + rw [Nat.cast_pow, Nat.cast_pow, ← pow_mul, ← Real.rpow_natCast_mul (Nat.cast_nonneg _)] + _ ≤ (t : ℝ) ^ (((a - 4) * t ^ 2 : ℕ) : ℝ) := + Real.rpow_le_rpow_of_exponent_le (by exact_mod_cast htone) hexp' + _ = (t : ℝ) ^ ((a - 4) * t ^ 2) := Real.rpow_natCast _ _ + exact ⟨n, hn, htg, hnrpow.trans_lt (by exact_mod_cast hgn)⟩ + +end TotientFibers + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/AffineDeduction.lean b/lean/OAI/NumberTheory/TwoPoint/AffineDeduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..107a533c46fb4ab12ff1c6961657267033b7ffdc --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/AffineDeduction.lean @@ -0,0 +1,181 @@ +import OAI.NumberTheory.TwoPoint.Bounds.Dilation +import OAI.NumberTheory.TwoPoint.Bounds.AffineTransfer +import OAI.NumberTheory.TwoPoint.Statements + +namespace OAI + +open Filter +open scoped BigOperators + +namespace TwoPointCorrelations + +def ProgressionCorrectedElliott : Prop := + ∀ f g : ℕ → ℂ, Multiplicative f → Multiplicative g → + OneBounded f → OneBounded g → + (UniformlyNonpretentious f ∨ UniformlyNonpretentious g) → + ∀ h l b : ℕ, 0 < h → 0 < l → + Tendsto (fun N : ℕ => residuePrefix (fun n => f n * g (n + h)) l b N / (N : ℂ)) + atTop (nhds 0) + +theorem Multiplicative.one_eq_zero_or_one {f : ℕ → ℂ} (hf : Multiplicative f) : + f 1 = 0 ∨ f 1 = 1 := by + have heq := hf 1 1 (by decide) (by decide) (by decide) + have hprod : f 1 * (f 1 - 1) = 0 := by + calc + f 1 * (f 1 - 1) = f 1 * f 1 - f 1 := by ring + _ = 0 := by simpa using congrArg (fun z : ℂ => z - f 1) heq.symm + rcases mul_eq_zero.mp hprod with h | h + · exact Or.inl h + · exact Or.inr (sub_eq_zero.mp h) + +theorem Multiplicative.zero_of_one_eq_zero {f : ℕ → ℂ} (hf : Multiplicative f) + (h0 : f 1 = 0) {n : ℕ} (hn : 0 < n) : f n = 0 := by + simpa [h0] using hf 1 n (by decide) hn (Nat.coprime_one_left n) + +lemma residuePrefix_congr {u v : ℕ → ℂ} (h : ∀ n, 0 < n → u n = v n) + (l b N : ℕ) : residuePrefix u l b N = residuePrefix v l b N := by + unfold residuePrefix + apply Finset.sum_congr rfl + intro n hn + rw [h n (Finset.mem_Ioc.mp hn).1] + +lemma residuePrefix_sum {ι : Type*} (s : Finset ι) (u : ι → ℕ → ℂ) (l b N : ℕ) : + residuePrefix (fun n => ∑ i ∈ s, u i n) l b N = + ∑ i ∈ s, residuePrefix (u i) l b N := by + unfold residuePrefix + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro n hn + split_ifs <;> simp + +lemma residuePrefix_const_mul (c : ℂ) (u : ℕ → ℂ) (l b N : ℕ) : + residuePrefix (fun n => c * u n) l b N = c * residuePrefix u l b N := by + unfold residuePrefix + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro n hn + split_ifs <;> simp + +/-- Finite signed local expansions preserve an established progression limit. -/ +theorem finite_expansion_progression_zero {ι κ : Type*} + (s : Finset ι) (t : Finset κ) (c : ι → ℂ) (d : κ → ℂ) + (F : ι → ℕ → ℂ) (G : κ → ℕ → ℂ) (u v : ℕ → ℂ) + (hu : ∀ n, 0 < n → u n = ∑ i ∈ s, c i * F i n) + (hv : ∀ n, 0 < n → v n = ∑ j ∈ t, d j * G j n) + (h l b : ℕ) + (hz : ∀ i ∈ s, ∀ j ∈ t, + Tendsto (fun N : ℕ => residuePrefix (fun n => F i n * G j (n + h)) l b N / + (N : ℂ)) atTop (nhds 0)) : + Tendsto (fun N : ℕ => residuePrefix (fun n => u n * v (n + h)) l b N / + (N : ℂ)) atTop (nhds 0) := by + have heq (N : ℕ) : residuePrefix (fun n => u n * v (n + h)) l b N / (N : ℂ) = + ∑ i ∈ s, ∑ j ∈ t, (c i * d j) * + (residuePrefix (fun n => F i n * G j (n + h)) l b N / (N : ℂ)) := by + rw [residuePrefix_congr (v := fun n => ∑ i ∈ s, ∑ j ∈ t, + (c i * d j) * (F i n * G j (n + h))) (by + intro n hn + rw [hu n hn, hv (n + h) (by omega)] + rw [Finset.sum_mul] + simp_rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + ring)] + simp only [residuePrefix_sum, residuePrefix_const_mul, Finset.sum_div] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + ring + simp_rw [heq] + have hout := tendsto_finsetSum s (fun i hi => + tendsto_finsetSum t (fun j hj => + (tendsto_const_nhds (x := c i * d j)).mul (hz i hi j hj))) + simpa using hout + +theorem ProgressionCorrectedElliott.dilations + (hprog : ProgressionCorrectedElliott) (f g : ℕ → ℂ) + (hf : Multiplicative f) (hg : Multiplicative g) + (hf1 : f 1 = 1) (hg1 : g 1 = 1) + (hfb : OneBounded f) (hgb : OneBounded g) + (hnp : UniformlyNonpretentious f ∨ UniformlyNonpretentious g) + (a a' h l b : ℕ) (ha : 0 < a) (ha' : 0 < a') (hh : 0 < h) (hl : 0 < l) : + Tendsto (fun N : ℕ => + residuePrefix (fun n => dilate a f n * dilate a' g (n + h)) l b N / (N : ℂ)) + atTop (nhds 0) := by + apply finite_expansion_progression_zero a.primeFactors.powerset a'.primeFactors.powerset + (fun E => (-1 : ℂ) ^ E.card) (fun E => (-1 : ℂ) ^ E.card) + (dilationComponent a f) (dilationComponent a' g) + (dilate a f) (dilate a' g) + (fun n hn => dilate_eq_sum_components a f ha hf hf1 hn) + (fun n hn => dilate_eq_sum_components a' g ha' hg hg1 hn) + intro E _ E' _ + apply hprog _ _ (dilationComponent_multiplicative a f E) + (dilationComponent_multiplicative a' g E') + (dilationComponent_oneBounded _ _ _ hfb) (dilationComponent_oneBounded _ _ _ hgb) + _ h l b hh hl + exact hnp.imp (dilationComponent_nonpretentious a f E hfb) + (dilationComponent_nonpretentious a' g E' hgb) + +private theorem affine_ordered_zero (hprog : ProgressionCorrectedElliott) + (f g : ℕ → ℂ) (hf : Multiplicative f) (hg : Multiplicative g) + (hf1 : f 1 = 1) (hg1 : g 1 = 1) (hfb : OneBounded f) (hgb : OneBounded g) + (hnp : UniformlyNonpretentious f ∨ UniformlyNonpretentious g) + (a₁ a₂ b₁ b₂ : ℕ) (ha₁ : 0 < a₁) (ha₂ : 0 < a₂) + (horder : a₂ * b₁ < a₁ * b₂) : + Tendsto (fun N : ℕ => affineSum f g a₁ a₂ b₁ b₂ N / (N : ℂ)) atTop (nhds 0) := by + have hp := hprog.dilations f g hf hg hf1 hg1 hfb hgb hnp a₂ a₁ + (a₁ * b₂ - a₂ * b₁) (a₁ * a₂) (a₂ * b₁) ha₂ ha₁ + (Nat.sub_pos_of_lt horder) (Nat.mul_pos ha₁ ha₂) + have ht := affine_mean_tendsto_zero + (fun m => dilate a₂ f m * dilate a₁ g (m + (a₁ * b₂ - a₂ * b₁))) + (a₁ * a₂) (a₂ * b₁) (Nat.mul_pos ha₁ ha₂) hp + apply ht.congr' + apply Filter.Eventually.of_forall + intro N + dsimp only + congr 1 + unfold affineSum + apply Finset.sum_congr rfl + intro n hn + have hl : a₁ * a₂ * n + a₂ * b₁ = a₂ * (a₁ * n + b₁) := by ring + have hr : a₁ * a₂ * n + a₂ * b₁ + (a₁ * b₂ - a₂ * b₁) = + a₁ * (a₂ * n + b₂) := by + calc + _ = a₁ * a₂ * n + a₁ * b₂ := by omega + _ = _ := by ring + rw [hr, hl] + simp [dilate, ha₁.ne', ha₂.ne'] + +/-- The manuscript's affine reduction, conditional here on its internal +progression theorem. This is not the published-input conditional main result. -/ +theorem ProgressionCorrectedElliott.affine (hprog : ProgressionCorrectedElliott) : + AffineCorrectedElliott := by + intro f g hf hg hfb hgb hnp a₁ a₂ b₁ b₂ ha₁ ha₂ hneq + rcases hf.one_eq_zero_or_one with hf0 | hf1 + · have hz (N : ℕ) : affineSum f g a₁ a₂ b₁ b₂ N = 0 := by + unfold affineSum + apply Finset.sum_eq_zero + intro n hn + have hnpos := (Finset.mem_Icc.mp hn).1 + rw [hf.zero_of_one_eq_zero hf0 (by nlinarith : 0 < a₁ * n + b₁), zero_mul] + simpa only [hz, zero_div] using (tendsto_const_nhds (x := (0 : ℂ)) (f := atTop)) + rcases hg.one_eq_zero_or_one with hg0 | hg1 + · have hz (N : ℕ) : affineSum f g a₁ a₂ b₁ b₂ N = 0 := by + unfold affineSum + apply Finset.sum_eq_zero + intro n hn + have hnpos := (Finset.mem_Icc.mp hn).1 + rw [hg.zero_of_one_eq_zero hg0 (by nlinarith : 0 < a₂ * n + b₂), mul_zero] + simpa only [hz, zero_div] using (tendsto_const_nhds (x := (0 : ℂ)) (f := atTop)) + rcases lt_or_gt_of_ne hneq with hlt | hgt + · have h := affine_ordered_zero hprog g f hg hf hg1 hf1 hgb hfb hnp.symm + a₂ a₁ b₂ b₁ ha₂ ha₁ hlt + simpa only [affineSum_swap f g] using h + · exact affine_ordered_zero hprog f g hf hg hf1 hg1 hfb hgb hnp + a₁ a₂ b₁ b₂ ha₁ ha₂ hgt + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Basic.lean b/lean/OAI/NumberTheory/TwoPoint/Basic.lean new file mode 100644 index 0000000000000000000000000000000000000000..6758ac5c3f8fa0155485302553eb551c9c278e4f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Basic.lean @@ -0,0 +1,93 @@ +import Mathlib.NumberTheory.ArithmeticFunction.Liouville +import Mathlib.Algebra.BigOperators.Intervals +import Mathlib.Analysis.Complex.Basic + +namespace OAI + +/-! +# Ordinary two-point correlations: concrete sums and affine transfer + +Definitions follow the introduction of the supplied manuscript +*Ordinary two-point correlations of multiplicative functions* (September 24, 2026). +The exact Liouville identities below are the algebraic part of §8. +No cancellation estimate is assumed or asserted here. +-/ + +open scoped BigOperators + +namespace TwoPointCorrelations + +/-- The standard Liouville function, viewed as complex valued. Its value at zero +is zero, as in mathlib; only positive arguments occur in the main statements. -/ +noncomputable def liouville (n : ℕ) : ℂ := ArithmeticFunction.liouville n + +/-- An ordinary sum, with weight one on each positive integer at most `N`. -/ +def correlationSum (f g : ℕ → ℂ) (h₁ h₂ N : ℕ) : ℂ := + ∑ n ∈ Finset.Icc 1 N, f (n + h₁) * g (n + h₂) + +/-- The ordinary affine correlation, allowing nonunit coefficients. -/ +def affineSum (f g : ℕ → ℂ) (a₁ a₂ b₁ b₂ N : ℕ) : ℂ := + ∑ n ∈ Finset.Icc 1 N, f (a₁ * n + b₁) * g (a₂ * n + b₂) + +/-- The progression sum includes every residue class, including zero. -/ +def progressionSum (f g : ℕ → ℂ) (h l b N : ℕ) : ℂ := + ∑ n ∈ (Finset.Icc 1 N).filter (fun n => n % l = b % l), f n * g (n + h) + +/-- Ordinary multiplicativity is required only for coprime positive arguments; +this also permits the identically zero function, as does the manuscript. -/ +def Multiplicative (f : ℕ → ℂ) : Prop := + ∀ m n : ℕ, 0 < m → 0 < n → m.Coprime n → f (m * n) = f m * f n + +def OneBounded (f : ℕ → ℂ) : Prop := ∀ n : ℕ, 0 < n → ‖f n‖ ≤ 1 + +@[simp] theorem liouville_mul (m n : ℕ) : + liouville (m * n) = liouville m * liouville n := by + simp [liouville, ArithmeticFunction.liouville_apply_mul] + +@[simp] theorem liouville_sq {n : ℕ} (hn : n ≠ 0) : liouville n ^ 2 = 1 := by + have h : (ArithmeticFunction.liouville n) ^ 2 = (1 : ℤ) := by + rw [ArithmeticFunction.liouville_apply hn, ← pow_mul, Nat.mul_comm _ 2, pow_mul] + norm_num + unfold liouville + exact_mod_cast h + +/-- Multiplying the two affine arguments by the opposite slopes gives an exact +identity. There is no coprimality restriction on any coefficient. -/ +theorem liouville_affine_dilation (a₁ a₂ b₁ b₂ n : ℕ) + (ha₁ : a₁ ≠ 0) (ha₂ : a₂ ≠ 0) : + liouville (a₁ * n + b₁) * liouville (a₂ * n + b₂) = + liouville (a₁ * a₂) * liouville (a₂ * (a₁ * n + b₁)) * + liouville (a₁ * (a₂ * n + b₂)) := by + have hs := liouville_sq (Nat.mul_ne_zero ha₁ ha₂) + calc + _ = liouville (a₁ * a₂) ^ 2 * + (liouville (a₁ * n + b₁) * liouville (a₂ * n + b₂)) := by rw [hs, one_mul] + _ = _ := by simp only [liouville_mul]; ring + +/-- The orientation with `a₂ b₁ ≤ a₁ b₂`; the opposite orientation is obtained +by swapping the two factors. This is manuscript equation (q:quant-affine-identity). -/ +theorem liouville_affine_ordered (a₁ a₂ b₁ b₂ n : ℕ) + (ha₁ : a₁ ≠ 0) (ha₂ : a₂ ≠ 0) (horder : a₂ * b₁ ≤ a₁ * b₂) : + liouville (a₁ * n + b₁) * liouville (a₂ * n + b₂) = + liouville (a₁ * a₂) * liouville (a₁ * a₂ * n + a₂ * b₁) * + liouville (a₁ * a₂ * n + a₂ * b₁ + (a₁ * b₂ - a₂ * b₁)) := by + rw [liouville_affine_dilation a₁ a₂ b₁ b₂ n ha₁ ha₂] + congr 2 + · congr 1; ring + · calc + a₁ * (a₂ * n + b₂) = a₁ * a₂ * n + a₁ * b₂ := by ring + _ = a₁ * a₂ * n + a₂ * b₁ + (a₁ * b₂ - a₂ * b₁) := by omega + +theorem liouville_multiplicative : Multiplicative liouville := by + intro m n _ _ _ + exact liouville_mul m n + +theorem liouville_oneBounded : OneBounded liouville := by + intro n hn + have hs : ‖liouville n‖ ^ 2 = 1 := by + rw [← norm_pow, liouville_sq hn.ne', norm_one] + nlinarith [norm_nonneg (liouville n)] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveLabels.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveLabels.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a6702b533b5be048f2f21d633d4622a2f5dc609 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveLabels.lean @@ -0,0 +1,288 @@ +import OAI.NumberTheory.TwoPoint.Walks.ReversedSegments + +namespace OAI + +/-! Active numerical labels in minimal prohibited witnesses. -/ + +namespace TwoPointCorrelations + +open Finset + +noncomputable def wordPrimeContribution (h : ℕ) (w : List SignedStep) (p a b : ℕ) : ℤ := by + classical + exact ∑ i ∈ Ico a b, if TuplePrimeAt w p i then wordStepDisplacement h w i else 0 + +/-- A contiguous relation with a nonzero contribution from this label. -/ +def ActivePrime (h : ℕ) (w : List SignedStep) (p : ℕ) : Prop := + ∃ c a b, a ≤ b ∧ b ≤ w.length ∧ (∃ i, TuplePrimeAt w c i) ∧ + (c : ℤ) ∣ intervalDisplacement (wordStepDisplacement h w) a b ∧ + ¬(c : ℤ) ∣ wordPrimeContribution h w p a b + +lemma wordPrimeContribution_eq_interval (h : ℕ) (w : List SignedStep) (p a b : ℕ) + (hp : ∀ i ∈ Ico a b, TuplePrimeAt w p i) : + wordPrimeContribution h w p a b = intervalDisplacement (wordStepDisplacement h w) a b := by + classical + unfold wordPrimeContribution intervalDisplacement + apply sum_congr rfl + intro i hi + simp only [hp i hi, ite_true] + +lemma wordPrimeContribution_eq_singleton (h : ℕ) (w : List SignedStep) (p a b j : ℕ) + (hj : j ∈ Ico a b) (hp : TuplePrimeAt w p j) + (hunique : ∀ i ∈ Ico a b, TuplePrimeAt w p i → i = j) : + wordPrimeContribution h w p a b = wordStepDisplacement h w j := by + classical + unfold wordPrimeContribution + rw [sum_eq_single j] + · simp only [hp, ite_true] + · intro i hi hne + have hnot : ¬TuplePrimeAt w p i := fun hpi => hne (hunique i hi hpi) + simp only [hnot, ite_false] + · exact fun h => False.elim (h hj) + +/-- A label first entering at the last step is active in the original +prohibited suffix, because its contribution is exactly that last step. -/ +lemma ForwardProhibited.last_new_active {h s : ℕ} {supply : ℕ → ℕ → Prop} + {w : List SignedStep} (hw : ForwardProhibited h s supply w) {z : ℕ} + (hz : TuplePrimeAt w z (w.length - 1)) + (hearlier : ∀ i, i < w.length - 1 → ¬TuplePrimeAt w z i) + (hoff : ∀ p i, (∃ j, TuplePrimeAt w p j) → i < w.length → + ¬TuplePrimeAt w p i → ¬(p : ℤ) ∣ wordStepDisplacement h w i) : + ActivePrime h w z := by + rcases hw with ⟨hlen, _, _, _, _, c, hc, hclast, a, ha, halast, hdiv⟩ + refine ⟨c, a, w.length, by omega, le_rfl, ⟨0, hc⟩, ?_, ?_⟩ + · simpa only [wordSlice, Nat.sub_self, List.take_length, List.length_drop] using + (show (c : ℤ) ∣ intervalDisplacement (wordStepDisplacement h w) a w.length from by + rw [← wordSlice_displacement h w (by omega)] + simpa only [wordSlice, ← List.length_drop, List.take_length] using hdiv) + · rw [wordPrimeContribution_eq_singleton h w z a w.length (w.length - 1) + (by simp only [mem_Ico]; omega) hz] + · exact hoff c (w.length - 1) ⟨0, hc⟩ (by omega) hclast + · intro i hi hzi + have hi' := (mem_Ico.mp hi).2 + by_contra hne + exact hearlier i (by omega) hzi + +lemma prime_dvd_wordPrimeContribution (h : ℕ) (w : List SignedStep) (p a b : ℕ) : + (p : ℤ) ∣ wordPrimeContribution h w p a b := by + classical + unfold wordPrimeContribution + apply Finset.dvd_sum + intro i _ + by_cases hpi : TuplePrimeAt w p i + · simpa only [hpi, ite_true] using (tuplePrime_dvd_step (h := h) hpi) + · simp only [hpi, ite_false, dvd_zero] + +lemma ActivePrime.distinct_controller {h p : ℕ} {w : List SignedStep} + (hp : ActivePrime h w p) : + ∃ c a b, c ≠ p ∧ a ≤ b ∧ b ≤ w.length ∧ (∃ i, TuplePrimeAt w c i) ∧ + (c : ℤ) ∣ intervalDisplacement (wordStepDisplacement h w) a b ∧ + ¬(c : ℤ) ∣ wordPrimeContribution h w p a b := by + obtain ⟨c, a, b, hab, hb, hc, hd, hn⟩ := hp + refine ⟨c, a, b, ?_, hab, hb, hc, hd, hn⟩ + intro heq + subst c + exact hn (prime_dvd_wordPrimeContribution h w p a b) + +/-- Intersecting an interval-shaped occurrence set with a prefix gives an +explicit nonempty interval of indices. -/ +lemma TuplePrimeIntervals.prefix_occurrences {w : List SignedStep} + (hw : TuplePrimeIntervals w) (p n : ℕ) (hn : n ≤ w.length) + (hp : ∃ j, j < n ∧ TuplePrimeAt w p j) : + ∃ a b, a < b ∧ b ≤ n ∧ ∀ i, i < n → + (TuplePrimeAt w p i ↔ a ≤ i ∧ i < b) := by + classical + let S := (range n).filter (TuplePrimeAt w p) + have hS : S.Nonempty := by + obtain ⟨j, hj, hpj⟩ := hp + exact ⟨j, mem_filter.mpr ⟨mem_range.mpr hj, hpj⟩⟩ + let a := S.min' hS + let b := S.max' hS + 1 + have haS : a ∈ S := min'_mem S hS + have hbS : b - 1 ∈ S := by + simpa only [b, Nat.add_sub_cancel] using max'_mem S hS + have han := (mem_range.mp (mem_filter.mp haS).1) + have hbn := (mem_range.mp (mem_filter.mp hbS).1) + have hab : a < b := by + have h := min'_le S (S.max' hS) (max'_mem S hS) + dsimp [a, b] + omega + refine ⟨a, b, hab, by dsimp [b] at *; omega, ?_⟩ + intro i hi + constructor + · intro hpi + have hiS : i ∈ S := mem_filter.mpr ⟨mem_range.mpr hi, hpi⟩ + exact ⟨min'_le S i hiS, Nat.lt_succ_of_le (le_max' S i hiS)⟩ + · rintro ⟨hai, hib⟩ + exact hw p a i (b - 1) hai (by omega) (by omega) + (mem_filter.mp haS).2 (mem_filter.mp hbS).2 + +lemma wordPrimeContribution_restrict (h : ℕ) (w : List SignedStep) (p n a b : ℕ) + (hbn : b ≤ n) + (hp : ∀ i, i < n → (TuplePrimeAt w p i ↔ a ≤ i ∧ i < b)) : + wordPrimeContribution h w p 0 n = intervalDisplacement (wordStepDisplacement h w) a b := by + classical + unfold wordPrimeContribution intervalDisplacement + calc + _ = ∑ i ∈ Ico a b, if TuplePrimeAt w p i then wordStepDisplacement h w i else 0 := by + symm + apply Finset.sum_subset (Ico_subset_Ico (Nat.zero_le a) hbn) + intro i hi hin + have hnot : ¬TuplePrimeAt w p i := by + intro hpi + exact hin (mem_Ico.mpr ((hp i (mem_Ico.mp hi).2).mp hpi)) + simp only [hnot, ite_false] + _ = _ := by + apply sum_congr rfl + intro i hi + simp only [(hp i (lt_of_lt_of_le (mem_Ico.mp hi).2 hbn)).mpr + ⟨(mem_Ico.mp hi).1, (mem_Ico.mp hi).2⟩, ite_true] + +/-- Minimality forbids a reversed suffix starting at a strictly positive +index, when an internal initial segment is divisible by its final prime. -/ +lemma MinimalWord.no_reversed_divisible_interval {h s : ℕ} {supply : ℕ → ℕ → Prop} + {w : List SignedStep} (hw : MinimalWord (ForwardProhibited h s supply) w) + {a c p : ℕ} (ha : 0 < a) (hac : a + 1 < c) (hc : c < w.length) + (hp : TuplePrimeAt w p (w.length - 1)) (hnot : ¬TuplePrimeAt w p a) : + ¬(p : ℤ) ∣ intervalDisplacement (wordStepDisplacement h w) a c := by + intro hdiv + have hpro := reversed_interval_forwardProhibited h s supply w hw.1.2.1 hw.1.2.2.1 + hw.1.2.2.2.1 hw.1.2.2.2.2.1 hac hc le_rfl hp hnot hdiv + apply hw.2 (reverseWord (wordSlice w a w.length)) + (Or.inr (reverseWord_infix (wordSlice_infix w a w.length))) ?_ hpro + rw [reverseWord_length, wordSlice_length w (by omega) le_rfl] + omega + +/-- Every label of a minimal prohibited word is active or has a nonzero +prefix contribution modulo an active label used at that departure. -/ +theorem MinimalWord.active_dichotomy {h s : ℕ} {supply : ℕ → ℕ → Prop} + {w : List SignedStep} (hw : MinimalWord (ForwardProhibited h s supply) w) + (hnew : ∀ i, i + 1 < w.length → + ∃ p, TuplePrimeAt w p (i + 1) ∧ ¬TuplePrimeAt w p i) + (hoff : ∀ p i, (∃ j, TuplePrimeAt w p j) → i < w.length → + ¬TuplePrimeAt w p i → ¬(p : ℤ) ∣ wordStepDisplacement h w i) + (y : ℕ) (hy : ∃ j, TuplePrimeAt w y j) : + ActivePrime h w y ∨ ∃ z i, ActivePrime h w z ∧ TuplePrimeAt w z i ∧ + ¬(z : ℤ) ∣ wordPrimeContribution h w y 0 i := by + classical + have hlen : 3 ≤ w.length := hw.1.1 + have hinter : TuplePrimeIntervals w := hw.1.2.2.2.2.1 + obtain ⟨z, hzlast', hzprev⟩ := hnew (w.length - 2) (by omega) + have heqlast : w.length - 2 + 1 = w.length - 1 := by omega + have hzlast : TuplePrimeAt w z (w.length - 1) := heqlast ▸ hzlast' + have hzearly : ∀ i, i < w.length - 1 → ¬TuplePrimeAt w z i := by + intro i hi hzi + exact hzprev (hinter z i (w.length - 2) (w.length - 1) + (by omega) (by omega) (by omega) hzi hzlast) + have hzactive := hw.1.last_new_active hzlast hzearly hoff + by_cases hypre : ∃ j, j < w.length - 1 ∧ TuplePrimeAt w y j + · obtain ⟨a, b, hab, hbn, hyinterval⟩ := + hinter.prefix_occurrences y (w.length - 1) (by omega) hypre + have hyeq := wordPrimeContribution_restrict h w y (w.length - 1) a b hbn hyinterval + by_cases hzd : (z : ℤ) ∣ wordPrimeContribution h w y 0 (w.length - 1) + · have hdiv : (z : ℤ) ∣ intervalDisplacement (wordStepDisplacement h w) a b := by + rwa [hyeq] at hzd + have hab2 : a + 1 < b := by + by_contra hn + have hb : b = a + 1 := by omega + have hd := hoff z a ⟨w.length - 1, hzlast⟩ (by omega) (hzearly a (by omega)) + exact hd (by simpa only [hb, intervalDisplacement_singleton] using hdiv) + have ha : a = 0 := by + by_contra hn + exact hw.no_reversed_divisible_interval (by omega) hab2 (by omega) + hzlast (hzearly a (by omega)) hdiv + obtain ⟨z', hz'one, hz'zero⟩ := hnew 0 (by omega) + obtain ⟨a', b', hab', hb'b, hz'interval⟩ := + hinter.prefix_occurrences z' b (by omega) ⟨1, by omega, hz'one⟩ + have ha' : a' = 1 := by + have hle := ((hz'interval 1 (by omega)).mp hz'one).1 + have hne : a' ≠ 0 := by + intro heq + have hp := (hz'interval a' (by omega)).mpr ⟨le_rfl, hab'⟩ + exact hz'zero (by simpa only [heq] using hp) + omega + have hzeq := wordPrimeContribution_restrict h w z' b a' b' hb'b hz'interval + have hnonzero : ¬(z : ℤ) ∣ wordPrimeContribution h w z' 0 b := by + intro hzero + have hdiv' : (z : ℤ) ∣ intervalDisplacement (wordStepDisplacement h w) 1 b' := by + simpa only [hzeq, ha'] using hzero + have hb' : 2 < b' := by + by_contra hn + have hb'eq : b' = 1 + 1 := by omega + exact (hoff z 1 ⟨w.length - 1, hzlast⟩ (by omega) (hzearly 1 (by omega))) + (by simpa only [hb'eq, intervalDisplacement_singleton] using hdiv') + exact hw.no_reversed_divisible_interval (by omega) hb' (by omega) + hzlast (hzearly 1 (by omega)) hdiv' + have hz'active : ActivePrime h w z' := by + refine ⟨z, 0, b, by omega, by omega, ⟨w.length - 1, hzlast⟩, ?_, hnonzero⟩ + simpa only [ha] using hdiv + right + refine ⟨z', 1, hz'active, hz'one, ?_⟩ + have hyzero : TuplePrimeAt w y 0 := (hyinterval 0 (by omega)).mpr ⟨by omega, by omega⟩ + rw [wordPrimeContribution_eq_singleton h w y 0 1 0 (by simp) hyzero] + · exact hoff z' 0 ⟨1, hz'one⟩ (by omega) hz'zero + · intro i hi _ + have := mem_Ico.mp hi + omega + · exact Or.inr ⟨z, w.length - 1, hzactive, hzlast, hzd⟩ + · left + have hyearly : ∀ i, i < w.length - 1 → ¬TuplePrimeAt w y i := by + intro i hi hpi + exact hypre ⟨i, hi, hpi⟩ + obtain ⟨j, hyj⟩ := hy + have hj := hyj.index_lt + have hjeq : j = w.length - 1 := by + by_contra hn + exact hyearly j (by omega) hyj + exact hw.1.last_new_active (hjeq ▸ hyj) hyearly hoff + +/-- Equal-size squarefree tuples that change must also acquire a new prime. -/ +lemma adjacent_tuple_new_prime (w : List SignedStep) (J : ℕ) + (hsq : ∀ a ∈ w, Squarefree a.tuple) + (hcard : ∀ a ∈ w, a.tuple.primeFactors.card = J) + (hchain : w.IsChain (fun a b => a.tuple ≠ b.tuple)) : + ∀ i, i + 1 < w.length → ∃ p, TuplePrimeAt w p (i + 1) ∧ ¬TuplePrimeAt w p i := by + intro i hi + have hi0 : i < w.length := by omega + have ha := List.getElem_mem hi0 + have hb := List.getElem_mem hi + have hneq : w[i].tuple ≠ w[i + 1].tuple := (List.isChain_iff_getElem.mp hchain) i hi + have hsets : w[i + 1].tuple.primeFactors ≠ w[i].tuple.primeFactors := by + intro heq + apply hneq + calc + _ = ∏ p ∈ w[i].tuple.primeFactors, p := (Nat.prod_primeFactors_of_squarefree (hsq _ ha)).symm + _ = ∏ p ∈ w[i + 1].tuple.primeFactors, p := by rw [heq] + _ = _ := Nat.prod_primeFactors_of_squarefree (hsq _ hb) + have hnot : ¬w[i + 1].tuple.primeFactors ⊆ w[i].tuple.primeFactors := by + intro hsub + apply hsets + exact Finset.eq_of_subset_of_card_le hsub (by rw [hcard _ ha, hcard _ hb]) + obtain ⟨p, hpb, hpa⟩ := Finset.not_subset.mp hnot + have hp := Nat.mem_primeFactors.mp hpb + refine ⟨p, (tuplePrimeAt_iff_getElem w p (i + 1) hi).mpr ⟨hp.1, hp.2.1⟩, ?_⟩ + intro hpi + have hpai := (tuplePrimeAt_iff_getElem w p i hi0).mp hpi + exact hpa (Nat.mem_primeFactors.mpr ⟨hpai.1, hpai.2, (hsq _ ha).ne_zero⟩) + +/-- The active-label dichotomy with the manuscript's concrete arithmetic +hypotheses: squarefree whole tuples of fixed prime-factor count, and prime +exclusion from the common multiplier and all padding factors. -/ +theorem MinimalWord.active_dichotomy_of_squarefree {h s J : ℕ} + {supply : ℕ → ℕ → Prop} {w : List SignedStep} + (hw : MinimalWord (ForwardProhibited h s supply) w) + (hsq : ∀ a ∈ w, Squarefree a.tuple) + (hcard : ∀ a ∈ w, a.tuple.primeFactors.card = J) + (hsupport : ∀ p j, TuplePrimeAt w p j → ¬p ∣ h ∧ ∀ a ∈ w, ¬p ∣ a.padding) + (y : ℕ) (hy : ∃ j, TuplePrimeAt w y j) : + ActivePrime h w y ∨ ∃ z i, ActivePrime h w z ∧ TuplePrimeAt w z i ∧ + ¬(z : ℤ) ∣ wordPrimeContribution h w y 0 i := by + apply hw.active_dichotomy (adjacent_tuple_new_prime w J hsq hcard hw.1.2.2.2.1) ?_ y hy + intro p i hseen hi hnot + apply word_prime_support hsupport p i ?_ hi hnot + obtain ⟨j, hj⟩ := hseen + exact ⟨j, hj.index_lt, hj⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateBudget.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..54883a64132fd1d28948d71b72559b2aea0e2ad9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateBudget.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActiveStateExpansion + +namespace OAI + +/-! The complete low-degree state family fits the scalar-comparison budget. -/ + +namespace TwoPointCorrelations + +lemma active_state_family_cost (L : ℝ) (n M R : ℕ) + (hL : 4800 ≤ L) (hn : (n : ℝ) ≤ Real.exp L) + (hM : (M : ℝ) ≤ 400 * Real.log L) (hR : (R : ℝ) ≤ 4 * L) : + (((M + 1) * (n + 1) ^ M : ℕ) : ℝ) ^ R ≤ Real.exp (L ^ 4) := by + have hLp : 0 ≤ L := by linarith + have hlog : 0 ≤ Real.log L := Real.log_nonneg (by linarith) + have hexp : (2 : ℝ) ≤ Real.exp L := by linarith [Real.add_one_le_exp L] + have hn' : (n : ℝ) + 1 ≤ Real.exp (2 * L) := by + have he : Real.exp (2 * L) = Real.exp L * Real.exp L := by + rw [show 2 * L = L + L by ring, Real.exp_add] + rw [he] + nlinarith + have hM' : (M : ℝ) + 1 ≤ Real.exp (400 * Real.log L) := by + linarith [Real.add_one_le_exp (400 * Real.log L)] + have hbase : (((M + 1) * (n + 1) ^ M : ℕ) : ℝ) ≤ + Real.exp (1200 * L * Real.log L) := by + push_cast + calc + _ ≤ Real.exp (400 * Real.log L) * (Real.exp (2 * L)) ^ M := + mul_le_mul hM' (pow_le_pow_left₀ (by positivity) hn' M) (by positivity) (by positivity) + _ = Real.exp (400 * Real.log L + M * (2 * L)) := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have hm := mul_le_mul_of_nonneg_right hM (show 0 ≤ 2 * L by positivity) + have hl := mul_le_mul_of_nonneg_right (show 1 ≤ L by linarith) hlog + nlinarith + have hlogL : Real.log L ≤ L := + (Real.log_le_sub_one_of_pos (by linarith)).trans (by linarith) + calc + _ ≤ (Real.exp (1200 * L * Real.log L)) ^ R := + pow_le_pow_left₀ (by positivity) hbase R + _ = Real.exp (R * (1200 * L * Real.log L)) := by rw [Real.exp_nat_mul] + _ ≤ Real.exp (4800 * L ^ 3) := by + apply Real.exp_le_exp.mpr + have hr := mul_le_mul_of_nonneg_right hR + (show 0 ≤ 1200 * L * Real.log L by positivity) + have hl := mul_le_mul_of_nonneg_left hlogL (show 0 ≤ 4800 * L ^ 2 by positivity) + nlinarith + _ ≤ _ := by + apply Real.exp_le_exp.mpr + nlinarith [mul_nonneg (show 0 ≤ L - 4800 by linarith) (pow_nonneg hLp 3)] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..177dc5f7606cf48bdb237d91fad29c5260a05f4b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateComparison.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActiveStateVectors +import OAI.NumberTheory.TwoPoint.Bounds.EventualResidueComparison + +namespace OAI + +/-! Arbitrary functions of the bounded active sets at the trace vertices +are compared at every finite interval, using their exact state expansion. -/ + +namespace TwoPointCorrelations + +open Finset Filter + +theorem BravermanDepth22Input.eventually_active_state_comparison (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (m : ℕ) (s : Fin m → ℕ) [∀ i, NeZero (s i)], + 0 < m → (m : ℝ) ≤ Real.exp L + 1 → + Pairwise (fun i j => (s i).Coprime (s j)) → + (∀ i, (s i : ℝ) ≤ Real.exp L) → + ∀ (R n Ninput M : ℕ), (n : ℝ) ≤ Real.exp L → + (M : ℝ) ≤ 400 * Real.log L → (R : ℝ) ≤ 4 * L → + ∀ (coord : Fin Ninput → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) + (index : Fin R → Fin n → Fin Ninput) + (f : (Fin R → Finset (Fin n)) → ℝ), + (∀ b : Fin R → boundedActiveStates n M, + |f (fun r => (b r).val)| ≤ Real.exp (L ^ 4)) → + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let F := fun z : ∀ j, ZMod (s j) => + let bits := residueCircuitInputs s coord test z + if ∀ r, (activeState (fun i => bits (index r i))).card ≤ M + then f (fun r => activeState (fun i => bits (index r i))) else 0 + |uniformAverage (fun x : Fin N => F (fun j => (a + x.val : ZMod (s j)))) - + uniformAverage F| ≤ Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hscalar⟩ := hBr.eventually_scalar_residue_comparison 1 (by norm_num) + refine ⟨A, hA, ?_⟩ + filter_upwards [hscalar, eventually_ge_atTop (4800 : ℝ)] with L hscalar hL + intro m s _ hm hmexp hcop hs R n Ninput M hn hM hR coord test index f hf a N hN + let c := fun b : Fin R → boundedActiveStates n M => + activeStateVectorCircuit index (fun r => (b r).val) + let coeff := fun b : Fin R → boundedActiveStates n M => f (fun r => (b r).val) + have hb := hscalar m s hm hmexp hcop hs _ Ninput coord test c coeff + (fun b => (activeStateVectorCircuit_depth index _).trans (by norm_num)) + (fun b => activeStateVector_size_budget L index _ (by linarith) hn hR) + (by simpa only [one_mul] using activeStateVector_coefficient_budget L f hL hn hM hR hf) + a N hN + have hexpand (z : ∀ j, ZMod (s j)) : + (if ∀ r, (activeState (fun i => residueCircuitInputs s coord test z (index r i))).card ≤ M + then f (fun r => activeState (fun i => residueCircuitInputs s coord test z (index r i))) else 0) = + ∑ b : Fin R → boundedActiveStates n M, coeff b * + eventIndicator (residueCircuitEvent s coord test (c b)) z := + activeStateVector_scalar_expansion M index f (residueCircuitInputs s coord test z) + dsimp only + simpa only [← hexpand] using hb + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateExpansion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1be26702486198cddb862c09f781e1fc527d23d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateExpansion.lean @@ -0,0 +1,143 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitEncoding +import OAI.NumberTheory.TwoPoint.Bounds.ScalarComparison +import Mathlib.Data.Nat.Choose.Bounds + +namespace OAI + +/-! Exact active-prime states give small scalar expansions after the +degree truncation. All absent prime tests remain in each conjunction. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def activeState {n : ℕ} (x : BooleanCube n) : Finset (Fin n) := + univ.filter (fun i => x i = true) + +def boundedActiveStates (n M : ℕ) : Finset (Finset (Fin n)) := + univ.powerset.filter (fun S => S.card ≤ M) + +lemma mem_boundedActiveStates {n M : ℕ} {S : Finset (Fin n)} : + S ∈ boundedActiveStates n M ↔ S.card ≤ M := by + simp only [boundedActiveStates, mem_filter, mem_powerset, subset_univ, true_and] + +lemma boundedActiveStates_card (n M : ℕ) : + (boundedActiveStates n M).card ≤ (M + 1) * (n + 1) ^ M := by + have he : boundedActiveStates n M = + (range (M + 1)).biUnion (fun r => univ.powersetCard r) := by + ext S + simp only [mem_boundedActiveStates, mem_biUnion, mem_range, mem_powersetCard, + subset_univ, true_and] + constructor + · intro hS + exact ⟨S.card, by omega, rfl⟩ + · rintro ⟨r, hr, he⟩ + omega + rw [he] + apply (card_biUnion_le).trans + calc + (∑ r ∈ range (M + 1), (univ.powersetCard r : Finset (Finset (Fin n))).card) = + ∑ r ∈ range (M + 1), n.choose r := by + simp only [card_powersetCard, card_univ, Fintype.card_fin] + _ ≤ ∑ _r ∈ range (M + 1), (n + 1) ^ M := by + apply sum_le_sum + intro r hr + exact (Nat.choose_le_pow n r).trans + ((Nat.pow_le_pow_left (Nat.le_succ n) r).trans + (Nat.pow_le_pow_right (by omega) (by simp only [mem_range] at hr; omega))) + _ = _ := by simp + +def activeStateCircuit {n : ℕ} (S : Finset (Fin n)) : AC0Circuit n := + .andGate (fun i : Fin n => .literal i (decide (i ∈ S))) + +lemma activeStateCircuit_eval {n : ℕ} (S : Finset (Fin n)) (x : BooleanCube n) : + (activeStateCircuit S).eval x = true ↔ activeState x = S := by + simp only [activeStateCircuit, AC0Circuit.eval, decide_eq_true_eq] + constructor + · intro h + ext i + have hi := h i + by_cases hs : i ∈ S <;> cases hx : x i <;> + simp_all [activeState] + · intro h i + have hi : x i = true ↔ i ∈ S := by + rw [← h] + simp only [activeState, mem_filter, mem_univ, true_and] + by_cases hs : i ∈ S <;> cases hx : x i <;> + simp_all [activeState] + +lemma activeStateCircuit_depth {n : ℕ} (S : Finset (Fin n)) : + (activeStateCircuit S).depth ≤ 1 := by + simp [activeStateCircuit, AC0Circuit.depth] + +lemma activeStateCircuit_size {n : ℕ} (S : Finset (Fin n)) : + (activeStateCircuit S).size = 1 + n := by + simp [activeStateCircuit, AC0Circuit.size] + +theorem activeState_scalar_expansion {n : ℕ} (M : ℕ) + (f : Finset (Fin n) → ℝ) (x : BooleanCube n) : + (if (activeState x).card ≤ M then f (activeState x) else 0) = + ∑ S ∈ boundedActiveStates n M, f S * (activeStateCircuit S).indicator x := by + simp only [AC0Circuit.indicator] + have hval (S : Finset (Fin n)) : + (if (activeStateCircuit S).eval x = true then (1 : ℝ) else 0) = + if activeState x = S then 1 else 0 := by + simp only [activeStateCircuit_eval] + simp only [hval, mul_ite, mul_one, mul_zero] + by_cases hx : (activeState x).card ≤ M + · rw [ite_eq_left hx, sum_eq_single_of_mem (activeState x) (mem_boundedActiveStates.mpr hx)] + · simp + · intro S _ hS + exact ite_eq_right (Ne.symm hS) + · rw [ite_eq_right hx] + symm + apply sum_eq_zero + intro S hS + apply ite_eq_right + intro he + exact hx (he.symm ▸ mem_boundedActiveStates.mp hS) + +lemma activeState_coefficient_mass {n M : ℕ} (f : Finset (Fin n) → ℝ) (C : ℝ) + (hf : ∀ S ∈ boundedActiveStates n M, |f S| ≤ C) : + ∑ S ∈ boundedActiveStates n M, |f S| ≤ ((M + 1) * (n + 1) ^ M : ℕ) * C := by + by_cases hC : 0 ≤ C + · calc + _ ≤ ∑ _S ∈ boundedActiveStates n M, C := sum_le_sum hf + _ = ((boundedActiveStates n M).card : ℝ) * C := by simp + _ ≤ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast boundedActiveStates_card n M) hC + · have hz : ∅ ∈ boundedActiveStates n M := mem_boundedActiveStates.mpr (by simp) + exact False.elim (hC ((abs_nonneg (f ∅)).trans (hf ∅ hz))) + +theorem activeState_average_comparison {n : ℕ} {α β : Type*} [Fintype α] [Fintype β] + (M : ℕ) (f : Finset (Fin n) → ℝ) (x : α → BooleanCube n) (y : β → BooleanCube n) + (C ε : ℝ) (hε : 0 ≤ ε) + (hf : ∀ S ∈ boundedActiveStates n M, |f S| ≤ C) + (hcompare : ∀ S ∈ boundedActiveStates n M, + |uniformAverage (fun a => (activeStateCircuit S).indicator (x a)) - + uniformAverage (fun b => (activeStateCircuit S).indicator (y b))| ≤ ε) : + |uniformAverage (fun a => if (activeState (x a)).card ≤ M then f (activeState (x a)) else 0) - + uniformAverage (fun b => if (activeState (y b)).card ≤ M then f (activeState (y b)) else 0)| ≤ + (((M + 1) * (n + 1) ^ M : ℕ) : ℝ) * C * ε := by + let S := boundedActiveStates n M + have hrep (z : BooleanCube n) : + (if (activeState z).card ≤ M then f (activeState z) else 0) = + ∑ t : S, f t.val * (activeStateCircuit t.val).indicator z := by + rw [activeState_scalar_expansion] + exact (sum_coe_sort S (fun t => f t * (activeStateCircuit t).indicator z)).symm + simp_rw [hrep] + have hb := scalar_average_comparison_uniform + (fun (t : S) a => (activeStateCircuit t.val).indicator (x a)) + (fun (t : S) b => (activeStateCircuit t.val).indicator (y b)) + (fun t : S => f t.val) ε (fun t => hcompare t.val t.property) + apply hb.trans + apply mul_le_mul_of_nonneg_right _ hε + change (∑ t : boundedActiveStates n M, |f t.val|) ≤ _ + calc + _ = ∑ t ∈ boundedActiveStates n M, |f t| := + sum_coe_sort (boundedActiveStates n M) (fun t => |f t|) + _ ≤ _ := activeState_coefficient_mass f C hf + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateVectors.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateVectors.lean new file mode 100644 index 0000000000000000000000000000000000000000..11b7ca698725c684c7ff094b72179df484fe247c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateVectors.lean @@ -0,0 +1,131 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActiveStateBudget + +namespace OAI + +/-! Simultaneous bounded active states at every vertex of a trace word. +Offsets may share residue coordinates; the circuit keeps this sharing explicit. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def activeStateVectorCircuit {R n m : ℕ} (index : Fin R → Fin n → Fin m) + (S : Fin R → Finset (Fin n)) : AC0Circuit m := + .andGate (fun r => .andGate (fun i => .literal (index r i) (decide (i ∈ S r)))) + +lemma activeStateVectorCircuit_eval {R n m : ℕ} (index : Fin R → Fin n → Fin m) + (S : Fin R → Finset (Fin n)) (x : BooleanCube m) : + (activeStateVectorCircuit index S).eval x = true ↔ + ∀ r, activeState (fun i => x (index r i)) = S r := by + change (decide (∀ r, (activeStateCircuit (S r)).eval (fun i => x (index r i)) = true) = true) ↔ _ + simp only [decide_eq_true_eq, activeStateCircuit_eval] + +lemma activeStateVectorCircuit_depth {R n m : ℕ} (index : Fin R → Fin n → Fin m) + (S : Fin R → Finset (Fin n)) : (activeStateVectorCircuit index S).depth ≤ 2 := by + change 1 + (univ.sup fun r : Fin R => (activeStateCircuit (S r)).depth) ≤ 2 + have hh : (univ.sup fun r : Fin R => (activeStateCircuit (S r)).depth) ≤ 1 := + Finset.sup_le (fun r _ => activeStateCircuit_depth (S r)) + omega + +lemma activeStateVectorCircuit_size {R n m : ℕ} (index : Fin R → Fin n → Fin m) + (S : Fin R → Finset (Fin n)) : + (activeStateVectorCircuit index S).size = 1 + R * (1 + n) := by + simp [activeStateVectorCircuit, AC0Circuit.size] + +theorem activeStateVector_scalar_expansion {R n m : ℕ} (M : ℕ) + (index : Fin R → Fin n → Fin m) (f : (Fin R → Finset (Fin n)) → ℝ) + (x : BooleanCube m) : + (if ∀ r, (activeState (fun i => x (index r i))).card ≤ M + then f (fun r => activeState (fun i => x (index r i))) else 0) = + ∑ b : Fin R → boundedActiveStates n M, + f (fun r => (b r).val) * + (activeStateVectorCircuit index (fun r => (b r).val)).indicator x := by + by_cases hx : ∀ r, (activeState (fun i => x (index r i))).card ≤ M + · let b₀ : Fin R → boundedActiveStates n M := fun r => + ⟨activeState (fun i => x (index r i)), mem_boundedActiveStates.mpr (hx r)⟩ + rw [ite_eq_left hx, sum_eq_single b₀] + · have he : (activeStateVectorCircuit index (fun r => (b₀ r).val)).eval x = true := + (activeStateVectorCircuit_eval index _ x).mpr (fun _ => rfl) + simp only [AC0Circuit.indicator, he, ite_true, mul_one] + rfl + · intro b _ hb + have he : (activeStateVectorCircuit index (fun r => (b r).val)).eval x ≠ true := by + intro he + have hs := (activeStateVectorCircuit_eval index _ x).mp he + apply hb + funext r + exact Subtype.ext (hs r).symm + simp [AC0Circuit.indicator, he] + · simp + · rw [ite_eq_right hx] + symm + apply sum_eq_zero + intro b _ + have he : (activeStateVectorCircuit index (fun r => (b r).val)).eval x ≠ true := by + intro he + have hs := (activeStateVectorCircuit_eval index _ x).mp he + apply hx + intro r + rw [hs r] + exact mem_boundedActiveStates.mp (b r).property + simp [AC0Circuit.indicator, he] + +lemma activeStateVector_coefficient_mass {R n M : ℕ} + (f : (Fin R → Finset (Fin n)) → ℝ) (C : ℝ) (hC : 0 ≤ C) + (hf : ∀ b : Fin R → boundedActiveStates n M, |f (fun r => (b r).val)| ≤ C) : + (∑ b : Fin R → boundedActiveStates n M, |f (fun r => (b r).val)|) ≤ + (((M + 1) * (n + 1) ^ M : ℕ) : ℝ) ^ R * C := by + calc + _ ≤ ∑ _b : Fin R → boundedActiveStates n M, C := sum_le_sum (fun b _ => hf b) + _ = ((boundedActiveStates n M).card : ℝ) ^ R * C := by + simp only [sum_const, card_univ, Fintype.card_fun, Fintype.card_coe, Fintype.card_fin, + nsmul_eq_mul, Nat.cast_pow] + _ ≤ _ := mul_le_mul_of_nonneg_right + (pow_le_pow_left₀ (by positivity) (by exact_mod_cast boundedActiveStates_card n M) R) hC + +lemma activeStateVector_size_budget {R n m : ℕ} (L : ℝ) + (index : Fin R → Fin n → Fin m) (S : Fin R → Finset (Fin n)) + (hL : 8 ≤ L) (hn : (n : ℝ) ≤ Real.exp L) (hR : (R : ℝ) ≤ 4 * L) : + ((activeStateVectorCircuit index S).size : ℝ) ≤ Real.exp (L ^ 6) := by + rw [activeStateVectorCircuit_size] + push_cast + have hE : (9 : ℝ) ≤ Real.exp L := by linarith [Real.add_one_le_exp L] + have hEL : L ≤ Real.exp L := by linarith [Real.add_one_le_exp L] + have hE1 : (1 : ℝ) ≤ Real.exp L := by linarith + have hprod := mul_le_mul hR (show (1 : ℝ) + n ≤ 2 * Real.exp L by linarith) + (show (0 : ℝ) ≤ 1 + n by positivity) (show 0 ≤ 4 * L by linarith) + have h2 : Real.exp (2 * L) = Real.exp L * Real.exp L := by + rw [show 2 * L = L + L by ring, Real.exp_add] + have h3 : Real.exp (3 * L) = Real.exp L * Real.exp (2 * L) := by + rw [show 3 * L = L + 2 * L by ring, Real.exp_add] + have h26 : L ^ 2 ≤ L ^ 6 := pow_le_pow_right₀ (by linarith : 1 ≤ L) (by norm_num) + calc + _ ≤ 9 * Real.exp (2 * L) := by rw [h2]; nlinarith + _ ≤ Real.exp (3 * L) := by rw [h3]; exact mul_le_mul_of_nonneg_right hE (Real.exp_pos _).le + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) + +lemma activeStateVector_coefficient_budget {R n M : ℕ} (L : ℝ) + (f : (Fin R → Finset (Fin n)) → ℝ) + (hL : 4800 ≤ L) (hn : (n : ℝ) ≤ Real.exp L) + (hM : (M : ℝ) ≤ 400 * Real.log L) (hR : (R : ℝ) ≤ 4 * L) + (hf : ∀ b : Fin R → boundedActiveStates n M, + |f (fun r => (b r).val)| ≤ Real.exp (L ^ 4)) : + (∑ b : Fin R → boundedActiveStates n M, |f (fun r => (b r).val)|) ≤ + Real.exp (L ^ 5) := by + apply (activeStateVector_coefficient_mass f (Real.exp (L ^ 4)) (Real.exp_pos _).le hf).trans + calc + _ ≤ Real.exp (L ^ 4) * Real.exp (L ^ 4) := + mul_le_mul_of_nonneg_right (active_state_family_cost L n M R hL hn hM hR) (Real.exp_pos _).le + _ = Real.exp (2 * L ^ 4) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have ht := mul_le_mul_of_nonneg_right (show (2 : ℝ) ≤ L by linarith) + (pow_nonneg (show 0 ≤ L by linarith) 4) + calc + 2 * L ^ 4 ≤ L * L ^ 4 := ht + _ = L ^ 5 := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineCompression.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineCompression.lean new file mode 100644 index 0000000000000000000000000000000000000000..fdd0a26409631cc38bbe276c7328ca65da2503d5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineCompression.lean @@ -0,0 +1,141 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualAffineSpectralTail +import OAI.NumberTheory.TwoPoint.Bounds.PrimePhysicalMatrix +import OAI.NumberTheory.TwoPoint.Bounds.SpectralScale + +namespace OAI + +/-! The literal compressed graph obeys the trace bound outside an +exponentially small set of origins in each fixed progression. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def primeBlockCompression {J : ℕ} (P : Fin J → Finset ℕ) + (M : ℕ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (keep : ℤ → Prop) (c : ℤ) : + EuclideanSpace ℂ (Fin M) →L[ℂ] EuclideanSpace ℂ (Fin M) := + let B := primeFamilyGraphOperator (fun j (p : P j) => p.val) (fun _ _ => 0) + (fun i : Fin M => (i.val : ℤ) + c) Q u eligible g L K extra h + (fun d i j => gate d i.val j.val ∧ keep ((i.val : ℤ) + c) ∧ keep ((j.val : ℤ) + c)) + let proj := coordinateProjection (fun i : Fin M => + (actualPaddingDegree (univ.biUnion P) ((i.val : ℤ) + c) : ℝ) ≤ 6 * W * J) + proj * (∑ d, B d) * proj + +theorem ModFiveThetaInput.eventually_actual_affine_compression_uniform + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ + ∀ (h l : ℕ) (_hh : 0 < h) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (_hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W), + ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + ∀ gate : ℕ → ℤ → ℤ → Prop, (∀ d n m, gate d n m ↔ gate d m n) → + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + uniformAverage (fun x : Fin N => if + 3 * (Real.exp 1 * (2 * (Real.exp (4 * J) * + (2 * Real.exp 150 * Real.sqrt W) ^ J))) < + ‖primeBlockCompression P ⌈Real.exp (103 * L)⌉₊ Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + L (Real.exp (4 * J)) W (fun _ => actualPaddingDegreeCut Qp L) h gate keep + (a + l * x.val : ℕ)‖ then (1 : ℝ) else 0) ≤ + Real.exp (-(2 * ⌊L⌋₊ : ℕ)) := by + obtain ⟨A, hA, htail⟩ := hprime.eventually_actual_affine_spectral_tail_uniform hBr + refine ⟨A, hA, ?_⟩ + intro h l hh E hE hEl W hW + have htail := htail h l hh E hE hEl W hW + filter_upwards [htail, hprime.eventually_actual_pool_masses E W hW] with L htail hmass + intro hL η hη hηone eligible he + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + let M := ⌈Real.exp (103 * L)⌉₊ + have hbounds := actual_spectral_scale_bounds J K W (Real.exp_pos _).le hW + have hprimeP := centeredPrimeBands_prime E (L ^ (199 / 200 : ℝ)) W J + have hdisjoint := centeredPrimeBands_disjoint E (L ^ (199 / 200 : ℝ)) W J + (Real.rpow_nonneg (by linarith) _) (by linarith) + have hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W := fun j => (hmass.2.1 j).2.1 + intro gate hgate a N hN + have ht := htail hL η hη hηone eligible he (fun d n m => gate (∏ j, (d j).val) n m) a N hN + apply le_trans _ ht + unfold uniformAverage + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + apply sum_le_sum + intro x _ + by_cases hr : R < realMatrixSpectralRadius + (shiftMatrix (primeBlockEmbedding (P := P) M) + (integerShiftNext Q (fun d => ∏ j, (d j).val) h) + (physicalShiftWeight Q (fun d => ∏ j, (d j).val) h + (fun d n m => gate (∏ j, (d j).val) n m) + (fun t n => maskedSignedIntegerWeight Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + (fun d => centeredTuple d.primeFactors) L K + (fun _ => actualPaddingDegreeCut Qp L) h keep t + (n + (a + l * x.val : ℕ))))) + · change (if _ then (1 : ℝ) else 0) ≤ if R < _ then 1 else 0 + rw [ite_eq_left hr] + split_ifs <;> norm_num + · have hc := prime_physical_compression P hprimeP hdisjoint + (fun i : Fin M => (i.val : ℤ)) + (fun i j hij => Fin.ext (Int.ofNat_inj.mp hij)) Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) L K W + (fun _ => actualPaddingDegreeCut Qp L) h gate hgate keep (a + l * x.val : ℕ) + (by linarith) (Real.exp_pos _).le (fun q _ => actualPaddingCoefficient_nonneg q) + (actualPaddingVertex_pos Qp) hV R hbounds.1 hbounds.2.1 hbounds.2.2 + (le_of_not_gt hr) + change ‖primeBlockCompression P M Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) L K W + (fun _ => actualPaddingDegreeCut Qp L) h gate keep (a + l * x.val : ℕ)‖ ≤ 3 * R at hc + change (if 3 * R < _ then (1 : ℝ) else 0) ≤ if R < _ then 1 else 0 + rw [ite_eq_right (not_lt.mpr hc), ite_eq_right hr] + +theorem ModFiveThetaInput.eventually_actual_affine_compression + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) + (h l : ℕ) (hh : 0 < h) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + ∀ gate : ℕ → ℤ → ℤ → Prop, (∀ d n m, gate d n m ↔ gate d m n) → + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + uniformAverage (fun x : Fin N => if + 3 * (Real.exp 1 * (2 * (Real.exp (4 * J) * + (2 * Real.exp 150 * Real.sqrt W) ^ J))) < + ‖primeBlockCompression P ⌈Real.exp (103 * L)⌉₊ Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + L (Real.exp (4 * J)) W (fun _ => actualPaddingDegreeCut Qp L) h gate keep + (a + l * x.val : ℕ)‖ then (1 : ℝ) else 0) ≤ + Real.exp (-(2 * ⌊L⌋₊ : ℕ)) := by + obtain ⟨A, hA, hbound⟩ := hprime.eventually_actual_affine_compression_uniform hBr + exact ⟨A, hA, hbound h l hh E hE hEl W hW⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineIntervalMatrix.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineIntervalMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a8671038ef4291c76c631072394f60fe06917dc --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineIntervalMatrix.lean @@ -0,0 +1,156 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualIntervalMatrix +import OAI.NumberTheory.TwoPoint.Bounds.ActualPrimeAffineWordComparison + +namespace OAI + +/-! The finite-block moment on a fixed progression of origins. This +allows the progression gate to be frozen before applying the trace bound. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem ModFiveThetaInput.eventually_actual_affine_interval_matrix_uniform + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ + ∀ (h l : ℕ) (_hh : 0 < h) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (_hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W), + ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + (fun d => centeredTuple d.primeFactors) L (Real.exp (4 * J)) + (fun _ => actualPaddingDegreeCut Qp L) h + (fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ (fun d q => (d, q) ∈ data.pairs) z) + ∀ gate : ((j : Fin J) → P j) → ℤ → ℤ → Prop, + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + uniformAverage (fun x : Fin N => matrixFrobeniusSq + (shiftMatrix (primeBlockEmbedding (P := P) ⌈Real.exp (103 * L)⌉₊) + (integerShiftNext Q (fun d => ∏ j, (d j).val) h) + (physicalShiftWeight Q (fun d => ∏ j, (d j).val) h gate + (fun t n => weight t (n + (a + l * x.val : ℕ)))) ^ ⌊L⌋₊)) ≤ + (Real.exp (4 * J) * (2 * Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * ⌊L⌋₊) + 1 := by + obtain ⟨A, hA, hword⟩ := hprime.eventually_actual_prime_affine_word_comparison_uniform hBr + refine ⟨A, hA, ?_⟩ + intro h l hh E hE hEl W hW + have hword := hword h l E hE hEl W hW + filter_upwards [hword, hprime.eventually_actual_block_trace h hh E hE W hW, + eventually_ge_atTop (4800 : ℝ)] with L hword htrace hlarge + intro hL η hη hηone eligible he + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let hB := canonicalTraceFamily_residue_bound h E W L eligible hL hW hE + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + (fun d => centeredTuple d.primeFactors) L (Real.exp (4 * J)) + (fun _ => actualPaddingDegreeCut Qp L) h + (fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ (fun d q => (d, q) ∈ data.pairs) z) + let D := (j : Fin J) → P j + let M := ⌈Real.exp (103 * L)⌉₊ + let V := D × Fin M + let embed : V → D × ℤ := primeBlockEmbedding M + let tuple : D → ℕ := fun d => ∏ j, (d j).val + have hprimeP := centeredPrimeBands_prime E (L ^ (199 / 200 : ℝ)) W J + have hdisjoint := centeredPrimeBands_disjoint E (L ^ (199 / 200 : ℝ)) W J + (Real.rpow_nonneg (by linarith) _) (by linarith) + have hP (j : Fin J) : P j ⊆ data.P := centeredPrimeBand_subset_pool E _ W J j + have hsq (q : ℕ) (hq : q ∈ Q) : Squarefree q := + retainedPrimeDivisor_squarefree Qp (fun _ hp => paddingPrimeSupply_prime hp) (mem_filter.mp hq).1 + have hpool (q : ℕ) (hq : q ∈ Q) : q.primeFactors ⊆ data.Q := + retainedPrimeDivisor_factors Qp (fun _ hp => paddingPrimeSupply_prime hp) (mem_filter.mp hq).1 + intro gate a N hN + have hNpos : 0 < N := by + have : (0 : ℝ) < N := (Real.exp_pos _).trans_le hN + exact_mod_cast this + let : Nonempty (Fin N) := ⟨⟨0, hNpos⟩⟩ + have hcompare := physicalMatrix_moment_comparison embed + (primeBlockEmbedding_injective M) Q tuple h gate weight + (maskedSignedIntegerWeight_flip Q actualPaddingCoefficient _ _ _ _ _ _ h _) + (FiniteLaw.uniform (Fin N)) (data.residueLaw ⌊Real.exp L⌋₊ hB) + (fun x => (a + l * x.val : ℕ)) data.residueOrigin ⌊L⌋₊ (Real.exp (-(L ^ 9))) + (Real.exp_pos _).le ?_ + · rw [FiniteLaw.uniform_average] at hcompare + have herr := trace_interval_error_le_one L ⌊L⌋₊ (Fintype.card V) + (Fintype.card (D × (Q × Bool))) hlarge (Nat.floor_le (by linarith)) + (Nat.cast_nonneg _) (actual_prime_block_dimension E W L hW hL) + (actual_prime_alphabet_size E W L hW hlarge) + have hupper := htrace hL η hη hηone eligible he gate + have hdiff := (le_abs_self _).trans (hcompare.trans herr) + dsimp only [embed, V, D, tuple, M, weight, data, Q, Qp, P, J] at hdiff + linarith + · intro i b c hend + let enc := closedTraceEncoding Q (b, c) + have hclosed : wordDisplacement h (columnTupleWord enc.2.1 enc.1 (fun j => (enc.2.2 j).val)) = 0 := by + rw [closedTraceEncoding_word] + exact integer_closed_word_displacement Q tuple h (embed i) b c hend + have hw := hword hL η hη hηone eligible he enc.2.1 enc.1 enc.2.2 hclosed + (a + i.2.val) N hN + rw [closedTraceEncoding_word] at hw + have ht := data.residue_average_translate hB + (fun n => scalarWalkProduct h weight n (integerClosedWordCode Q tuple (b, c))) + (fun n m hnm => scalarWalkProduct_residue_congr (data.P ∪ data.Q) h weight _ + (fun t ht z z' hz => primeClosedPair_residue_congr data hB hP hprimeP hdisjoint + ⌊L ^ (1 / 10 : ℝ)⌋₊ Q actualPaddingCoefficient (fun d q => (d, q) ∈ data.pairs) + (actualPaddingVertex Qp) L (Real.exp (4 * J)) (fun _ => actualPaddingDegreeCut Qp L) + hsq hpool (actualPaddingVertex_residue_congr Qp) + (fun _ n m hnm => actualPaddingDegreeCut_residue_congr Qp L n m hnm) + b c t ht z z' (fun p => hz p.val p.property)) n m (fun p hp => hnm ⟨p, hp⟩)) + (embed i).2 + have havg : (data.residueLaw ⌊Real.exp L⌋₊ hB).average (fun r => + scalarWalkProduct h weight ((embed i).2 + data.residueOrigin r) + (integerClosedWordCode Q tuple (b, c))) = + (data.residueLaw ⌊Real.exp L⌋₊ hB).average (fun r => + scalarWalkProduct h weight (data.residueOrigin r) + (integerClosedWordCode Q tuple (b, c))) := by + simpa only [add_comm (embed i).2] using ht + rw [FiniteLaw.uniform_average] + rw [havg] + simpa only [embed, primeBlockEmbedding, Nat.cast_add, Nat.cast_mul, + add_assoc, add_left_comm (a : ℤ)] using hw + +theorem ModFiveThetaInput.eventually_actual_affine_interval_matrix + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) + (h l : ℕ) (hh : 0 < h) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + (fun d => centeredTuple d.primeFactors) L (Real.exp (4 * J)) + (fun _ => actualPaddingDegreeCut Qp L) h + (fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ (fun d q => (d, q) ∈ data.pairs) z) + ∀ gate : ((j : Fin J) → P j) → ℤ → ℤ → Prop, + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + uniformAverage (fun x : Fin N => matrixFrobeniusSq + (shiftMatrix (primeBlockEmbedding (P := P) ⌈Real.exp (103 * L)⌉₊) + (integerShiftNext Q (fun d => ∏ j, (d j).val) h) + (physicalShiftWeight Q (fun d => ∏ j, (d j).val) h gate + (fun t n => weight t (n + (a + l * x.val : ℕ)))) ^ ⌊L⌋₊)) ≤ + (Real.exp (4 * J) * (2 * Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * ⌊L⌋₊) + 1 := by + obtain ⟨A, hA, hbound⟩ := hprime.eventually_actual_affine_interval_matrix_uniform hBr + exact ⟨A, hA, hbound h l hh E hE hEl W hW⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineSpectralTail.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineSpectralTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..a47beeee5f34eb16896a15b8849a04ef514cc528 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineSpectralTail.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualAffineIntervalMatrix +import OAI.NumberTheory.TwoPoint.Bounds.MatrixSpectralTail + +namespace OAI + +/-! Exceptional origins along a fixed progression for the actual finite block. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem ModFiveThetaInput.eventually_actual_affine_spectral_tail_uniform + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ + ∀ (h l : ℕ) (_hh : 0 < h) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (_hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W), + ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + (fun d => centeredTuple d.primeFactors) L (Real.exp (4 * J)) + (fun _ => actualPaddingDegreeCut Qp L) h + (fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ (fun d q => (d, q) ∈ data.pairs) z) + ∀ gate : ((j : Fin J) → P j) → ℤ → ℤ → Prop, + let matrix := fun c : ℤ => shiftMatrix + (primeBlockEmbedding (P := P) ⌈Real.exp (103 * L)⌉₊) + (integerShiftNext Q (fun d => ∏ j, (d j).val) h) + (physicalShiftWeight Q (fun d => ∏ j, (d j).val) h gate + (fun t n => weight t (n + c))) + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + uniformAverage (fun x : Fin N => if + Real.exp 1 * (2 * (Real.exp (4 * J) * (2 * Real.exp 150 * Real.sqrt W) ^ J)) < + realMatrixSpectralRadius (matrix (a + l * x.val : ℕ)) then (1 : ℝ) else 0) ≤ + Real.exp (-(2 * ⌊L⌋₊ : ℕ)) := by + obtain ⟨A, hA, htrace⟩ := hprime.eventually_actual_affine_interval_matrix_uniform hBr + refine ⟨A, hA, ?_⟩ + intro h l hh E hE hEl W hW + have htrace := htrace h l hh E hE hEl W hW + filter_upwards [htrace] with L htrace + intro hL η hη hηone eligible he + dsimp only + intro gate a N hN + have hNpos : 0 < N := by + have : (0 : ℝ) < N := (Real.exp_pos _).trans_le hN + exact_mod_cast this + let : Nonempty (Fin N) := ⟨⟨0, hNpos⟩⟩ + have hk : 0 < ⌊L⌋₊ := (Nat.le_floor_iff (by linarith : 0 ≤ L)).mpr (by simpa using hL) + have hsqrt : 1 ≤ Real.sqrt W := by simpa using Real.sqrt_le_sqrt hW + have hbase : 1 ≤ Real.exp (4 * (primeSupplyCount W L : ℝ)) * + (2 * Real.exp 150 * Real.sqrt W) ^ primeSupplyCount W L := by + have hinner : 1 ≤ 2 * Real.exp 150 * Real.sqrt W := by + have hx : 1 ≤ 2 * Real.exp 150 := by linarith [Real.one_le_exp (show (0 : ℝ) ≤ 150 by norm_num)] + simpa only [one_mul] using mul_le_mul hx hsqrt zero_le_one (by positivity) + simpa only [one_mul] using mul_le_mul + (Real.one_le_exp (show 0 ≤ 4 * (primeSupplyCount W L : ℝ) by positivity)) + (one_le_pow₀ hinner) zero_le_one (Real.exp_pos _).le + have hm := htrace hL η hη hηone eligible he gate a N hN + rw [← FiniteLaw.uniform_average] at hm + have ht := (FiniteLaw.uniform (Fin N)).matrix_spectral_tail_add_one _ ⌊L⌋₊ hk _ hbase hm + simpa only [FiniteLaw.probability, FiniteLaw.uniform_average] using ht + +theorem ModFiveThetaInput.eventually_actual_affine_spectral_tail + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) + (h l : ℕ) (hh : 0 < h) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + (fun d => centeredTuple d.primeFactors) L (Real.exp (4 * J)) + (fun _ => actualPaddingDegreeCut Qp L) h + (fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ (fun d q => (d, q) ∈ data.pairs) z) + ∀ gate : ((j : Fin J) → P j) → ℤ → ℤ → Prop, + let matrix := fun c : ℤ => shiftMatrix + (primeBlockEmbedding (P := P) ⌈Real.exp (103 * L)⌉₊) + (integerShiftNext Q (fun d => ∏ j, (d j).val) h) + (physicalShiftWeight Q (fun d => ∏ j, (d j).val) h gate + (fun t n => weight t (n + c))) + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + uniformAverage (fun x : Fin N => if + Real.exp 1 * (2 * (Real.exp (4 * J) * (2 * Real.exp 150 * Real.sqrt W) ^ J)) < + realMatrixSpectralRadius (matrix (a + l * x.val : ℕ)) then (1 : ℝ) else 0) ≤ + Real.exp (-(2 * ⌊L⌋₊ : ℕ)) := by + obtain ⟨A, hA, hbound⟩ := hprime.eventually_actual_affine_spectral_tail_uniform hBr + exact ⟨A, hA, hbound h l hh E hE hEl W hW⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineTesting.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineTesting.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6d0d0a9190478ff093e2dae6a54388993720d6f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineTesting.lean @@ -0,0 +1,144 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualAffineCompression +import OAI.NumberTheory.TwoPoint.Bounds.ProjectedGraphTesting + +namespace OAI + +/-! Average the actual graph test over fixed-progression block origins, +using compression on good blocks and the deterministic bound elsewhere. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem ModFiveThetaInput.eventually_actual_affine_testing_uniform + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ + ∀ (h l : ℕ) (_hh : 0 < h) (_hl : 0 < l) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (_hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W), + ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + ∀ gate : ℕ → ℤ → ℤ → Prop, (∀ d n m, gate d n m ↔ gate d m n) → + ∀ f : ℤ → ℂ, (∀ n, ‖f n‖ ≤ 1) → + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let M := ⌈Real.exp (103 * L)⌉₊ + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + uniformAverage (fun x : Fin N => + let v := paddingTestVector Qp L (fun i : Fin M => (i.val : ℤ) + (a + l * x.val : ℕ)) f + ‖inner ℂ v (primeBlockCompression P M Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + L K W (fun _ => actualPaddingDegreeCut Qp L) h gate keep + (a + l * x.val : ℕ) v)‖) ≤ + (3 * R) * ((l : ℝ) * (2 * M * paddingTiltNormalizer Qp)) + + ((M : ℝ) * (2 * K * (8 * W) ^ J) * (5 : ℝ) ^ (400 * Real.log L)) * + Real.exp (-(2 * ⌊L⌋₊ : ℕ)) := by + obtain ⟨Ac, hAc, hcomp⟩ := hprime.eventually_actual_affine_compression_uniform hBr + obtain ⟨Av, hAv, hnorm⟩ := hBr.eventually_padding_test_progression_norm + refine ⟨Ac + Av, by omega, ?_⟩ + intro h l hh hl E hE hEl W hW + have hcomp := hcomp h l hh E hE hEl W hW + filter_upwards [hcomp, hnorm, hprime.eventually_actual_pool_masses E W hW] + with L hcomp hnorm hmass + intro hL η hη hηone eligible he + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + let M := ⌈Real.exp (103 * L)⌉₊ + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + have hprimeP := centeredPrimeBands_prime E (L ^ (199 / 200 : ℝ)) W J + have hdisjoint := centeredPrimeBands_disjoint E (L ^ (199 / 200 : ℝ)) W J + (Real.rpow_nonneg (by linarith) _) (by linarith) + have hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W := fun j => (hmass.2.1 j).2.1 + intro gate hgate f hf a N hN + have hNc : Real.exp (L ^ Ac / 2) ≤ (N : ℝ) := + (Real.exp_le_exp.mpr (div_le_div_of_nonneg_right + (pow_le_pow_right₀ hL (Nat.le_add_right Ac Av)) (by norm_num))).trans hN + have hNv : Real.exp (L ^ Av / 2) ≤ (N : ℝ) := + (Real.exp_le_exp.mpr (div_le_div_of_nonneg_right + (pow_le_pow_right₀ hL (Nat.le_add_left Av Ac)) (by norm_num))).trans hN + have hNpos : 0 < N := by exact_mod_cast (Real.exp_pos _).trans_le hN + let : Nonempty (Fin N) := ⟨⟨0, hNpos⟩⟩ + let T (x : Fin N) := primeBlockCompression P M Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + L K W (fun _ => actualPaddingDegreeCut Qp L) h gate keep (a + l * x.val : ℕ) + let v (x : Fin N) := paddingTestVector Qp L + (fun i : Fin M => (i.val : ℤ) + (a + l * x.val : ℕ)) f + have hb := hcomp hL η hη hηone eligible he gate hgate a N hNc + have hv := hnorm Qp (fun p hp => paddingPrimeSupply_prime hp) + (fun p hp => paddingPrimeSupply_bounds E L hp) (fun i : Fin M => (i.val : ℤ)) f hf a l N hl hNv + have hv' : uniformAverage (fun x : Fin N => ‖v x‖ ^ 2) ≤ + (l : ℝ) * (2 * M * paddingTiltNormalizer Qp) := by + simpa only [v, add_comm ((a + l * _ : ℕ) : ℤ), Fintype.card_fin] using hv + have htest := (FiniteLaw.uniform (Fin N)).average_operator_test T v + (3 * R) ((M : ℝ) * (2 * K * (8 * W) ^ J) * (5 : ℝ) ^ (400 * Real.log L)) + ((l : ℝ) * (2 * M * paddingTiltNormalizer Qp)) (Real.exp (-(2 * ⌊L⌋₊ : ℕ))) + (by positivity) (by positivity) ?_ ?_ ?_ + · simpa only [FiniteLaw.uniform_average, T, v, R, K, M, keep, data, Q, Qp, P, J] using htest + · simpa only [FiniteLaw.uniform_average] using hv' + · simpa only [FiniteLaw.probability, FiniteLaw.uniform_average, T, R, K, M, keep, data, Q, Qp, P, J] using hb + · intro x _ + have ht := projected_padding_graph_test P hprimeP hdisjoint + (fun i : Fin M => (i.val : ℤ) + (a + l * x.val : ℕ)) + (fun i j hij => Fin.ext (Int.ofNat_inj.mp (add_right_cancel hij))) + Q Qp actualPaddingCoefficient (fun d q => (d, q) ∈ data.pairs) L K W + (fun _ => actualPaddingDegreeCut Qp L) h + (fun d i j => gate d i.val j.val ∧ keep ((i.val : ℤ) + (a + l * x.val : ℕ)) ∧ + keep ((j.val : ℤ) + (a + l * x.val : ℕ))) + (by linarith) (Real.exp_pos _).le (by linarith) + (fun q _ => actualPaddingCoefficient_nonneg q) hV f hf + simpa only [primeBlockCompression, T, v, Fintype.card_fin] using ht + +theorem ModFiveThetaInput.eventually_actual_affine_testing + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) + (h l : ℕ) (hh : 0 < h) (hl : 0 < l) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + ∀ gate : ℕ → ℤ → ℤ → Prop, (∀ d n m, gate d n m ↔ gate d m n) → + ∀ f : ℤ → ℂ, (∀ n, ‖f n‖ ≤ 1) → + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let M := ⌈Real.exp (103 * L)⌉₊ + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + uniformAverage (fun x : Fin N => + let v := paddingTestVector Qp L (fun i : Fin M => (i.val : ℤ) + (a + l * x.val : ℕ)) f + ‖inner ℂ v (primeBlockCompression P M Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + L K W (fun _ => actualPaddingDegreeCut Qp L) h gate keep + (a + l * x.val : ℕ) v)‖) ≤ + (3 * R) * ((l : ℝ) * (2 * M * paddingTiltNormalizer Qp)) + + ((M : ℝ) * (2 * K * (8 * W) ^ J) * (5 : ℝ) ^ (400 * Real.log L)) * + Real.exp (-(2 * ⌊L⌋₊ : ℕ)) := by + obtain ⟨A, hA, hbound⟩ := hprime.eventually_actual_affine_testing_uniform hBr + exact ⟨A, hA, hbound h l hh hl E hE hEl W hW⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineWordComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineWordComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..791e24d66bd29169a686ca59938fad028849ef70 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualAffineWordComparison.lean @@ -0,0 +1,123 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualWordComparison +import OAI.NumberTheory.TwoPoint.Bounds.AffineWeightedWordComparison + +namespace OAI + +/-! The concrete signed masked word on a fixed arithmetic progression +of origins, preserving the original residue-model expectation. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +local instance affineWordPrime_neZero {h J M : ℕ} (data : ProhibitedPrimeFamily h J M) + (i : Fin (Fintype.card ↥(data.P ∪ data.Q))) : + NeZero (primeResidueModuli (data.P ∪ data.Q) i) := + ⟨(primeResidueModuli_prime _ (fun p hp => data.prime ⟨p, hp⟩) i).ne_zero⟩ + +theorem BravermanDepth22Input.eventually_actual_affine_word_comparison (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M R s B : ℕ) (data : ProhibitedPrimeFamily h J M) + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + (s : ℝ) ≤ L → ((J + M : ℕ) : ℝ) ≤ L ^ 2 → + (data.pairs.card : ℝ) ≤ Real.exp (101 * L) → + 0 < R → ((R + 1 : ℕ) : ℝ) ≤ 4 * L → ((R * J : ℕ) : ℝ) ≤ L ^ 2 → + ∀ (Q : Finset ℕ), Q ⊆ retainedPrimeDivisors data.Q → + ∀ (P : Fin J → Finset ℕ) + (w : ColumnPrimeAssignment J R P) (forward : Fin R → Bool) (padding : Fin R → ℕ), + (∀ j, ∀ p ∈ P j, p.Prime) → + (∀ j l, l ≠ j → Disjoint (P j) (P l)) → + (∀ i, ((padding i).primeFactors.card : ℝ) ≤ 100 * Real.log L) → + ∀ (label : Fin R × Fin J → ↥(data.P ∪ data.Q)), + (∀ i j, (label (i, j)).val = (w j i).val) → + wordDisplacement h (columnTupleWord w forward padding) = 0 → + ∀ (eligible : ℕ → ℕ → Prop) (K : ℝ) (a l N : ℕ), + (∀ p ∈ data.P ∪ data.Q, l.Coprime p) → Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient eligible + (actualPaddingVertex data.Q) (fun d => centeredTuple d.primeFactors) L K + (fun _ => actualPaddingDegreeCut data.Q L) h + (fun z => ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) z) + |uniformAverage (fun x : Fin N => scalarWalkProduct h weight (a + l * x.val) + (columnTupleWord w forward padding)) - + (data.residueLaw B hB).average (fun r => scalarWalkProduct h weight (data.residueOrigin r) + (columnTupleWord w forward padding))| ≤ Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hcomp⟩ := hBr.eventually_affine_weighted_word_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hcomp, eventually_ge_atTop (4800 : ℝ)] with L hcomp hL + intro h J M R s B data hB hpool hBL hs hJM hpairs hR hRL hRJ Q hQ P w forward padding + hprime hdisjoint hdeg label hlabel hclosed eligible K a l N hl hN + let m := Fintype.card ↥data.Q + let e : Fin m ≃ data.Q := (Fintype.equivFin ↥data.Q).symm + let primes := data.P ∪ data.Q + let modulus := primeResidueModuli primes + let (i : Fin (Fintype.card primes)) : NeZero (modulus i) := + ⟨(primeResidueModuli_prime primes (fun p hp => data.prime ⟨p, hp⟩) i).ne_zero⟩ + let step := fun i => SignedStep.mk (forward i) (columnTuple w i) (padding i) + let literal := actualWordLiterals data s e step label + let F := fun z : ∀ i, ZMod (modulus i) => actualWordBoolean data s Q e step + (fun i j => (w j i).val) eligible L K + (residueCircuitInputs modulus (primeLiteralCoordinate primes literal) (primeLiteralTest primes literal) z) + have hp : ∀ p ∈ primes, p.Prime := fun p hp => data.prime ⟨p, hp⟩ + have hcard : (Fintype.card primes : ℝ) ≤ Real.exp L := by + have hb := primePool_card_bound primes hp B hB + have hb' : (primes.card : ℝ) ≤ B := by exact_mod_cast hb + simpa only [Fintype.card_coe] using hb'.trans hBL + have hm : (m : ℝ) ≤ Real.exp L := by + have he : m = data.Q.card := by simpa only [Fintype.card_fin, Fintype.card_coe] using Fintype.card_congr e + rw [he] + have hq : (data.Q.card : ℝ) ≤ primes.card := by + exact_mod_cast card_le_card (subset_union_right : data.Q ⊆ primes) + exact hq.trans (by simpa only [Fintype.card_coe] using hcard) + have hpzero : 0 < Fintype.card primes := by + simpa only [Fintype.card_coe] using card_pos.mpr hpool + have hmod : ∀ i, (modulus i : ℝ) ≤ Real.exp L := by + intro i + exact primeResidueModuli_bound primes (Real.exp L) + (fun p hp => (show (p : ℝ) ≤ B by exact_mod_cast hB p hp).trans hBL) i + have hR' : (R : ℝ) ≤ 4 * L := by push_cast at hRL; linarith + have hsize := prohibitedWordKeepCircuit_size_budget data.pairs h s (J + M) + (actualWordBadIndex data s R m) L (by linarith) hRL hs hJM hpairs + (data.pair_primeFactors_card) + have hc := hcomp (Fintype.card primes) modulus hpzero (by linarith) + (primeResidueModuli_coprime primes hp) hmod (R + 1) m (R * J) _ ⌊400 * Real.log L⌋₊ + hm (Nat.floor_le (mul_nonneg (by norm_num) (Real.log_nonneg (by linarith)))) hRL hRJ + (primeLiteralCoordinate primes literal) (primeLiteralTest primes literal) + (actualWordQIndex data s R m) (actualWordPIndex data s R m) + (actualWordCoefficient data.Q Q e (fun t => eligible t.tuple) L K step (fun i j => (w j i).val)) + (prohibitedWordKeepCircuit data.pairs h s (actualWordBadIndex data s R m)) + (fun b => actualWordCoefficient_budget data.Q Q e (fun t => eligible t.tuple) L K step _ + (fun i j => hprime j _ (w j i).property) hL hR' hdeg _ _) + ((prohibitedWordKeepCircuit_depth data.pairs h s _).trans (by norm_num)) hsize a l N (fun i => hl _ ((Fintype.equivFin primes).symm i).property) hN + change |uniformAverage (fun x : Fin N => F (fun i => (a + l * x.val : ZMod (modulus i)))) - + uniformAverage F| ≤ Real.exp (-(L ^ 9)) at hc + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient eligible + (actualPaddingVertex data.Q) (fun d => centeredTuple d.primeFactors) L K + (fun _ => actualPaddingDegreeCut data.Q L) h + (fun z => ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) z) + have hF (n : ℤ) : F (fun i => (n : ZMod (modulus i))) = + scalarWalkProduct h weight n (columnTupleWord w forward padding) := + actualWordBoolean_integer data s Q hQ e w forward padding hprime hdisjoint label hlabel + eligible L K (by linarith) n hR hclosed + have hmodel : (data.residueLaw B hB).average (fun r => + scalarWalkProduct h weight (data.residueOrigin r) (columnTupleWord w forward padding)) = + uniformAverage F := by + rw [← data.residue_average_canonical hB F] + apply congrArg (data.residueLaw B hB).average + funext r + rw [← hF, data.canonical_origin] + dsimp only + rw [hmodel] + have hsample : (fun x : Fin N => scalarWalkProduct h weight (a + l * x.val) + (columnTupleWord w forward padding)) = + (fun x : Fin N => F (fun i => (a + l * x.val : ZMod (modulus i)))) := by + funext x + simpa only [Int.cast_add, Int.cast_mul, Int.cast_natCast, Nat.cast_add, Nat.cast_mul] using + (hF (a + l * x.val)).symm + rw [hsample] + exact hc + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualBilinearTesting.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualBilinearTesting.lean new file mode 100644 index 0000000000000000000000000000000000000000..607de1df6a02a1505a56a2ead2808dcf0948963c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualBilinearTesting.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualAffineTesting +import OAI.NumberTheory.TwoPoint.Bounds.PaddingPolarization + +namespace OAI + +/-! Two bounded sequences in the already-proved canonical graph estimate. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem ModFiveThetaInput.eventually_actual_affine_bilinear_testing + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ + ∀ (h l : ℕ) (_hh : 0 < h) (_hl : 0 < l) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (_hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W), + ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + ∀ gate : ℕ → ℤ → ℤ → Prop, (∀ d n m, gate d n m ↔ gate d m n) → + ∀ f g : ℤ → ℂ, (∀ n, ‖f n‖ ≤ 1) → (∀ n, ‖g n‖ ≤ 1) → + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let M := ⌈Real.exp (103 * L)⌉₊ + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + uniformAverage (fun x : Fin N => + let u := paddingTestVector Qp L (fun i : Fin M => (i.val : ℤ) + (a + l * x.val : ℕ)) f + let v := paddingTestVector Qp L (fun i : Fin M => (i.val : ℤ) + (a + l * x.val : ℕ)) g + ‖inner ℂ u (primeBlockCompression P M Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + L K W (fun _ => actualPaddingDegreeCut Qp L) h gate keep + (a + l * x.val : ℕ) v)‖) ≤ + 4 * ((3 * R) * ((l : ℝ) * (2 * M * paddingTiltNormalizer Qp)) + + ((M : ℝ) * (2 * K * (8 * W) ^ J) * (5 : ℝ) ^ (400 * Real.log L)) * + Real.exp (-(2 * ⌊L⌋₊ : ℕ))) := by + obtain ⟨A, hA, ht⟩ := hprime.eventually_actual_affine_testing_uniform hBr + refine ⟨A, hA, ?_⟩ + intro h l hh hl E hE hEl W hW + filter_upwards [ht h l hh hl E hE hEl W hW] with L htest + intro hL η hη hηone eligible he + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + let M := ⌈Real.exp (103 * L)⌉₊ + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + intro gate hgate f g hf hg a N hN + let site (x : Fin N) (i : Fin M) := (i.val : ℤ) + (a + l * x.val : ℕ) + let T (x : Fin N) := primeBlockCompression P M Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + L K W (fun _ => actualPaddingDegreeCut Qp L) h gate keep (a + l * x.val : ℕ) + apply uniformAverage_padding_bilinear Qp L site T _ ?_ f g hf hg + intro F hF + exact htest hL η hη hηone eligible he gate hgate F hF a N hN + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualBlockTrace.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualBlockTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..7633c751a0a1c41c925492677b0a0ba5bdacd583 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualBlockTrace.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualPrimeMatrix +import OAI.NumberTheory.TwoPoint.Bounds.PrimeBlockDimension + +namespace OAI + +/-! The actual finite block has the dimension required by the residue trace bound. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +def primeBlockEmbedding {J : ℕ} {P : Fin J → Finset ℕ} (N : ℕ) : + (((j : Fin J) → P j) × Fin N) → (((j : Fin J) → P j) × ℤ) := + fun x => (x.1, (x.2.val : ℤ)) + +lemma primeBlockEmbedding_injective {J : ℕ} {P : Fin J → Finset ℕ} (N : ℕ) : + Function.Injective (primeBlockEmbedding (P := P) N) := by + intro a b hab + apply Prod.ext + · exact congrArg (fun z : ((j : Fin J) → P j) × ℤ => z.1) hab + · apply Fin.ext + have he : (a.2.val : ℤ) = (b.2.val : ℤ) := congrArg Prod.snd hab + exact_mod_cast he + +theorem ModFiveThetaInput.eventually_actual_block_trace (hprime : ModFiveThetaInput) + (h : ℕ) (hh : 0 < h) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) (W : ℝ) (hW : 1 ≤ W) : + ∀ᶠ L : ℝ in atTop, ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let B := ⌊Real.exp L⌋₊ + let hB := canonicalTraceFamily_residue_bound h E W L eligible hL hW hE + let g := actualPaddingVertex Qp + let keep := fun n => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) n + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) g (fun d => centeredTuple d.primeFactors) + L (Real.exp (4 * J)) (fun _ => actualPaddingDegreeCut Qp L) h keep + let N := ⌈Real.exp (103 * L)⌉₊ + ∀ gate : ((j : Fin J) → P j) → ℤ → ℤ → Prop, + (data.residueLaw B hB).average (fun r => matrixFrobeniusSq + (shiftMatrix (primeBlockEmbedding (P := P) N) + (integerShiftNext Q (fun d => ∏ j, (d j).val) h) + (physicalShiftWeight Q (fun d => ∏ j, (d j).val) h gate + (fun t n => weight t (n + data.residueOrigin r))) ^ ⌊L⌋₊)) ≤ + (Real.exp (4 * J) * (2 * Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * ⌊L⌋₊) := by + filter_upwards [hprime.eventually_actual_prime_matrix_trace h hh E hE W hW] with L htrace + intro hL η hη hηone eligible he + dsimp only + intro gate + exact htrace hL η hη hηone eligible he _ (primeBlockEmbedding _) + (primeBlockEmbedding_injective _) (actual_prime_block_dimension E W L hW hL) gate + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualCenterDegree.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualCenterDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3c4934d6280be0fdb8bf1839d4be03c89444a7f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualCenterDegree.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeDegreeTail +import OAI.NumberTheory.TwoPoint.Walks.TuplePrimeArithmetic + +namespace OAI + +/-! Specialize the arithmetic-geometric mean bound to the literal tuple +centers and the degree projection of the integer graph. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma actualPaddingDegree_biUnion {J : ℕ} (P : Fin J → Finset ℕ) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) (n : ℤ) : + actualPaddingDegree (univ.biUnion P) n = ∑ j, actualPaddingDegree (P j) n := by + have he : (univ.biUnion P).filter (fun p : ℕ => (p : ℤ) ∣ n) = + univ.biUnion (fun j => (P j).filter (fun p : ℕ => (p : ℤ) ∣ n)) := by + ext p + simp only [mem_filter, mem_biUnion, mem_univ, true_and] + aesop + unfold actualPaddingDegree + rw [he, card_biUnion] + intro j _ l _ hjl + exact (hdisjoint j l (Ne.symm hjl)).mono (filter_subset _ _) (filter_subset _ _) + +lemma prime_band_indicator_sum {J : ℕ} (P : Fin J → Finset ℕ) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) (n : ℤ) : + (∑ j : Fin J, ∑ p : P j, if (p.val : ℤ) ∣ n then (1 : ℝ) else 0) = + (actualPaddingDegree (univ.biUnion P) n : ℝ) := by + rw [actualPaddingDegree_biUnion P hdisjoint, Nat.cast_sum] + simp [actualPrimeDegree_eq_count, booleanCount] + +theorem actual_centeredTuple_square_sum_le {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) (n : ℤ) (W : ℝ) + (hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W) + (hdegree : (actualPaddingDegree (univ.biUnion P) n : ℝ) ≤ 6 * W * J) : + (∑ d : (j : Fin J) → P j, + |centeredTuple (∏ j, (d j).val).primeFactors n| ^ 2) ≤ (8 * W) ^ J := by + have hd : (∑ j : Fin J, ∑ p : P j, + if (p.val : ℤ) ∣ n then (1 : ℝ) else 0) ≤ 6 * W * J := by + rw [actualPaddingDegree_biUnion P hdisjoint, Nat.cast_sum] at hdegree + simpa [actualPrimeDegree_eq_count, booleanCount] using hdegree + have hb := familyCenter_square_sum_le (fun j (p : P j) => p.val) + (fun j p => hprime j _ p.property) (fun _ _ => 0) n W + (fun j => hV j) (by simpa only [zero_add, Fintype.card_fin] using hd) + simpa only [familyCenter_zero_eq_centeredTuple _ (fun j p => hprime j _ p.property) + _ (selectedPrimeValues_injective _ hdisjoint), familyTuple, Fintype.card_fin] using hb + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualClosedPairCatalog.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualClosedPairCatalog.lean new file mode 100644 index 0000000000000000000000000000000000000000..f48967c983e45efa312a40ce2cbab07f4c149068 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualClosedPairCatalog.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResidueMatrixMoment +import OAI.NumberTheory.TwoPoint.Walks.ClosedTraceSummation +import OAI.NumberTheory.TwoPoint.Bounds.PrimeMatrixResidues +import OAI.NumberTheory.TwoPoint.Bounds.PhysicalPathSupport + +namespace OAI + +/-! The actual trace catalog retains the numerical masks and allowed pair support. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {D V : Type*} [DecidableEq D] [Fintype D] [Fintype V] + +def closedPairNumericalTest (embed : V → D × ℤ) (Q : Finset ℕ) (tuple : D → ℕ) + (h : ℕ) (gate : D → ℤ → ℤ → Prop) {k : ℕ} (x : D × ℤ) + (p : (Fin k → D × (Q × Bool)) × (Fin k → D × (Q × Bool))) : Prop := + shiftWordEnd (integerShiftNext Q tuple h) x p.1 = + shiftWordEnd (integerShiftNext Q tuple h) x p.2 ∧ + integerPathMask embed Q tuple h gate x p.1 ≠ 0 ∧ + integerPathMask embed Q tuple h gate x p.2 ≠ 0 + +noncomputable def actualClosedPairCatalog (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (h : ℕ) (gate : D → ℤ → ℤ → Prop) (pairs : Finset (ℕ × ℕ)) + (k : ℕ) (x : D × ℤ) : + Finset ((Fin k → D × (Q × Bool)) × (Fin k → D × (Q × Bool))) := + univ.filter (fun p => closedPairNumericalTest embed Q tuple h gate x p ∧ + ∀ t ∈ integerClosedWordCode Q tuple p, (t.tuple, t.padding) ∈ pairs) + +omit [DecidableEq D] [Fintype V] in +theorem actualClosedPairCatalog_sum {h J M B k : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (embed : V → D × ℤ) (Q : Finset ℕ) (tuple : D → ℕ) + (gate : D → ℤ → ℤ → Prop) (weight : SignedStep → ℤ → ℝ) + (hsupport : ∀ t n, weight t n ≠ 0 → (t.tuple, t.padding) ∈ data.pairs) + (x : D × ℤ) : + (∑ a : Fin k → D × (Q × Bool), ∑ b : Fin k → D × (Q × Bool), + if closedPairNumericalTest embed Q tuple h gate x (a, b) then + |(data.residueLaw B hB).average (fun r => scalarWalkProduct h weight + (data.residueOrigin r) (integerClosedWordCode Q tuple (a, b)))| else 0) = + ∑ p ∈ actualClosedPairCatalog embed Q tuple h gate data.pairs k x, + |(data.residueLaw B hB).average (fun r => scalarWalkProduct h weight + (data.residueOrigin r) (integerClosedWordCode Q tuple p))| := by + simp only [actualClosedPairCatalog, sum_filter, Fintype.sum_prod_type] + apply sum_congr rfl + intro a _ + apply sum_congr rfl + intro b _ + by_cases hv : closedPairNumericalTest embed Q tuple h gate x (a, b) + · by_cases hp : ∀ t ∈ integerClosedWordCode Q tuple (a, b), (t.tuple, t.padding) ∈ data.pairs + · rw [ite_eq_left hv, ite_eq_left ⟨hv, hp⟩] + · have hz (r : ↥(data.P ∪ data.Q) → Fin B) : + scalarWalkProduct h weight (data.residueOrigin r) (integerClosedWordCode Q tuple (a, b)) = 0 := by + by_contra hne + exact hp (scalarWalkProduct_pairs h weight data.pairs hsupport _ _ hne) + simp only [hv, hp, and_false, ite_true, ite_false, hz, FiniteLaw.average_const, abs_zero] + · simp only [hv, false_and, ite_false] + +omit [DecidableEq D] [Fintype V] in +theorem actualClosedPairCatalog_closed {h k : ℕ} + (embed : V → D × ℤ) (Q : Finset ℕ) (tuple : D → ℕ) + (gate : D → ℤ → ℤ → Prop) (pairs : Finset (ℕ × ℕ)) (x : D × ℤ) + (p : (Fin k → D × (Q × Bool)) × (Fin k → D × (Q × Bool))) + (hp : p ∈ actualClosedPairCatalog embed Q tuple h gate pairs k x) : + wordDisplacement h (integerClosedWordCode Q tuple p) = 0 := by + exact integer_closed_word_displacement Q tuple h x p.1 p.2 (mem_filter.mp hp).2.1.1 + +theorem actualClosedPairCatalog_chains {h k : ℕ} + (embed : V → D × ℤ) (Q : Finset ℕ) (tuple : D → ℕ) (hinj : Function.Injective tuple) + (gate : D → ℤ → ℤ → Prop) (pairs : Finset (ℕ × ℕ)) (x : D × ℤ) + (p : (Fin k → D × (Q × Bool)) × (Fin k → D × (Q × Bool))) + (hp : p ∈ actualClosedPairCatalog embed Q tuple h gate pairs k x) : + ((integerClosedWordCode Q tuple p).take k).IsChain (fun a b => a.tuple ≠ b.tuple) ∧ + ((integerClosedWordCode Q tuple p).drop k).IsChain (fun a b => a.tuple ≠ b.tuple) := by + have ht := (mem_filter.mp hp).2.1 + have ha := integerPathMask_tuple_chain embed Q tuple hinj h gate x p.1 ht.2.1 + have hb := integerPathMask_tuple_chain embed Q tuple hinj h gate x p.2 ht.2.2 + have hlen : (integerStepWord Q tuple p.1).length = k := by + simp only [integerStepWord, List.length_map, List.length_ofFn] + have htake : (integerStepWord Q tuple p.1).take k = integerStepWord Q tuple p.1 := by + simpa only [hlen] using (List.take_length (l := integerStepWord Q tuple p.1)) + have hdrop : (integerStepWord Q tuple p.1).drop k = [] := by + simpa only [hlen] using (List.drop_length (l := integerStepWord Q tuple p.1)) + simp only [integerClosedWordCode, List.take_append, List.drop_append, hlen, Nat.sub_self, + List.take_zero, List.drop_zero, List.append_nil, List.nil_append, htake, hdrop] + exact ⟨ha, reverseWord_chain hb⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualCodeAssignments.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualCodeAssignments.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac3e4dcee65a5c6dd91529400a470ee487237a79 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualCodeAssignments.lean @@ -0,0 +1,103 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualSlotClasses +import OAI.NumberTheory.TwoPoint.Bounds.PositiveWordProbability + +namespace OAI + +/-! Actual code assignments preserve prime pools and the distinct-prime weight. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {R : ℕ} + +lemma actualSlotPrime_mem_tuplePool (w : Fin R → SignedStep) (P : Finset ℕ) + (hP : ∀ i, (w i).tuple.primeFactors ⊆ P) (s : ActualPrimeSlot w) + (hs : actualSlotKind w s = false) : actualSlotPrime w s ∈ P := by + rcases s with ⟨i, p | p⟩ + · exact hP i p.property + · cases hs + +lemma actualSlotPrime_mem_paddingPool (w : Fin R → SignedStep) (Q : Finset ℕ) + (hQ : ∀ i, (w i).padding.primeFactors ⊆ Q) (s : ActualPrimeSlot w) + (hs : actualSlotKind w s = true) : actualSlotPrime w s ∈ Q := by + rcases s with ⟨i, p | p⟩ + · cases hs + · exact hQ i p.property + +lemma actualPrimeSlotData_prime_image (w : Fin R → SignedStep) : + univ.image (actualPrimeSlotData w).prime = univ.image (actualSlotPrime w) := by + ext p + constructor + · rintro hp + obtain ⟨i, _, rfl⟩ := mem_image.mp hp + exact mem_image.mpr ⟨(actualPrimeSlotEquiv w).symm i, mem_univ _, rfl⟩ + · rintro hp + obtain ⟨s, _, rfl⟩ := mem_image.mp hp + refine mem_image.mpr ⟨actualPrimeSlotEquiv w s, mem_univ _, ?_⟩ + change actualSlotPrime w ((actualPrimeSlotEquiv w).symm (actualPrimeSlotEquiv w s)) = _ + rw [Equiv.symm_apply_apply] + +lemma actualPrimeSlot_support (w : Fin R → SignedStep) + (ht : ∀ i, (w i).tuple ≠ 0) (hq : ∀ i, (w i).padding ≠ 0) : + wordDivisorPrimeSupport (List.ofFn w) = univ.image (actualSlotPrime w) := by + ext p + simp only [wordDivisorPrimeSupport, mem_biUnion, List.mem_toFinset, List.mem_ofFn] + constructor + · rintro ⟨a, ⟨i, rfl⟩, hp⟩ + rw [Nat.primeFactors_mul (hq i) (ht i), mem_union] at hp + rcases hp with hp | hp + · exact mem_image.mpr ⟨⟨i, Sum.inr ⟨p, hp⟩⟩, mem_univ _, rfl⟩ + · exact mem_image.mpr ⟨⟨i, Sum.inl ⟨p, hp⟩⟩, mem_univ _, rfl⟩ + · rintro hp + obtain ⟨⟨i, p | p⟩, _, rfl⟩ := mem_image.mp hp + · refine ⟨w i, ⟨i, rfl⟩, ?_⟩ + rw [Nat.primeFactors_mul (hq i) (ht i), mem_union] + exact Or.inr p.property + · refine ⟨w i, ⟨i, rfl⟩, ?_⟩ + rw [Nat.primeFactors_mul (hq i) (ht i), mem_union] + exact Or.inl p.property + +/-- The encoded assignment pays exactly one reciprocal per distinct prime. -/ +theorem actual_code_reciprocal_weight (w : Fin R → SignedStep) + (ht : ∀ i, (w i).tuple ≠ 0) (hq : ∀ i, (w i).padding ≠ 0) : + (∏ z : (actualPrimeSlotData w).code.usedClasses, + ((actualPrimeSlotData w).prime z.val : ℝ)⁻¹) = + ∏ p ∈ wordDivisorPrimeSupport (List.ofFn w), (p : ℝ)⁻¹ := by + rw [actualPrimeSlot_support w ht hq, ← actualPrimeSlotData_prime_image] + rw [← PrimeSlotData.code_value_image, prod_image] + exact fun z _ t _ h => (actualPrimeSlotData w).code_value_injective h + +/-- Actual tuple and padding classes inhabit their separate numerical pools. -/ +theorem actual_code_pool_assignments (w : Fin R → SignedStep) (P Q : Finset ℕ) + (hP : ∀ i, (w i).tuple.primeFactors ⊆ P) + (hQ : ∀ i, (w i).padding.primeFactors ⊆ Q) : + ∃ a : (actualPrimeSlotData w).code.tupleClasses → P, + ∃ b : {z : (actualPrimeSlotData w).code.usedClasses // + z ∉ (actualPrimeSlotData w).code.tupleClasses} → Q, + joinCoordinates (actualPrimeSlotData w).code.tupleClasses + (fun z => (a z).val) (fun z => (b z).val) = + fun z => (actualPrimeSlotData w).prime z.val := by + let c := (actualPrimeSlotData w).code + have htuple (z : c.tupleClasses) : (actualPrimeSlotData w).prime z.val.val ∈ P := by + apply actualSlotPrime_mem_tuplePool w P hP + ((actualPrimeSlotEquiv w).symm z.val.val) + exact (mem_filter.mp z.property).2 + have hpadding (z : {z : c.usedClasses // z ∉ c.tupleClasses}) : + (actualPrimeSlotData w).prime z.val.val ∈ Q := by + apply actualSlotPrime_mem_paddingPool w Q hQ + ((actualPrimeSlotEquiv w).symm z.val.val) + have hn : ¬c.2.2.2 z.val.val = false := by + intro hz + exact z.property (mem_filter.mpr ⟨mem_univ _, hz⟩) + change c.2.2.2 z.val.val = true + cases he : c.2.2.2 z.val.val <;> simp_all + refine ⟨(fun z => ⟨_, htuple z⟩), (fun z => ⟨_, hpadding z⟩), ?_⟩ + funext z + dsimp only [joinCoordinates] + split_ifs <;> rfl + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualColumnCatalog.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualColumnCatalog.lean new file mode 100644 index 0000000000000000000000000000000000000000..64ff6ac56d3ffbe7ad0ae4bcb0ead33ae8bb318d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualColumnCatalog.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualColumnWeights + +namespace OAI + +/-! Structural properties of the column fiber of actual closed matrix paths. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma singletonLabels_card_le_slots {ι τ : Type*} [Fintype ι] [Fintype τ] + [DecidableEq ι] (label : τ → ι) : + (singletonLabels label).card ≤ Fintype.card τ := by + rw [← singleton_slot_count label] + exact (card_le_card (filter_subset _ _)).trans_eq (card_univ) + +variable {h J M k : ℕ} {P : Fin J → Finset ℕ} + {V : Type*} [Fintype V] + +omit [Fintype V] in +lemma actualColumnCatalog_pairs (data : ProhibitedPrimeFamily h J M) + (embed : V → ((j : Fin J) → P j) × ℤ) (Q : Finset ℕ) + (gate : ((j : Fin J) → P j) → ℤ → ℤ → Prop) + (x : ((j : Fin J) → P j) × ℤ) (forward : Fin (2 * k) → Bool) + (a : ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q)) + (ha : a ∈ closedTraceFiber Q + (actualClosedPairCatalog embed Q (fun d => ∏ j, (d j).val) h gate data.pairs k x) forward) + (i : Fin (2 * k)) : (columnTuple a.1 i, (a.2 i).val) ∈ data.pairs := by + obtain ⟨p, hp, hw⟩ := closedTraceFiber_word Q _ forward a ha + have hs := (mem_filter.mp hp).2.2 + apply hs (SignedStep.mk (forward i) (columnTuple a.1 i) (a.2 i).val) + rw [← hw] + exact List.mem_ofFn.mpr ⟨i, rfl⟩ + +lemma actualColumnCatalog_chains (data : ProhibitedPrimeFamily h J M) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (embed : V → ((j : Fin J) → P j) × ℤ) (Q : Finset ℕ) + (gate : ((j : Fin J) → P j) → ℤ → ℤ → Prop) + (x : ((j : Fin J) → P j) × ℤ) (forward : Fin (2 * k) → Bool) + (a : ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q)) + (ha : a ∈ closedTraceFiber Q + (actualClosedPairCatalog embed Q (fun d => ∏ j, (d j).val) h gate data.pairs k x) forward) : + ((columnTupleWord a.1 forward (fun i => (a.2 i).val)).take k).IsChain + (fun a b => a.tuple ≠ b.tuple) ∧ + ((columnTupleWord a.1 forward (fun i => (a.2 i).val)).drop k).IsChain + (fun a b => a.tuple ≠ b.tuple) := by + obtain ⟨p, hp, hw⟩ := closedTraceFiber_word Q _ forward a ha + rw [hw] + exact actualClosedPairCatalog_chains embed Q _ (primeTuple_injective hprime hdisjoint) + gate data.pairs x p hp + +omit [Fintype V] in +lemma actualColumnCatalog_crude_cost (data : ProhibitedPrimeFamily h J M) + (hP : ∀ j, P j ⊆ data.P) (L C : ℝ) + (hL : 1 ≤ L) (hlog : 1 ≤ Real.log L) (hk : (k : ℝ) ≤ L) + (hJ : (J : ℝ) ≤ C * Real.log L) (hM : (M : ℝ) ≤ 100 * Real.log L) + (embed : V → ((j : Fin J) → P j) × ℤ) (Q : Finset ℕ) + (gate : ((j : Fin J) → P j) → ℤ → ℤ → Prop) + (x : ((j : Fin J) → P j) × ℤ) (forward : Fin (2 * k) → Bool) + (a : ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q)) + (ha : a ∈ closedTraceFiber Q + (actualClosedPairCatalog embed Q (fun d => ∏ j, (d j).val) h gate data.pairs k x) forward) : + columnCrudeCap L a * 2 ^ (2 * k * J + (singletonLabels (actualColumnLabel data hP a.1)).card) ≤ + Real.exp ((4 * C + 402) * L * (Real.log L) ^ 2) := by + have hs : (singletonLabels (actualColumnLabel data hP a.1)).card ≤ 2 * k * J := by + simpa only [Fintype.card_prod, Fintype.card_fin] using + singletonLabels_card_le_slots (actualColumnLabel data hP a.1) + apply columnCrudeCap_exp L (4 * C) a hL hlog (by push_cast; linarith) + · have hs' : ((singletonLabels (actualColumnLabel data hP a.1)).card : ℝ) ≤ 2 * k * J := by + exact_mod_cast hs + have hp := mul_le_mul (mul_le_mul_of_nonneg_left hk (by norm_num)) hJ + (show (0 : ℝ) ≤ J by positivity) (show 0 ≤ 2 * L by positivity) + push_cast + nlinarith + · intro i + exact (show (((a.2 i).val).primeFactors.card : ℝ) ≤ M by + exact_mod_cast data.padding_card _ + (actualColumnCatalog_pairs data embed Q gate x forward a ha i)).trans hM + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualColumnTrace.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualColumnTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8df11b8073452fb3e0600f61bfb0243a59b92f1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualColumnTrace.lean @@ -0,0 +1,119 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualColumnCatalog +import OAI.NumberTheory.TwoPoint.Walks.ColumnTraceTotal +import OAI.NumberTheory.TwoPoint.Bounds.TraceParameterBudget +import OAI.NumberTheory.TwoPoint.Bounds.TraceErrorAbsorption + +namespace OAI + +/-! The four trace estimates applied to the actual matrix-path fiber. +All caps, singleton costs, padding majorants and witness lengths are discharged. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem eventually_actual_column_trace (h : ℕ) (C W : ℝ) + (hh : 0 < h) (hC : 0 ≤ C) (hW : 1 ≤ W) : + ∀ᶠ L : ℝ in atTop, ∀ (J M B H Y Qmax Dmax : ℕ) + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (P : Fin J → Finset ℕ) (Q : Finset ℕ) + (hP : ∀ j, P j ⊆ data.P), + 1 ≤ J → ((J + M : ℕ) : ℝ) ≤ C * Real.log L → + (∀ j, 1 ≤ primeHarmonicMass (P j)) → + (∀ j, primeHarmonicMass (P j) ≤ 2 * W) → + (∀ j, primeHarmonicMass (P j) ≤ L ^ (2 : ℕ)) → + 1 ≤ primeHarmonicMass data.P → + primeHarmonicMass data.P ≤ L ^ (2 : ℕ) → primeHarmonicMass data.Q ≤ L ^ (2 : ℕ) → + (M : ℝ) ≤ 100 * Real.log L → + (∀ j, ∀ p ∈ P j, p.Prime) → + (∀ j l, l ≠ j → Disjoint (P j) (P l)) → + (∀ p ∈ data.P, H ≤ p) → (∀ p ∈ data.P, p ≤ Y) → + 1 ≤ Y → (Y : ℝ) ≤ Real.exp L → Real.exp (L ^ (199 / 200 : ℝ)) ≤ H → + (Qmax : ℝ) ≤ Real.exp (100 * L + 1) → (Dmax : ℝ) ≤ Real.exp (2 * L) → + (∀ dq ∈ data.pairs, dq.2 ≤ Qmax) → + (∀ w : (j : Fin J) → P j, ∀ j, (∏ l ∈ univ.erase j, (w l).val) ≤ Dmax) → + (∀ q ∈ Q, Squarefree q) → (∀ q ∈ Q, q.primeFactors ⊆ data.Q) → + ∀ (u : ℕ → ℝ) (g : ℤ → ℝ) (K : ℝ) + (eligible : ℕ → ℕ → Prop) (extra : ℕ → ℤ → Prop), + (∀ q, 0 ≤ u q) → (∀ q, u q ≤ crudePaddingWeight q) → + (∀ n, 1 ≤ (g n) ^ 2) → 1 ≤ K → + (∀ n m : ℤ, (∀ p ∈ data.Q, (n : ZMod p) = (m : ZMod p)) → g n = g m) → + (∀ d n m, (∀ p ∈ data.Q, (n : ZMod p) = (m : ZMod p)) → + (extra d n ↔ extra d m)) → + ∀ (V : Type) [Fintype V] [DecidableEq V] + (embed : V → ((j : Fin J) → P j) × ℤ) + (gate : ((j : Fin J) → P j) → ℤ → ℤ → Prop) + (x : ((j : Fin J) → P j) × ℤ) (forward : Fin (2 * ⌊L⌋₊) → Bool), + let s := ⌊L ^ (1 / 10 : ℝ)⌋₊ + let D := 2 * ⌊L⌋₊ + ⌊L ^ (1 / 12 : ℝ)⌋₊ * s + Real.exp (108 * L) * (∑ a ∈ closedTraceFiber Q + (actualClosedPairCatalog embed Q (fun d => ∏ j, (d j).val) h gate data.pairs ⌊L⌋₊ x) forward, + |prohibitedCenteredAverage data hB s D + (columnTupleWord a.1 forward (fun i => (a.2 i).val)) (actualColumnLabel data hP a.1) + (actualColumnWeight data u eligible g L K extra forward a)|) ≤ + (K * (2 * Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * ⌊L⌋₊) := by + filter_upwards [eventually_prohibited_column_trace_total h C 0 (2 * C + 1) (4 * C + 402) W + hC (by norm_num) (by positivity) (by positivity) hW, + eventually_trace_slot_budgets C hC, eventually_trace_witness_budgets C hC, + eventually_trace_absorption, eventually_ge_atTop (2 : ℝ), + Real.tendsto_log_atTop.eventually (eventually_ge_atTop 1)] with + L htrace hslots hwitness habs hL hlog + intro J M B H Y Qmax Dmax data hB P Q hP hJ hJM hVm hVM hVpoly hmass hPmass hQmass + hM hprime hdisjoint hlo hhi hY hYexp hH hQmax hDmax hqmax hdmax hsq hpool + u g K eligible extra hu hub hg hK hgdep hextra V _ _ embed gate x forward + dsimp only + let k := ⌊L⌋₊ + let s := ⌊L ^ (1 / 10 : ℝ)⌋₊ + let n := ⌊L ^ (1 / 12 : ℝ)⌋₊ + let D := 2 * k + n * s + let F := closedTraceFiber Q + (actualClosedPairCatalog embed Q (fun d => ∏ j, (d j).val) h gate data.pairs k x) forward + let label (a : ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q)) := + actualColumnLabel data hP a.1 + let base (p : ↥(data.P ∪ data.Q)) : Fin B := + ⟨0, (data.prime p).pos.trans_le (hB p.val p.property)⟩ + have hklo : L / 2 ≤ (k : ℝ) := hwitness.1 + have hkhi : (k : ℝ) ≤ L := hwitness.2.1 + have hk : 0 < k := by + have : (0 : ℝ) < k := by linarith + exact_mod_cast this + have hR : 0 < 2 * k := by omega + have hJC : (J : ℝ) ≤ C * Real.log L := + (show (J : ℝ) ≤ (J + M : ℕ) by exact_mod_cast Nat.le_add_right J M).trans hJM + have hs := hslots k J M hkhi hJM + obtain ⟨_, _, hspos, hslo, hnpos, hnhi, hKn, hKlo, hKhi, hDL, hcover⟩ := hwitness + have hpairs (a) (ha : a ∈ F) (i) : (columnTuple a.1 i, (a.2 i).val) ∈ data.pairs := + actualColumnCatalog_pairs data embed Q gate x forward a ha i + have hchains (a) (ha : a ∈ F) := + actualColumnCatalog_chains data hprime hdisjoint embed Q gate x forward a ha + have hb := htrace J M B s D k n (n / 8) H Y Qmax Dmax data hB P Q F hR forward label base + (actualColumnWeight data u eligible g L K extra forward) (columnCrudeCap L) + (Real.exp ((4 * C + 402) * L * (Real.log L) ^ 2)) 1 ⟨k, by omega⟩ + u (fun w i => eligible (columnTupleAtNat w i)) g K + (fun w i => extra (columnTupleAtNat w i)) (actualColumnNext h forward) data.residueOrigin + hJ hklo hkhi hJM hs.1 hs.2.1 hs.2.2 hP hVm hVM hVpoly hmass hPmass hQmass hM + hprime hdisjoint hlo hhi hY hYexp hH hQmax hDmax hpairs + (fun a ha i => hqmax _ (hpairs a ha i)) + (fun a _ i j => hdmax (fun l => a.1 l i) j) (fun _ _ _ _ => rfl) + (Real.exp_pos _).le le_rfl (by norm_num) (by simp) + (fun a _ => columnCrudeCap_nonneg L (by linarith) a) + (fun a _ z => actualColumnWeight_nonneg data u eligible g L K extra forward + (by linarith) hu a z) + (fun a _ z => actualColumnWeight_le_cap data u eligible g L K extra forward + (by linarith) hu hub hg a z) + (fun a ha => actualColumnCatalog_crude_cost data hP L C (by linarith) hlog hkhi hJC hM + embed Q gate x forward a ha) + (fun a _ ha => columnCrudeCap_small L (by linarith) a ha) + (fun a _ z t ht => actualColumnWeight_independent data hP u eligible g L K extra forward + hsq hpool hgdep hextra a z t ht) + (fun a _ z hz => actualColumnWeight_padding data u eligible g L K extra forward a z hz) + le_rfl (fun a _ ha => hcover J _ hJC ha) hDL hnpos hnhi hKn hKlo hKhi hh hspos hslo + (fun a ha => (hchains a ha).1) (fun a ha => (hchains a ha).2) (by linarith) hu + (fun a _ z => actualColumnWeight_le_retained data u eligible g L K extra forward + (by linarith) hu a z) + exact habs J k K W _ hJ (by omega) hK hW hb + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualColumnWeights.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualColumnWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c4db3f4a525078723ccefab76bb08635301ff48 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualColumnWeights.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.TwoPoint.Walks.ColumnPaddingBridge +import OAI.NumberTheory.TwoPoint.Walks.ColumnMatrixTrace + +namespace OAI + +/-! Verify all weight hypotheses of the trace estimate for the literal +departure product appearing in the matrix expansion. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def actualColumnWeight {h J M R B : ℕ} {P : Fin J → Finset ℕ} {Q : Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) (forward : Fin R → Bool) + (a : ColumnPrimeAssignment J R P × (Fin R → Q)) + (x : ↥(data.P ∪ data.Q) → Fin B) : ℝ := + data.residueValue (fun n => scalarWalkProduct h + (retainedEdgeDeparture Q u (fun t => eligible t.tuple) g L K (fun t => extra t.tuple) h) + n (columnTupleWord a.1 forward (fun i => (a.2 i).val))) x + +lemma actualColumnWeight_nonneg {h J M R B : ℕ} {P : Fin J → Finset ℕ} {Q : Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) (forward : Fin R → Bool) + (hL : 0 ≤ L) (hu : ∀ q, 0 ≤ u q) + (a : ColumnPrimeAssignment J R P × (Fin R → Q)) + (x : ↥(data.P ∪ data.Q) → Fin B) : + 0 ≤ actualColumnWeight data u eligible g L K extra forward a x := + scalarWalkProduct_nonneg h _ + (retainedEdgeDeparture_nonneg Q u _ g L K _ h hL hu) _ _ + +lemma actualColumnWeight_le_cap {h J M R B : ℕ} {P : Fin J → Finset ℕ} {Q : Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) (forward : Fin R → Bool) + (hL : 0 ≤ L) (hu : ∀ q, 0 ≤ u q) (hub : ∀ q, u q ≤ crudePaddingWeight q) + (hg : ∀ n, 1 ≤ (g n) ^ 2) + (a : ColumnPrimeAssignment J R P × (Fin R → Q)) + (x : ↥(data.P ∪ data.Q) → Fin B) : + actualColumnWeight data u eligible g L K extra forward a x ≤ columnCrudeCap L a := + retained_word_le_crude Q u _ g L K _ h hL hu hub hg + (fun i => SignedStep.mk (forward i) (columnTuple a.1 i) (a.2 i).val) _ + +lemma actualColumnWeight_padding {h J M R B : ℕ} {P : Fin J → Finset ℕ} {Q : Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) (forward : Fin R → Bool) + (a : ColumnPrimeAssignment J R P × (Fin R → Q)) + (x : ↥(data.P ∪ data.Q) → Fin B) + (hx : actualColumnWeight data u eligible g L K extra forward a x ≠ 0) : + MainPaddingTests Subtype.val h B (columnTupleWord a.1 forward (fun i => (a.2 i).val)) x := + lifted_retained_word_padding_tests data Q u _ g L K _ + (fun i => SignedStep.mk (forward i) (columnTuple a.1 i) (a.2 i).val) x hx + +lemma actualColumnWeight_independent {h J M R B : ℕ} {P : Fin J → Finset ℕ} {Q : Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (hP : ∀ j, P j ⊆ data.P) + (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) (g : ℤ → ℝ) (L K : ℝ) + (extra : ℕ → ℤ → Prop) (forward : Fin R → Bool) + (hsq : ∀ q ∈ Q, Squarefree q) (hpool : ∀ q ∈ Q, q.primeFactors ⊆ data.Q) + (hg : ∀ n m : ℤ, (∀ p ∈ data.Q, (n : ZMod p) = (m : ZMod p)) → g n = g m) + (hextra : ∀ d n m, (∀ p ∈ data.Q, (n : ZMod p) = (m : ZMod p)) → + (extra d n ↔ extra d m)) + (a : ColumnPrimeAssignment J R P × (Fin R → Q)) + (x y : ↥(data.P ∪ data.Q) → Fin B) + (hxy : ∀ p, p ∉ univ.image (actualColumnLabel data hP a.1) → x p = y p) : + actualColumnWeight data u eligible g L K extra forward a x = + actualColumnWeight data u eligible g L K extra forward a y := by + apply lifted_retained_word_independent_tuple data Q u _ g L K _ + (fun i => SignedStep.mk (forward i) (columnTuple a.1 i) (a.2 i).val) + hsq hpool hg (fun t => hextra t.tuple) (actualColumnLabel data hP a.1) _ x y hxy + intro p hp + obtain ⟨i, _, rfl⟩ := mem_image.mp hp + exact hP i.2 (a.1 i.2 i.1).property + +lemma actualColumnWeight_le_retained {h J M B k : ℕ} {P : Fin J → Finset ℕ} {Q : Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) (forward : Fin (2 * k) → Bool) + (hL : 0 ≤ L) (hu : ∀ q, 0 ≤ u q) + (a : ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q)) + (x : ↥(data.P ∪ data.Q) → Fin B) : + actualColumnWeight data u eligible g L K extra forward a x ≤ + retainedColumnPaddingWeight Q u (fun w i => eligible (columnTupleAtNat w i)) g L K + (fun w i => extra (columnTupleAtNat w i)) (actualColumnNext h forward) + (data.residueOrigin x) a.1 a.2 := + retained_word_le_column Q u eligible g L K extra h hL hu a.1 forward a.2 _ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualDesignations.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualDesignations.lean new file mode 100644 index 0000000000000000000000000000000000000000..db3c48ce1cec83e73cd0fd6e7afe79b5a77c57c2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualDesignations.lean @@ -0,0 +1,108 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PerfectRows +import OAI.NumberTheory.TwoPoint.Bounds.DesignationWeights + +namespace OAI + +/-! Literal lit/unlit slot sets and the reciprocal coefficient of an actual word. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι τ : Type*} [Fintype ι] [Fintype τ] [DecidableEq ι] + +def nonsingletonLitSlots (label : τ → ι) (lit : τ → Bool) : Finset τ := + univ.filter (fun t => label t ∈ nonsingletonLabels label ∧ lit t = true) + +def nonsingletonUnlitSlots (label : τ → ι) (lit : τ → Bool) : Finset τ := + univ.filter (fun t => label t ∈ nonsingletonLabels label ∧ lit t = false) + +lemma nonsingleton_lit_fiber (label : τ → ι) (lit : τ → Bool) (i : ι) : + (nonsingletonLitSlots label lit).filter (fun t => label t = i) = + if i ∈ nonsingletonLabels label then litOccurrences label lit i else ∅ := by + classical + ext t + by_cases ht : label t = i <;> by_cases hi : i ∈ nonsingletonLabels label <;> + simp [nonsingletonLitSlots, litOccurrences, labelOccurrences, ht, hi] + +lemma nonsingleton_unlit_fiber (label : τ → ι) (lit : τ → Bool) (i : ι) : + (nonsingletonUnlitSlots label lit).filter (fun t => label t = i) = + if i ∈ nonsingletonLabels label then unlitOccurrences label lit i else ∅ := by + classical + ext t + by_cases ht : label t = i <;> by_cases hi : i ∈ nonsingletonLabels label <;> + simp [nonsingletonUnlitSlots, unlitOccurrences, labelOccurrences, ht, hi] + +lemma singleton_not_nonsingleton (label : τ → ι) (i : ι) + (hi : i ∈ singletonLabels label) : i ∉ nonsingletonLabels label := by + have hc := (mem_filter.mp hi).2 + simp only [nonsingletonLabels, mem_filter, mem_univ, true_and, hc] + omega + +lemma nonsingleton_of_used_not_singleton (label : τ → ι) (i : ι) + (hused : 0 < (labelOccurrences label i).card) (hi : i ∉ singletonLabels label) : + i ∈ nonsingletonLabels label := by + have hn : (labelOccurrences label i).card ≠ 1 := by + simpa only [singletonLabels, mem_filter, mem_univ, true_and] using hi + exact mem_filter.mpr ⟨mem_univ _, by omega⟩ + +/-- The literal number of unlit nonsingleton slots is the sum of their +per-label occurrence counts, without charging singleton slots. -/ +lemma nonsingleton_unlit_card (label : τ → ι) (lit : τ → Bool) : + (nonsingletonUnlitSlots label lit).card = + ∑ i : nonsingletonLabels label, (unlitOccurrences label lit i.val).card := by + rw [nonsingletonUnlitSlots, unlit_slot_count] + exact (sum_coe_sort _ _).symm + +/-- On actual observed labels, the designated coefficient has one basic +reciprocal per prime and the exact extra powers from the nonsingletons. -/ +theorem actual_designation_reciprocal_bound (label : τ → ι) (lit : τ → Bool) + (hused : ∀ i, 0 < (labelOccurrences label i).card) + (p : ι → ℝ) (H : ℝ) (hH : 0 < H) (hp : ∀ i, H ≤ p i) : + (∏ t ∈ nonsingletonUnlitSlots label lit, (p (label t))⁻¹) * + (∏ i ∈ (nonsingletonLitSlots label lit).image label, (p i)⁻¹) * + (∏ i ∈ singletonLabels label, (p i)⁻¹) ≤ + (∏ i, (p i)⁻¹) * H⁻¹ ^ + (∑ i : nonsingletonLabels label, + extraReciprocalExponent (litOccurrences label lit i.val).card + (unlitOccurrences label lit i.val).card) := by + classical + have hzero (i : ι) (hi : i ∈ singletonLabels label) : + ((nonsingletonLitSlots label lit).filter (fun t => label t = i)).card = 0 ∧ + ((nonsingletonUnlitSlots label lit).filter (fun t => label t = i)).card = 0 := by + simp only [nonsingleton_lit_fiber, nonsingleton_unlit_fiber, + ite_eq_right (singleton_not_nonsingleton label i hi), card_empty, and_self] + have hm (i : ι) (hi : i ∉ singletonLabels label) : + 2 ≤ ((nonsingletonLitSlots label lit).filter (fun t => label t = i)).card + + ((nonsingletonUnlitSlots label lit).filter (fun t => label t = i)).card := by + have hns := nonsingleton_of_used_not_singleton label i (hused i) hi + simp only [nonsingleton_lit_fiber, nonsingleton_unlit_fiber, ite_eq_left hns] + rw [lit_unlit_count] + exact (mem_filter.mp hns).2 + have hs : (∑ i, extraReciprocalExponent + ((nonsingletonLitSlots label lit).filter (fun t => label t = i)).card + ((nonsingletonUnlitSlots label lit).filter (fun t => label t = i)).card) = + ∑ i : nonsingletonLabels label, + extraReciprocalExponent (litOccurrences label lit i.val).card + (unlitOccurrences label lit i.val).card := by + calc + _ = ∑ i ∈ nonsingletonLabels label, extraReciprocalExponent + ((nonsingletonLitSlots label lit).filter (fun t => label t = i)).card + ((nonsingletonUnlitSlots label lit).filter (fun t => label t = i)).card := by + apply (sum_subset (subset_univ _) ?_).symm + intro i _ hi + simp [nonsingleton_lit_fiber, nonsingleton_unlit_fiber, hi, + extraReciprocalExponent, litReciprocalExponent] + _ = ∑ i ∈ nonsingletonLabels label, + extraReciprocalExponent (litOccurrences label lit i).card + (unlitOccurrences label lit i).card := by + apply sum_congr rfl + intro i hi + simp only [nonsingleton_lit_fiber, nonsingleton_unlit_fiber, ite_eq_left hi] + _ = _ := (sum_coe_sort _ _).symm + simpa only [hs] using designated_all_reciprocal_bound (singletonLabels label) + (nonsingletonLitSlots label lit) (nonsingletonUnlitSlots label lit) label p H hzero hm hH hp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualIntervalMatrix.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualIntervalMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ef9f83043e1aab944a18d0a6e6c5407707bb121 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualIntervalMatrix.lean @@ -0,0 +1,124 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualPrimeWordComparison +import OAI.NumberTheory.TwoPoint.Bounds.ActualBlockTrace +import OAI.NumberTheory.TwoPoint.Bounds.PrimeAlphabetSize +import OAI.NumberTheory.TwoPoint.Bounds.TraceIntervalError + +namespace OAI + +/-! The actual masked matrix on every sufficiently long integer interval. +The error includes all initial vertices and both paths of the trace. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem ModFiveThetaInput.eventually_actual_interval_matrix + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) + (h : ℕ) (hh : 0 < h) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) (W : ℝ) (hW : 1 ≤ W) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + (fun d => centeredTuple d.primeFactors) L (Real.exp (4 * J)) + (fun _ => actualPaddingDegreeCut Qp L) h + (fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ (fun d q => (d, q) ∈ data.pairs) z) + ∀ gate : ((j : Fin J) → P j) → ℤ → ℤ → Prop, + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + uniformAverage (fun x : Fin N => matrixFrobeniusSq + (shiftMatrix (primeBlockEmbedding (P := P) ⌈Real.exp (103 * L)⌉₊) + (integerShiftNext Q (fun d => ∏ j, (d j).val) h) + (physicalShiftWeight Q (fun d => ∏ j, (d j).val) h gate + (fun t n => weight t (n + (a + x.val : ℕ)))) ^ ⌊L⌋₊)) ≤ + (Real.exp (4 * J) * (2 * Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * ⌊L⌋₊) + 1 := by + obtain ⟨A, hA, hword⟩ := hprime.eventually_actual_prime_word_comparison hBr h E hE W hW + refine ⟨A, hA, ?_⟩ + filter_upwards [hword, hprime.eventually_actual_block_trace h hh E hE W hW, + eventually_ge_atTop (4800 : ℝ)] with L hword htrace hlarge + intro hL η hη hηone eligible he + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let hB := canonicalTraceFamily_residue_bound h E W L eligible hL hW hE + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + (fun d => centeredTuple d.primeFactors) L (Real.exp (4 * J)) + (fun _ => actualPaddingDegreeCut Qp L) h + (fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ (fun d q => (d, q) ∈ data.pairs) z) + let D := (j : Fin J) → P j + let M := ⌈Real.exp (103 * L)⌉₊ + let V := D × Fin M + let embed : V → D × ℤ := primeBlockEmbedding M + let tuple : D → ℕ := fun d => ∏ j, (d j).val + have hprimeP := centeredPrimeBands_prime E (L ^ (199 / 200 : ℝ)) W J + have hdisjoint := centeredPrimeBands_disjoint E (L ^ (199 / 200 : ℝ)) W J + (Real.rpow_nonneg (by linarith) _) (by linarith) + have hP (j : Fin J) : P j ⊆ data.P := centeredPrimeBand_subset_pool E _ W J j + have hsq (q : ℕ) (hq : q ∈ Q) : Squarefree q := + retainedPrimeDivisor_squarefree Qp (fun _ hp => paddingPrimeSupply_prime hp) (mem_filter.mp hq).1 + have hpool (q : ℕ) (hq : q ∈ Q) : q.primeFactors ⊆ data.Q := + retainedPrimeDivisor_factors Qp (fun _ hp => paddingPrimeSupply_prime hp) (mem_filter.mp hq).1 + intro gate a N hN + have hNpos : 0 < N := by + have : (0 : ℝ) < N := (Real.exp_pos _).trans_le hN + exact_mod_cast this + let : Nonempty (Fin N) := ⟨⟨0, hNpos⟩⟩ + have hcompare := physicalMatrix_moment_comparison embed + (primeBlockEmbedding_injective M) Q tuple h gate weight + (maskedSignedIntegerWeight_flip Q actualPaddingCoefficient _ _ _ _ _ _ h _) + (FiniteLaw.uniform (Fin N)) (data.residueLaw ⌊Real.exp L⌋₊ hB) + (fun x => (a + x.val : ℕ)) data.residueOrigin ⌊L⌋₊ (Real.exp (-(L ^ 9))) + (Real.exp_pos _).le ?_ + · rw [FiniteLaw.uniform_average] at hcompare + have herr := trace_interval_error_le_one L ⌊L⌋₊ (Fintype.card V) + (Fintype.card (D × (Q × Bool))) hlarge (Nat.floor_le (by linarith)) + (Nat.cast_nonneg _) (actual_prime_block_dimension E W L hW hL) + (actual_prime_alphabet_size E W L hW hlarge) + have hupper := htrace hL η hη hηone eligible he gate + have hdiff := (le_abs_self _).trans (hcompare.trans herr) + dsimp only [embed, V, D, tuple, M, weight, data, Q, Qp, P, J] at hdiff + linarith + · intro i b c hend + let enc := closedTraceEncoding Q (b, c) + have hclosed : wordDisplacement h (columnTupleWord enc.2.1 enc.1 (fun j => (enc.2.2 j).val)) = 0 := by + rw [closedTraceEncoding_word] + exact integer_closed_word_displacement Q tuple h (embed i) b c hend + have hw := hword hL η hη hηone eligible he enc.2.1 enc.1 enc.2.2 hclosed + (a + i.2.val) N hN + rw [closedTraceEncoding_word] at hw + have ht := data.residue_average_translate hB + (fun n => scalarWalkProduct h weight n (integerClosedWordCode Q tuple (b, c))) + (fun n m hnm => scalarWalkProduct_residue_congr (data.P ∪ data.Q) h weight _ + (fun t ht z z' hz => primeClosedPair_residue_congr data hB hP hprimeP hdisjoint + ⌊L ^ (1 / 10 : ℝ)⌋₊ Q actualPaddingCoefficient (fun d q => (d, q) ∈ data.pairs) + (actualPaddingVertex Qp) L (Real.exp (4 * J)) (fun _ => actualPaddingDegreeCut Qp L) + hsq hpool (actualPaddingVertex_residue_congr Qp) + (fun _ n m hnm => actualPaddingDegreeCut_residue_congr Qp L n m hnm) + b c t ht z z' (fun p => hz p.val p.property)) n m (fun p hp => hnm ⟨p, hp⟩)) + (embed i).2 + have havg : (data.residueLaw ⌊Real.exp L⌋₊ hB).average (fun r => + scalarWalkProduct h weight ((embed i).2 + data.residueOrigin r) + (integerClosedWordCode Q tuple (b, c))) = + (data.residueLaw ⌊Real.exp L⌋₊ hB).average (fun r => + scalarWalkProduct h weight (data.residueOrigin r) + (integerClosedWordCode Q tuple (b, c))) := by + simpa only [add_comm (embed i).2] using ht + rw [FiniteLaw.uniform_average] + rw [havg] + simpa only [embed, primeBlockEmbedding, Nat.cast_add, + add_assoc, add_left_comm (a : ℤ)] using hw + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualMatrixTrace.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualMatrixTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..b0d5c2b187ac6af18f918c1e8bc1e86f0e0ba95f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualMatrixTrace.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MatrixTraceSummation + +namespace OAI + +/-! The actual residue-model matrix moment at the canonical trace length. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem eventually_actual_matrix_trace (h : ℕ) (C W : ℝ) + (hh : 0 < h) (hC : 0 ≤ C) (hW : 1 ≤ W) : + ∀ᶠ L : ℝ in atTop, ∀ (J M B H Y Qmax Dmax : ℕ) + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (P : Fin J → Finset ℕ) (Q : Finset ℕ) + (_hP : ∀ j, P j ⊆ data.P), + 1 ≤ J → ((J + M : ℕ) : ℝ) ≤ C * Real.log L → + (∀ j, 1 ≤ primeHarmonicMass (P j)) → + (∀ j, primeHarmonicMass (P j) ≤ 2 * W) → + (∀ j, primeHarmonicMass (P j) ≤ L ^ (2 : ℕ)) → + 1 ≤ primeHarmonicMass data.P → + primeHarmonicMass data.P ≤ L ^ (2 : ℕ) → primeHarmonicMass data.Q ≤ L ^ (2 : ℕ) → + (M : ℝ) ≤ 100 * Real.log L → + (∀ j, ∀ p ∈ P j, p.Prime) → + (∀ j l, l ≠ j → Disjoint (P j) (P l)) → + (∀ p ∈ data.P, H ≤ p) → (∀ p ∈ data.P, p ≤ Y) → + 1 ≤ Y → (Y : ℝ) ≤ Real.exp L → Real.exp (L ^ (199 / 200 : ℝ)) ≤ H → + (Qmax : ℝ) ≤ Real.exp (100 * L + 1) → (Dmax : ℝ) ≤ Real.exp (2 * L) → + (∀ dq ∈ data.pairs, dq.2 ≤ Qmax) → + (∀ w : (j : Fin J) → P j, ∀ j, (∏ l ∈ univ.erase j, (w l).val) ≤ Dmax) → + (∀ q ∈ Q, Squarefree q) → (∀ q ∈ Q, q.primeFactors ⊆ data.Q) → + ∀ (u : ℕ → ℝ) (g : ℤ → ℝ) (K : ℝ) + (eligible : ℕ → ℕ → Prop) (extra : ℕ → ℤ → Prop), + (∀ q, 0 ≤ u q) → (∀ q, u q ≤ crudePaddingWeight q) → + (∀ n, 1 ≤ (g n) ^ 2) → 1 ≤ K → + (∀ n m : ℤ, (∀ p ∈ data.Q, (n : ZMod p) = (m : ZMod p)) → g n = g m) → + (∀ d n m, (∀ p ∈ data.Q, (n : ZMod p) = (m : ZMod p)) → + (extra d n ↔ extra d m)) → + ∀ (V : Type) [Fintype V] [DecidableEq V] + (embed : V → ((j : Fin J) → P j) × ℤ), Function.Injective embed → + (Fintype.card V : ℝ) ≤ Real.exp (106 * L) → + ∀ (gate : ((j : Fin J) → P j) → ℤ → ℤ → Prop), + (∀ d q, eligible d q → (d, q) ∈ data.pairs) → + let s := ⌊L ^ (1 / 10 : ℝ)⌋₊ + let tuple := fun d : (j : Fin J) → P j => ∏ j, (d j).val + let weight := maskedSignedIntegerWeight Q u eligible g (fun d => centeredTuple d.primeFactors) + L K extra h (fun n => ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) n) + (data.residueLaw B hB).average (fun r => matrixFrobeniusSq + (shiftMatrix embed (integerShiftNext Q tuple h) (physicalShiftWeight Q tuple h gate + (fun t n => weight t (n + data.residueOrigin r))) ^ ⌊L⌋₊)) ≤ + (K * (2 * Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * ⌊L⌋₊) := by + filter_upwards [eventually_actual_column_trace h C W hh hC hW, + eventually_ge_atTop (2 : ℝ)] with L hcolumn hL + intro J M B H Y Qmax Dmax data hB P Q hP hJ hJM hVm hVM hVpoly hmass hPmass hQmass + hM hprime hdisjoint hlo hhi hY hYexp hH hQmax hDmax hqmax hdmax hsq hpool + u g K eligible extra hu hub hg hK hgdep hextra V _ _ embed hinj hdim gate hallowed + dsimp only + have hkhi : (⌊L⌋₊ : ℝ) ≤ L := Nat.floor_le (by linarith) + have hk : 0 < ⌊L⌋₊ := by + have ht := Nat.lt_floor_add_one L + have hp : (0 : ℝ) < (⌊L⌋₊ : ℝ) := by linarith + exact_mod_cast hp + have hgzero (n : ℤ) : g n ≠ 0 := by + intro he + have hb := hg n + rw [he, zero_pow (by decide : (2 : ℕ) ≠ 0)] at hb + linarith + apply matrix_residue_trace_of_column_bounds data hB hP hprime hdisjoint + ⌊L ^ (1 / 10 : ℝ)⌋₊ + (2 * ⌊L⌋₊ + ⌊L ^ (1 / 12 : ℝ)⌋₊ * ⌊L ^ (1 / 10 : ℝ)⌋₊) + (by omega) (by omega) embed hinj Q u eligible g L K _ extra gate hsq hpool + hgzero hgdep hextra hallowed (by positivity) + (trace_dimension_allowance L ⌊L⌋₊ (Fintype.card V) (by linarith) hkhi hdim) + exact hcolumn J M B H Y Qmax Dmax data hB P Q hP hJ hJM hVm hVM hVpoly hmass + hPmass hQmass hM hprime hdisjoint hlo hhi hY hYexp hH hQmax hDmax hqmax hdmax + hsq hpool u g K eligible extra hu hub hg hK hgdep hextra V embed gate + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingCuts.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingCuts.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e08bb2d4d8f39793f873b11fba411a270a15f4c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingCuts.lean @@ -0,0 +1,183 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualPaddingMarginal + +namespace OAI + +/-! Loss of padding mass from the actual graph density and degree +cutoffs. The second moment is applied before discarding the large bins. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma FiniteLaw.weighted_large_bin_cut {A I : Type*} [Fintype A] + (μ : FiniteLaw A) (bins : Finset I) (weight : A → ℝ) + (hw : ∀ a, 0 ≤ weight a) (ρ : A → I → ℝ) + (hρ : ∀ a j, 0 ≤ ρ a j) (K L : ℝ) (hK : 0 < K) (hL : 0 < L) : + μ.average (fun a => weight a * + ∑ j ∈ bins, if K / L < ρ a j then ρ a j else 0) ≤ + (L / K) * μ.average (fun a => weight a * ∑ j ∈ bins, (ρ a j) ^ 2) := by + calc + _ ≤ μ.average (fun a => weight a * + ∑ j ∈ bins, (L / K) * (ρ a j) ^ 2) := by + apply μ.average_mono + intro a + apply mul_le_mul_of_nonneg_left _ (hw a) + exact sum_le_sum (fun j _ => large_nonnegative_value (ρ a j) K L (hρ a j) hK hL) + _ = _ := by + simp only [← mul_sum, FiniteLaw.average] + rw [mul_sum] + apply sum_congr rfl + intro a _ + ring + +theorem ModFiveThetaInput.actual_family_padding_large_bin_cut (hP : ModFiveThetaInput) + (E : Finset ℕ) : + ∃ C : ℝ, 0 < C ∧ ∀ (L η c K : ℝ) (h J M B : ℕ) + (data : ProhibitedPrimeFamily h J M), data.Q = paddingPrimeSupply E L → + ∀ (site : ℤ) (bins : Finset ℤ), 1 ≤ L → 0 < η → η ≤ 1 → 0 < K → + ∀ (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (D : Finset ℕ), D ⊆ retainedPrimeDivisors data.Q → + (data.residueLaw B hB).average (fun x => + (actualPaddingVertex data.Q (data.residueOrigin x + site)) ^ 2 * + ∑ j ∈ bins, if K / L < paddingDensity D actualPaddingCoefficient + (actualPaddingBin η c j) (actualPaddingVertex data.Q) (data.residueOrigin x + site) + then paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex data.Q) (data.residueOrigin x + site) else 0) / + paddingTiltNormalizer data.Q ≤ C / K := by + obtain ⟨C, hC, hb⟩ := hP.actual_family_padding_bin_square E + refine ⟨C, hC, ?_⟩ + intro L η c K h J M B data hQ site bins hL hη hηone hK hB D hD + have hLp : 0 < L := zero_lt_one.trans_le hL + let μ := data.residueLaw B hB + let ρ := fun (x : ↥(data.P ∪ data.Q) → Fin B) j => paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex data.Q) (data.residueOrigin x + site) + let w := fun (x : ↥(data.P ∪ data.Q) → Fin B) => (actualPaddingVertex data.Q (data.residueOrigin x + site)) ^ 2 + have hs := μ.weighted_large_bin_cut bins w (fun x => sq_nonneg _) ρ + (fun x j => actualPaddingDensity_nonneg data.Q D _ _) K L hK hLp + calc + _ ≤ ((L / K) * μ.average (fun x => w x * ∑ j ∈ bins, (ρ x j) ^ 2)) / + paddingTiltNormalizer data.Q := + div_le_div_of_nonneg_right hs (paddingTiltNormalizer_pos data.Q).le + _ = (L / K) * (μ.average (fun x => w x * ∑ j ∈ bins, (ρ x j) ^ 2) / + paddingTiltNormalizer data.Q) := by ring + _ ≤ (L / K) * (C / L) := mul_le_mul_of_nonneg_left + (hb L η c h J M B data hQ site bins hL hη hηone hB D hD) + (div_nonneg hLp.le hK.le) + _ = C / K := by field_simp + +/-- The bin densities form a subprobability distribution even after +restricting the available padding divisors. -/ +lemma actualPaddingDensity_sum_le_one (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) (D : Finset ℕ) + (hD : D ⊆ retainedPrimeDivisors Q) (n : ℤ) + (η c : ℝ) (hη : 0 < η) (bins : Finset ℤ) : + (∑ j ∈ bins, paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex Q) n) ≤ 1 := by + unfold paddingDensity + rw [← sum_div, sum_comm, actualPaddingVertex_sq] + apply (div_le_one (zero_lt_one.trans_le (actualPaddingWeight_one_le Q n))).mpr + calc + _ ≤ ∑ q ∈ D, if (q : ℤ) ∣ n then actualPaddingCoefficient q else 0 := by + apply sum_le_sum + intro q _ + have he (j : ℤ) : actualPaddingBin η c j q ↔ paddingBin η c (Real.log q) = j := + (paddingBin_eq_iff η c (Real.log q) j hη).symm + simp only [he] + by_cases hd : (q : ℤ) ∣ n + · simp only [hd, and_true] + simp only [sum_ite_eq] + split_ifs + · exact le_rfl + · exact actualPaddingCoefficient_nonneg q + · simp only [hd, and_false, ite_false, sum_const_zero, le_refl] + _ ≤ ∑ q ∈ retainedPrimeDivisors Q, + if (q : ℤ) ∣ n then actualPaddingCoefficient q else 0 := by + apply sum_le_sum_of_subset_of_nonneg hD + intro q _ _ + split_ifs + · exact actualPaddingCoefficient_nonneg q + · exact le_rfl + _ = _ := (actualPaddingWeight_eq_divisor_sum Q hQ n).symm + +lemma actualPadding_keep_loss (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (D : Finset ℕ) (hD : D ⊆ retainedPrimeDivisors Q) (n : ℤ) + (L K η c : ℝ) (hη : 0 < η) (bins : Finset ℤ) : + (∑ j ∈ bins, if ¬integerEdgeKeep D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex Q) L K (actualPaddingDegreeCut Q L) n then + paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex Q) n else 0) ≤ + (∑ j ∈ bins, if K / L < paddingDensity D actualPaddingCoefficient + (actualPaddingBin η c j) (actualPaddingVertex Q) n then + paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex Q) n else 0) + + if ¬actualPaddingDegreeCut Q L n then 1 else 0 := by + by_cases hc : actualPaddingDegreeCut Q L n + · simp only [integerEdgeKeep, hc, and_true, not_le, not_true_eq_false, + ite_false, add_zero, le_refl] + · have hs := actualPaddingDensity_sum_le_one Q hQ D hD n η c hη bins + have hp : 0 ≤ ∑ j ∈ bins, if K / L < paddingDensity D actualPaddingCoefficient + (actualPaddingBin η c j) (actualPaddingVertex Q) n then + paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex Q) n else 0 := by + apply sum_nonneg + intro j _ + split_ifs + · exact actualPaddingDensity_nonneg Q D _ n + · exact le_rfl + simp only [integerEdgeKeep, hc, and_false, not_false_eq_true, ite_true] + linarith + +/-- Both literal vertex cutoffs together remove only `O(1/K) + L⁻¹⁰⁰` +of the normalized, padding-weighted mass, summed over all selected bins. -/ +theorem ModFiveThetaInput.eventually_actual_padding_keep_loss + (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, + ∀ (η c K : ℝ) (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M), + data.Q = paddingPrimeSupply E L → + ∀ (site : ℤ) (bins : Finset ℤ), 0 < η → η ≤ 1 → 0 < K → + ∀ (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (D : Finset ℕ), D ⊆ retainedPrimeDivisors data.Q → + (data.residueLaw B hB).average (fun x => + (actualPaddingVertex data.Q (data.residueOrigin x + site)) ^ 2 * + ∑ j ∈ bins, if ¬integerEdgeKeep D actualPaddingCoefficient + (actualPaddingBin η c j) (actualPaddingVertex data.Q) L K + (actualPaddingDegreeCut data.Q L) (data.residueOrigin x + site) then + paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex data.Q) (data.residueOrigin x + site) else 0) / + paddingTiltNormalizer data.Q ≤ C / K + L ^ (-100 : ℝ) := by + obtain ⟨C, hC, hb⟩ := hP.actual_family_padding_large_bin_cut E + refine ⟨C, hC, ?_⟩ + filter_upwards [hP.eventually_actual_family_padding_degree_tail E, + eventually_ge_atTop (1 : ℝ)] with L ht hL + intro η c K h J M B data hQ site bins hη hηone hK hB D hD + let μ := data.residueLaw B hB + let ρ := fun (x : ↥(data.P ∪ data.Q) → Fin B) j => paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex data.Q) (data.residueOrigin x + site) + let w := fun (x : ↥(data.P ∪ data.Q) → Fin B) => (actualPaddingVertex data.Q (data.residueOrigin x + site)) ^ 2 + let bad := fun (x : ↥(data.P ∪ data.Q) → Fin B) => if ¬actualPaddingDegreeCut data.Q L + (data.residueOrigin x + site) then (1 : ℝ) else 0 + have hp := fun (x : ↥(data.P ∪ data.Q) → Fin B) => actualPadding_keep_loss data.Q data.primeQ D hD + (data.residueOrigin x + site) L K η c hη bins + calc + _ ≤ (μ.average (fun x => w x * + ∑ j ∈ bins, if K / L < ρ x j then ρ x j else 0) + + μ.average (fun x => w x * bad x)) / paddingTiltNormalizer data.Q := by + apply div_le_div_of_nonneg_right _ (paddingTiltNormalizer_pos data.Q).le + calc + _ ≤ μ.average (fun x => w x * + ((∑ j ∈ bins, if K / L < ρ x j then ρ x j else 0) + bad x)) := by + apply μ.average_mono + intro x + exact mul_le_mul_of_nonneg_left (hp x) (sq_nonneg _) + _ = _ := by simp only [FiniteLaw.average, mul_add, sum_add_distrib] + _ = μ.average (fun x => w x * + ∑ j ∈ bins, if K / L < ρ x j then ρ x j else 0) / paddingTiltNormalizer data.Q + + μ.average (fun x => w x * bad x) / paddingTiltNormalizer data.Q := add_div _ _ _ + _ ≤ C / K + L ^ (-100 : ℝ) := add_le_add + (hb L η c K h J M B data hQ site bins hL hη hηone hK hB D hD) + (ht h J M B data hQ hB site) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingIntegerBounds.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingIntegerBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..3dd79fcae0009e4e6092e34ec4d9f0a1037f9e89 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingIntegerBounds.lean @@ -0,0 +1,264 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingActiveState +import OAI.NumberTheory.TwoPoint.Bounds.ActiveStateComparison +import OAI.NumberTheory.TwoPoint.Bounds.ResidueLawUniform + +namespace OAI + +/-! Truncated padding weights on actual integer intervals. The finite +active-state comparison is used only after the degree restriction. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma uniformAverage_pi_product {ι : Type*} [Fintype ι] [DecidableEq ι] + {β : ι → Type*} [∀ i, Fintype (β i)] (f : (i : ι) → β i → ℝ) : + uniformAverage (fun x : ∀ i, β i => ∏ i, f i (x i)) = + ∏ i, uniformAverage (f i) := by + simp only [uniformAverage, Fintype.card_pi, Nat.cast_prod] + rw [← Fintype.prod_sum, prod_div_distrib] + +lemma uniformAverage_padding_factor (p : ℕ) [NeZero p] (site : ℤ) : + uniformAverage (fun z : ZMod p => if z + (site : ZMod p) = 0 then (5 : ℝ) else 1) = + 1 + 4 / (p : ℝ) := by + have he (z : ZMod p) : z + (site : ZMod p) = 0 ↔ z = -(site : ZMod p) := by + constructor <;> intro h <;> linear_combination h + have hf (z : ZMod p) : + (if z = -(site : ZMod p) then (5 : ℝ) else 1) = + 1 + if z = -(site : ZMod p) then (4 : ℝ) else 0 := by + split_ifs <;> norm_num + simp only [he, hf, uniformAverage, sum_add_distrib, sum_const, + card_univ, nsmul_eq_mul, mul_one, sum_ite_eq', mem_univ, ite_true, ZMod.card] + have hp : (p : ℝ) ≠ 0 := by exact_mod_cast NeZero.ne p + field_simp + +noncomputable def primeStateTruncatedWeight {m : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (M : ℕ) (site : ℤ) (z : ∀ i, ZMod (s i)) : ℝ := + let S := activeState (fun i => decide (z i + (site : ZMod (s i)) = 0)) + if S.card ≤ M then (5 : ℝ) ^ S.card else 0 + +lemma activeState_five_pow {m : ℕ} (x : BooleanCube m) : + (5 : ℝ) ^ (activeState x).card = ∏ i, if x i then (5 : ℝ) else 1 := by + rw [← prod_const] + simp only [activeState, prod_filter] + +lemma primeStateTruncatedWeight_average_le {m : ℕ} (s : Fin m → ℕ) + [∀ i, NeZero (s i)] (M : ℕ) (site : ℤ) : + uniformAverage (primeStateTruncatedWeight s M site) ≤ + ∏ i, (1 + 4 / (s i : ℝ)) := by + calc + _ ≤ uniformAverage (fun z : ∀ i, ZMod (s i) => + (5 : ℝ) ^ (activeState (fun i => decide (z i + (site : ZMod (s i)) = 0))).card) := by + unfold uniformAverage + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + apply sum_le_sum + intro z _ + dsimp only [primeStateTruncatedWeight] + split_ifs + · exact le_rfl + · positivity + _ = uniformAverage (fun z : ∀ i, ZMod (s i) => + ∏ i, if z i + (site : ZMod (s i)) = 0 then (5 : ℝ) else 1) := by + simp only [activeState_five_pow, decide_eq_true_eq] + _ = _ := by + rw [uniformAverage_pi_product + (fun i (z : ZMod (s i)) => if z + (site : ZMod (s i)) = 0 then (5 : ℝ) else 1)] + simp only [uniformAverage_padding_factor] + +lemma padding_state_coefficient_bound (L : ℝ) (r : ℕ) + (hL : 4800 ≤ L) (hr : (r : ℝ) ≤ 400 * Real.log L) : + (5 : ℝ) ^ r ≤ Real.exp (L ^ 4) := by + have hL0 : 0 ≤ L := by linarith + have hlog : Real.log L ≤ L := + (Real.log_le_sub_one_of_pos (by linarith)).trans (by linarith) + have hpow : 2000 * L ≤ L ^ 4 := by + have h1 := mul_nonneg hL0 (show 0 ≤ L - 2000 by linarith) + have h2 := mul_nonneg (sq_nonneg L) (show 0 ≤ L ^ 2 - 1 by nlinarith) + nlinarith + calc + _ ≤ (Real.exp 5) ^ r := pow_le_pow_left₀ (by norm_num) + (by linarith [Real.add_one_le_exp (5 : ℝ)]) r + _ = Real.exp (r * 5) := by rw [Real.exp_nat_mul] + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) + +theorem BravermanDepth22Input.eventually_prime_state_weight (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (m : ℕ) (s : Fin m → ℕ) [∀ i, NeZero (s i)], + 0 < m → (m : ℝ) ≤ Real.exp L → + Pairwise (fun i j => (s i).Coprime (s j)) → + (∀ i, (s i : ℝ) ≤ Real.exp L) → + ∀ (site : ℤ) (a N : ℕ), Real.exp (L ^ A / 2) ≤ (N : ℝ) → + uniformAverage (fun x : Fin N => primeStateTruncatedWeight s + ⌊400 * Real.log L⌋₊ site (fun i => (a + x.val : ZMod (s i)))) ≤ + (∏ i, (1 + 4 / (s i : ℝ))) + Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hcompare⟩ := hBr.eventually_active_state_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hcompare, eventually_ge_atTop (4800 : ℝ)] with L hcompare hL + intro m s _ hm hmL hcop hs site a N hN + let M : ℕ := ⌊400 * Real.log L⌋₊ + have hlog : 0 ≤ 400 * Real.log L := + mul_nonneg (by norm_num) (Real.log_nonneg (by linarith)) + have hM : (M : ℝ) ≤ 400 * Real.log L := Nat.floor_le hlog + let f : (Fin 1 → Finset (Fin m)) → ℝ := fun S => (5 : ℝ) ^ (S 0).card + have hf : ∀ b : Fin 1 → boundedActiveStates m M, + |f (fun r => (b r).val)| ≤ Real.exp (L ^ 4) := by + intro b + dsimp [f] + rw [abs_of_nonneg (pow_nonneg (by norm_num) _)] + apply padding_state_coefficient_bound L _ hL + exact (Nat.cast_le.mpr (mem_boundedActiveStates.mp (b 0).property)).trans hM + have hc := hcompare m s hm (by linarith) hcop hs 1 m m M hmL hM + (by norm_num; linarith) + (fun i => i) (fun i z => decide (z + (site : ZMod (s i)) = 0)) + (fun _ i => i) f hf a N hN + have he (z : ∀ i, ZMod (s i)) : + (if ∀ r : Fin 1, + (activeState (fun i => residueCircuitInputs s (fun i => i) + (fun i z => decide (z + (site : ZMod (s i)) = 0)) z i)).card ≤ M + then f (fun _ => activeState (fun i => residueCircuitInputs s (fun i => i) + (fun i z => decide (z + (site : ZMod (s i)) = 0)) z i)) else 0) = + primeStateTruncatedWeight s M site z := by + simp only [residueCircuitInputs, f, primeStateTruncatedWeight, forall_const] + dsimp only at hc + simp only [he] at hc + have hb := primeStateTruncatedWeight_average_le s M site + linarith [(le_abs_self + (uniformAverage (fun x : Fin N => primeStateTruncatedWeight s M site + (fun i => (a + x.val : ZMod (s i)))) - + uniformAverage (primeStateTruncatedWeight s M site))).trans hc] + +lemma primeStateTruncatedWeight_actual {m : ℕ} (Q : Finset ℕ) (e : Fin m ≃ Q) + [∀ i, NeZero (e i).val] (M : ℕ) (site n : ℤ) : + primeStateTruncatedWeight (fun i => (e i).val) M site + (fun i => (n : ZMod (e i).val)) = + if actualPaddingDegree Q (n + site) ≤ M then actualPaddingWeight Q (n + site) else 0 := by + have hs : activeState (fun i => decide ((n : ZMod (e i).val) + + (site : ZMod (e i).val) = 0)) = paddingActiveState Q e (n + site) := by + apply (paddingActiveState_residue Q e _ (n + site) _).symm + intro i + exact Int.cast_add n site + simp only [primeStateTruncatedWeight, hs, paddingActiveState_card, actualPaddingWeight] + +lemma primeSet_card_le_exp (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (L : ℝ) (hupper : ∀ p ∈ Q, (p : ℝ) ≤ Real.exp L) : + (Q.card : ℝ) ≤ Real.exp L := by + have hs : Q ⊆ Icc 1 ⌊Real.exp L⌋₊ := by + intro p hp + exact mem_Icc.mpr ⟨(hQ p hp).one_lt.le, + (Nat.le_floor_iff (Real.exp_pos L).le).mpr (hupper p hp)⟩ + have hc : Q.card ≤ ⌊Real.exp L⌋₊ := by + simpa only [Nat.card_Icc, Nat.add_sub_cancel] using card_le_card hs + exact (Nat.cast_le.mpr hc).trans (Nat.floor_le (Real.exp_pos L).le) + +lemma paddingTiltNormalizer_one_le (Q : Finset ℕ) : 1 ≤ paddingTiltNormalizer Q := by + calc + 1 = ∏ _p : Q, (1 : ℝ) := by simp + _ ≤ paddingTiltNormalizer Q := by + apply prod_le_prod₀ + · intro p _ + exact zero_le_one + · intro p _ + exact le_add_of_nonneg_right (by positivity) + +/-- The manuscript's truncated-weight estimate, for literal integer +sites and every permitted interval and offset. -/ +theorem BravermanDepth22Input.eventually_actual_padding_weight (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (Q : Finset ℕ), (∀ p ∈ Q, p.Prime) → + (∀ p ∈ Q, (p : ℝ) ≤ Real.exp L) → + ∀ (site : ℤ) (a N : ℕ), Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let T := uniformAverage (fun x : Fin N => + (actualPaddingVertex Q (((a + x.val : ℕ) : ℤ) + site)) ^ 2 * + if actualPaddingDegreeCut Q L (((a + x.val : ℕ) : ℤ) + site) then 1 else 0) + T ≤ paddingTiltNormalizer Q + Real.exp (-(L ^ 9)) ∧ + T ≤ 2 * paddingTiltNormalizer Q := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_prime_state_weight + refine ⟨A, hA, ?_⟩ + filter_upwards [hb, eventually_ge_atTop (4800 : ℝ)] with L hb hL + intro Q hQ hupper site a N hN + have hL0 : 0 ≤ L := by linarith + have hlog : 0 ≤ 400 * Real.log L := + mul_nonneg (by norm_num) (Real.log_nonneg (by linarith)) + have hmain : uniformAverage (fun x : Fin N => + (actualPaddingVertex Q (((a + x.val : ℕ) : ℤ) + site)) ^ 2 * + if actualPaddingDegreeCut Q L (((a + x.val : ℕ) : ℤ) + site) then 1 else 0) ≤ + paddingTiltNormalizer Q + Real.exp (-(L ^ 9)) := by + by_cases hne : Q.Nonempty + · let m := Fintype.card Q + let e : Fin m ≃ Q := (Fintype.equivFin Q).symm + let s := fun i : Fin m => (e i).val + let (i : Fin m) : NeZero (s i) := ⟨(hQ _ (e i).property).ne_zero⟩ + have hm : 0 < m := Fintype.card_pos_iff.mpr ⟨⟨hne.choose, hne.choose_spec⟩⟩ + have hmL : (m : ℝ) ≤ Real.exp L := by + simpa only [m, Fintype.card_coe] using primeSet_card_le_exp Q hQ L hupper + have hcop : Pairwise (fun i j => (s i).Coprime (s j)) := by + intro i j hij + apply (Nat.coprime_primes (hQ _ (e i).property) (hQ _ (e j).property)).mpr + intro he + exact hij (e.injective (Subtype.ext he)) + have hs (i : Fin m) : (s i : ℝ) ≤ Real.exp L := hupper _ (e i).property + have hh := hb m s hm hmL hcop hs site a N hN + have heval (x : Fin N) : primeStateTruncatedWeight s ⌊400 * Real.log L⌋₊ site + (fun i => (a + x.val : ZMod (s i))) = + (actualPaddingVertex Q (((a + x.val : ℕ) : ℤ) + site)) ^ 2 * + if actualPaddingDegreeCut Q L (((a + x.val : ℕ) : ℤ) + site) then 1 else 0 := by + have hx := primeStateTruncatedWeight_actual Q e ⌊400 * Real.log L⌋₊ site + ((a + x.val : ℕ) : ℤ) + simp only [Nat.cast_add, Int.cast_add, Int.cast_natCast] at hx + rw [hx] + simp only [Nat.le_floor_iff hlog, actualPaddingVertex_sq, + actualPaddingDegreeCut, Nat.cast_add] + split_ifs <;> simp + have hnorm : (∏ i, (1 + 4 / (s i : ℝ))) = paddingTiltNormalizer Q := + e.prod_comp (fun p : Q => 1 + 4 / (p.val : ℝ)) + simpa only [heval, hnorm] using hh + · have hQempty : Q = ∅ := not_nonempty_iff_eq_empty.mp hne + subst Q + have hNpos : 0 < N := by exact_mod_cast (Real.exp_pos _).trans_le hN + let : NeZero N := ⟨by omega⟩ + have hf (x : Fin N) : + (actualPaddingVertex ∅ (((a + x.val : ℕ) : ℤ) + site)) ^ 2 * + (if actualPaddingDegreeCut ∅ L (((a + x.val : ℕ) : ℤ) + site) + then (1 : ℝ) else 0) = 1 := by + simp only [actualPaddingVertex_sq, actualPaddingWeight, actualPaddingDegree, + filter_empty, card_empty, pow_zero, actualPaddingDegreeCut, Nat.cast_zero, + hlog, ite_true, mul_one] + simp only [hf, uniformAverage_const] + have hnorm : paddingTiltNormalizer ∅ = 1 := by simp [paddingTiltNormalizer] + rw [hnorm] + linarith [Real.exp_pos (-(L ^ 9))] + dsimp only + refine ⟨hmain, ?_⟩ + have he : Real.exp (-(L ^ 9)) ≤ 1 := + Real.exp_le_one_iff.mpr (neg_nonpos.mpr (pow_nonneg hL0 _)) + have hS := paddingTiltNormalizer_one_le Q + linarith + +/-- Summing over any fixed finite collection of offsets costs its cardinality. -/ +theorem BravermanDepth22Input.eventually_actual_padding_weight_sum + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (Q : Finset ℕ), (∀ p ∈ Q, p.Prime) → + (∀ p ∈ Q, (p : ℝ) ≤ Real.exp L) → + ∀ {ι : Type*} [DecidableEq ι] (offsets : Finset ι) (site : ι → ℤ) + (a N : ℕ), Real.exp (L ^ A / 2) ≤ (N : ℝ) → + (∑ i ∈ offsets, uniformAverage (fun x : Fin N => + (actualPaddingVertex Q (((a + x.val : ℕ) : ℤ) + site i)) ^ 2 * + if actualPaddingDegreeCut Q L (((a + x.val : ℕ) : ℤ) + site i) + then 1 else 0)) ≤ + 2 * (offsets.card : ℝ) * paddingTiltNormalizer Q := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_actual_padding_weight + refine ⟨A, hA, ?_⟩ + filter_upwards [hb] with L hb + intro Q hQ hupper ι _ offsets site a N hN + calc + _ ≤ ∑ _i ∈ offsets, 2 * paddingTiltNormalizer Q := by + apply sum_le_sum + intro i _ + exact (hb Q hQ hupper (site i) a N hN).2 + _ = _ := by rw [sum_const, nsmul_eq_mul]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingMarginal.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingMarginal.lean new file mode 100644 index 0000000000000000000000000000000000000000..cde436a48fec2d44179b6164453a2e7587341128 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingMarginal.lean @@ -0,0 +1,126 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResidueRestriction +import OAI.NumberTheory.TwoPoint.Bounds.ActualPaddingResidues + +namespace OAI + +/-! The actual padding estimates under the full tuple-and-padding residue +law. All dependence on the tuple coordinates is removed by the proved +product-law restriction identity. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +namespace ProhibitedPrimeFamily + +variable {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + +lemma residue_average_padding_squares + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) (D : Finset ℕ) + (hD : D ⊆ retainedPrimeDivisors data.Q) (site : ℤ) + (η c : ℝ) (bins : Finset ℤ) : + (data.residueLaw B hB).average (fun x => + (actualPaddingVertex data.Q (data.residueOrigin x + site)) ^ 2 * + ∑ j ∈ bins, (paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex data.Q) (data.residueOrigin x + site)) ^ 2) = + (data.paddingResidueLaw B hB).average (fun x => + (actualPaddingVertex data.Q (data.paddingResidueOrigin x + site)) ^ 2 * + ∑ j ∈ bins, (paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex data.Q) (data.paddingResidueOrigin x + site)) ^ 2) := by + apply data.residue_average_padding_shift hB site (fun n => + (actualPaddingVertex data.Q n) ^ 2 * ∑ j ∈ bins, + (paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex data.Q) n) ^ 2) + intro n m hnm + rw [actualPaddingVertex_residue_congr data.Q n m hnm] + congr 1 + apply sum_congr rfl + intro j _ + rw [actualPaddingDensity_residue_congr data.Q data.primeQ D hD _ n m hnm] + +lemma residue_average_padding_degree_tail + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) (site : ℤ) (L : ℝ) : + (data.residueLaw B hB).average (fun x => + (actualPaddingVertex data.Q (data.residueOrigin x + site)) ^ 2 * + if ¬actualPaddingDegreeCut data.Q L (data.residueOrigin x + site) then 1 else 0) = + (data.paddingResidueLaw B hB).average (fun x => + (actualPaddingVertex data.Q (data.paddingResidueOrigin x + site)) ^ 2 * + if ¬actualPaddingDegreeCut data.Q L (data.paddingResidueOrigin x + site) then 1 else 0) := by + apply data.residue_average_padding_shift hB site (fun n => + (actualPaddingVertex data.Q n) ^ 2 * + if ¬actualPaddingDegreeCut data.Q L n then 1 else 0) + intro n m hnm + rw [actualPaddingVertex_residue_congr data.Q n m hnm, + actualPaddingDegreeCut_residue_congr data.Q L n m hnm] + +end ProhibitedPrimeFamily + +theorem ModFiveThetaInput.actual_family_padding_bin_square (hP : ModFiveThetaInput) + (E : Finset ℕ) : + ∃ C : ℝ, 0 < C ∧ ∀ (L η c : ℝ) (h J M B : ℕ) + (data : ProhibitedPrimeFamily h J M), data.Q = paddingPrimeSupply E L → + ∀ (site : ℤ) (bins : Finset ℤ), 1 ≤ L → 0 < η → η ≤ 1 → + ∀ (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (D : Finset ℕ), D ⊆ retainedPrimeDivisors data.Q → + (data.residueLaw B hB).average (fun x => + (actualPaddingVertex data.Q (data.residueOrigin x + site)) ^ 2 * + ∑ j ∈ bins, (paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex data.Q) (data.residueOrigin x + site)) ^ 2) / + paddingTiltNormalizer data.Q ≤ C / L := by + obtain ⟨C, hC, hb⟩ := hP.actual_padding_residue_bin_square E + refine ⟨C, hC, ?_⟩ + intro L η c h J M B data hQ site bins hL hη hηone hB D hD + rw [data.residue_average_padding_squares hB D hD site η c bins] + have hbQ : ∀ (Q : Finset ℕ), Q = paddingPrimeSupply E L → + ∀ (hprime : ∀ p ∈ Q, p.Prime) (hQB : ∀ p ∈ Q, p ≤ B) + (N : (Q → Fin B) → ℤ), + (∀ z (p : Q), (N z : ZMod p.val) = + ((z p).val : ZMod p.val) + (site : ZMod p.val)) → + D ⊆ retainedPrimeDivisors Q → + (FiniteLaw.independent (fun p : Q => uniformResidueLaw B p.val + (hprime p p.property).pos (hQB p p.property))).average (fun z => + (actualPaddingVertex Q (N z)) ^ 2 * ∑ j ∈ bins, + (paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex Q) (N z)) ^ 2) / paddingTiltNormalizer Q ≤ C / L := by + intro Q hQ hprime hQB N hN hD + subst Q + exact hb L η c B site bins hL hη hηone hQB D hD N hN + apply hbQ data.Q hQ data.primeQ (fun p hp => hB p (mem_union_right _ hp)) + (fun z => data.paddingResidueOrigin z + site) _ hD + intro z p + rw [Int.cast_add, data.paddingResidueOrigin_spec z p] + +theorem ModFiveThetaInput.eventually_actual_family_padding_degree_tail + (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M), + data.Q = paddingPrimeSupply E L → + ∀ (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) (site : ℤ), + (data.residueLaw B hB).average (fun x => + (actualPaddingVertex data.Q (data.residueOrigin x + site)) ^ 2 * + if ¬actualPaddingDegreeCut data.Q L (data.residueOrigin x + site) then 1 else 0) / + paddingTiltNormalizer data.Q ≤ L ^ (-100 : ℝ) := by + filter_upwards [hP.eventually_actual_padding_degree_tail E] with L hb + intro h J M B data hQ hB site + rw [data.residue_average_padding_degree_tail hB site L] + have hbQ : ∀ (Q : Finset ℕ), Q = paddingPrimeSupply E L → + ∀ (hprime : ∀ p ∈ Q, p.Prime) (hQB : ∀ p ∈ Q, p ≤ B) + (N : (Q → Fin B) → ℤ), + (∀ z (p : Q), (N z : ZMod p.val) = + ((z p).val : ZMod p.val) + (site : ZMod p.val)) → + (FiniteLaw.independent (fun p : Q => uniformResidueLaw B p.val + (hprime p p.property).pos (hQB p p.property))).average (fun z => + (actualPaddingVertex Q (N z)) ^ 2 * + if ¬actualPaddingDegreeCut Q L (N z) then 1 else 0) / + paddingTiltNormalizer Q ≤ L ^ (-100 : ℝ) := by + intro Q hQ hprime hQB N hN + subst Q + exact hb B site hQB N hN + apply hbQ data.Q hQ data.primeQ (fun p hp => hB p (mem_union_right _ hp)) + (fun z => data.paddingResidueOrigin z + site) + intro z p + rw [Int.cast_add, data.paddingResidueOrigin_spec z p] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingProduct.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..70358f6e91f2dde6003669d1c651311b007f11c5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingProduct.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.TwoPoint.Bounds.GoodRetainedWordSum +import OAI.NumberTheory.TwoPoint.Walks.WordSegments +import OAI.NumberTheory.TwoPoint.Walks.TupleColumnWords + +namespace OAI + +/-! Identify recursive padding weights with the literal product at the numerical departures. -/ + +namespace TwoPointCorrelations + +open Finset + +theorem paddingWordWeight_eq_prod_sites (Q : Finset ℕ) + (weight : ℕ → ℤ → ℕ → ℝ) (next : ℕ → ℤ → ℕ → ℤ) + {m : ℕ} (i : ℕ) (n : ℤ) (q : Fin m → Q) (site : Fin (m + 1) → ℤ) + (hzero : site 0 = n) + (hstep : ∀ t : Fin m, site t.succ = next (i + t.val) (site t.castSucc) (q t).val) : + paddingWordWeight Q weight next i n q = + ∏ t : Fin m, weight (i + t.val) (site t.castSucc) (q t).val := by + induction m generalizing i n with + | zero => simp [paddingWordWeight] + | succ m ih => + rw [paddingWordWeight, Fin.prod_univ_succ] + have hz : site (Fin.succ 0) = next i n (q 0).val := by + simpa only [Fin.val_zero, Nat.add_zero, Fin.castSucc_zero, hzero] using hstep 0 + have hs : ∀ t : Fin m, (fun u : Fin (m + 1) => site u.succ) t.succ = + next (i + 1 + t.val) ((fun u : Fin (m + 1) => site u.succ) t.castSucc) + ((Fin.tail q) t).val := by + intro t + simpa only [Fin.val_succ, Nat.add_assoc, Nat.add_comm 1 t.val, + Fin.succ_castSucc, Fin.tail] using hstep t.succ + rw [ih (i + 1) _ (Fin.tail q) (fun u => site u.succ) hz hs] + simp only [Fin.val_zero, Nat.add_zero, Fin.castSucc_zero, hzero] + congr 1 + apply prod_congr rfl + intro t _ + simp only [Fin.val_succ, Nat.add_assoc, Nat.add_comm 1 t.val, + Fin.succ_castSucc, Fin.tail] + +lemma wordDisplacement_take_succ (h : ℕ) (word : List SignedStep) (t : ℕ) : + wordDisplacement h (word.take (t + 1)) = + wordDisplacement h (word.take t) + wordStepDisplacement h word t := by + simp only [wordDisplacement_take, sum_range_succ] + +theorem paddingWordWeight_eq_departure_product {Q : Finset ℕ} {m : ℕ} + (h : ℕ) (step : Fin m → SignedStep) (q : Fin m → Q) + (weight : ℕ → ℤ → ℕ → ℝ) (next : ℕ → ℤ → ℕ → ℤ) (n : ℤ) + (hnext : ∀ t : Fin m, ∀ z, next t.val z (q t).val = z + (step t).displacement h) : + paddingWordWeight Q weight next 0 n q = + ∏ t : Fin m, weight t.val + (n + wordDisplacement h ((List.ofFn step).take t.val)) (q t).val := by + let site (t : Fin (m + 1)) := n + wordDisplacement h ((List.ofFn step).take t.val) + have hz : site 0 = n := by simp [site] + have hs (t : Fin m) : site t.succ = next (0 + t.val) (site t.castSucc) (q t).val := by + rw [Nat.zero_add, hnext] + simp only [site, Fin.val_succ, Fin.val_castSucc, wordDisplacement_take_succ] + have ht : wordStepDisplacement h (List.ofFn step) t.val = (step t).displacement h := by + simp only [wordStepDisplacement, List.getElem?_ofFn, t.isLt, dite_true, Fin.eta, + Option.map_some, Option.getD_some] + rw [ht, add_assoc] + simpa only [Nat.zero_add, site, Fin.val_castSucc] using + paddingWordWeight_eq_prod_sites Q weight next 0 n q site hz hs + +theorem retainedColumnPaddingWeight_eq_departure_product {J k : ℕ} + {P : Fin J → Finset ℕ} (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ColumnPrimeAssignment J (2 * k) P → ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) + (extra : ColumnPrimeAssignment J (2 * k) P → ℕ → ℤ → Prop) + (next : ColumnPrimeAssignment J (2 * k) P → ℕ → ℤ → ℕ → ℤ) + (h : ℕ) (n : ℤ) (w : ColumnPrimeAssignment J (2 * k) P) + (forward : Fin (2 * k) → Bool) (q : Fin (2 * k) → Q) + (hnext : ∀ i : Fin (2 * k), ∀ z, next w i.val z (q i).val = + z + (SignedStep.mk (forward i) (columnTuple w i) (q i).val).displacement h) : + retainedColumnPaddingWeight Q u eligible g L K extra next n w q = + ∏ i : Fin (2 * k), retainedPaddingAtom Q u (eligible w i.val) g L K (extra w i.val) + (n + wordDisplacement h ((columnTupleWord w forward (fun i => (q i).val)).take i.val)) + (q i).val := by + exact paddingWordWeight_eq_departure_product h + (fun i => SignedStep.mk (forward i) (columnTuple w i) (q i).val) q + (fun i z r => retainedPaddingAtom Q u (eligible w i) g L K (extra w i) z r) + (next w) n hnext + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingResidues.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingResidues.lean new file mode 100644 index 0000000000000000000000000000000000000000..0bb96702748ac804df9be3d10397735cdaae03c1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingResidues.lean @@ -0,0 +1,119 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualPaddingWeights +import OAI.NumberTheory.TwoPoint.Bounds.PaddingDegreeTail +import OAI.NumberTheory.TwoPoint.Bounds.PaddingLargeBinCut + +namespace OAI + +/-! The proved padding laws applied to the graph's actual integer +normalization and bin density at any common lift of the prime residues. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma actualPaddingAvailability_lift (Q : Finset ℕ) (B : ℕ) (site : ℤ) + (z : Q → Fin B) (n : ℤ) + (hn : ∀ p : Q, (n : ZMod p.val) = ((z p).val : ZMod p.val) + (site : ZMod p.val)) : + (fun p : Q => decide ((p.val : ℤ) ∣ n)) = paddingResidueAvailable Q B site z := by + funext p + have hd : (p.val : ℤ) ∣ n ↔ (p.val : ℤ) ∣ ((z p).val : ℤ) + site := by + rw [← ZMod.intCast_zmod_eq_zero_iff_dvd, ← ZMod.intCast_zmod_eq_zero_iff_dvd, + Int.cast_add, Int.cast_natCast, hn p] + simp only [paddingResidueAvailable, hd] + +lemma actualPaddingWeight_lift (Q : Finset ℕ) (B : ℕ) (site : ℤ) + (z : Q → Fin B) (n : ℤ) + (hn : ∀ p : Q, (n : ZMod p.val) = ((z p).val : ZMod p.val) + (site : ZMod p.val)) : + actualPaddingWeight Q n = paddingTiltWeight Q (paddingResidueAvailable Q B site z) := by + rw [actualPaddingWeight_eq_tilt, actualPaddingAvailability_lift Q B site z n hn] + +lemma actualPaddingDegree_lift (Q : Finset ℕ) (B : ℕ) (site : ℤ) + (z : Q → Fin B) (n : ℤ) + (hn : ∀ p : Q, (n : ZMod p.val) = ((z p).val : ZMod p.val) + (site : ZMod p.val)) : + (actualPaddingDegree Q n : ℝ) = booleanCount (paddingResidueAvailable Q B site z) := by + rw [actualPaddingDegree_eq_available, actualPaddingAvailability_lift Q B site z n hn, + paddingAvailablePrimes_card, booleanCount_eq_card] + rfl + +lemma actualPaddingBin_lift (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (B : ℕ) (site : ℤ) (z : Q → Fin B) (n : ℤ) + (hn : ∀ p : Q, (n : ZMod p.val) = ((z p).val : ZMod p.val) + (site : ZMod p.val)) + (η c : ℝ) (j : ℤ) (hη : 0 < η) : + integerPaddingBinMass Q n η c j = + literalPaddingBinMass Q (paddingResidueAvailable Q B site z) η c j := by + rw [← literalPaddingBinMass_integer Q hQ n η c j hη, + actualPaddingAvailability_lift Q B site z n hn] + +/-- The literal graph density, including an arbitrary restriction on the +padding-divisor set, has the same squared-bin bound at any residue lift. -/ +theorem ModFiveThetaInput.actual_padding_residue_bin_square (hP : ModFiveThetaInput) + (E : Finset ℕ) : + ∃ C : ℝ, 0 < C ∧ ∀ (L η c : ℝ) (B : ℕ) (site : ℤ) (bins : Finset ℤ), + 1 ≤ L → 0 < η → η ≤ 1 → + ∀ (hQB : ∀ p ∈ paddingPrimeSupply E L, p ≤ B) + (D : Finset ℕ), D ⊆ retainedPrimeDivisors (paddingPrimeSupply E L) → + ∀ N : (paddingPrimeSupply E L → Fin B) → ℤ, + (∀ z (p : paddingPrimeSupply E L), + (N z : ZMod p.val) = ((z p).val : ZMod p.val) + (site : ZMod p.val)) → + (FiniteLaw.independent (fun p : paddingPrimeSupply E L => + uniformResidueLaw B p.val (paddingPrimeSupply_prime p.property).pos + (hQB p p.property))).average (fun z => + (actualPaddingVertex (paddingPrimeSupply E L) (N z)) ^ 2 * + ∑ j ∈ bins, (paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex (paddingPrimeSupply E L)) (N z)) ^ 2) / + paddingTiltNormalizer (paddingPrimeSupply E L) ≤ C / L := by + obtain ⟨C, hC, hb⟩ := hP.padding_residue_bin_square E + refine ⟨C, hC, ?_⟩ + intro L η c B site bins hL hη hηone hQB D hD N hN + let Q := paddingPrimeSupply E L + let μ := FiniteLaw.independent (fun p : Q => + uniformResidueLaw B p.val (paddingPrimeSupply_prime p.property).pos (hQB p p.property)) + calc + _ ≤ μ.average (fun z => paddingTiltWeight Q (paddingResidueAvailable Q B site z) * + ∑ j ∈ bins, (literalPaddingBinMass Q (paddingResidueAvailable Q B site z) η c j) ^ 2) / + paddingTiltNormalizer Q := by + apply div_le_div_of_nonneg_right _ (paddingTiltNormalizer_pos Q).le + apply μ.average_mono + intro z + rw [actualPaddingVertex_sq, actualPaddingWeight_lift Q B site z (N z) (hN z)] + apply mul_le_mul_of_nonneg_left _ (paddingTiltWeight_pos Q _).le + apply sum_le_sum + intro j _ + apply pow_le_pow_left₀ (actualPaddingDensity_nonneg Q D (actualPaddingBin η c j) (N z)) + exact (actualPaddingDensity_le_integerBin Q D hD (N z) η c j).trans_eq + (actualPaddingBin_lift Q (fun _ hp => paddingPrimeSupply_prime hp) + B site z (N z) (hN z) η c j hη) + _ ≤ C / L := hb L η c B site bins hL hη hηone hQB + +/-- Deleting vertices with more than `400 log L` padding primes has the +proved weighted probability cost for the literal graph normalization. -/ +theorem ModFiveThetaInput.eventually_actual_padding_degree_tail (hP : ModFiveThetaInput) + (E : Finset ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (B : ℕ) (site : ℤ) + (hQB : ∀ p ∈ paddingPrimeSupply E L, p ≤ B) + (N : (paddingPrimeSupply E L → Fin B) → ℤ), + (∀ z (p : paddingPrimeSupply E L), + (N z : ZMod p.val) = ((z p).val : ZMod p.val) + (site : ZMod p.val)) → + (FiniteLaw.independent (fun p : paddingPrimeSupply E L => + uniformResidueLaw B p.val (paddingPrimeSupply_prime p.property).pos + (hQB p p.property))).average (fun z => + (actualPaddingVertex (paddingPrimeSupply E L) (N z)) ^ 2 * + if ¬actualPaddingDegreeCut (paddingPrimeSupply E L) L (N z) then 1 else 0) / + paddingTiltNormalizer (paddingPrimeSupply E L) ≤ L ^ (-100 : ℝ) := by + filter_upwards [hP.eventually_padding_residue_degree_tail E] with L hL + intro B site hQB N hN + have he (z : paddingPrimeSupply E L → Fin B) : + (actualPaddingVertex (paddingPrimeSupply E L) (N z)) ^ 2 * + (if ¬actualPaddingDegreeCut (paddingPrimeSupply E L) L (N z) then 1 else 0) = + paddingTiltWeight _ (paddingResidueAvailable _ B site z) * + (if 400 * Real.log L < booleanCount (paddingResidueAvailable _ B site z) + then 1 else 0) := by + rw [actualPaddingVertex_sq, actualPaddingWeight_lift _ B site z (N z) (hN z)] + simp only [actualPaddingDegreeCut, actualPaddingDegree_lift _ B site z (N z) (hN z), not_le] + simp_rw [he] + exact hL B site hQB + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingWeights.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..763de420c5cc4e45bceacb5d092bd9a9fb79baca --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPaddingWeights.lean @@ -0,0 +1,201 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeTuplePool +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedWeightIndependence + +namespace OAI + +/-! The graph's literal padding weight and vertex normalization. +The normalization is the square root of `5^omega_Q(n)` and depends +only on the padding-prime residues, including at the integer zero. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def actualPaddingDegree (Q : Finset ℕ) (n : ℤ) : ℕ := + (Q.filter (fun p : ℕ => (p : ℤ) ∣ n)).card + +noncomputable def actualPaddingWeight (Q : Finset ℕ) (n : ℤ) : ℝ := + (5 : ℝ) ^ actualPaddingDegree Q n + +noncomputable def actualPaddingVertex (Q : Finset ℕ) (n : ℤ) : ℝ := + Real.sqrt (actualPaddingWeight Q n) + +noncomputable def actualPaddingCoefficient (q : ℕ) : ℝ := + (4 : ℝ) ^ q.primeFactors.card + +lemma actualPaddingCoefficient_nonneg (q : ℕ) : 0 ≤ actualPaddingCoefficient q := by + unfold actualPaddingCoefficient + positivity + +lemma actualPaddingWeight_one_le (Q : Finset ℕ) (n : ℤ) : 1 ≤ actualPaddingWeight Q n := + one_le_pow₀ (by norm_num) + +lemma actualPaddingVertex_one_le (Q : Finset ℕ) (n : ℤ) : 1 ≤ actualPaddingVertex Q n := by + simpa only [actualPaddingVertex, Real.sqrt_one] using + Real.sqrt_le_sqrt (actualPaddingWeight_one_le Q n) + +lemma actualPaddingVertex_pos (Q : Finset ℕ) (n : ℤ) : 0 < actualPaddingVertex Q n := + zero_lt_one.trans_le (actualPaddingVertex_one_le Q n) + +lemma actualPaddingVertex_ne_zero (Q : Finset ℕ) (n : ℤ) : actualPaddingVertex Q n ≠ 0 := + (actualPaddingVertex_pos Q n).ne' + +lemma actualPaddingVertex_sq (Q : Finset ℕ) (n : ℤ) : + actualPaddingVertex Q n ^ 2 = actualPaddingWeight Q n := + Real.sq_sqrt (zero_le_one.trans (actualPaddingWeight_one_le Q n)) + +lemma actualPaddingDegree_residue_congr (Q : Finset ℕ) (n m : ℤ) + (hnm : ∀ p ∈ Q, (n : ZMod p) = (m : ZMod p)) : + actualPaddingDegree Q n = actualPaddingDegree Q m := by + unfold actualPaddingDegree + congr 1 + ext p + simp only [mem_filter] + apply and_congr_right + intro hp + rw [← ZMod.intCast_zmod_eq_zero_iff_dvd, ← ZMod.intCast_zmod_eq_zero_iff_dvd, hnm p hp] + +lemma actualPaddingWeight_residue_congr (Q : Finset ℕ) (n m : ℤ) + (hnm : ∀ p ∈ Q, (n : ZMod p) = (m : ZMod p)) : + actualPaddingWeight Q n = actualPaddingWeight Q m := by + unfold actualPaddingWeight + rw [actualPaddingDegree_residue_congr Q n m hnm] + +lemma actualPaddingVertex_residue_congr (Q : Finset ℕ) (n m : ℤ) + (hnm : ∀ p ∈ Q, (n : ZMod p) = (m : ZMod p)) : + actualPaddingVertex Q n = actualPaddingVertex Q m := by + unfold actualPaddingVertex + rw [actualPaddingWeight_residue_congr Q n m hnm] + +noncomputable def actualPaddingDegreeCut (Q : Finset ℕ) (L : ℝ) (n : ℤ) : Prop := + (actualPaddingDegree Q n : ℝ) ≤ 400 * Real.log L + +lemma actualPaddingDegreeCut_residue_congr (Q : Finset ℕ) (L : ℝ) (n m : ℤ) + (hnm : ∀ p ∈ Q, (n : ZMod p) = (m : ZMod p)) : + actualPaddingDegreeCut Q L n ↔ actualPaddingDegreeCut Q L m := by + unfold actualPaddingDegreeCut + rw [actualPaddingDegree_residue_congr Q n m hnm] + +lemma actualPaddingDegree_eq_available (Q : Finset ℕ) (n : ℤ) : + actualPaddingDegree Q n = + (paddingAvailablePrimes Q (fun p => decide ((p.val : ℤ) ∣ n))).card := by + rw [paddingAvailablePrimes_integer] + rfl + +lemma actualPaddingWeight_eq_tilt (Q : Finset ℕ) (n : ℤ) : + actualPaddingWeight Q n = paddingTiltWeight Q (fun p => decide ((p.val : ℤ) ∣ n)) := by + rw [paddingTiltWeight_eq_five_pow, ← paddingAvailablePrimes_card, + ← actualPaddingDegree_eq_available] + rfl + +lemma actualPaddingWeight_eq_divisor_sum (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) (n : ℤ) : + actualPaddingWeight Q n = ∑ q ∈ retainedPrimeDivisors Q, + if (q : ℤ) ∣ n then actualPaddingCoefficient q else 0 := by + simpa only [actualPaddingWeight, actualPaddingDegree, actualPaddingCoefficient] using + (padding_integer_weight_total Q hQ n).symm + +def actualPaddingBin (η c : ℝ) (j : ℤ) (q : ℕ) : Prop := + (j : ℝ) * η ≤ Real.log q + c ∧ Real.log q + c < ((j : ℝ) + 1) * η + +/-- With all squarefree padding divisors available, the graph density is +exactly the literal normalized bin mass. -/ +lemma actualPaddingDensity_eq_integerBin (Q : Finset ℕ) (n : ℤ) (η c : ℝ) (j : ℤ) : + paddingDensity (retainedPrimeDivisors Q) actualPaddingCoefficient + (actualPaddingBin η c j) (actualPaddingVertex Q) n = + integerPaddingBinMass Q n η c j := by + unfold paddingDensity integerPaddingBinMass + rw [actualPaddingVertex_sq] + change (∑ q ∈ retainedPrimeDivisors Q, + if actualPaddingBin η c j q ∧ (q : ℤ) ∣ n then actualPaddingCoefficient q else 0) / + (5 : ℝ) ^ (Q.filter (fun p : ℕ => (p : ℤ) ∣ n)).card = _ + have hs : (∑ q ∈ retainedPrimeDivisors Q, + if actualPaddingBin η c j q ∧ (q : ℤ) ∣ n then actualPaddingCoefficient q else 0) = + ∑ q ∈ retainedPrimeDivisors Q, + if (q : ℤ) ∣ n ∧ (j : ℝ) * η ≤ Real.log q + c ∧ + Real.log q + c < ((j : ℝ) + 1) * η + then (4 : ℝ) ^ q.primeFactors.card else 0 := by + apply sum_congr rfl + intro q _ + have he : actualPaddingBin η c j q ∧ (q : ℤ) ∣ n ↔ + (q : ℤ) ∣ n ∧ (j : ℝ) * η ≤ Real.log q + c ∧ + Real.log q + c < ((j : ℝ) + 1) * η := by + unfold actualPaddingBin + tauto + simp only [he, actualPaddingCoefficient] + rw [hs, zpow_neg, zpow_natCast, div_eq_mul_inv, mul_comm] + +lemma actualPaddingDensity_nonneg (Q : Finset ℕ) (D : Finset ℕ) + (eligible : ℕ → Prop) (n : ℤ) : + 0 ≤ paddingDensity D actualPaddingCoefficient eligible (actualPaddingVertex Q) n := by + unfold paddingDensity + apply div_nonneg _ (sq_nonneg _) + apply sum_nonneg + intro q _ + split_ifs + · exact actualPaddingCoefficient_nonneg q + · exact le_rfl + +lemma actualPaddingDensity_le_one (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (D : Finset ℕ) (hD : D ⊆ retainedPrimeDivisors Q) + (eligible : ℕ → Prop) (n : ℤ) : + paddingDensity D actualPaddingCoefficient eligible (actualPaddingVertex Q) n ≤ 1 := by + unfold paddingDensity + rw [actualPaddingVertex_sq] + apply (div_le_one (zero_lt_one.trans_le (actualPaddingWeight_one_le Q n))).mpr + calc + _ ≤ ∑ q ∈ D, if (q : ℤ) ∣ n then actualPaddingCoefficient q else 0 := by + apply sum_le_sum + intro q _ + by_cases he : eligible q <;> by_cases hd : (q : ℤ) ∣ n + · simp only [he, hd, and_self, ite_true, le_refl] + · simp only [he, hd, and_false, ite_false, le_refl] + · simp only [he, hd, false_and, ite_false, ite_true] + exact actualPaddingCoefficient_nonneg q + · simp only [he, hd, false_and, ite_false, le_refl] + _ ≤ ∑ q ∈ retainedPrimeDivisors Q, + if (q : ℤ) ∣ n then actualPaddingCoefficient q else 0 := by + apply sum_le_sum_of_subset_of_nonneg hD + intro q _ _ + split_ifs + · exact actualPaddingCoefficient_nonneg q + · exact le_rfl + _ = _ := (actualPaddingWeight_eq_divisor_sum Q hQ n).symm + +lemma actualPaddingDensity_le_integerBin (Q : Finset ℕ) (D : Finset ℕ) + (hD : D ⊆ retainedPrimeDivisors Q) (n : ℤ) (η c : ℝ) (j : ℤ) : + paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex Q) n ≤ integerPaddingBinMass Q n η c j := by + rw [← actualPaddingDensity_eq_integerBin Q n η c j] + unfold paddingDensity + apply div_le_div_of_nonneg_right _ (sq_nonneg _) + apply sum_le_sum_of_subset_of_nonneg hD + intro q _ _ + split_ifs + · exact actualPaddingCoefficient_nonneg q + · exact le_rfl + +lemma actualPaddingDensity_residue_congr (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (D : Finset ℕ) (hD : D ⊆ retainedPrimeDivisors Q) (eligible : ℕ → Prop) + (n m : ℤ) (hnm : ∀ p ∈ Q, (n : ZMod p) = (m : ZMod p)) : + paddingDensity D actualPaddingCoefficient eligible (actualPaddingVertex Q) n = + paddingDensity D actualPaddingCoefficient eligible (actualPaddingVertex Q) m := + paddingDensity_eq_of_prime_residues Q D actualPaddingCoefficient eligible (actualPaddingVertex Q) + (fun _ hq => retainedPrimeDivisor_squarefree Q hQ (hD hq)) + (fun _ hq => retainedPrimeDivisor_factors Q hQ (hD hq)) n m hnm + (actualPaddingVertex_residue_congr Q n m hnm) + +lemma actualPaddingKeep_residue_congr (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (D : Finset ℕ) (hD : D ⊆ retainedPrimeDivisors Q) (eligible : ℕ → Prop) + (L K : ℝ) (n m : ℤ) (hnm : ∀ p ∈ Q, (n : ZMod p) = (m : ZMod p)) : + integerEdgeKeep D actualPaddingCoefficient eligible (actualPaddingVertex Q) L K + (actualPaddingDegreeCut Q L) n ↔ + integerEdgeKeep D actualPaddingCoefficient eligible (actualPaddingVertex Q) L K + (actualPaddingDegreeCut Q L) m := by + unfold integerEdgeKeep + rw [actualPaddingDensity_residue_congr Q hQ D hD eligible n m hnm, + actualPaddingDegreeCut_residue_congr Q L n m hnm] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeAffineWordComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeAffineWordComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..97080ea59092d4b7b7f807c72cfb4f18b0abb1d2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeAffineWordComparison.lean @@ -0,0 +1,151 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualAffineWordComparison +import OAI.NumberTheory.TwoPoint.Bounds.ActualPrimeWordComparison + +namespace OAI + +/-! Canonical prime bands exclude every prime factor of the progression +modulus, so the affine-origin word comparison has no additional premise. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma canonicalTraceFamily_coprime (h l : ℕ) (E : Finset ℕ) (W L : ℝ) + (eligible : ℕ → ℕ → Prop) (hL : 1 ≤ L) (hW : 1 ≤ W) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) : + ∀ p ∈ (canonicalTraceFamily h E W L eligible hL hW hE).P ∪ + (canonicalTraceFamily h E W L eligible hL hW hE).Q, l.Coprime p := by + intro p hp + have hprime := (canonicalTraceFamily h E W L eligible hL hW hE).prime ⟨p, hp⟩ + have hnot : p ∉ E := by + rcases mem_union.mp hp with hp | hp + · obtain ⟨j, hj⟩ := mem_primeTuplePool.mp hp + exact (centeredPrimeSupply_mem hj).2.2.1 + · exact (mem_sdiff.mp hp).2 + exact (hprime.coprime_iff_not_dvd.mpr (fun hd => hnot (hEl p hprime hd))).symm + +theorem ModFiveThetaInput.eventually_actual_prime_affine_word_comparison_uniform + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ + ∀ (h l : ℕ) (E : Finset ℕ) (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (_hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) + (W : ℝ) (hW : 1 ≤ W), + ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let B := ⌊Real.exp L⌋₊ + let hB := canonicalTraceFamily_residue_bound h E W L eligible hL hW hE + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + (fun d => centeredTuple d.primeFactors) L (Real.exp (4 * J)) + (fun _ => actualPaddingDegreeCut Qp L) h + (fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ (fun d q => (d, q) ∈ data.pairs) z) + ∀ (w : ColumnPrimeAssignment J (2 * ⌊L⌋₊) P) (forward : Fin (2 * ⌊L⌋₊) → Bool) + (padding : Fin (2 * ⌊L⌋₊) → Q), + wordDisplacement h (columnTupleWord w forward (fun i => (padding i).val)) = 0 → + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + |uniformAverage (fun x : Fin N => scalarWalkProduct h weight (a + l * x.val) + (columnTupleWord w forward (fun i => (padding i).val))) - + (data.residueLaw B hB).average (fun r => scalarWalkProduct h weight (data.residueOrigin r) + (columnTupleWord w forward (fun i => (padding i).val)))| ≤ Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hcompare⟩ := hBr.eventually_actual_affine_word_comparison + refine ⟨A, hA, ?_⟩ + intro h l E hE hEl W hW + filter_upwards [hcompare, hprime.eventually_actual_pool_masses E W hW, + eventually_ge_atTop (4800 : ℝ)] with L hcompare hmasses hlarge + intro hL η hη hηone eligible he + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let hB := canonicalTraceFamily_residue_bound h E W L eligible hL hW hE + have hpool : (data.P ∪ data.Q).Nonempty := by + by_contra hn + have hempty : data.P = ∅ := not_nonempty_iff_eq_empty.mp + (fun hp => hn (hp.mono subset_union_left)) + have hp := hmasses.2.2.1 + change 1 ≤ primeHarmonicMass data.P at hp + rw [hempty] at hp + norm_num [primeHarmonicMass] at hp + have hdegree := prime_trace_degree_budget W L hW hL + have hlog : Real.log L ≤ L := (Real.log_le_sub_one_of_pos (by linarith)).trans (by linarith) + have hJM : ((J + ⌊100 * Real.log L⌋₊ : ℕ) : ℝ) ≤ L ^ 2 := + hdegree.1.trans (by nlinarith) + have hs : (⌊L ^ (1 / 10 : ℝ)⌋₊ : ℝ) ≤ L := by + apply (Nat.floor_le (Real.rpow_nonneg (by linarith) _)).trans + simpa using Real.rpow_le_rpow_of_exponent_le hL (show (1 / 10 : ℝ) ≤ 1 by norm_num) + have hk : (⌊L⌋₊ : ℝ) ≤ L := Nat.floor_le (by linarith) + have hkpos : 0 < ⌊L⌋₊ := by + apply (Nat.le_floor_iff (by linarith : 0 ≤ L)).mpr + simpa using hL + have hRL : ((2 * ⌊L⌋₊ + 1 : ℕ) : ℝ) ≤ 4 * L := by push_cast; linarith + have hJ : (J : ℝ) ≤ L / 2 := by + have hc := primeSupplyCount_mul_bound W L (by linarith) hL + change (J : ℝ) * (6 * W) ≤ (1 / 200 : ℝ) * Real.log L at hc + have hj : 0 ≤ (J : ℝ) := Nat.cast_nonneg _ + nlinarith + have hRJ : ((2 * ⌊L⌋₊ * J : ℕ) : ℝ) ≤ L ^ 2 := by + push_cast + nlinarith [mul_le_mul hk hJ (Nat.cast_nonneg J) (by linarith : 0 ≤ L)] + have hpair : (data.pairs.card : ℝ) ≤ Real.exp (101 * L) := + actualProhibitedPrimeFamily_pairs_card h J ⌊100 * Real.log L⌋₊ E + (L ^ (199 / 200 : ℝ)) W L η eligible (Real.rpow_nonneg (by linarith) _) + (by linarith) hE hL hη hηone he + intro w forward padding hclosed a N hN + have hq : Q ⊆ retainedPrimeDivisors data.Q := fun q hq => (mem_filter.mp hq).1 + exact hcompare h J ⌊100 * Real.log L⌋₊ (2 * ⌊L⌋₊) ⌊L ^ (1 / 10 : ℝ)⌋₊ + ⌊Real.exp L⌋₊ data hB hpool (Nat.floor_le (Real.exp_pos _).le) hs hJM hpair + (by omega) hRL hRJ Q hq P w forward (fun i => (padding i).val) + (centeredPrimeBands_prime E _ W J) + (centeredPrimeBands_disjoint E _ W J (Real.rpow_nonneg (by linarith) _) (by linarith)) + (fun i => (show (((padding i).val.primeFactors.card : ℕ) : ℝ) ≤ + (⌊100 * Real.log L⌋₊ : ℝ) by exact_mod_cast (mem_filter.mp (padding i).property).2).trans hdegree.2) + (actualColumnLabel data (fun j => centeredPrimeBand_subset_pool E _ W J j) w) + (fun _ _ => rfl) hclosed (fun d q => (d, q) ∈ data.pairs) (Real.exp (4 * J)) a l N + (canonicalTraceFamily_coprime h l E W L eligible hL hW hE hEl) hN + +theorem ModFiveThetaInput.eventually_actual_prime_affine_word_comparison + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) + (h l : ℕ) (E : Finset ℕ) (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) + (W : ℝ) (hW : 1 ≤ W) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let B := ⌊Real.exp L⌋₊ + let hB := canonicalTraceFamily_residue_bound h E W L eligible hL hW hE + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + (fun d => centeredTuple d.primeFactors) L (Real.exp (4 * J)) + (fun _ => actualPaddingDegreeCut Qp L) h + (fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ (fun d q => (d, q) ∈ data.pairs) z) + ∀ (w : ColumnPrimeAssignment J (2 * ⌊L⌋₊) P) (forward : Fin (2 * ⌊L⌋₊) → Bool) + (padding : Fin (2 * ⌊L⌋₊) → Q), + wordDisplacement h (columnTupleWord w forward (fun i => (padding i).val)) = 0 → + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + |uniformAverage (fun x : Fin N => scalarWalkProduct h weight (a + l * x.val) + (columnTupleWord w forward (fun i => (padding i).val))) - + (data.residueLaw B hB).average (fun r => scalarWalkProduct h weight (data.residueOrigin r) + (columnTupleWord w forward (fun i => (padding i).val)))| ≤ Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hbound⟩ := hprime.eventually_actual_prime_affine_word_comparison_uniform hBr + exact ⟨A, hA, hbound h l E hE hEl W hW⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeFamily.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..875db60f58a3e0820db263360f2c0d5b48b14fb1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeFamily.lean @@ -0,0 +1,120 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeTuplePool +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedDensity + +namespace OAI + +/-! The prohibited-word data are constructed from the actual prime bands, +not assumed. Padding divisors have the requested degree cap, and the +finite pair catalog can impose any numerical eligibility condition. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def centeredPrimeBands (E : Finset ℕ) (A W : ℝ) (J : ℕ) + (j : Fin J) : Finset ℕ := centeredPrimeSupply E A W j.val + +noncomputable def centeredPrimePool (E : Finset ℕ) (A W : ℝ) (J : ℕ) : Finset ℕ := + primeTuplePool (centeredPrimeBands E A W J) + +lemma centeredPrimeBands_prime (E : Finset ℕ) (A W : ℝ) (J : ℕ) + (j : Fin J) (p : ℕ) (hp : p ∈ centeredPrimeBands E A W J j) : p.Prime := + (centeredPrimeSupply_mem hp).1 + +lemma centeredPrimeBands_disjoint (E : Finset ℕ) (A W : ℝ) (J : ℕ) + (hA : 0 ≤ A) (hW : 0 ≤ W) (j l : Fin J) (hne : l ≠ j) : + Disjoint (centeredPrimeBands E A W J j) (centeredPrimeBands E A W J l) := + centeredPrimeSupply_pairwise_disjoint E A W hA hW + (fun he => hne (Fin.ext he.symm)) + +lemma centeredPrimePool_disjoint_padding (E : Finset ℕ) (A W L : ℝ) (J : ℕ) : + Disjoint (centeredPrimePool E A W J) (paddingPrimeSupply E L) := by + apply disjoint_left.mpr + intro p hp hq + obtain ⟨j, hj⟩ := mem_primeTuplePool.mp hp + exact (disjoint_left.mp (centered_padding_disjoint E A W L j.val)) hj hq + +/-- The exclusion set need only contain prime divisors of the fixed shift. +It may contain additional fixed primes, such as those dividing the modulus. -/ +noncomputable def actualProhibitedPrimeFamily (h J M : ℕ) (E : Finset ℕ) + (A W L : ℝ) (eligible : ℕ → ℕ → Prop) + (hA : 0 ≤ A) (hW : 0 ≤ W) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) : ProhibitedPrimeFamily h J M where + P := centeredPrimePool E A W J + Q := paddingPrimeSupply E L + pairs := primeFamilyPairs (centeredPrimeBands E A W J) (paddingPrimeSupply E L) M eligible + primeP p hp := primeTuplePool_prime (centeredPrimeBands_prime E A W J) hp + primeQ _ hp := paddingPrimeSupply_prime hp + disjoint := centeredPrimePool_disjoint_padding E A W L J + excluded p hp := by + obtain ⟨j, hj⟩ := mem_primeTuplePool.mp hp + intro hph + have hs := centeredPrimeSupply_mem hj + exact hs.2.2.1 (hE p hs.1 hph) + tuple_squarefree dq hdq := + (primeTupleDivisors_arithmetic _ (centeredPrimeBands_prime E A W J) + (centeredPrimeBands_disjoint E A W J hA hW) (mem_primeFamilyPairs.mp hdq).1).1 + padding_squarefree dq hdq := + retainedPrimeDivisor_squarefree _ (fun _ hp => paddingPrimeSupply_prime hp) + (mem_primeFamilyPairs.mp hdq).2.1 + tuple_card dq hdq := + (primeTupleDivisors_arithmetic _ (centeredPrimeBands_prime E A W J) + (centeredPrimeBands_disjoint E A W J hA hW) (mem_primeFamilyPairs.mp hdq).1).2.1 + padding_card dq hdq := (mem_primeFamilyPairs.mp hdq).2.2.1 + tuple_pool dq hdq := + (primeTupleDivisors_arithmetic _ (centeredPrimeBands_prime E A W J) + (centeredPrimeBands_disjoint E A W J hA hW) (mem_primeFamilyPairs.mp hdq).1).2.2 + padding_pool dq hdq := + retainedPrimeDivisor_factors _ (fun _ hp => paddingPrimeSupply_prime hp) + (mem_primeFamilyPairs.mp hdq).2.1 + +lemma actualProhibitedPrimeFamily_pairs (h J M : ℕ) (E : Finset ℕ) + (A W L : ℝ) (eligible : ℕ → ℕ → Prop) (hA : 0 ≤ A) (hW : 0 ≤ W) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) (d q : ℕ) : + (d, q) ∈ (actualProhibitedPrimeFamily h J M E A W L eligible hA hW hE).pairs ↔ + d ∈ primeTupleDivisors (centeredPrimeBands E A W J) ∧ + q ∈ retainedPrimeDivisors (paddingPrimeSupply E L) ∧ + q.primeFactors.card ≤ M ∧ eligible d q := mem_primeFamilyPairs + +lemma centeredPrimeBand_subset_pool (E : Finset ℕ) (A W : ℝ) (J : ℕ) (j : Fin J) : + centeredPrimeBands E A W J j ⊆ centeredPrimePool E A W J := by + intro p hp + exact mem_primeTuplePool.mpr ⟨j, hp⟩ + +lemma centeredPrimePool_bounds (E : Finset ℕ) (A W L : ℝ) (J : ℕ) + (hA : 0 ≤ A) (hW : 0 ≤ W) (hL : primeSupplyEndpoint A W J ≤ L) + {p : ℕ} (hp : p ∈ centeredPrimePool E A W J) : + Real.exp A < (p : ℝ) ∧ (p : ℝ) ≤ Real.exp L := by + obtain ⟨j, hj⟩ := mem_primeTuplePool.mp hp + exact centeredPrimeSupply_global_bounds hA hW j.isLt hL hj + +lemma paddingPrimeSupply_bounds (E : Finset ℕ) (L : ℝ) {p : ℕ} + (hp : p ∈ paddingPrimeSupply E L) : (p : ℝ) ≤ Real.exp L := + modFivePrimesUpTo_le (Real.exp_pos _).le (Finset.mem_sdiff.mp hp).1 + +lemma actualProhibitedPrimeFamily_residue_bound (h J M : ℕ) (E : Finset ℕ) + (A W L : ℝ) (eligible : ℕ → ℕ → Prop) (hA : 0 ≤ A) (hW : 0 ≤ W) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) (hL : primeSupplyEndpoint A W J ≤ L) + {p : ℕ} + (hp : p ∈ (actualProhibitedPrimeFamily h J M E A W L eligible hA hW hE).P ∪ + (actualProhibitedPrimeFamily h J M E A W L eligible hA hW hE).Q) : + p ≤ ⌊Real.exp L⌋₊ := by + apply (Nat.le_floor_iff (Real.exp_pos _).le).mpr + rcases mem_union.mp hp with hp | hp + · exact (centeredPrimePool_bounds E A W L J hA hW hL hp).2 + · exact paddingPrimeSupply_bounds E L hp + +lemma centeredPrimePool_lower_nat (E : Finset ℕ) (A W L : ℝ) (J : ℕ) + (hA : 0 ≤ A) (hW : 0 ≤ W) (hL : primeSupplyEndpoint A W J ≤ L) + {p : ℕ} (hp : p ∈ centeredPrimePool E A W J) : ⌈Real.exp A⌉₊ ≤ p := + Nat.ceil_le.mpr (centeredPrimePool_bounds E A W L J hA hW hL hp).1.le + +/-- Taking `E = h.primeFactors` is sufficient for any nonzero fixed shift. -/ +lemma shiftPrimeFactors_cover {h : ℕ} (hh : h ≠ 0) : + ∀ p, p.Prime → p ∣ h → p ∈ h.primeFactors := + fun _ hp hph => hp.mem_primeFactors hph hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeMatrix.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..26e898207134eeae79a562f2fe3a4dbf1c965c6e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeMatrix.lean @@ -0,0 +1,104 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualMatrixTrace +import OAI.NumberTheory.TwoPoint.Bounds.ActualPaddingWeights +import OAI.NumberTheory.TwoPoint.Bounds.PrimeTraceParameters + +namespace OAI + +/-! The residue-model trace bound for the actual prime supplies and padding +normalization. Its only analytic input is the cited fixed-modulus prime theorem. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def canonicalTraceFamily (h : ℕ) (E : Finset ℕ) (W L : ℝ) + (eligible : ℕ → ℕ → Prop) (hL : 1 ≤ L) (hW : 1 ≤ W) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) : + ProhibitedPrimeFamily h (primeSupplyCount W L) ⌊100 * Real.log L⌋₊ := + actualProhibitedPrimeFamily h (primeSupplyCount W L) ⌊100 * Real.log L⌋₊ E + (L ^ (199 / 200 : ℝ)) W L eligible + (Real.rpow_nonneg (zero_le_one.trans hL) _) (zero_le_one.trans hW) hE + +lemma canonicalTraceFamily_residue_bound (h : ℕ) (E : Finset ℕ) (W L : ℝ) + (eligible : ℕ → ℕ → Prop) (hL : 1 ≤ L) (hW : 1 ≤ W) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) : + ∀ p ∈ (canonicalTraceFamily h E W L eligible hL hW hE).P ∪ + (canonicalTraceFamily h E W L eligible hL hW hE).Q, p ≤ ⌊Real.exp L⌋₊ := + fun _ hp => actualProhibitedPrimeFamily_residue_bound h _ _ E _ W L eligible _ _ hE + (primeSupplyScale_endpoint W L (zero_lt_one.trans_le hW) hL) hp + +theorem ModFiveThetaInput.eventually_actual_prime_matrix_trace (hprime : ModFiveThetaInput) + (h : ℕ) (hh : 0 < h) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) (W : ℝ) (hW : 1 ≤ W) : + ∀ᶠ L : ℝ in atTop, ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let B := ⌊Real.exp L⌋₊ + let hB := canonicalTraceFamily_residue_bound h E W L eligible hL hW hE + let g := actualPaddingVertex Qp + let keep := fun n => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) n + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) g (fun d => centeredTuple d.primeFactors) + L (Real.exp (4 * J)) (fun _ => actualPaddingDegreeCut Qp L) h keep + ∀ (V : Type) [Fintype V] [DecidableEq V] + (embed : V → ((j : Fin J) → P j) × ℤ), Function.Injective embed → + (Fintype.card V : ℝ) ≤ Real.exp (106 * L) → + ∀ gate : ((j : Fin J) → P j) → ℤ → ℤ → Prop, + (data.residueLaw B hB).average (fun r => matrixFrobeniusSq + (shiftMatrix embed (integerShiftNext Q (fun d => ∏ j, (d j).val) h) + (physicalShiftWeight Q (fun d => ∏ j, (d j).val) h gate + (fun t n => weight t (n + data.residueOrigin r))) ^ ⌊L⌋₊)) ≤ + (Real.exp (4 * J) * (2 * Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * ⌊L⌋₊) := by + filter_upwards [eventually_actual_matrix_trace h 101 W hh (by norm_num) hW, + hprime.eventually_actual_pool_masses E W hW] with L htrace hmasses + intro hL η hη hηone eligible he + dsimp only + let J := primeSupplyCount W L + let A := L ^ (199 / 200 : ℝ) + let P := centeredPrimeBands E A W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let hB := canonicalTraceFamily_residue_bound h E W L eligible hL hW hE + have hA : 0 < A := Real.rpow_pos_of_pos (zero_lt_one.trans_le hL) _ + have hend : primeSupplyEndpoint A W J ≤ L := + primeSupplyScale_endpoint W L (zero_lt_one.trans_le hW) hL + have hP (j : Fin J) : P j ⊆ data.P := centeredPrimeBand_subset_pool E A W J j + have hdegree := prime_trace_degree_budget W L hW hL + have hep := prime_trace_endpoints L hL + have hq (q : ℕ) (hq : q ∈ Q) : q ∈ retainedPrimeDivisors Qp := (mem_filter.mp hq).1 + intro V _ _ embed hinj hdim gate + apply htrace J ⌊100 * Real.log L⌋₊ ⌊Real.exp L⌋₊ ⌈Real.exp A⌉₊ + ⌊Real.exp L⌋₊ ⌊Real.exp (100 * L + 1)⌋₊ ⌊Real.exp (2 * L)⌋₊ data hB P Q hP + hmasses.1 hdegree.1 + (fun j => (hmasses.2.1 j).1) (fun j => (hmasses.2.1 j).2.1) + (fun j => (hmasses.2.1 j).2.2) + hmasses.2.2.1 hmasses.2.2.2.2.1 hmasses.2.2.2.2.2 hdegree.2 + (centeredPrimeBands_prime E A W J) (centeredPrimeBands_disjoint E A W J hA.le (by linarith)) + (fun _ hp => centeredPrimePool_lower_nat E A W L J hA.le (by linarith) hend hp) + (fun p hp => hB p (mem_union_left _ hp)) + hep.1 hep.2.1 hep.2.2.1 hep.2.2.2.1 hep.2.2.2.2 + (fun dq hdq => actualProhibitedPrimeFamily_padding_upper h J ⌊100 * Real.log L⌋₊ + E A W L η eligible hA.le (by linarith) hE hη hηone he hdq) + (fun w j => centeredPrimeTuple_complement_upper E A W L J hA hW hend w j) + (fun q hqQ => retainedPrimeDivisor_squarefree Qp (fun _ hp => paddingPrimeSupply_prime hp) (hq q hqQ)) + (fun q hqQ => retainedPrimeDivisor_factors Qp (fun _ hp => paddingPrimeSupply_prime hp) (hq q hqQ)) + actualPaddingCoefficient (actualPaddingVertex Qp) (Real.exp (4 * J)) + (fun d q => (d, q) ∈ data.pairs) (fun _ => actualPaddingDegreeCut Qp L) + actualPaddingCoefficient_nonneg (fun _ => le_rfl) + (fun n => by rw [actualPaddingVertex_sq]; exact actualPaddingWeight_one_le Qp n) + (Real.one_le_exp (by positivity)) + (actualPaddingVertex_residue_congr Qp) + (fun _ n m hnm => actualPaddingDegreeCut_residue_congr Qp L n m hnm) + V embed hinj hdim gate (fun _ _ hp => hp) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a497cc86480f60688ec69679d1c86ef8f33dfc9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeScale.lean @@ -0,0 +1,158 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualPrimeFamily + +namespace OAI + +/-! Harmonic masses and integer endpoints for the literal prime family. +These derive the trace theorem's prime-pool hypotheses from the single +fixed-modulus published input. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma centeredPrimePool_mass (E : Finset ℕ) (A W : ℝ) (J : ℕ) + (hA : 0 ≤ A) (hW : 0 ≤ W) : + primeHarmonicMass (centeredPrimePool E A W J) = + ∑ j : Fin J, primeHarmonicMass (centeredPrimeBands E A W J j) := + primeTuplePool_mass _ (centeredPrimeBands_disjoint E A W J hA hW) + +lemma centeredPrimePool_mass_bounds (E : Finset ℕ) (A W : ℝ) (J : ℕ) + (hA : 0 ≤ A) (hW : 0 ≤ W) + (hmass : ∀ j : Fin J, + W ≤ primeHarmonicMass (centeredPrimeBands E A W J j) ∧ + primeHarmonicMass (centeredPrimeBands E A W J j) ≤ 2 * W) : + (J : ℝ) * W ≤ primeHarmonicMass (centeredPrimePool E A W J) ∧ + primeHarmonicMass (centeredPrimePool E A W J) ≤ J * (2 * W) := by + rw [centeredPrimePool_mass E A W J hA hW] + constructor + · calc + _ = ∑ _j : Fin J, W := by simp + _ ≤ _ := sum_le_sum (fun j _ => (hmass j).1) + · calc + _ ≤ ∑ _j : Fin J, 2 * W := sum_le_sum (fun j _ => (hmass j).2) + _ = _ := by simp + +lemma primeSupplyCount_mul_bound (W L : ℝ) (hW : 0 < W) (hL : 1 ≤ L) : + (primeSupplyCount W L : ℝ) * (6 * W) ≤ (1 / 200 : ℝ) * Real.log L := by + have hlog : 0 ≤ Real.log L := Real.log_nonneg hL + have hj : (primeSupplyCount W L : ℝ) ≤ + ((1 / 200 : ℝ) * Real.log L) / (6 * W) := Nat.floor_le (by positivity) + exact (le_div_iff₀ (by positivity : 0 < 6 * W)).mp hj + +theorem ModFiveThetaInput.eventually_padding_pool_mass (hP : ModFiveThetaInput) + (E : Finset ℕ) : + ∀ᶠ L : ℝ in atTop, + primeHarmonicMass (paddingPrimeSupply E L) ≤ Real.log L := by + obtain ⟨C, hC, hm⟩ := hP.padding_reciprocal_mass E + filter_upwards [eventually_ge_atTop (1 : ℝ), eventually_ge_atTop (Real.exp (4 * C))] + with L hL hLC + have hlog : 4 * C ≤ Real.log L := by + simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos _) hLC + rw [primeHarmonicMass_eq_sum] + linarith [hm L hL] + +/-- All pool-mass hypotheses used by the literal column trace hold for +the constructed bands. The numerical eligibility predicate does not +enter these estimates. -/ +theorem ModFiveThetaInput.eventually_actual_pool_masses (hP : ModFiveThetaInput) + (E : Finset ℕ) (W : ℝ) (hW : 1 ≤ W) : + ∀ᶠ L : ℝ in atTop, + let J := primeSupplyCount W L + let A := L ^ (199 / 200 : ℝ) + 1 ≤ J ∧ + (∀ j : Fin J, 1 ≤ primeHarmonicMass (centeredPrimeBands E A W J j) ∧ + primeHarmonicMass (centeredPrimeBands E A W J j) ≤ 2 * W ∧ + primeHarmonicMass (centeredPrimeBands E A W J j) ≤ L ^ (2 : ℕ)) ∧ + 1 ≤ primeHarmonicMass (centeredPrimePool E A W J) ∧ + primeHarmonicMass (centeredPrimePool E A W J) ≤ Real.log L / 600 ∧ + primeHarmonicMass (centeredPrimePool E A W J) ≤ L ^ (2 : ℕ) ∧ + primeHarmonicMass (paddingPrimeSupply E L) ≤ L ^ (2 : ℕ) := by + filter_upwards [hP.eventually_actual_prime_supplies E W hW, + hP.eventually_padding_pool_mass E, eventually_ge_atTop (1 : ℝ)] with L hs hq hL + let J := primeSupplyCount W L + let A := L ^ (199 / 200 : ℝ) + have hLp : 0 < L := zero_lt_one.trans_le hL + have hA : 0 ≤ A := Real.rpow_nonneg hLp.le _ + have hWp : 0 < W := zero_lt_one.trans_le hW + have hmass (j : Fin J) : + W ≤ primeHarmonicMass (centeredPrimeBands E A W J j) ∧ + primeHarmonicMass (centeredPrimeBands E A W J j) ≤ 2 * W := by + simpa only [primeHarmonicMass_eq_sum, centeredPrimeBands, A] using (hs.2.2 j.val).2 + have hp := centeredPrimePool_mass_bounds E A W J hA hWp.le hmass + have hj : (1 : ℝ) ≤ J := by exact_mod_cast hs.1 + have hpoolone : 1 ≤ primeHarmonicMass (centeredPrimePool E A W J) := by + have hprod : 1 ≤ (J : ℝ) * W := hW.trans (by + simpa only [one_mul] using mul_le_mul_of_nonneg_right hj hWp.le) + exact hprod.trans hp.1 + have hpoollog : primeHarmonicMass (centeredPrimePool E A W J) ≤ Real.log L / 600 := by + have hb := primeSupplyCount_mul_bound W L hWp hL + change (J : ℝ) * (6 * W) ≤ (1 / 200 : ℝ) * Real.log L at hb + nlinarith [hp.2] + have hlog : Real.log L ≤ L := + (Real.log_le_sub_one_of_pos hLp).trans (by linarith) + have hLsq : L ≤ L ^ (2 : ℕ) := by nlinarith + have hpoolpoly : primeHarmonicMass (centeredPrimePool E A W J) ≤ L ^ (2 : ℕ) := by + have hlog0 : 0 ≤ Real.log L := Real.log_nonneg hL + exact hpoollog.trans ((by linarith : Real.log L / 600 ≤ Real.log L).trans + (hlog.trans hLsq)) + refine ⟨hs.1, ?_, hpoolone, hpoollog, hpoolpoly, hq.trans (hlog.trans hLsq)⟩ + intro j + refine ⟨hW.trans (hmass j).1, (hmass j).2, ?_⟩ + exact (primeHarmonicMass_mono (centeredPrimeBand_subset_pool E A W J j)).trans hpoolpoly + +lemma centeredPrimeTuple_upper (E : Finset ℕ) (A W L : ℝ) (J : ℕ) + (hA : 0 < A) (hW : 1 ≤ W) (hL : primeSupplyEndpoint A W J ≤ L) + {d : ℕ} (hd : d ∈ primeTupleDivisors (centeredPrimeBands E A W J)) : + d ≤ ⌊Real.exp (2 * L)⌋₊ := by + have hb := centeredPrimeTuple_log_bound hA hW hL hd + apply (Nat.le_floor_iff (Real.exp_pos _).le).mpr + have hdpos : (0 : ℝ) < d := by exact_mod_cast hb.1 + simpa only [Real.exp_log hdpos] using Real.exp_le_exp.mpr hb.2 + +/-- Removing one prime from an actual tuple only reduces its value. -/ +lemma centeredPrimeTuple_complement_upper (E : Finset ℕ) (A W L : ℝ) (J : ℕ) + (hA : 0 < A) (hW : 1 ≤ W) (hL : primeSupplyEndpoint A W J ≤ L) + (x : (j : Fin J) → centeredPrimeBands E A W J j) (j : Fin J) : + (∏ i ∈ univ.erase j, (x i).val) ≤ ⌊Real.exp (2 * L)⌋₊ := by + apply le_trans _ (centeredPrimeTuple_upper E A W L J hA hW hL + (mem_image.mpr ⟨x, mem_univ _, rfl⟩)) + exact Nat.le_of_dvd (prod_pos (fun i _ => (centeredPrimeSupply_mem (x i).property).1.pos)) + (prod_dvd_prod_of_subset (univ.erase j) univ (fun i => (x i).val) (erase_subset _ _)) + +lemma paddingPairEligible_padding_upper {L η : ℝ} {d q : ℕ} + (hη : 0 < η) (hηone : η ≤ 1) (hd : 0 < d) + (he : PaddingPairEligible L η d q) : q ≤ ⌊Real.exp (100 * L + 1)⌋₊ := by + by_cases hq : q = 0 + · simp [hq] + have hd0 : (d : ℝ) ≠ 0 := by exact_mod_cast hd.ne' + have hq0 : (q : ℝ) ≠ 0 := by exact_mod_cast hq + let j := paddingBin η 0 (Real.log (d * q : ℕ)) + have hj := (mem_paddingBinIndices_iff L η j hη).mp he.2 + have hx := (paddingBin_eq_iff η 0 (Real.log (d * q : ℕ)) j hη).mp rfl + simp only [add_zero] at hx + have hxupper : Real.log (d * q : ℕ) ≤ 100 * L + 1 := by + nlinarith [hj.2, hx.2] + have hqlog : Real.log q ≤ Real.log (d * q : ℕ) := by + rw [Nat.cast_mul, Real.log_mul hd0 hq0] + linarith [log_nat_nonneg d] + apply (Nat.le_floor_iff (Real.exp_pos _).le).mpr + have hqp : (0 : ℝ) < q := by exact_mod_cast Nat.pos_of_ne_zero hq + simpa only [Real.exp_log hqp] using Real.exp_le_exp.mpr (hqlog.trans hxupper) + +lemma actualProhibitedPrimeFamily_padding_upper (h J M : ℕ) (E : Finset ℕ) + (A W L η : ℝ) (eligible : ℕ → ℕ → Prop) (hA : 0 ≤ A) (hW : 0 ≤ W) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) (hη : 0 < η) (hηone : η ≤ 1) + (he : ∀ d q, eligible d q → PaddingPairEligible L η d q) + {dq : ℕ × ℕ} + (hdq : dq ∈ (actualProhibitedPrimeFamily h J M E A W L eligible hA hW hE).pairs) : + dq.2 ≤ ⌊Real.exp (100 * L + 1)⌋₊ := by + have hm := (actualProhibitedPrimeFamily_pairs h J M E A W L eligible hA hW hE + dq.1 dq.2).mp hdq + have hs := (actualProhibitedPrimeFamily h J M E A W L eligible hA hW hE).tuple_squarefree dq hdq + exact paddingPairEligible_padding_upper hη hηone (Nat.pos_of_ne_zero hs.ne_zero) + (he dq.1 dq.2 hm.2.2.2) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeSlots.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeSlots.lean new file mode 100644 index 0000000000000000000000000000000000000000..2de1fa5ad3409896a168cc74ba8134475822f8c7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeSlots.lean @@ -0,0 +1,123 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeSlotCode +import Mathlib.Algebra.BigOperators.Associated + +namespace OAI + +/-! Actual prime factors give a complete bounded-slot code for a numerical word. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {R : ℕ} + +abbrev ActualPrimeSlot (w : Fin R → SignedStep) := + Σ i : Fin R, (w i).tuple.primeFactors ⊕ (w i).padding.primeFactors + +def actualSlotPrime (w : Fin R → SignedStep) (s : ActualPrimeSlot w) : ℕ := + match s.2 with + | .inl p => p.val + | .inr p => p.val + +def actualSlotKind (w : Fin R → SignedStep) (s : ActualPrimeSlot w) : Bool := + match s.2 with + | .inl _ => false + | .inr _ => true + +lemma actualSlotPrime_prime (w : Fin R → SignedStep) (s : ActualPrimeSlot w) : + (actualSlotPrime w s).Prime := by + rcases s with ⟨i, p | p⟩ + · exact Nat.prime_of_mem_primeFactors p.property + · exact Nat.prime_of_mem_primeFactors p.property + +lemma actualPrimeSlot_card_ge (w : Fin R → SignedStep) + (hused : ∀ i, 1 ≤ (w i).tuple.primeFactors.card + (w i).padding.primeFactors.card) : + R ≤ Fintype.card (ActualPrimeSlot w) := by + have hs := sum_le_sum (fun i (_ : i ∈ (univ : Finset (Fin R))) => hused i) + simpa only [Fintype.card_sigma, Fintype.card_sum, Fintype.card_coe, + sum_const, card_univ, Fintype.card_fin, smul_eq_mul, mul_one] using hs + +theorem actualPrimeSlot_card_le (w : Fin R → SignedStep) (J M : ℕ) + (hJ : ∀ i, (w i).tuple.primeFactors.card ≤ J) + (hM : ∀ i, (w i).padding.primeFactors.card ≤ M) : + Fintype.card (ActualPrimeSlot w) ≤ R * (J + M) := by + rw [Fintype.card_sigma] + calc + _ = ∑ i : Fin R, ((w i).tuple.primeFactors.card + (w i).padding.primeFactors.card) := by + simp only [Fintype.card_sum, Fintype.card_coe] + _ ≤ ∑ _i : Fin R, (J + M) := sum_le_sum (fun i _ => Nat.add_le_add (hJ i) (hM i)) + _ = _ := by simp + +noncomputable def actualPrimeSlotEquiv (w : Fin R → SignedStep) : + ActualPrimeSlot w ≃ Fin (Fintype.card (ActualPrimeSlot w)) := + Fintype.equivFin (ActualPrimeSlot w) + +noncomputable def actualPrimeSlotData (w : Fin R → SignedStep) : + PrimeSlotData R (Fintype.card (ActualPrimeSlot w)) where + forward i := (w i).forward + row j := ((actualPrimeSlotEquiv w).symm j).1 + isPadding j := actualSlotKind w ((actualPrimeSlotEquiv w).symm j) + prime j := actualSlotPrime w ((actualPrimeSlotEquiv w).symm j) + +lemma actualSlot_factor (w : Fin R → SignedStep) (i : Fin R) (b : Bool) + (ht : Squarefree (w i).tuple) (hq : Squarefree (w i).padding) : + (∏ s : ActualPrimeSlot w, + if s.1 = i ∧ actualSlotKind w s = b then actualSlotPrime w s else 1) = + if b then (w i).padding else (w i).tuple := by + rw [Fintype.prod_sigma] + rw [prod_eq_single i] + · rw [Fintype.prod_sum_type] + cases b + · have hp := (Finset.prod_coe_sort (s := (w i).tuple.primeFactors) + (f := fun p : ℕ => p)).trans (Nat.prod_primeFactors_of_squarefree ht) + simpa [actualSlotKind, actualSlotPrime] using hp + · have hp := (Finset.prod_coe_sort (s := (w i).padding.primeFactors) + (f := fun p : ℕ => p)).trans (Nat.prod_primeFactors_of_squarefree hq) + simpa [actualSlotKind, actualSlotPrime] using hp + · intro j _ hji + simp only [hji, false_and, ite_false, prod_const_one] + · simp + +lemma actualPrimeSlotData_factor (w : Fin R → SignedStep) (i : Fin R) (b : Bool) + (ht : Squarefree (w i).tuple) (hq : Squarefree (w i).padding) : + (actualPrimeSlotData w).factor i b = if b then (w i).padding else (w i).tuple := by + have he := (actualPrimeSlotEquiv w).symm.prod_comp + (fun s : ActualPrimeSlot w => + if s.1 = i ∧ actualSlotKind w s = b then actualSlotPrime w s else 1) + calc + _ = ∏ s : ActualPrimeSlot w, + if s.1 = i ∧ actualSlotKind w s = b then actualSlotPrime w s else 1 := by + unfold PrimeSlotData.factor PrimeSlotData.slots + rw [prod_filter] + refine Eq.trans ?_ he + apply prod_congr rfl + intro j _ + dsimp only [actualPrimeSlotData] + congr 1 + _ = _ := actualSlot_factor w i b ht hq + +theorem actualPrimeSlotData_word (w : Fin R → SignedStep) + (ht : ∀ i, Squarefree (w i).tuple) (hq : ∀ i, Squarefree (w i).padding) : + (actualPrimeSlotData w).word = List.ofFn w := by + unfold PrimeSlotData.word + congr 1 + funext i + rw [actualPrimeSlotData_factor w i false (ht i) (hq i), + actualPrimeSlotData_factor w i true (ht i) (hq i)] + cases he : w i + simp [actualPrimeSlotData, he] + +/-- The explicit crude code and one number per observed prime class recover +both factors of every step in the original word. -/ +theorem actual_word_code (w : Fin R → SignedStep) + (ht : ∀ i, Squarefree (w i).tuple) (hq : ∀ i, Squarefree (w i).padding) : + ∃ c : CrudeWordCode R (Fintype.card (ActualPrimeSlot w)) R, + ∃ value : c.usedClasses → ℕ, c.numericalWord value = List.ofFn w := by + refine ⟨(actualPrimeSlotData w).code, (fun c => (actualPrimeSlotData w).prime c.val), ?_⟩ + rw [CrudeWordCode.numericalWord_encode] + exact actualPrimeSlotData_word w ht hq + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeWordComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeWordComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..91a5c199ddebb5705ea9255acab823b0d63f0dc6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualPrimeWordComparison.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualWordComparison +import OAI.NumberTheory.TwoPoint.Bounds.ActualPrimeMatrix +import OAI.NumberTheory.TwoPoint.Bounds.PrimePairCatalog + +namespace OAI + +/-! The literal prime supply and bounded padding catalog satisfy every +parameter of the actual finite-origin word comparison. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem ModFiveThetaInput.eventually_actual_prime_word_comparison + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) + (h : ℕ) (E : Finset ℕ) (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (W : ℝ) (hW : 1 ≤ W) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let B := ⌊Real.exp L⌋₊ + let hB := canonicalTraceFamily_residue_bound h E W L eligible hL hW hE + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) (actualPaddingVertex Qp) + (fun d => centeredTuple d.primeFactors) L (Real.exp (4 * J)) + (fun _ => actualPaddingDegreeCut Qp L) h + (fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ (fun d q => (d, q) ∈ data.pairs) z) + ∀ (w : ColumnPrimeAssignment J (2 * ⌊L⌋₊) P) (forward : Fin (2 * ⌊L⌋₊) → Bool) + (padding : Fin (2 * ⌊L⌋₊) → Q), + wordDisplacement h (columnTupleWord w forward (fun i => (padding i).val)) = 0 → + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + |uniformAverage (fun x : Fin N => scalarWalkProduct h weight (a + x.val) + (columnTupleWord w forward (fun i => (padding i).val))) - + (data.residueLaw B hB).average (fun r => scalarWalkProduct h weight (data.residueOrigin r) + (columnTupleWord w forward (fun i => (padding i).val)))| ≤ Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hcompare⟩ := hBr.eventually_actual_word_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hcompare, hprime.eventually_actual_pool_masses E W hW, + eventually_ge_atTop (4800 : ℝ)] with L hcompare hmasses hlarge + intro hL η hη hηone eligible he + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let hB := canonicalTraceFamily_residue_bound h E W L eligible hL hW hE + have hpool : (data.P ∪ data.Q).Nonempty := by + by_contra hn + have hempty : data.P = ∅ := not_nonempty_iff_eq_empty.mp + (fun hp => hn (hp.mono subset_union_left)) + have hp := hmasses.2.2.1 + change 1 ≤ primeHarmonicMass data.P at hp + rw [hempty] at hp + norm_num [primeHarmonicMass] at hp + have hdegree := prime_trace_degree_budget W L hW hL + have hlog : Real.log L ≤ L := (Real.log_le_sub_one_of_pos (by linarith)).trans (by linarith) + have hJM : ((J + ⌊100 * Real.log L⌋₊ : ℕ) : ℝ) ≤ L ^ 2 := + hdegree.1.trans (by nlinarith) + have hs : (⌊L ^ (1 / 10 : ℝ)⌋₊ : ℝ) ≤ L := by + apply (Nat.floor_le (Real.rpow_nonneg (by linarith) _)).trans + simpa using Real.rpow_le_rpow_of_exponent_le hL (show (1 / 10 : ℝ) ≤ 1 by norm_num) + have hk : (⌊L⌋₊ : ℝ) ≤ L := Nat.floor_le (by linarith) + have hkpos : 0 < ⌊L⌋₊ := by + apply (Nat.le_floor_iff (by linarith : 0 ≤ L)).mpr + simpa using hL + have hRL : ((2 * ⌊L⌋₊ + 1 : ℕ) : ℝ) ≤ 4 * L := by push_cast; linarith + have hJ : (J : ℝ) ≤ L / 2 := by + have hc := primeSupplyCount_mul_bound W L (by linarith) hL + change (J : ℝ) * (6 * W) ≤ (1 / 200 : ℝ) * Real.log L at hc + have hj : 0 ≤ (J : ℝ) := Nat.cast_nonneg _ + nlinarith + have hRJ : ((2 * ⌊L⌋₊ * J : ℕ) : ℝ) ≤ L ^ 2 := by + push_cast + nlinarith [mul_le_mul hk hJ (Nat.cast_nonneg J) (by linarith : 0 ≤ L)] + have hpair : (data.pairs.card : ℝ) ≤ Real.exp (101 * L) := + actualProhibitedPrimeFamily_pairs_card h J ⌊100 * Real.log L⌋₊ E + (L ^ (199 / 200 : ℝ)) W L η eligible (Real.rpow_nonneg (by linarith) _) + (by linarith) hE hL hη hηone he + intro w forward padding hclosed a N hN + have hq : Q ⊆ retainedPrimeDivisors data.Q := fun q hq => (mem_filter.mp hq).1 + exact hcompare h J ⌊100 * Real.log L⌋₊ (2 * ⌊L⌋₊) ⌊L ^ (1 / 10 : ℝ)⌋₊ + ⌊Real.exp L⌋₊ data hB hpool (Nat.floor_le (Real.exp_pos _).le) hs hJM hpair + (by omega) hRL hRJ Q hq P w forward (fun i => (padding i).val) + (centeredPrimeBands_prime E _ W J) + (centeredPrimeBands_disjoint E _ W J (Real.rpow_nonneg (by linarith) _) (by linarith)) + (fun i => (show (((padding i).val.primeFactors.card : ℕ) : ℝ) ≤ + (⌊100 * Real.log L⌋₊ : ℝ) by exact_mod_cast (mem_filter.mp (padding i).property).2).trans hdegree.2) + (actualColumnLabel data (fun j => centeredPrimeBand_subset_pool E _ W J j) w) + (fun _ _ => rfl) hclosed (fun d q => (d, q) ∈ data.pairs) (Real.exp (4 * J)) a N hN + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualProhibitedDensity.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualProhibitedDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..a5e4f7e055b2ca1be106e0fab3f30cd14396a830 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualProhibitedDensity.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualPrimeMatrix +import OAI.NumberTheory.TwoPoint.Bounds.PrimeTraceParameters +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedDensity + +namespace OAI + +/-! Apply the finite prohibited-word density estimate to the actual +prime bands and padding degree cap. No rare-event density hypothesis +is retained in this specialization. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma ProhibitedPrimeFamily.whole_factor_card_le {h J M : ℕ} + (data : ProhibitedPrimeFamily h J M) (dq : ℕ × ℕ) (hdq : dq ∈ data.pairs) : + (dq.2 * dq.1).primeFactors.card ≤ J + M := by + rw [Nat.primeFactors_mul (data.padding_squarefree dq hdq).ne_zero + (data.tuple_squarefree dq hdq).ne_zero] + have hc := card_union_le dq.2.primeFactors dq.1.primeFactors + rw [data.tuple_card dq hdq] at hc + have hm := data.padding_card dq hdq + omega + +theorem ModFiveThetaInput.eventually_actual_prohibited_density + (hP : ModFiveThetaInput) (h : ℕ) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) (W : ℝ) (hW : 1 ≤ W) : + ∀ᶠ L : ℝ in atTop, ∀ (hL : 1 ≤ L) (eligible : ℕ → ℕ → Prop), + let data := canonicalTraceFamily h E W L eligible hL hW hE + let B := ⌊Real.exp L⌋₊ + let hB := canonicalTraceFamily_residue_bound h E W L eligible hL hW hE + (data.residueLaw B hB).probability (data.deletedEvent ⌊L ^ (1 / 10 : ℝ)⌋₊ B) ≤ + Real.exp (-(1 / 2 : ℝ) * L ^ (199 / 200 : ℝ)) := by + have hs := (tendsto_rpow_atTop (show (0 : ℝ) < 1 / 10 by norm_num)).eventually + (eventually_ge_atTop 1) + filter_upwards [eventually_prohibited_density 101 (by norm_num), + hP.eventually_actual_pool_masses E W hW, hs] with L hd hm hs + intro hL eligible + let J := primeSupplyCount W L + let M := ⌊100 * Real.log L⌋₊ + let s := ⌊L ^ (1 / 10 : ℝ)⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let B := ⌊Real.exp L⌋₊ + let H := ⌈Real.exp (L ^ (199 / 200 : ℝ))⌉₊ + let hB := canonicalTraceFamily_residue_bound h E W L eligible hL hW hE + have hspos : 1 ≤ s := by + apply (Nat.le_floor_iff (Real.rpow_nonneg (zero_le_one.trans hL) _)).mpr + simpa only [Nat.cast_one] using hs + have hsupper : (s : ℝ) ≤ L ^ (1 / 10 : ℝ) := + Nat.floor_le (Real.rpow_nonneg (zero_le_one.trans hL) _) + have hslots : ((s * (J + M) : ℕ) : ℝ) ≤ 101 * s * Real.log L := by + have hb := mul_le_mul_of_nonneg_left (prime_trace_degree_budget W L hW hL).1 + (show (0 : ℝ) ≤ s by positivity) + push_cast at hb ⊢ + nlinarith + have hlo (p : ℕ) (hp : p ∈ data.P) : H ≤ p := by + apply centeredPrimePool_lower_nat E (L ^ (199 / 200 : ℝ)) W L J + (Real.rpow_nonneg (zero_le_one.trans hL) _) (zero_le_one.trans hW) + (primeSupplyScale_endpoint W L (zero_lt_one.trans_le hW) hL) + exact hp + exact hd h s J M B H data hB hspos hsupper hslots hm.2.2.1 hm.2.2.2.2.1 + hm.2.2.2.2.2 (Nat.le_ceil _) (prime_trace_endpoints L hL).1 + (prime_trace_endpoints L hL).2.1 hlo + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualRareDeletion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualRareDeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b297e3c3215261fedadec7a6eeed8f28a6cfb42 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualRareDeletion.lean @@ -0,0 +1,121 @@ +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedRowComparison +import OAI.NumberTheory.TwoPoint.Bounds.PrimePairCatalog + +namespace OAI + +/-! The prohibited-site part of the deletion estimate. The rare-event +cost is controlled after summing the actual positive tuple/padding row; +only the finite-interval comparison error pays for individual pairs. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma padding_pair_count_le (D : Finset ℕ) (padding : ℕ → Finset ℕ) + (pairs : Finset (ℕ × ℕ)) + (hp : ∀ d ∈ D, ∀ q ∈ padding d, (d, q) ∈ pairs) : + (∑ d ∈ D, (padding d).card) ≤ pairs.card := by + rw [← card_sigma] + apply card_le_card_of_injOn (fun z : (d : ℕ) × ℕ => (z.1, z.2)) + · intro z hz + obtain ⟨hd, hq⟩ := mem_sigma.mp hz + exact hp z.1 hd z.2 hq + · intro x _ y _ hxy + exact Sigma.ext (congrArg Prod.fst hxy) (by simpa using congrArg Prod.snd hxy) + +theorem ModFiveThetaInput.eventually_prohibited_model_row (hP : ModFiveThetaInput) + (E : Finset ℕ) (W C : ℝ) (hW : 10 ≤ W) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ (h M B s : ℕ) + (data : ProhibitedPrimeFamily h (primeSupplyCount W L) M), + data.P = centeredPrimePool E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) → + data.Q = paddingPrimeSupply E L → + ∀ (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.residueLaw B hB).probability (data.deletedEvent s B) ≤ + Real.exp (-(1 / 2 : ℝ) * L ^ (199 / 200 : ℝ)) → + ∀ (D : Finset ℕ), D ⊆ primeTupleDivisors + (centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L)) → + ∀ (padding : ℕ → Finset ℕ), + (∀ d ∈ D, padding d ⊆ retainedPrimeDivisors data.Q) → + ∀ (A : ℝ), 0 ≤ A → A ≤ Real.exp (C * Real.log L) → ∀ site : ℤ, + A * (data.residueLaw B hB).average (fun x => + prohibitedPositiveRow data s D padding (data.residueOrigin x + site)) ≤ + Real.exp (-L ^ (9 / 10 : ℝ)) := by + filter_upwards [hP.eventually_actual_rare_row E W C hW hC, + eventually_ge_atTop (1 : ℝ)] with L hb hL + intro h M B s data hp hq hB hprob D hD padding hpadding A hA hAcap site + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) + let bad := fun x : ↥(data.P ∪ data.Q) → Fin B => + ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) (data.residueOrigin x + site) + have hpbad : (data.residueLaw B hB).probability bad ≤ + Real.exp (-(1 / 2 : ℝ) * L ^ (199 / 200 : ℝ)) := by + rw [data.prohibited_probability_translate hB s site] + exact hprob + have hrow (x : ↥(data.P ∪ data.Q) → Fin B) : + prohibitedPositiveRow data s D padding (data.residueOrigin x + site) ≤ + primeRowMajorant P data.Q (data.residueOrigin x + site) * if bad x then 1 else 0 := by + apply prohibitedPositiveRow_le data s P (centeredPrimeBands_prime E _ W _) + (centeredPrimeBands_disjoint E _ W _ (Real.rpow_nonneg (by linarith) _) (by linarith)) + D hD padding hpadding + exact (mul_le_mul_of_nonneg_left ((data.residueLaw B hB).average_mono hrow) hA).trans + (hb h M B data hp hq hB site bad hpbad A hA hAcap) + +theorem BravermanDepth22Input.eventually_actual_prohibited_deletion + (hBr : BravermanDepth22Input) (hP : ModFiveThetaInput) + (E : Finset ℕ) (W C : ℝ) (hW : 10 ≤ W) (hC : 0 ≤ C) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h M B s cap : ℕ) (data : ProhibitedPrimeFamily h (primeSupplyCount W L) M), + data.P = centeredPrimePool E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) → + data.Q = paddingPrimeSupply E L → + ∀ (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + (s : ℝ) ≤ L → (cap : ℝ) ≤ L ^ 2 → + (data.pairs.card : ℝ) ≤ Real.exp (101 * L) → + (∀ dq ∈ data.pairs, (dq.2 * dq.1).primeFactors.card ≤ cap) → + (data.residueLaw B hB).probability (data.deletedEvent s B) ≤ + Real.exp (-(1 / 2 : ℝ) * L ^ (199 / 200 : ℝ)) → + (primeSupplyCount W L : ℝ) ≤ L ^ 2 → + ∀ (D : Finset ℕ), D ⊆ primeTupleDivisors + (centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L)) → + ∀ (padding : ℕ → Finset ℕ), + (∀ d ∈ D, padding d ⊆ retainedPrimeDivisors data.Q) → + (∀ d ∈ D, ∀ q ∈ padding d, (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) → + (∀ d ∈ D, ∀ q ∈ padding d, (d, q) ∈ data.pairs) → + ∀ (T : ℝ), 0 ≤ T → T ≤ Real.exp (C * Real.log L) → + ∀ (site : ℤ) (a N : ℕ), Real.exp (L ^ A / 2) ≤ (N : ℝ) → + T * uniformAverage (fun x : Fin N => + prohibitedPositiveRow data s D padding ((a + x.val : ℤ) + site)) ≤ + Real.exp (-L ^ (9 / 10 : ℝ)) + + T * data.pairs.card * Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hc⟩ := hBr.eventually_prohibited_row_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hc, hP.eventually_prohibited_model_row E W C hW hC, + eventually_ge_atTop (1 : ℝ)] with L hc hm hL + intro h M B s cap data hp hq hB hpool hBL hs hcap hpair hdegree hprob hJ D hD + padding hpadding hqdegree hpairs T hT hTcap site a N hN + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) + have hprime := centeredPrimeBands_prime E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) + have hdisj := centeredPrimeBands_disjoint E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) + (Real.rpow_nonneg (by linarith) _) (by linarith : 0 ≤ W) + have hd (d : ℕ) (hd : d ∈ D) := primeTupleDivisors_arithmetic P hprime hdisj (hD hd) + have hsupport (d : ℕ) (hmem : d ∈ D) : d.primeFactors ⊆ data.P ∪ data.Q := by + apply (hd d hmem).2.2.trans + rw [hp] + exact subset_union_left + have hcard (d : ℕ) (hmem : d ∈ D) : (d.primeFactors.card : ℝ) ≤ L ^ 2 := by + rw [(hd d hmem).2.1] + exact hJ + have hcompare := hc h (primeSupplyCount W L) M B s cap data hB hpool hBL hs hcap + hpair hdegree D hsupport hcard padding hpadding hqdegree site a N hN + have hmodel := hm h M B s data hp hq hB hprob D hD padding hpadding T hT hTcap site + have hcount : ((∑ d ∈ D, (padding d).card : ℕ) : ℝ) ≤ data.pairs.card := by + exact_mod_cast padding_pair_count_le D padding data.pairs hpairs + have hdiff := (le_abs_self _).trans hcompare + have hdiffT := mul_le_mul_of_nonneg_left hdiff hT + have hcountT := mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_right hcount (Real.exp_pos (-(L ^ 9))).le) hT + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualRareRow.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualRareRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..22ff6e2a792c2c8fba8bafd0832791257a1c8594 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualRareRow.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RareRowDecay + +namespace OAI + +/-! The row-moment and rare-site bounds for the literal centered prime +bands. All mass and scale assumptions are supplied by the fixed-modulus +prime theorem and the actual band-count definition. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma primeRowMajorant_nonneg {J : ℕ} (P : Fin J → Finset ℕ) (Q : Finset ℕ) (n : ℤ) : + 0 ≤ primeRowMajorant P Q n := by + apply mul_nonneg (zero_le_one.trans (actualPaddingWeight_one_le Q n)) + apply prod_nonneg + intro j _ + apply add_nonneg (Nat.cast_nonneg _) + unfold primeHarmonicMass + positivity + +theorem ModFiveThetaInput.eventually_actual_row_second_moment (hP : ModFiveThetaInput) + (E : Finset ℕ) (W : ℝ) (hW : 10 ≤ W) : + ∀ᶠ L : ℝ in atTop, ∀ (h M B : ℕ) + (data : ProhibitedPrimeFamily h (primeSupplyCount W L) M), + data.P = centeredPrimePool E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) → + data.Q = paddingPrimeSupply E L → + ∀ (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) (site : ℤ), + (data.residueLaw B hB).average (fun x => + (primeRowMajorant (centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L)) + data.Q (data.residueOrigin x + site)) ^ 2) ≤ L ^ (25 : ℕ) := by + filter_upwards [hP.eventually_actual_prime_supplies E W (by linarith), + hP.eventually_padding_pool_mass E, eventually_ge_atTop (1 : ℝ)] with L hs hq hL + intro h M B data hp hqeq hB site + let J := primeSupplyCount W L + let A := L ^ (199 / 200 : ℝ) + let P := centeredPrimeBands E A W J + have hA : 0 ≤ A := Real.rpow_nonneg (by linarith) _ + have hsub (j : Fin J) : P j ⊆ data.P := by + rw [hp] + exact centeredPrimeBand_subset_pool E A W J j + have hdisjoint (j l : Fin J) (hne : l ≠ j) : Disjoint (P j) (P l) := + centeredPrimeBands_disjoint E A W J hA (by linarith) j l hne + have hV (j : Fin J) : primeHarmonicMass (P j) ≤ 2 * W := by + simpa only [P, centeredPrimeBands, primeHarmonicMass_eq_sum, A] using (hs.2.2 j.val).2.2 + have hQ : (∑ p ∈ data.Q, 1 / (p : ℝ)) ≤ Real.log L := by + rw [hqeq, ← primeHarmonicMass_eq_sum] + exact hq + have hJ : (J : ℝ) * (6 * W) ≤ Real.log L := by + have hj := primeSupplyCount_mul_bound W L (by linarith) hL + have hl := Real.log_nonneg hL + change (J : ℝ) * (6 * W) ≤ (1 / 200 : ℝ) * Real.log L at hj + linarith + exact data.prime_row_second_moment_polynomial hB P hsub hdisjoint site L W hL hW hQ hV hJ + +theorem ModFiveThetaInput.eventually_actual_rare_row (hP : ModFiveThetaInput) + (E : Finset ℕ) (W C : ℝ) (hW : 10 ≤ W) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ (h M B : ℕ) + (data : ProhibitedPrimeFamily h (primeSupplyCount W L) M), + data.P = centeredPrimePool E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) → + data.Q = paddingPrimeSupply E L → + ∀ (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) (site : ℤ) + (bad : (↥(data.P ∪ data.Q) → Fin B) → Prop), + (data.residueLaw B hB).probability bad ≤ + Real.exp (-(1 / 2 : ℝ) * L ^ (199 / 200 : ℝ)) → + ∀ A : ℝ, 0 ≤ A → A ≤ Real.exp (C * Real.log L) → + A * (data.residueLaw B hB).average (fun x => + primeRowMajorant (centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L)) + data.Q (data.residueOrigin x + site) * if bad x then 1 else 0) ≤ + Real.exp (-L ^ (9 / 10 : ℝ)) := by + filter_upwards [hP.eventually_actual_row_second_moment E W hW, + eventually_rare_row_decay C hC, eventually_ge_atTop (1 : ℝ)] with L hm hd hL + intro h M B data hp hq hB site bad hbad A hA hAcap + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) + let F := fun x : ↥(data.P ∪ data.Q) → Fin B => + primeRowMajorant P data.Q (data.residueOrigin x + site) + have hF : ∀ x, 0 ≤ F x := fun x => primeRowMajorant_nonneg P data.Q _ + have hs := (data.residueLaw B hB).square_event_average_le F bad + have hL0 : 0 ≤ L := by linarith + have hmoment : (data.residueLaw B hB).average (fun x => (F x) ^ 2) ≤ L ^ (25 : ℕ) := + hm h M B data hp hq hB site + have hsq := hs.trans (mul_le_mul hmoment hbad + ((data.residueLaw B hB).probability_nonneg bad) (by positivity)) + exact hd A _ hA ((data.residueLaw B hB).average_nonneg (fun x => + mul_nonneg (hF x) (by split_ifs <;> norm_num))) hAcap hsq + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualRetainedBin.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualRetainedBin.lean new file mode 100644 index 0000000000000000000000000000000000000000..e4acee943a1db09fa5607168f427176a1cf28917 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualRetainedBin.lean @@ -0,0 +1,125 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualRetainedPrefix +import OAI.NumberTheory.TwoPoint.Walks.RetainedBoundaryScale +import OAI.NumberTheory.TwoPoint.Walks.BlockTestNormalization + +namespace OAI + +/-! The canonical retained-bin estimate: spectral main term plus an +exponentially small error, uniformly in the bin and progression class. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem ModFiveThetaInput.eventually_actual_retained_bin_uniform + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ + ∀ (h l : ℕ) (_hh : 0 < h) (_hl : 0 < l) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (_hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W), + ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + ∀ b N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + ‖retainedPrimePrefix P Q Qp actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) L K W (fun _ => actualPaddingDegreeCut Qp L) + h (progressionEdgeGate h l b) keep N‖ ≤ + 3 * (l : ℝ) ^ 2 * paddingTiltNormalizer Qp * R / L + 3 * Real.exp (-L) := by + obtain ⟨A, hA, hb⟩ := hprime.eventually_actual_retained_prefix_uniform hBr + refine ⟨A, hA, ?_⟩ + intro h l hh hl E hE hEl W hW + have hb := hb h l hh hl E hE hEl W hW + filter_upwards [hb, eventually_retained_row_scale W hW, + eventually_const_le_exp_quarter h, eventually_const_le_exp_quarter l, + eventually_ge_atTop (212 : ℝ)] with L hb hrow hhsize hlsize hlarge + intro hL η hη hηone eligible he + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + let M := ⌈Real.exp (103 * L)⌉₊ + let D := K / L * (5 : ℝ) ^ (400 * Real.log L) * (8 * W) ^ J + intro b N hN + have hLp : 0 < L := by linarith + have hMp : (0 : ℝ) < M := lt_of_lt_of_le (Real.exp_pos _) (Nat.le_ceil _) + have hMlo : Real.exp (103 * L) ≤ (M : ℝ) := Nat.le_ceil _ + have hMhi : (M : ℝ) ≤ 2 * Real.exp (103 * L) := by + have hc := Nat.ceil_lt_add_one (show 0 ≤ Real.exp (103 * L) from (Real.exp_pos _).le) + have he : 1 ≤ Real.exp (103 * L) := Real.one_le_exp (by linarith) + dsimp only [M] + linarith + have hNlarge : Real.exp (106 * L) ≤ (N : ℝ) := by + apply le_trans (Real.exp_le_exp.mpr ?_) hN + have hp : L ^ 2 ≤ L ^ A := pow_le_pow_right₀ hL (by omega) + nlinarith + have herr := retained_boundary_error_bound L D h l M N (by linarith) + (by dsimp [D, K]; positivity) (Nat.cast_nonneg _) (Nat.cast_nonneg _) + hrow hhsize hlsize hMlo hMhi hNlarge + have hf : ((h * ⌊Real.exp (100 * L + 1)⌋₊ : ℕ) : ℝ) ≤ + (h : ℝ) * Real.exp (100 * L + 1) := by + push_cast + exact mul_le_mul_of_nonneg_left (Nat.floor_le (Real.exp_pos _).le) (Nat.cast_nonneg _) + have hboundary : ((h * ⌊Real.exp (100 * L + 1)⌋₊ : ℕ) : ℝ) / M * D ≤ + ((h : ℝ) * Real.exp (100 * L + 1)) / M * D := by + gcongr + have ht := hb hL η hη hηone eligible he b N hN + have hnorm := block_test_normalization L K ((8 * W) ^ J) + ((5 : ℝ) ^ (400 * Real.log L)) R (paddingTiltNormalizer Qp) M l + (Real.exp (-(2 * ⌊L⌋₊ : ℕ))) hLp.ne' hMp.ne' + change ‖retainedPrimePrefix P Q Qp actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) L K W (fun _ => actualPaddingDegreeCut Qp L) + h (progressionEdgeGate h l b) keep N‖ ≤ _ + change ‖retainedPrimePrefix P Q Qp actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) L K W (fun _ => actualPaddingDegreeCut Qp L) + h (progressionEdgeGate h l b) keep N‖ ≤ _ at ht + rw [hnorm] at ht + change _ + _ + _ ≤ 3 * Real.exp (-L) at herr + dsimp only [D] at herr hboundary + linarith + +theorem ModFiveThetaInput.eventually_actual_retained_bin + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) + (h l : ℕ) (hh : 0 < h) (hl : 0 < l) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + ∀ b N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + ‖retainedPrimePrefix P Q Qp actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) L K W (fun _ => actualPaddingDegreeCut Qp L) + h (progressionEdgeGate h l b) keep N‖ ≤ + 3 * (l : ℝ) ^ 2 * paddingTiltNormalizer Qp * R / L + 3 * Real.exp (-L) := by + obtain ⟨A, hA, hbound⟩ := hprime.eventually_actual_retained_bin_uniform hBr + exact ⟨A, hA, hbound h l hh hl E hE hEl W hW⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualRetainedPrefix.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualRetainedPrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3d4eee73dbac8737a709480a07b1dbbb34d8714 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualRetainedPrefix.lean @@ -0,0 +1,148 @@ +import OAI.NumberTheory.TwoPoint.Walks.RetainedActiveEdges +import OAI.NumberTheory.TwoPoint.Walks.BlockFormPrefixBound +import OAI.NumberTheory.TwoPoint.Bounds.InitialAverage + +namespace OAI + +/-! Apply the spectral block estimate to the actual retained correlation. +The conclusion records all boundary errors before their asymptotic absorption. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def retainedPrimePrefix {J : ℕ} (P : Fin J → Finset ℕ) + (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (keep : ℤ → Prop) (N : ℕ) : ℂ := + positivePrefix (fun n => ∑ e : ((j : Fin J) → P j) × Q, + retainedPrimeEdge P Q Qp u eligible L K W extra h gate keep e n + ((n : ℤ) + (h * e.2.val * ∏ j, (e.1 j).val : ℕ))) N / (N : ℂ) + +theorem ModFiveThetaInput.eventually_actual_retained_prefix_uniform + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ + ∀ (h l : ℕ) (_hh : 0 < h) (_hl : 0 < l) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (_hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W), + ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + let M := ⌈Real.exp (103 * L)⌉₊ + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + let D := K / L * (5 : ℝ) ^ (400 * Real.log L) * (8 * W) ^ J + ∀ b N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + ‖retainedPrimePrefix P Q Qp actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) L K W (fun _ => actualPaddingDegreeCut Qp L) + h (progressionEdgeGate h l b) keep N‖ ≤ + (l : ℝ) * ((3 * R) * ((l : ℝ) * (2 * M * paddingTiltNormalizer Qp)) + + ((M : ℝ) * (2 * K * (8 * W) ^ J) * (5 : ℝ) ^ (400 * Real.log L)) * + Real.exp (-(2 * ⌊L⌋₊ : ℕ))) / (2 * L * M) + + ((h * ⌊Real.exp (100 * L + 1)⌋₊ : ℕ) : ℝ) / M * D + + 2 * (M : ℝ) / N * D := by + obtain ⟨A, hA, hb⟩ := hprime.eventually_progression_block_testing_uniform hBr + refine ⟨A, hA, ?_⟩ + intro h l hh hl E hE hEl W hW + have hb := hb h l hh hl E hE hEl W hW + filter_upwards [hb, hprime.eventually_actual_pool_masses E W hW] with L hb hmass + intro hL η hη hηone eligible he + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + let M := ⌈Real.exp (103 * L)⌉₊ + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + let D := K / L * (5 : ℝ) ^ (400 * Real.log L) * (8 * W) ^ J + let active := fun d q => (d, q) ∈ data.pairs + intro b N hN + let F := ambientLiouvilleBlockForm P M Q Qp actualPaddingCoefficient active + L K W (fun _ => actualPaddingDegreeCut Qp L) h (progressionEdgeGate h l b) keep + let B := (3 * R) * ((l : ℝ) * (2 * M * paddingTiltNormalizer Qp)) + + ((M : ℝ) * (2 * K * (8 * W) ^ J) * (5 : ℝ) ^ (400 * Real.log L)) * + Real.exp (-(2 * ⌊L⌋₊ : ℕ)) + have hNp : 0 < N := by exact_mod_cast (Real.exp_pos _).trans_le hN + have hMp : 0 < M := Nat.one_le_ceil_iff.mpr (Real.exp_pos _) + have havg : uniformAverage (fun t : Fin N => ‖F t.val‖) ≤ (l : ℝ) * B := by + have ht := hb hL η hη hηone eligible he b N hN + exact (uniformAverage_initial_le (fun t => ‖F t‖) (fun _ => norm_nonneg _) l N hl hNp).trans + (mul_le_mul_of_nonneg_left ht (Nat.cast_nonneg _)) + have hp := centeredPrimeBands_prime E (L ^ (199 / 200 : ℝ)) W J + have hd := centeredPrimeBands_disjoint E (L ^ (199 / 200 : ℝ)) W J + (Real.rpow_nonneg (by linarith) _) (by linarith) + have hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W := fun j => (hmass.2.1 j).2.1 + have hrow (n : ℕ) (_hn : 0 < n) : + (∑ e : ((j : Fin J) → P j) × Q, + ‖retainedPrimeEdge P Q Qp actualPaddingCoefficient active L K W + (fun _ => actualPaddingDegreeCut Qp L) h (progressionEdgeGate h l b) keep e n + ((n : ℤ) + retainedPrimeStep active h e)‖) ≤ D := by + simp only [retainedPrimeEdge_active_step_eq] + exact retainedPrimeEdge_row_bound P hp hd Q Qp actualPaddingCoefficient active L K W + (fun _ => actualPaddingDegreeCut Qp L) h (progressionEdgeGate h l b) keep + (by linarith) (Real.exp_pos _).le (by linarith) + (fun q _ => actualPaddingCoefficient_nonneg q) hV n + have hstep (e : ((j : Fin J) → P j) × Q) : + retainedPrimeStep active h e ≤ h * ⌊Real.exp (100 * L + 1)⌋₊ := by + apply retainedPrimeStep_le h hη hηone + intro d q hmem + exact he d q (canonicalTraceFamily_pair_eligible h E W L eligible hL hW hE d q hmem) + have ht := block_form_prefix_bound (retainedPrimeStep active h) + (fun e n => retainedPrimeEdge P Q Qp actualPaddingCoefficient active L K W + (fun _ => actualPaddingDegreeCut Qp L) h (progressionEdgeGate h l b) keep e n + ((n : ℤ) + retainedPrimeStep active h e)) F M + (h * ⌊Real.exp (100 * L + 1)⌋₊) N hMp hNp L ((l : ℝ) * B) D + (by linarith) (by dsimp [D, K]; positivity) hstep hrow + (fun t => ambientLiouvilleBlockForm_active P hp hd M Q Qp actualPaddingCoefficient active + L K W (fun _ => actualPaddingDegreeCut Qp L) h (progressionEdgeGate h l b) + (progressionEdgeGate_symmetric h l b) keep t) havg + simpa only [retainedPrimeEdge_active_step_eq, retainedPrimePrefix] using ht + +theorem ModFiveThetaInput.eventually_actual_retained_prefix + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) + (h l : ℕ) (hh : 0 < h) (hl : 0 < l) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + let M := ⌈Real.exp (103 * L)⌉₊ + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + let D := K / L * (5 : ℝ) ^ (400 * Real.log L) * (8 * W) ^ J + ∀ b N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + ‖retainedPrimePrefix P Q Qp actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) L K W (fun _ => actualPaddingDegreeCut Qp L) + h (progressionEdgeGate h l b) keep N‖ ≤ + (l : ℝ) * ((3 * R) * ((l : ℝ) * (2 * M * paddingTiltNormalizer Qp)) + + ((M : ℝ) * (2 * K * (8 * W) ^ J) * (5 : ℝ) ^ (400 * Real.log L)) * + Real.exp (-(2 * ⌊L⌋₊ : ℕ))) / (2 * L * M) + + ((h * ⌊Real.exp (100 * L + 1)⌋₊ : ℕ) : ℝ) / M * D + + 2 * (M : ℝ) / N * D := by + obtain ⟨A, hA, hbound⟩ := hprime.eventually_actual_retained_prefix_uniform hBr + exact ⟨A, hA, hbound h l hh hl E hE hEl W hW⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualSlotClasses.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualSlotClasses.lean new file mode 100644 index 0000000000000000000000000000000000000000..75bb7537bc13f072611351f3eb483b9dbebcd58c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualSlotClasses.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualPrimeSlots +import OAI.NumberTheory.TwoPoint.Bounds.PrimeSlotClasses + +namespace OAI + +/-! Actual squarefree prime occurrences satisfy the code's class conditions. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace PrimeSlotData + +variable {R N : ℕ} + +lemma code_value_injective (a : PrimeSlotData R N) : + Function.Injective (fun z : a.code.usedClasses => a.prime z.val) := by + intro z t h + obtain ⟨i, _, hi⟩ := mem_image.mp z.property + obtain ⟨j, _, hj⟩ := mem_image.mp t.property + apply Subtype.ext + rw [← hi, ← hj] + apply (a.code_class_eq_iff i j).mpr + have he : a.prime (a.code.2.1 i) = a.prime (a.code.2.1 j) := by + simpa only [hi, hj] using h + exact (a.code_class_prime i).symm.trans (he.trans + (a.code_class_prime j)) + +lemma code_value_image (a : PrimeSlotData R N) : + (univ.image (fun z : a.code.usedClasses => a.prime z.val)) = univ.image a.prime := by + ext p + constructor + · rintro hp + obtain ⟨z, _, rfl⟩ := mem_image.mp hp + exact mem_image.mpr ⟨z.val, mem_univ _, rfl⟩ + · rintro hp + obtain ⟨i, _, rfl⟩ := mem_image.mp hp + exact mem_image.mpr ⟨a.code.classAt i, mem_univ _, a.code_class_prime i⟩ + +lemma code_kindConsistent (a : PrimeSlotData R N) + (hk : ∀ i j, a.prime i = a.prime j → a.isPadding i = a.isPadding j) : + a.code.KindConsistent := by + intro j + exact hk _ _ (a.code_class_prime j) + +lemma code_rowInjective (a : PrimeSlotData R N) + (hi : ∀ i j, a.row i = a.row j → a.isPadding i = a.isPadding j → + a.prime i = a.prime j → i = j) : a.code.RowInjective := by + intro r b i hi' j hj' he + have hir := (mem_filter.mp hi').2 + have hjr := (mem_filter.mp hj').2 + exact hi i j (hir.1.trans hjr.1.symm) (hir.2.trans hjr.2.symm) + ((a.code_class_eq_iff i j).mp he) + +end PrimeSlotData + +variable {R : ℕ} + +lemma actualSlot_eq_of_data (w : Fin R → SignedStep) (s t : ActualPrimeSlot w) + (hr : s.1 = t.1) (hk : actualSlotKind w s = actualSlotKind w t) + (hp : actualSlotPrime w s = actualSlotPrime w t) : s = t := by + rcases s with ⟨i, p | p⟩ <;> rcases t with ⟨j, q | q⟩ <;> cases hr + · congr 2 + exact Subtype.ext hp + · cases hk + · cases hk + · congr 2 + exact Subtype.ext hp + +lemma actualSlot_kind_of_prime (w : Fin R → SignedStep) + (hd : ∀ i j, Disjoint (w i).tuple.primeFactors (w j).padding.primeFactors) + (s t : ActualPrimeSlot w) (hp : actualSlotPrime w s = actualSlotPrime w t) : + actualSlotKind w s = actualSlotKind w t := by + rcases s with ⟨i, p | p⟩ <;> rcases t with ⟨j, q | q⟩ + · rfl + · change p.val = q.val at hp + exact False.elim ((disjoint_left.mp (hd i j)) p.property + (by simpa only [hp] using q.property)) + · change p.val = q.val at hp + exact False.elim ((disjoint_left.mp (hd j i)) q.property + (by simpa only [← hp] using p.property)) + · rfl + +theorem actualPrimeSlotData_code_kindConsistent (w : Fin R → SignedStep) + (hd : ∀ i j, Disjoint (w i).tuple.primeFactors (w j).padding.primeFactors) : + (actualPrimeSlotData w).code.KindConsistent := by + apply PrimeSlotData.code_kindConsistent + intro i j hp + exact actualSlot_kind_of_prime w hd _ _ hp + +theorem actualPrimeSlotData_code_rowInjective (w : Fin R → SignedStep) : + (actualPrimeSlotData w).code.RowInjective := by + apply PrimeSlotData.code_rowInjective + intro i j hr hk hp + apply (actualPrimeSlotEquiv w).symm.injective + exact actualSlot_eq_of_data w _ _ hr hk hp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWitnessRecord.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWitnessRecord.lean new file mode 100644 index 0000000000000000000000000000000000000000..05cc7fe92ce7dd9d9e1ea8ee4f5624f06fe5b3bb --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWitnessRecord.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.TwoPoint.Walks.AttachedWitnessCatalog +import OAI.NumberTheory.TwoPoint.Bounds.NumericalWitnessEncoding + +namespace OAI + +/-! Encode an actual attached witness family without adding any numerical choices. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem actual_witness_has_encoded_record {n : ℕ} {ι : Type*} + (main : List SignedStep) (word : Fin n → List SignedStep) + (attachment : Fin n → ℕ) (hatt : ∀ i, attachment i ≤ main.length) + (P Q : Finset ℕ) (T h s J : ℕ) (supply : ℕ → ℕ → Prop) (p : ι → ℕ) + (hnum : NumericalWitnessEvent main word p h s J supply) + (hT : Fintype.card (ActualPrimeSlot (recordedWitnessWord main word).get) ≤ T) + (ht : ∀ t ∈ recordedWitnessWord main word, Squarefree t.tuple) + (hq : ∀ t ∈ recordedWitnessWord main word, Squarefree t.padding) + (hP : ∀ t ∈ recordedWitnessWord main word, t.tuple.primeFactors ⊆ P) + (hQ : ∀ t ∈ recordedWitnessWord main word, t.padding.primeFactors ⊆ Q) + (hd : ∀ t ∈ recordedWitnessWord main word, ∀ u ∈ recordedWitnessWord main word, + Disjoint t.tuple.primeFactors u.padding.primeFactors) + (hprime : ∀ p ∈ P, p.Prime) : + ∃ d : WitnessRecord n (recordedWitnessWord main word).length, + ∃ e : PrimeWordEncoding (recordedWitnessWord main word).length T P Q, + e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) (fun i => (d.1.2.2 i).val) + h s J supply ∧ + e.decode = recordedWitnessWord main word ∧ + e.decode.take d.1.1.val = main ∧ + (∀ i, (e.decode.drop (d.1.2.1 i).val).take (d.1.2.2 i).val = word i) ∧ + (∀ i, (d.2 i).val = attachment i) ∧ + e.weight = ∏ q ∈ wordDivisorPrimeSupport e.decode, (q : ℝ)⁻¹ := by + let v := recordedWitnessWord main word + obtain ⟨d, hdmain, hdword, hdatt⟩ := recorded_witness_record main word attachment hatt + have hnum' : NumericalWitnessEvent ((List.ofFn v.get).take d.1.1.val) + (fun i => ((List.ofFn v.get).drop (d.1.2.1 i).val).take (d.1.2.2 i).val) + p h s J supply := by + simpa only [List.ofFn_get, v, hdmain, hdword] using hnum + obtain ⟨e, he, hdecode, hweight⟩ := PrimeWordEncoding.covers_witnesses v.get hT + (fun i => ht _ (List.get_mem v i)) (fun i => hq _ (List.get_mem v i)) + (fun i => hP _ (List.get_mem v i)) (fun i => hQ _ (List.get_mem v i)) + (fun i j => hd _ (List.get_mem v i) _ (List.get_mem v j)) hprime + d.1.1.val (fun i => (d.1.2.1 i).val) (fun i => (d.1.2.2 i).val) + h s J supply p hnum' + rw [List.ofFn_get] at hdecode hweight + refine ⟨d, e, he, hdecode, ?_, ?_, hdatt, ?_⟩ + · simpa only [hdecode] using hdmain + · intro i + simpa only [hdecode] using hdword i + · simpa only [hdecode] using hweight + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWordBoolean.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWordBoolean.lean new file mode 100644 index 0000000000000000000000000000000000000000..13ac887e93d43504e0a18620c78c12a53c3330c2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWordBoolean.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualWordInputs +import OAI.NumberTheory.TwoPoint.Walks.ClosedWordStateMask +import OAI.NumberTheory.TwoPoint.Walks.WordDegreeSupport + +namespace OAI + +/-! The actual closed scalar word is precisely the bounded-state Boolean +function to which weighted finite-interval comparison applies. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def actualWordBoolean {h J M R m : ℕ} (data : ProhibitedPrimeFamily h J M) + (s : ℕ) (Q : Finset ℕ) (e : Fin m ≃ data.Q) (step : Fin R → SignedStep) + (p : Fin R → Fin J → ℕ) (eligible : ℕ → ℕ → Prop) (L K : ℝ) + (x : BooleanCube (Fintype.card (ActualWordInput data s R m))) : ℝ := + let S := fun r => activeState (fun i => x (actualWordQIndex data s R m r i)) + if (∀ r, (S r).card ≤ ⌊400 * Real.log L⌋₊) ∧ + (prohibitedWordKeepCircuit data.pairs h s (actualWordBadIndex data s R m)).eval x = true + then actualWordCoefficient data.Q Q e (fun t => eligible t.tuple) L K step p S + (fun k => x (actualWordPIndex data s R m k)) + else 0 + +lemma actualWordBoolean_integer {h J M R m : ℕ} {P : Fin J → Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (s : ℕ) (Q : Finset ℕ) + (hQ : Q ⊆ retainedPrimeDivisors data.Q) (e : Fin m ≃ data.Q) + (w : ColumnPrimeAssignment J R P) (forward : Fin R → Bool) (padding : Fin R → ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (hlabel : ∀ i j, (label (i, j)).val = (w j i).val) + (eligible : ℕ → ℕ → Prop) (L K : ℝ) (hL : 1 ≤ L) (n : ℤ) + (hR : 0 < R) (hclosed : wordDisplacement h (columnTupleWord w forward padding) = 0) : + let step := fun i => SignedStep.mk (forward i) (columnTuple w i) (padding i) + actualWordBoolean data s Q e step (fun i j => (w j i).val) eligible L K + (actualWordIntegerBits data s e step label n) = + scalarWalkProduct h + (maskedSignedIntegerWeight Q actualPaddingCoefficient eligible (actualPaddingVertex data.Q) + (fun d => centeredTuple d.primeFactors) L K (fun _ => actualPaddingDegreeCut data.Q L) + h (fun z => ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) z)) + n (List.ofFn step) := by + dsimp only + let step := fun i => SignedStep.mk (forward i) (columnTuple w i) (padding i) + let x := actualWordIntegerBits data s e step label n + have hS (r : Fin (R + 1)) : + activeState (fun i => x (actualWordQIndex data s R m r i)) = + paddingActiveState data.Q e (wordVertexSite h step n r) := by + unfold paddingActiveState + congr 1 + funext i + exact actualWordQIndex_eval data s e step label n r i + have hbits : (fun k => x (actualWordPIndex data s R m k)) = wordCenteredBits w h step n := + funext (actualWordPIndex_eval data s e w step label hlabel n) + have hmask : (prohibitedWordKeepCircuit data.pairs h s + (actualWordBadIndex data s R m)).eval x = true ↔ + ∀ r, ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) (wordVertexSite h step n r) := + prohibitedWordKeepCircuit_eval data.pairs h s data.whole_squarefree _ _ x + (actualWordBadIndex_eval data s e step label n) + rw [closed_actual_word_state w forward padding hprime hdisjoint data.Q Q + data.primeQ hQ e eligible L K h n hR hclosed] + change actualWordBoolean data s Q e step (fun i j => (w j i).val) eligible L K x = _ + simp only [actualWordBoolean, hS, hbits, hmask] + let S := fun r => paddingActiveState data.Q e (wordVertexSite h step n r) + let coeff := actualWordCoefficient data.Q Q e (fun t => eligible t.tuple) L K step + (fun i j => (w j i).val) S (wordCenteredBits w h step n) + have ht : (if ∀ r, (S r).card ≤ ⌊400 * Real.log L⌋₊ then coeff else 0) = coeff := + actualWordCoefficient_truncation data.Q Q e (fun t => eligible t.tuple) L K step + (fun i j => (w j i).val) S _ hR hL + dsimp only [S, coeff, step] at ht ⊢ + by_cases hm : ∀ r, ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) + (wordVertexSite h (fun i => SignedStep.mk (forward i) (columnTuple w i) (padding i)) n r) + · simpa [hm] using ht + · simp [hm] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWordComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWordComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..c2d5dc743fab2231b0c0afaea3db429e3f1ac18e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWordComparison.lean @@ -0,0 +1,133 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualWordBoolean +import OAI.NumberTheory.TwoPoint.Walks.WeightedWordComparison +import OAI.NumberTheory.TwoPoint.Bounds.PrimeCoordinates + +namespace OAI + +/-! The actual signed closed word has the finite-origin error required +by the matrix trace argument. Only the published Braverman input is +used for this transfer; the residue expectation is unchanged. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +local instance wordPrime_neZero {h J M : ℕ} (data : ProhibitedPrimeFamily h J M) + (i : Fin (Fintype.card ↥(data.P ∪ data.Q))) : + NeZero (primeResidueModuli (data.P ∪ data.Q) i) := + ⟨(primeResidueModuli_prime _ (fun p hp => data.prime ⟨p, hp⟩) i).ne_zero⟩ + +lemma ProhibitedPrimeFamily.pair_primeFactors_card {h J M : ℕ} + (data : ProhibitedPrimeFamily h J M) (dq : ℕ × ℕ) (hdq : dq ∈ data.pairs) : + (dq.2 * dq.1).primeFactors.card ≤ J + M := by + rw [Nat.primeFactors_mul (data.padding_squarefree _ hdq).ne_zero + (data.tuple_squarefree _ hdq).ne_zero] + have hh := card_union_le dq.2.primeFactors dq.1.primeFactors + rw [data.tuple_card _ hdq] at hh + have hq := data.padding_card _ hdq + omega + +theorem BravermanDepth22Input.eventually_actual_word_comparison (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M R s B : ℕ) (data : ProhibitedPrimeFamily h J M) + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + (s : ℝ) ≤ L → ((J + M : ℕ) : ℝ) ≤ L ^ 2 → + (data.pairs.card : ℝ) ≤ Real.exp (101 * L) → + 0 < R → ((R + 1 : ℕ) : ℝ) ≤ 4 * L → ((R * J : ℕ) : ℝ) ≤ L ^ 2 → + ∀ (Q : Finset ℕ), Q ⊆ retainedPrimeDivisors data.Q → + ∀ (P : Fin J → Finset ℕ) + (w : ColumnPrimeAssignment J R P) (forward : Fin R → Bool) (padding : Fin R → ℕ), + (∀ j, ∀ p ∈ P j, p.Prime) → + (∀ j l, l ≠ j → Disjoint (P j) (P l)) → + (∀ i, ((padding i).primeFactors.card : ℝ) ≤ 100 * Real.log L) → + ∀ (label : Fin R × Fin J → ↥(data.P ∪ data.Q)), + (∀ i j, (label (i, j)).val = (w j i).val) → + wordDisplacement h (columnTupleWord w forward padding) = 0 → + ∀ (eligible : ℕ → ℕ → Prop) (K : ℝ) (a N : ℕ), Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient eligible + (actualPaddingVertex data.Q) (fun d => centeredTuple d.primeFactors) L K + (fun _ => actualPaddingDegreeCut data.Q L) h + (fun z => ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) z) + |uniformAverage (fun x : Fin N => scalarWalkProduct h weight (a + x.val) + (columnTupleWord w forward padding)) - + (data.residueLaw B hB).average (fun r => scalarWalkProduct h weight (data.residueOrigin r) + (columnTupleWord w forward padding))| ≤ Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hcomp⟩ := hBr.eventually_weighted_word_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hcomp, eventually_ge_atTop (4800 : ℝ)] with L hcomp hL + intro h J M R s B data hB hpool hBL hs hJM hpairs hR hRL hRJ Q hQ P w forward padding + hprime hdisjoint hdeg label hlabel hclosed eligible K a N hN + let m := Fintype.card ↥data.Q + let e : Fin m ≃ data.Q := (Fintype.equivFin ↥data.Q).symm + let primes := data.P ∪ data.Q + let modulus := primeResidueModuli primes + let (i : Fin (Fintype.card primes)) : NeZero (modulus i) := + ⟨(primeResidueModuli_prime primes (fun p hp => data.prime ⟨p, hp⟩) i).ne_zero⟩ + let step := fun i => SignedStep.mk (forward i) (columnTuple w i) (padding i) + let literal := actualWordLiterals data s e step label + let F := fun z : ∀ i, ZMod (modulus i) => actualWordBoolean data s Q e step + (fun i j => (w j i).val) eligible L K + (residueCircuitInputs modulus (primeLiteralCoordinate primes literal) (primeLiteralTest primes literal) z) + have hp : ∀ p ∈ primes, p.Prime := fun p hp => data.prime ⟨p, hp⟩ + have hcard : (Fintype.card primes : ℝ) ≤ Real.exp L := by + have hb := primePool_card_bound primes hp B hB + have hb' : (primes.card : ℝ) ≤ B := by exact_mod_cast hb + simpa only [Fintype.card_coe] using hb'.trans hBL + have hm : (m : ℝ) ≤ Real.exp L := by + have he : m = data.Q.card := by simpa only [Fintype.card_fin, Fintype.card_coe] using Fintype.card_congr e + rw [he] + have hq : (data.Q.card : ℝ) ≤ primes.card := by + exact_mod_cast card_le_card (subset_union_right : data.Q ⊆ primes) + exact hq.trans (by simpa only [Fintype.card_coe] using hcard) + have hpzero : 0 < Fintype.card primes := by + simpa only [Fintype.card_coe] using card_pos.mpr hpool + have hmod : ∀ i, (modulus i : ℝ) ≤ Real.exp L := by + intro i + exact primeResidueModuli_bound primes (Real.exp L) + (fun p hp => (show (p : ℝ) ≤ B by exact_mod_cast hB p hp).trans hBL) i + have hR' : (R : ℝ) ≤ 4 * L := by push_cast at hRL; linarith + have hsize := prohibitedWordKeepCircuit_size_budget data.pairs h s (J + M) + (actualWordBadIndex data s R m) L (by linarith) hRL hs hJM hpairs + (data.pair_primeFactors_card) + have hc := hcomp (Fintype.card primes) modulus hpzero (by linarith) + (primeResidueModuli_coprime primes hp) hmod (R + 1) m (R * J) _ ⌊400 * Real.log L⌋₊ + hm (Nat.floor_le (mul_nonneg (by norm_num) (Real.log_nonneg (by linarith)))) hRL hRJ + (primeLiteralCoordinate primes literal) (primeLiteralTest primes literal) + (actualWordQIndex data s R m) (actualWordPIndex data s R m) + (actualWordCoefficient data.Q Q e (fun t => eligible t.tuple) L K step (fun i j => (w j i).val)) + (prohibitedWordKeepCircuit data.pairs h s (actualWordBadIndex data s R m)) + (fun b => actualWordCoefficient_budget data.Q Q e (fun t => eligible t.tuple) L K step _ + (fun i j => hprime j _ (w j i).property) hL hR' hdeg _ _) + ((prohibitedWordKeepCircuit_depth data.pairs h s _).trans (by norm_num)) hsize a N hN + change |uniformAverage (fun x : Fin N => F (fun i => (a + x.val : ZMod (modulus i)))) - + uniformAverage F| ≤ Real.exp (-(L ^ 9)) at hc + let weight := maskedSignedIntegerWeight Q actualPaddingCoefficient eligible + (actualPaddingVertex data.Q) (fun d => centeredTuple d.primeFactors) L K + (fun _ => actualPaddingDegreeCut data.Q L) h + (fun z => ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) z) + have hF (n : ℤ) : F (fun i => (n : ZMod (modulus i))) = + scalarWalkProduct h weight n (columnTupleWord w forward padding) := + actualWordBoolean_integer data s Q hQ e w forward padding hprime hdisjoint label hlabel + eligible L K (by linarith) n hR hclosed + have hmodel : (data.residueLaw B hB).average (fun r => + scalarWalkProduct h weight (data.residueOrigin r) (columnTupleWord w forward padding)) = + uniformAverage F := by + rw [← data.residue_average_canonical hB F] + apply congrArg (data.residueLaw B hB).average + funext r + rw [← hF, data.canonical_origin] + dsimp only + rw [hmodel] + have hsample : (fun x : Fin N => scalarWalkProduct h weight (a + x.val) + (columnTupleWord w forward padding)) = + (fun x : Fin N => F (fun i => (a + x.val : ZMod (modulus i)))) := by + funext x + simpa only [Int.cast_add, Int.cast_natCast, Nat.cast_add] using (hF (a + x.val)).symm + rw [hsample] + exact hc + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWordInputs.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWordInputs.lean new file mode 100644 index 0000000000000000000000000000000000000000..031be3481f92d5c4942ec8fd27aad912b5fe482c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWordInputs.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedWordCircuit +import OAI.NumberTheory.TwoPoint.Bounds.ActualWordStateIdentity + +namespace OAI + +/-! A finite list of every literal in a weighted word: the padding +state at each endpoint, its centered-prime tests, and every occurrence +in the prohibited-site DNFs. Equal primes share one residue coordinate. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +abbrev ActualWordInput {h J M : ℕ} (data : ProhibitedPrimeFamily h J M) + (s R m : ℕ) := + (Fin (R + 1) × Fin m) ⊕ + ((Fin R × Fin J) ⊕ (Fin (R + 1) × Fin (Fintype.card (ProhibitedInputs data.pairs h s)))) + +noncomputable def actualWordInputEquiv {h J M : ℕ} (data : ProhibitedPrimeFamily h J M) + (s R m : ℕ) : ActualWordInput data s R m ≃ Fin (Fintype.card (ActualWordInput data s R m)) := + Fintype.equivFin _ + +noncomputable def actualWordLiterals {h J M R m : ℕ} (data : ProhibitedPrimeFamily h J M) + (s : ℕ) (e : Fin m ≃ data.Q) (step : Fin R → SignedStep) + (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) : + Fin (Fintype.card (ActualWordInput data s R m)) → ↥(data.P ∪ data.Q) × ℤ := fun i => + match (actualWordInputEquiv data s R m).symm i with + | .inl (r, j) => (⟨(e j).val, mem_union_right _ (e j).property⟩, wordVertexSite h step 0 r) + | .inr (.inl (r, j)) => (label (r, j), wordVertexSite h step 0 r.castSucc) + | .inr (.inr (r, j)) => + ((data.prohibitedLiteral s j).1, wordVertexSite h step 0 r + (data.prohibitedLiteral s j).2) + +noncomputable def actualWordQIndex {h J M : ℕ} (data : ProhibitedPrimeFamily h J M) + (s R m : ℕ) (r : Fin (R + 1)) (j : Fin m) : + Fin (Fintype.card (ActualWordInput data s R m)) := + actualWordInputEquiv data s R m (.inl (r, j)) + +noncomputable def actualWordPIndex {h J M : ℕ} (data : ProhibitedPrimeFamily h J M) + (s R m : ℕ) (k : Fin (R * J)) : Fin (Fintype.card (ActualWordInput data s R m)) := + actualWordInputEquiv data s R m (.inr (.inl (finProdFinEquiv.symm k))) + +noncomputable def actualWordBadIndex {h J M : ℕ} (data : ProhibitedPrimeFamily h J M) + (s R m : ℕ) (r : Fin (R + 1)) (j : Fin (Fintype.card (ProhibitedInputs data.pairs h s))) : + Fin (Fintype.card (ActualWordInput data s R m)) := + actualWordInputEquiv data s R m (.inr (.inr (r, j))) + +noncomputable def actualWordIntegerBits {h J M R m : ℕ} (data : ProhibitedPrimeFamily h J M) + (s : ℕ) (e : Fin m ≃ data.Q) (step : Fin R → SignedStep) + (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) (n : ℤ) : + BooleanCube (Fintype.card (ActualWordInput data s R m)) := + residueCircuitInputs (primeResidueModuli (data.P ∪ data.Q)) + (primeLiteralCoordinate (data.P ∪ data.Q) (actualWordLiterals data s e step label)) + (primeLiteralTest (data.P ∪ data.Q) (actualWordLiterals data s e step label)) + (fun j => (n : ZMod (primeResidueModuli (data.P ∪ data.Q) j))) + +lemma actualWordQIndex_eval {h J M R m : ℕ} (data : ProhibitedPrimeFamily h J M) + (s : ℕ) (e : Fin m ≃ data.Q) (step : Fin R → SignedStep) + (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) (n : ℤ) (r : Fin (R + 1)) (j : Fin m) : + actualWordIntegerBits data s e step label n (actualWordQIndex data s R m r j) = + decide (((e j).val : ℤ) ∣ wordVertexSite h step n r) := by + rw [actualWordIntegerBits, primeLiteral_integer_input] + simp only [actualWordLiterals, actualWordQIndex, Equiv.symm_apply_apply, wordVertexSite, + zero_add] + rfl + +lemma actualWordBadIndex_eval {h J M R m : ℕ} (data : ProhibitedPrimeFamily h J M) + (s : ℕ) (e : Fin m ≃ data.Q) (step : Fin R → SignedStep) + (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) (n : ℤ) (r : Fin (R + 1)) + (j : Fin (Fintype.card (ProhibitedInputs data.pairs h s))) : + actualWordIntegerBits data s e step label n (actualWordBadIndex data s R m r j) = + prohibitedInputAt data.pairs h s (wordVertexSite h step n r) j := by + rw [actualWordIntegerBits, primeLiteral_integer_input] + simp only [actualWordLiterals, actualWordBadIndex, Equiv.symm_apply_apply, + ProhibitedPrimeFamily.prohibitedLiteral, prohibitedInputAt, wordVertexSite, zero_add, + add_assoc] + +lemma actualWordPIndex_eval {h J M R m : ℕ} {P : Fin J → Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (s : ℕ) (e : Fin m ≃ data.Q) + (w : ColumnPrimeAssignment J R P) (step : Fin R → SignedStep) + (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (hlabel : ∀ i j, (label (i, j)).val = (w j i).val) (n : ℤ) (k : Fin (R * J)) : + actualWordIntegerBits data s e step label n (actualWordPIndex data s R m k) = + wordCenteredBits w h step n k := by + rw [actualWordIntegerBits, primeLiteral_integer_input] + simp only [actualWordLiterals, actualWordPIndex, Equiv.symm_apply_apply] + simp only [hlabel, wordCenteredBits, wordVertexSite, zero_add] + rfl + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWordStateIdentity.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWordStateIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ed62bee7c7d06386bdf8a6c3265b8cb4979e5af --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ActualWordStateIdentity.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.TwoPoint.Walks.WeightedWordCoefficient + +namespace OAI + +/-! Exact evaluation of the coefficient table on the integer sites of a +word, including both endpoints of every retained departure. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def wordVertexSite {R : ℕ} (h : ℕ) (step : Fin R → SignedStep) (n : ℤ) + (i : Fin (R + 1)) : ℤ := + n + wordDisplacement h ((List.ofFn step).take i.val) + +lemma wordVertexSite_step {R : ℕ} (h : ℕ) (step : Fin R → SignedStep) (n : ℤ) + (i : Fin R) : + wordVertexSite h step n i.succ = + wordVertexSite h step n i.castSucc + (step i).displacement h := by + unfold wordVertexSite + rw [wordDisplacement_take, wordDisplacement_take] + simp only [Fin.val_succ, Fin.val_castSucc, sum_range_succ] + have he : wordStepDisplacement h (List.ofFn step) i.val = (step i).displacement h := by + simp [wordStepDisplacement] + rw [he] + ring + +lemma retainedWord_eq_state_product {R m : ℕ} (Qp Q : Finset ℕ) + (hQp : ∀ p ∈ Qp, p.Prime) (hQ : Q ⊆ retainedPrimeDivisors Qp) + (e : Fin m ≃ Qp) (eligible : SignedStep → ℕ → Prop) (L K : ℝ) + (h : ℕ) (step : Fin R → SignedStep) (n : ℤ) : + scalarWalkProduct h + (retainedEdgeDeparture Q actualPaddingCoefficient eligible (actualPaddingVertex Qp) L K + (fun _ => actualPaddingDegreeCut Qp L) h) n (List.ofFn step) = + ∏ i : Fin R, paddingStateDeparture Qp Q e eligible L K (step i) + (paddingActiveState Qp e (wordVertexSite h step n i.castSucc)) + (paddingActiveState Qp e (wordVertexSite h step n i.succ)) := by + rw [scalarWalkProduct_ofFn] + apply prod_congr rfl + intro i _ + rw [retainedEdgeDeparture_eq_state Qp Q hQp hQ e] + change paddingStateDeparture Qp Q e eligible L K (step i) + (paddingActiveState Qp e (wordVertexSite h step n i.castSucc)) + (paddingActiveState Qp e (wordVertexSite h step n i.castSucc + (step i).displacement h)) = _ + rw [← wordVertexSite_step] + +noncomputable def wordCenteredBits {J R : ℕ} {P : Fin J → Finset ℕ} + (w : ColumnPrimeAssignment J R P) (h : ℕ) (step : Fin R → SignedStep) (n : ℤ) : + BooleanCube (R * J) := fun k => + let ij := finProdFinEquiv.symm k + decide (((w ij.2 ij.1).val : ℤ) ∣ wordVertexSite h step n ij.1.castSucc) + +lemma wordCenteredBits_apply {J R : ℕ} {P : Fin J → Finset ℕ} + (w : ColumnPrimeAssignment J R P) (h : ℕ) (step : Fin R → SignedStep) (n : ℤ) + (i : Fin R) (j : Fin J) : + wordCenteredBits w h step n (finProdFinEquiv (i, j)) = + decide (((w j i).val : ℤ) ∣ wordVertexSite h step n i.castSucc) := + congrArg (fun ij : Fin R × Fin J => + decide (((w ij.2 ij.1).val : ℤ) ∣ wordVertexSite h step n ij.1.castSucc)) + ((finProdFinEquiv : Fin R × Fin J ≃ Fin (R * J)).symm_apply_apply (i, j)) + +lemma centeredWord_eq_state_bits {J R : ℕ} {P : Fin J → Finset ℕ} + (w : ColumnPrimeAssignment J R P) (forward : Fin R → Bool) (padding : Fin R → ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) (h : ℕ) (n : ℤ) : + let step := fun i => SignedStep.mk (forward i) (columnTuple w i) (padding i) + scalarWalkProduct h (fun t n => centeredTuple t.tuple.primeFactors n) n (List.ofFn step) = + centeredWordBits (fun i j => (w j i).val) (wordCenteredBits w h step n) := by + dsimp only + rw [scalarWalkProduct_ofFn] + unfold centeredWordBits + apply prod_congr rfl + intro i _ + rw [centeredTuple_column w i hprime hdisjoint] + apply prod_congr rfl + intro j _ + simp only [wordCenteredBits_apply, decide_eq_true_eq] + rfl + +lemma actualWordCoefficient_integer_identity {J R m : ℕ} {P : Fin J → Finset ℕ} + (w : ColumnPrimeAssignment J R P) (forward : Fin R → Bool) (padding : Fin R → ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (Qp Q : Finset ℕ) (hQp : ∀ p ∈ Qp, p.Prime) (hQ : Q ⊆ retainedPrimeDivisors Qp) + (e : Fin m ≃ Qp) (eligible : SignedStep → ℕ → Prop) (L K : ℝ) (h : ℕ) (n : ℤ) : + let step := fun i => SignedStep.mk (forward i) (columnTuple w i) (padding i) + actualWordCoefficient Qp Q e eligible L K step (fun i j => (w j i).val) + (fun i => paddingActiveState Qp e (wordVertexSite h step n i)) + (wordCenteredBits w h step n) = + scalarWalkProduct h + (retainedEdgeDeparture Q actualPaddingCoefficient eligible (actualPaddingVertex Qp) L K + (fun _ => actualPaddingDegreeCut Qp L) h) n (List.ofFn step) * + scalarWalkProduct h (fun t n => centeredTuple t.tuple.primeFactors n) n (List.ofFn step) := by + dsimp only + rw [actualWordCoefficient, retainedWord_eq_state_product Qp Q hQp hQ e, + centeredWord_eq_state_bits w forward padding hprime hdisjoint] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/AffineResidueAverage.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/AffineResidueAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d8636bb7380ed56cb45caa01adabea4bb971d69 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/AffineResidueAverage.lean @@ -0,0 +1,30 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteAverages +import Mathlib.Data.ZMod.Basic +import Mathlib.Algebra.Group.Units.Equiv + +namespace OAI + +/-! Freeze a progression class and change every prime residue by the +same invertible affine map. This preserves the precise uniform model. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +lemma uniformAverage_residue_affine {m : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (a l : ℕ) (hl : ∀ i, l.Coprime (s i)) (F : (∀ i, ZMod (s i)) → ℝ) : + uniformAverage (fun z : ∀ i, ZMod (s i) => + F (fun i => (a : ZMod (s i)) + (l : ZMod (s i)) * z i)) = + uniformAverage F := by + let e : (∀ i, ZMod (s i)) ≃ (∀ i, ZMod (s i)) := Equiv.piCongrRight fun i => + (Units.mulLeft (ZMod.unitOfCoprime l (hl i))).trans (Equiv.addLeft (a : ZMod (s i))) + have he (z : ∀ i, ZMod (s i)) : e z = + fun i => (a : ZMod (s i)) + (l : ZMod (s i)) * z i := by + funext i + change (a : ZMod (s i)) + (ZMod.unitOfCoprime l (hl i) : ZMod (s i)) * z i = _ + rw [ZMod.coe_unitOfCoprime] + simpa only [he] using uniformAverage_equiv e F + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/AffineTransfer.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/AffineTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c45610fd7eb8ee05319576604f9284a86ab8ad0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/AffineTransfer.lean @@ -0,0 +1,147 @@ +import OAI.NumberTheory.TwoPoint.Basic +import Mathlib.Data.Nat.ModEq +import Mathlib.Data.Nat.Dist +import Mathlib.Analysis.SpecificLimits.Basic + +namespace OAI + +/-! +# Exact progression and affine endpoint identities + +These finite identities implement the endpoint step of §8 of the manuscript. +They include nonunit residue classes and do not assume any cancellation theorem. +-/ + +open scoped BigOperators + +namespace TwoPointCorrelations + +/-- A prefix sum on any residue class, without a coprimality assumption. -/ +def residuePrefix (u : ℕ → ℂ) (l b N : ℕ) : ℂ := + ∑ m ∈ Finset.Ioc 0 N, if m % l = b % l then u m else 0 + +lemma progression_interval_image (l b N : ℕ) (hl : 0 < l) : + (Finset.Icc 1 N).image (fun n => l * n + b) = + (Finset.Ioc b (l * N + b)).filter (fun m => m % l = b % l) := by + ext m + simp only [Finset.mem_image, Finset.mem_Icc, Finset.mem_filter, Finset.mem_Ioc] + constructor + · rintro ⟨n, ⟨hn, hnN⟩, rfl⟩ + constructor + · constructor + · have : 0 < l * n := Nat.mul_pos hl hn + omega + · exact Nat.add_le_add_right (Nat.mul_le_mul_left l hnN) b + · simp + · rintro ⟨⟨hbm, hmN⟩, hmod⟩ + have hdvd : l ∣ m - b := Nat.ModEq.dvd' hmod.symm + obtain ⟨n, hn⟩ := hdvd + have heq : l * n + b = m := by omega + refine ⟨n, ⟨?_, ?_⟩, heq⟩ + · by_contra h + have hn0 : n = 0 := by omega + subst n + simp only [Nat.mul_zero, zero_add] at heq + omega + · exact Nat.le_of_mul_le_mul_left (by omega : l * n ≤ l * N) hl + +/-- Exact extraction of an affine subsequence from two progression prefixes. -/ +theorem affine_sum_eq_residue_prefix (u : ℕ → ℂ) (l b N : ℕ) (hl : 0 < l) : + (∑ n ∈ Finset.Icc 1 N, u (l * n + b)) = + residuePrefix u l b (l * N + b) - residuePrefix u l b b := by + have hinj : Set.InjOn (fun n : ℕ => l * n + b) (Finset.Icc 1 N) := by + intro n hn m hm hnm + exact Nat.eq_of_mul_eq_mul_left hl (Nat.add_right_cancel hnm) + have hsum : (∑ n ∈ Finset.Icc 1 N, u (l * n + b)) = + ∑ m ∈ (Finset.Ioc b (l * N + b)).filter (fun m => m % l = b % l), u m := by + rw [← progression_interval_image l b N hl, Finset.sum_image hinj] + have hsplit := Finset.sum_Ioc_consecutive + (fun m => if m % l = b % l then u m else 0) + (Nat.zero_le b) (Nat.le_add_left b (l * N)) + unfold residuePrefix + rw [hsum, Finset.sum_filter] + exact eq_sub_iff_add_eq.mpr (by simpa [add_comm] using hsplit) + +/-- The ordered Liouville affine sum has exactly the progression endpoints +specified in the manuscript, with no condition on the residue class. -/ +theorem liouville_affine_sum_endpoints (a₁ a₂ b₁ b₂ N : ℕ) + (ha₁ : 0 < a₁) (ha₂ : 0 < a₂) (horder : a₂ * b₁ ≤ a₁ * b₂) : + affineSum liouville liouville a₁ a₂ b₁ b₂ N = + liouville (a₁ * a₂) * + (residuePrefix (fun m => liouville m * liouville (m + (a₁ * b₂ - a₂ * b₁))) + (a₁ * a₂) (a₂ * b₁) (a₁ * a₂ * N + a₂ * b₁) - + residuePrefix (fun m => liouville m * liouville (m + (a₁ * b₂ - a₂ * b₁))) + (a₁ * a₂) (a₂ * b₁) (a₂ * b₁)) := by + unfold affineSum + simp_rw [liouville_affine_ordered a₁ a₂ b₁ b₂ _ ha₁.ne' ha₂.ne' horder] + simp_rw [mul_assoc] + rw [← Finset.mul_sum] + congr 1 + simpa only [mul_assoc] using affine_sum_eq_residue_prefix + (fun m => liouville m * liouville (m + (a₁ * b₂ - a₂ * b₁))) + (a₁ * a₂) (a₂ * b₁) N (Nat.mul_pos ha₁ ha₂) + +/-- Swapping the two factors does not alter an affine correlation. -/ +theorem affineSum_swap (f g : ℕ → ℂ) (a₁ a₂ b₁ b₂ N : ℕ) : + affineSum f g a₁ a₂ b₁ b₂ N = affineSum g f a₂ a₁ b₂ b₁ N := by + unfold affineSum + apply Finset.sum_congr rfl + intro n hn + exact mul_comm _ _ + +/-- The exact endpoint formula with either determinant sign. -/ +theorem liouville_affine_sum_endpoints_all (a₁ a₂ b₁ b₂ N : ℕ) + (ha₁ : 0 < a₁) (ha₂ : 0 < a₂) : + let l := a₁ * a₂ + let b := min (a₂ * b₁) (a₁ * b₂) + let h := Nat.dist (a₁ * b₂) (a₂ * b₁) + affineSum liouville liouville a₁ a₂ b₁ b₂ N = + liouville l * + (residuePrefix (fun m => liouville m * liouville (m + h)) l b (l * N + b) - + residuePrefix (fun m => liouville m * liouville (m + h)) l b b) := by + dsimp + rcases le_total (a₂ * b₁) (a₁ * b₂) with hle | hle + · rw [min_eq_left hle, Nat.dist_eq_sub_of_le_right hle] + exact liouville_affine_sum_endpoints a₁ a₂ b₁ b₂ N ha₁ ha₂ hle + · rw [affineSum_swap, min_eq_right hle, Nat.dist_eq_sub_of_le hle] + simpa only [Nat.mul_comm a₁ a₂] using + liouville_affine_sum_endpoints a₂ a₁ b₂ b₁ N ha₂ ha₁ hle + +/-- Passage from a vanishing progression mean to its affine subsequence. -/ +theorem affine_mean_tendsto_zero (u : ℕ → ℂ) (l b : ℕ) (hl : 0 < l) + (hp : Filter.Tendsto (fun M : ℕ => residuePrefix u l b M / (M : ℂ)) + Filter.atTop (nhds 0)) : + Filter.Tendsto (fun N : ℕ => (∑ n ∈ Finset.Icc 1 N, u (l * n + b)) / (N : ℂ)) + Filter.atTop (nhds 0) := by + have ht : Filter.Tendsto (fun N : ℕ => l * N + b) Filter.atTop Filter.atTop := by + apply Filter.tendsto_atTop.mpr + intro k + filter_upwards [Filter.eventually_ge_atTop k] with N hN + have : N ≤ l * N := by nlinarith + omega + have hsample := hp.comp ht + have hratio : Filter.Tendsto (fun N : ℕ => ((l * N + b : ℕ) : ℂ) / (N : ℂ)) + Filter.atTop (nhds (l : ℂ)) := by + have h := Filter.Tendsto.add (tendsto_const_nhds (x := (l : ℂ))) + (tendsto_const_div_atTop_nhds_zero_nat (𝕜 := ℂ) (b : ℂ)) + simp only [add_zero] at h + apply h.congr' + filter_upwards [Filter.eventually_ge_atTop 1] with N hN + have hn : (N : ℂ) ≠ 0 := by exact_mod_cast (by omega : N ≠ 0) + push_cast + field_simp + have hboundary := tendsto_const_div_atTop_nhds_zero_nat (𝕜 := ℂ) (residuePrefix u l b b) + have hresult := (hratio.mul hsample).sub hboundary + simp only [mul_zero, sub_zero] at hresult + apply hresult.congr' + filter_upwards [Filter.eventually_ge_atTop 1] with N hN + have hn : (N : ℂ) ≠ 0 := by exact_mod_cast (by omega : N ≠ 0) + have hmNat : 0 < l * N + b := by nlinarith + have hm : ((l * N + b : ℕ) : ℂ) ≠ 0 := by exact_mod_cast hmNat.ne' + rw [affine_sum_eq_residue_prefix u l b N hl] + dsimp only [Function.comp_apply] + field_simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/AffineWeightedWordComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/AffineWeightedWordComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d98389fb971f91e00681f4f1816a2db23baf6b7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/AffineWeightedWordComparison.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.TwoPoint.Walks.WeightedWordComparison +import OAI.NumberTheory.TwoPoint.Bounds.AffineResidueAverage + +namespace OAI + +/-! The existing signed word comparison on each fixed progression class. +All state, circuit and coefficient budgets remain unchanged. -/ + +namespace TwoPointCorrelations + +open Finset Filter + +theorem BravermanDepth22Input.eventually_affine_weighted_word_comparison + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (m : ℕ) (s : Fin m → ℕ) [∀ i, NeZero (s i)], + 0 < m → (m : ℝ) ≤ Real.exp L + 1 → + Pairwise (fun i j => (s i).Coprime (s j)) → + (∀ i, (s i : ℝ) ≤ Real.exp L) → + ∀ (R n t Ninput M : ℕ), (n : ℝ) ≤ Real.exp L → + (M : ℝ) ≤ 400 * Real.log L → (R : ℝ) ≤ 4 * L → (t : ℝ) ≤ L ^ 2 → + ∀ (coord : Fin Ninput → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) + (qindex : Fin R → Fin n → Fin Ninput) (pindex : Fin t → Fin Ninput) + (f : (Fin R → Finset (Fin n)) → BooleanCube t → ℝ) (c : AC0Circuit Ninput), + (∀ b : (Fin R → boundedActiveStates n M) × BooleanCube t, + |f (fun r => (b.1 r).val) b.2| ≤ Real.exp (L ^ 4)) → + c.depth ≤ 19 → (c.size : ℝ) ≤ Real.exp (L ^ 3) → + ∀ a l N : ℕ, (∀ i, l.Coprime (s i)) → Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let F := fun z : ∀ j, ZMod (s j) => + let bits := residueCircuitInputs s coord test z + if (∀ r, (activeState (fun i => bits (qindex r i))).card ≤ M) ∧ c.eval bits = true + then f (fun r => activeState (fun i => bits (qindex r i))) (fun i => bits (pindex i)) + else 0 + |uniformAverage (fun x : Fin N => F (fun j => (a + l * x.val : ZMod (s j)))) - + uniformAverage F| ≤ Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hbase⟩ := hBr.eventually_weighted_word_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hbase] with L hbase + intro m s _ hm hmexp hcop hs R n t Ninput M hn hM hR ht coord test qindex pindex f c hf hc hsize a l N hl hN + let affineTest := fun i (z : ZMod (s (coord i))) => + test i ((a : ZMod (s (coord i))) + (l : ZMod (s (coord i))) * z) + let F := fun z : ∀ j, ZMod (s j) => + let bits := residueCircuitInputs s coord test z + if (∀ r, (activeState (fun i => bits (qindex r i))).card ≤ M) ∧ c.eval bits = true + then f (fun r => activeState (fun i => bits (qindex r i))) (fun i => bits (pindex i)) + else 0 + let G := fun z : ∀ j, ZMod (s j) => + let bits := residueCircuitInputs s coord affineTest z + if (∀ r, (activeState (fun i => bits (qindex r i))).card ≤ M) ∧ c.eval bits = true + then f (fun r => activeState (fun i => bits (qindex r i))) (fun i => bits (pindex i)) + else 0 + have hbits (z : ∀ j, ZMod (s j)) : residueCircuitInputs s coord affineTest z = + residueCircuitInputs s coord test (fun j => (a : ZMod (s j)) + (l : ZMod (s j)) * z j) := rfl + have hG (z : ∀ j, ZMod (s j)) : G z = + F (fun j => (a : ZMod (s j)) + (l : ZMod (s j)) * z j) := by + dsimp only [G, F] + rw [hbits] + have hb := hbase m s hm hmexp hcop hs R n t Ninput M hn hM hR ht + coord affineTest qindex pindex f c hf hc hsize 0 N hN + change |uniformAverage (fun x : Fin N => G (fun j => ((0 : ℕ) : ZMod (s j)) + x.val)) - + uniformAverage G| ≤ Real.exp (-(L ^ 9)) at hb + have hGfun : G = fun z => F (fun j => (a : ZMod (s j)) + (l : ZMod (s j)) * z j) := funext hG + rw [hGfun] at hb + rw [uniformAverage_residue_affine s a l hl F] at hb + simpa only [Nat.cast_add, Nat.cast_mul, Nat.cast_zero, zero_add] using hb + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/AmbientLitOrigin.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/AmbientLitOrigin.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c7dd4fe68cb49851be8269849c29d1d35d24015 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/AmbientLitOrigin.lean @@ -0,0 +1,41 @@ +import OAI.NumberTheory.TwoPoint.Bounds.LitCommonOrigin +import OAI.NumberTheory.TwoPoint.Walks.TuplePerfectRows + +namespace OAI + +/-! Lit consistency in the full prime pool supplies the common tuple-column origins. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem ambient_lit_common_origin {ι : Type*} [Fintype ι] [DecidableEq ι] {R J : ℕ} + (B : ℕ) (p : ι → ℕ) (hprime : ∀ i, (p i).Prime) (hinj : Function.Injective p) + (hpB : ∀ i, p i ≤ B) (label : Fin R × Fin J → ι) + (U : Finset (Fin R × Fin J)) (offset : Fin R → ℤ) (base : ι → Fin B) + (hL : LitConsistent (nonsingletonSlots label \ U) label + (fun t => forcedResidue B (p (label t)) (hprime _).pos (hpB _) (offset t.1))) : + ∃ n : ℤ, ∀ i ∈ perfectRows label U, ∀ j, (p (label (i, j)) : ℤ) ∣ n + offset i := by + obtain ⟨n, hn⟩ := lit_consistency_common_origin B p hprime hinj hpB + (nonsingletonSlots label \ U) label (fun t => offset t.1) base hL + exact ⟨n, fun i hi j => hn (i, j) (perfectRows_lit label U i hi j)⟩ + +theorem ambient_tuple_lit_origin {ι : Type*} [Fintype ι] [DecidableEq ι] + {R J : ℕ} {P : Fin J → Finset ℕ} (w : ColumnPrimeAssignment J R P) + (B : ℕ) (p : ι → ℕ) (hprime : ∀ i, (p i).Prime) (hinj : Function.Injective p) + (hpB : ∀ i, p i ≤ B) (label : Fin R × Fin J → ι) + (hlabel : ∀ i j, p (label (i, j)) = (w j i).val) + (U : Finset (Fin R × Fin J)) (offset : Fin R → ℤ) (base : ι → Fin B) + (perfect : Finset (Fin R)) (hperfect : perfect ⊆ perfectRows label U) + (hL : LitConsistent (nonsingletonSlots label \ U) label + (fun t => forcedResidue B (p (label t)) (hprime _).pos (hpB _) (offset t.1))) : + ∃ n : ℤ, ∀ i ∈ perfect, ∀ j, ((w j i).val : ℤ) ∣ n + offset i := by + obtain ⟨n, hn⟩ := ambient_lit_common_origin B p hprime hinj hpB label U offset base hL + refine ⟨n, ?_⟩ + intro i hi j + simpa only [hlabel] using hn i (hperfect hi) j + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/AmbientTupleLabels.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/AmbientTupleLabels.lean new file mode 100644 index 0000000000000000000000000000000000000000..97934893e3447d18f4a920329781e8309a3d3bd7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/AmbientTupleLabels.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.TwoPoint.Walks.TupleResidueLabels +import OAI.NumberTheory.TwoPoint.Bounds.ObservedReciprocalBound +import OAI.NumberTheory.TwoPoint.Walks.TuplePerfectRows + +namespace OAI + +/-! Actual tuple slots have the same equality pattern in the ambient prime pool and column coordinates. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma columnPrimeValue_injective {J : ℕ} {P : Fin J → Finset ℕ} + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) : + Function.Injective (fun c : (j : Fin J) × P j => c.2.val) := by + rintro ⟨j, p⟩ ⟨l, q⟩ hpq + change p.val = q.val at hpq + have hjl : j = l := by + by_contra hne + exact disjoint_left.mp (hdisjoint j l (Ne.symm hne)) p.property (hpq.symm ▸ q.property) + subst l + exact congrArg (Sigma.mk j) (Subtype.ext hpq) + +lemma tuple_label_eq_iff {ι : Type*} [Fintype ι] [DecidableEq ι] + {J R : ℕ} {P : Fin J → Finset ℕ} (w : ColumnPrimeAssignment J R P) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (p : ι → ℕ) (hinj : Function.Injective p) (label : Fin R × Fin J → ι) + (hlabel : ∀ i j, p (label (i, j)) = (w j i).val) (t u : Fin R × Fin J) : + label t = label u ↔ tupleSlotLabel w t = tupleSlotLabel w u := by + rw [← hinj.eq_iff, ← (columnPrimeValue_injective hdisjoint).eq_iff] + change p (label t) = p (label u) ↔ (w t.2 t.1).val = (w u.2 u.1).val + rw [show p (label t) = (w t.2 t.1).val from hlabel t.1 t.2, + show p (label u) = (w u.2 u.1).val from hlabel u.1 u.2] + +lemma tuple_label_singletonSlots {ι : Type*} [Fintype ι] [DecidableEq ι] + {J R : ℕ} {P : Fin J → Finset ℕ} (w : ColumnPrimeAssignment J R P) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (p : ι → ℕ) (hinj : Function.Injective p) (label : Fin R × Fin J → ι) + (hlabel : ∀ i j, p (label (i, j)) = (w j i).val) : + singletonSlots label = singletonSlots (tupleSlotLabel w) := by + have he (t : Fin R × Fin J) : labelOccurrences label (label t) = + labelOccurrences (tupleSlotLabel w) (tupleSlotLabel w t) := by + ext u + simp only [labelOccurrences, mem_filter, mem_univ, true_and] + exact tuple_label_eq_iff w hdisjoint p hinj label hlabel u t + ext t + simp only [singletonSlots, singletonLabels, mem_filter, mem_univ, true_and, he] + +lemma tuple_label_singleton_count {ι : Type*} [Fintype ι] [DecidableEq ι] + {J R : ℕ} {P : Fin J → Finset ℕ} (w : ColumnPrimeAssignment J R P) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (p : ι → ℕ) (hinj : Function.Injective p) (label : Fin R × Fin J → ι) + (hlabel : ∀ i j, p (label (i, j)) = (w j i).val) : + (singletonLabels label).card = columnSingletonCount w := by + calc + _ = (singletonSlots label).card := (singleton_slot_count label).symm + _ = (singletonSlots (tupleSlotLabel w)).card := + congrArg Finset.card (tuple_label_singletonSlots w hdisjoint p hinj label hlabel) + _ = _ := (singleton_slot_count (tupleSlotLabel w)).trans (tupleSlotLabel_singletons w) + +lemma tuple_label_perfectRows {ι : Type*} [Fintype ι] [DecidableEq ι] + {J R : ℕ} {P : Fin J → Finset ℕ} (w : ColumnPrimeAssignment J R P) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (p : ι → ℕ) (hinj : Function.Injective p) (label : Fin R × Fin J → ι) + (hlabel : ∀ i j, p (label (i, j)) = (w j i).val) (U : Finset (Fin R × Fin J)) : + perfectRows label U = perfectRows (tupleSlotLabel w) U := by + simp only [perfectRows, tuple_label_singletonSlots w hdisjoint p hinj label hlabel] + +lemma tuple_label_reciprocal {ι : Type*} [Fintype ι] [DecidableEq ι] + {J R : ℕ} {P : Fin J → Finset ℕ} (w : ColumnPrimeAssignment J R P) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (p : ι → ℕ) (hinj : Function.Injective p) (label : Fin R × Fin J → ι) + (hlabel : ∀ i j, p (label (i, j)) = (w j i).val) : + (∏ i ∈ univ.image label, (p i : ℝ)⁻¹) = columnReciprocalWeight w := by + have he : (univ.image label).image p = tuplePrimeSupport w := by + ext q + simp only [mem_image, mem_univ, true_and, mem_tuplePrimeSupport] + constructor + · rintro ⟨i, ⟨t, rfl⟩, rfl⟩ + exact ⟨t.2, t.1, (hlabel t.1 t.2).symm⟩ + · rintro ⟨j, i, rfl⟩ + exact ⟨label (i, j), ⟨(i, j), rfl⟩, hlabel i j⟩ + rw [← tuplePrimeSupport_reciprocal w hdisjoint, ← he] + exact (prod_image (g := p) (f := fun q : ℕ => (q : ℝ)⁻¹) + (fun _ _ _ _ h => hinj h)).symm + +theorem designatedReciprocal_le_tuple {ι : Type*} [Fintype ι] [DecidableEq ι] + {J R : ℕ} {P : Fin J → Finset ℕ} (w : ColumnPrimeAssignment J R P) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (p : ι → ℕ) (hinj : Function.Injective p) (hp : ∀ i, 0 < p i) + (label : Fin R × Fin J → ι) + (hlabel : ∀ i j, p (label (i, j)) = (w j i).val) + (U : Finset (Fin R × Fin J)) (hU : U ⊆ nonsingletonSlots label) : + designatedReciprocal p (singletonLabels label) (nonsingletonSlots label \ U) U label ≤ + columnReciprocalWeight w := by + have hb := full_word_designated_reciprocal_bound label U hU p 1 + (by norm_num) (fun i => by exact_mod_cast hp i) + rw [designation_sdiff_decidable (fun a b => Classical.propDecidable (a = b)) + (inferInstance : DecidableEq (Fin R × Fin J)) _ _] at hb + simpa only [inv_one, one_pow, mul_one, tuple_label_reciprocal w hdisjoint p hinj label hlabel] + using hb + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/BadCatalogCost.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/BadCatalogCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..c818e405679e370b283f254faae30901d5ba82e6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/BadCatalogCost.lean @@ -0,0 +1,308 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SplitBadWordSum +import OAI.NumberTheory.TwoPoint.Bounds.BadEventDecay + +namespace OAI + +/-! +# The cost of the complete short-word catalog + +Numerical primes are summed by reciprocal weight, rather than counted as +additional symbols. This leaves only signs, equality classes, row records, +and tuple/padding flags. The bound includes every length and every slot +count up to the stated budgets, including invalid codes. +-/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace CrudeWordCode + +variable {R N : ℕ} + +/-- The finite cost left after one nondegenerate prime relation is imposed. -/ +noncomputable def badReciprocalCost (c : CrudeWordCode R N R) (VP VQ : ℝ) : ℝ := + (Fintype.card c.tupleClasses ^ 2 * (R + 1) ^ 2 : ℕ) * + VP ^ Fintype.card c.tupleClasses * + VQ ^ Fintype.card {z : c.usedClasses // z ∉ c.tupleClasses} + +lemma badReciprocalCost_nonneg (c : CrudeWordCode R N R) {VP VQ : ℝ} + (hP : 0 ≤ VP) (hQ : 0 ≤ VQ) : 0 ≤ c.badReciprocalCost VP VQ := by + unfold badReciprocalCost + positivity + +lemma tuple_padding_class_count (c : CrudeWordCode R N R) : + Fintype.card c.tupleClasses + + Fintype.card {z : c.usedClasses // z ∉ c.tupleClasses} = + Fintype.card c.usedClasses := by + rw [Fintype.card_subtype_compl] + exact Nat.add_sub_of_le (Fintype.card_subtype_le (fun z => z ∈ c.tupleClasses)) + +lemma class_count_le_slots (c : CrudeWordCode R N R) : + Fintype.card c.tupleClasses + + Fintype.card {z : c.usedClasses // z ∉ c.tupleClasses} ≤ N := by + rw [c.tuple_padding_class_count] + simpa only [Fintype.card_fin] using + (Fintype.card_subtype_le (fun z : Fin N => z ∈ c.usedClasses)) + +/-- Tuple and padding classes together use at most one reciprocal mass per slot. -/ +lemma class_mass_le (c : CrudeWordCode R N R) {VP VQ A : ℝ} + (hP : 0 ≤ VP) (hQ : 0 ≤ VQ) (hPA : VP ≤ A) (hQA : VQ ≤ A) + (hA : 1 ≤ A) : + VP ^ Fintype.card c.tupleClasses * + VQ ^ Fintype.card {z : c.usedClasses // z ∉ c.tupleClasses} ≤ A ^ N := by + calc + _ ≤ A ^ Fintype.card c.tupleClasses * + A ^ Fintype.card {z : c.usedClasses // z ∉ c.tupleClasses} := + mul_le_mul (pow_le_pow_left₀ hP hPA _) (pow_le_pow_left₀ hQ hQA _) + (pow_nonneg hQ _) (pow_nonneg (zero_le_one.trans hA) _) + _ = A ^ (Fintype.card c.tupleClasses + + Fintype.card {z : c.usedClasses // z ∉ c.tupleClasses}) := (pow_add _ _ _).symm + _ ≤ A ^ N := pow_le_pow_right₀ hA c.class_count_le_slots + +end CrudeWordCode + +/-- All lengths, all actual slot counts, and all finite equality codes. -/ +noncomputable def badCatalogCost (s T : ℕ) (VP VQ : ℝ) : ℝ := + ∑ R : Fin (s + 1), ∑ N : Fin (T + 1), + ∑ c : CrudeWordCode R.val N.val R.val, c.badReciprocalCost VP VQ + +lemma short_log_le_square (s : ℕ) (L : ℝ) (hs : 1 ≤ s) + (hlog : 1 ≤ Real.log L) : Real.log L ≤ s * (Real.log L) ^ 2 := by + have hsr : (1 : ℝ) ≤ s := by exact_mod_cast hs + have hsq : Real.log L ≤ (Real.log L) ^ 2 := by nlinarith + nlinarith [mul_nonneg (sub_nonneg.mpr hsr) (sq_nonneg (Real.log L))] + +lemma short_polynomial_exp_bound (s k : ℕ) (L : ℝ) (hs : 1 ≤ s) + (hL : 0 < L) (hlog : 1 ≤ Real.log L) : + L ^ k ≤ Real.exp ((k : ℝ) * s * (Real.log L) ^ 2) := by + calc + _ = Real.exp ((k : ℝ) * Real.log L) := by + rw [Real.exp_nat_mul, Real.exp_log hL] + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have h := mul_le_mul_of_nonneg_left (short_log_le_square s L hs hlog) + (Nat.cast_nonneg k : (0 : ℝ) ≤ k) + nlinarith + +/-- Unlike the coarser pattern estimate, this bound does not need `R ≤ N`; +empty or invalid codes may therefore be retained in the catalog. -/ +lemma short_crudeWordCode_bound (R N s : ℕ) (L C : ℝ) + (hlog : 1 ≤ Real.log L) (hR : R ≤ s) + (hslots : (N : ℝ) ≤ C * s * Real.log L) + (hN : (N : ℝ) + 1 ≤ L ^ (2 : ℕ)) + (hspoly : (s : ℝ) + 1 ≤ L ^ (2 : ℕ)) : + (Fintype.card (CrudeWordCode R N R) : ℝ) ≤ + Real.exp ((1 + 5 * C) * s * (Real.log L) ^ 2) := by + have hlog2 : Real.log 2 ≤ Real.log L := by + have h := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + linarith + have hlogN : Real.log ((N : ℝ) + 1) ≤ 2 * Real.log L := by + have h := Real.log_le_log (by positivity : (0 : ℝ) < N + 1) hN + simpa only [Real.log_pow, Nat.cast_ofNat] using h + have hRpoly : (R : ℝ) + 1 ≤ L ^ (2 : ℕ) := by + have hr : (R : ℝ) ≤ s := by exact_mod_cast hR + linarith + have hlogR : Real.log ((R : ℝ) + 1) ≤ 2 * Real.log L := by + have h := Real.log_le_log (by positivity : (0 : ℝ) < R + 1) hRpoly + simpa only [Real.log_pow, Nat.cast_ofNat] using h + have h1 : (R : ℝ) * Real.log 2 ≤ s * Real.log L := + mul_le_mul (by exact_mod_cast hR) hlog2 + (Real.log_nonneg (by norm_num)) (Nat.cast_nonneg _) + have h2 := mul_le_mul_of_nonneg_left hlogN (Nat.cast_nonneg N : (0 : ℝ) ≤ N) + have h3 := mul_le_mul_of_nonneg_left hlogR (Nat.cast_nonneg N : (0 : ℝ) ≤ N) + have h4 := mul_le_mul_of_nonneg_left hlog2 (Nat.cast_nonneg N : (0 : ℝ) ≤ N) + have h5 := mul_le_mul_of_nonneg_right hslots (show 0 ≤ Real.log L by linarith) + have h6 : (s : ℝ) * Real.log L ≤ s * (Real.log L) ^ 2 := by + have hh : Real.log L ≤ (Real.log L) ^ 2 := by nlinarith + exact mul_le_mul_of_nonneg_left hh (Nat.cast_nonneg _) + apply (card_crudeWordCode_exp R N R).trans + apply Real.exp_le_exp.mpr + nlinarith + +/-- The reciprocal masses and the choice of one relation cost only an +additional `exp ((8 + 2 C) s log² L)` for a fixed code. -/ +lemma short_badReciprocalCost_bound {R N s : ℕ} (c : CrudeWordCode R N R) + (VP VQ L C : ℝ) (hs : 1 ≤ s) (hL : 1 ≤ L) (hlog : 1 ≤ Real.log L) + (hR : R ≤ s) (hslots : (N : ℝ) ≤ C * s * Real.log L) + (hN : (N : ℝ) + 1 ≤ L ^ (2 : ℕ)) + (hspoly : (s : ℝ) + 1 ≤ L ^ (2 : ℕ)) + (hP : 0 ≤ VP) (hQ : 0 ≤ VQ) + (hPupper : VP ≤ L ^ (2 : ℕ)) (hQupper : VQ ≤ L ^ (2 : ℕ)) : + c.badReciprocalCost VP VQ ≤ + Real.exp ((8 + 2 * C) * s * (Real.log L) ^ 2) := by + have hLp : 0 < L := lt_of_lt_of_le zero_lt_one hL + have htu : Fintype.card c.tupleClasses ≤ N := by + have hh := c.class_count_le_slots + omega + have ht : (Fintype.card c.tupleClasses : ℝ) ≤ L ^ (2 : ℕ) := by + have hh : (Fintype.card c.tupleClasses : ℝ) ≤ N := by exact_mod_cast htu + linarith + have hr : (R : ℝ) + 1 ≤ L ^ (2 : ℕ) := by + have hh : (R : ℝ) ≤ s := by exact_mod_cast hR + linarith + have hmeta : (Fintype.card c.tupleClasses ^ 2 * (R + 1) ^ 2 : ℕ) ≤ + Real.exp ((8 : ℝ) * s * (Real.log L) ^ 2) := by + calc + _ = (Fintype.card c.tupleClasses : ℝ) ^ 2 * ((R : ℝ) + 1) ^ 2 := by + push_cast + rfl + _ ≤ (L ^ (2 : ℕ)) ^ 2 * (L ^ (2 : ℕ)) ^ 2 := by gcongr + _ = L ^ (8 : ℕ) := by ring + _ ≤ _ := short_polynomial_exp_bound s 8 L hs hLp hlog + have hmass : VP ^ Fintype.card c.tupleClasses * + VQ ^ Fintype.card {z : c.usedClasses // z ∉ c.tupleClasses} ≤ + Real.exp (2 * C * s * (Real.log L) ^ 2) := by + calc + _ ≤ (L ^ (2 : ℕ)) ^ N := + c.class_mass_le hP hQ hPupper hQupper (one_le_pow₀ hL) + _ = Real.exp ((N : ℝ) * (2 * Real.log L)) := by + rw [Real.exp_nat_mul] + congr 1 + rw [show 2 * Real.log L = Real.log L + Real.log L by ring, + Real.exp_add, Real.exp_log hLp] + ring + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have hh := mul_le_mul_of_nonneg_right hslots + (show 0 ≤ 2 * Real.log L by linarith) + nlinarith + calc + c.badReciprocalCost VP VQ = + (Fintype.card c.tupleClasses ^ 2 * (R + 1) ^ 2 : ℕ) * + (VP ^ Fintype.card c.tupleClasses * + VQ ^ Fintype.card {z : c.usedClasses // z ∉ c.tupleClasses}) := by + unfold CrudeWordCode.badReciprocalCost + ring + _ ≤ Real.exp ((8 : ℝ) * s * (Real.log L) ^ 2) * + Real.exp (2 * C * s * (Real.log L) ^ 2) := + mul_le_mul hmeta hmass (by positivity) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +/-- Sum over every code of one fixed length and slot count. -/ +lemma short_badCode_sum_bound (R N s : ℕ) (VP VQ L C : ℝ) + (hs : 1 ≤ s) (hL : 1 ≤ L) (hlog : 1 ≤ Real.log L) + (hR : R ≤ s) (hslots : (N : ℝ) ≤ C * s * Real.log L) + (hN : (N : ℝ) + 1 ≤ L ^ (2 : ℕ)) + (hspoly : (s : ℝ) + 1 ≤ L ^ (2 : ℕ)) + (hP : 0 ≤ VP) (hQ : 0 ≤ VQ) + (hPupper : VP ≤ L ^ (2 : ℕ)) (hQupper : VQ ≤ L ^ (2 : ℕ)) : + (∑ c : CrudeWordCode R N R, c.badReciprocalCost VP VQ) ≤ + Real.exp ((9 + 7 * C) * s * (Real.log L) ^ 2) := by + calc + _ ≤ ∑ _c : CrudeWordCode R N R, + Real.exp ((8 + 2 * C) * s * (Real.log L) ^ 2) := by + exact sum_le_sum (fun c _ => short_badReciprocalCost_bound c VP VQ L C + hs hL hlog hR hslots hN hspoly hP hQ hPupper hQupper) + _ = (Fintype.card (CrudeWordCode R N R) : ℝ) * + Real.exp ((8 + 2 * C) * s * (Real.log L) ^ 2) := by + simp only [sum_const, card_univ, nsmul_eq_mul] + _ ≤ Real.exp ((1 + 5 * C) * s * (Real.log L) ^ 2) * + Real.exp ((8 + 2 * C) * s * (Real.log L) ^ 2) := + mul_le_mul_of_nonneg_right + (short_crudeWordCode_bound R N s L C hlog hR hslots hN hspoly) + (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +/-- The complete catalog, including both bounded integer parameters, has +the required `exp (O(s log² L))` reciprocal cost. -/ +theorem badCatalogCost_exp_bound (s T : ℕ) (VP VQ L C : ℝ) + (hs : 1 ≤ s) (hL : 1 ≤ L) (hlog : 1 ≤ Real.log L) + (hslots : (T : ℝ) ≤ C * s * Real.log L) + (hT : (T : ℝ) + 1 ≤ L ^ (2 : ℕ)) + (hspoly : (s : ℝ) + 1 ≤ L ^ (2 : ℕ)) + (hP : 0 ≤ VP) (hQ : 0 ≤ VQ) + (hPupper : VP ≤ L ^ (2 : ℕ)) (hQupper : VQ ≤ L ^ (2 : ℕ)) : + badCatalogCost s T VP VQ ≤ + Real.exp ((13 + 7 * C) * s * (Real.log L) ^ 2) := by + have hLp : 0 < L := lt_of_lt_of_le zero_lt_one hL + have hfactor : ((s + 1) * (T + 1) : ℕ) ≤ + Real.exp ((4 : ℝ) * s * (Real.log L) ^ 2) := by + calc + _ = ((s : ℝ) + 1) * ((T : ℝ) + 1) := by push_cast; rfl + _ ≤ L ^ (2 : ℕ) * L ^ (2 : ℕ) := by gcongr + _ = L ^ (4 : ℕ) := by ring + _ ≤ _ := short_polynomial_exp_bound s 4 L hs hLp hlog + calc + badCatalogCost s T VP VQ ≤ ∑ _R : Fin (s + 1), ∑ _N : Fin (T + 1), + Real.exp ((9 + 7 * C) * s * (Real.log L) ^ 2) := by + apply sum_le_sum + intro R _ + apply sum_le_sum + intro N _ + apply short_badCode_sum_bound R.val N.val s VP VQ L C hs hL hlog + (Nat.le_of_lt_succ R.isLt) _ _ hspoly hP hQ hPupper hQupper + · have hh : (N.val : ℝ) ≤ T := by exact_mod_cast Nat.le_of_lt_succ N.isLt + exact hh.trans hslots + · have hh : (N.val : ℝ) ≤ T := by exact_mod_cast Nat.le_of_lt_succ N.isLt + linarith + _ = (((s + 1) * (T + 1) : ℕ) : ℝ) * + Real.exp ((9 + 7 * C) * s * (Real.log L) ^ 2) := by + simp only [sum_const, card_univ, Fintype.card_fin, nsmul_eq_mul] + push_cast + ring + _ ≤ Real.exp ((4 : ℝ) * s * (Real.log L) ^ 2) * + Real.exp ((9 + 7 * C) * s * (Real.log L) ^ 2) := + mul_le_mul_of_nonneg_right hfactor (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +open Filter + +/-- The polynomial side conditions in the finite estimate follow from the +actual short-word and slot budgets once the scale is sufficiently large. -/ +theorem eventually_badCatalogCost_exp_bound (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ (s T : ℕ) (VP VQ : ℝ), + 1 ≤ s → (s : ℝ) ≤ L ^ (1 / 10 : ℝ) → + (T : ℝ) ≤ C * s * Real.log L → + 0 ≤ VP → 0 ≤ VQ → VP ≤ L ^ (2 : ℕ) → VQ ≤ L ^ (2 : ℕ) → + badCatalogCost s T VP VQ ≤ + Real.exp ((13 + 7 * C) * s * (Real.log L) ^ 2) := by + have hsmall := (isLittleO_log_rpow_atTop + (show 0 < (9 / 10 : ℝ) by norm_num)).bound + (show 0 < 1 / (C + 1) by positivity) + filter_upwards [eventually_ge_atTop 2, + Real.tendsto_log_atTop.eventually (eventually_ge_atTop 1), hsmall] with L hL hlog hh + intro s T VP VQ hs hsupper hslots hP hQ hPupper hQupper + have hLp : 0 < L := by linarith + rw [Real.norm_eq_abs, abs_of_nonneg (show 0 ≤ Real.log L by linarith), + Real.norm_eq_abs, abs_of_pos (Real.rpow_pos_of_pos hLp _)] at hh + have hClog : C * Real.log L ≤ L ^ (9 / 10 : ℝ) := by + calc + _ ≤ (C + 1) * Real.log L := by nlinarith + _ ≤ (C + 1) * ((1 / (C + 1)) * L ^ (9 / 10 : ℝ)) := + mul_le_mul_of_nonneg_left hh (by positivity) + _ = _ := by field_simp [show C + 1 ≠ 0 by linarith] + have hsL : (s : ℝ) ≤ L := by + apply hsupper.trans + simpa only [Real.rpow_one] using + Real.rpow_le_rpow_of_exponent_le (show 1 ≤ L by linarith) + (show (1 / 10 : ℝ) ≤ 1 by norm_num) + have hTL : (T : ℝ) ≤ L := by + calc + _ ≤ (s : ℝ) * (C * Real.log L) := by nlinarith [hslots] + _ ≤ L ^ (1 / 10 : ℝ) * L ^ (9 / 10 : ℝ) := + mul_le_mul hsupper hClog (by positivity) (by positivity) + _ = L := by rw [← Real.rpow_add hLp]; norm_num + exact badCatalogCost_exp_bound s T VP VQ L C hs (by linarith) hlog hslots + (by nlinarith) (by nlinarith) hP hQ hPupper hQupper + +/-- The full short-word enumeration is dominated by the single prime +saving. This is the numerical end of the prohibited-site density estimate. -/ +theorem eventually_badCatalog_decay (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ (s T : ℕ) (VP VQ H B total : ℝ), + 1 ≤ s → (s : ℝ) ≤ L ^ (1 / 10 : ℝ) → + (T : ℝ) ≤ C * s * Real.log L → + 0 ≤ VP → 0 ≤ VQ → VP ≤ L ^ (2 : ℕ) → VQ ≤ L ^ (2 : ℕ) → + Real.exp (L ^ (199 / 200 : ℝ)) ≤ H → 1 ≤ B → B ≤ Real.exp L → + total ≤ badCatalogCost s T VP VQ * (H⁻¹ + (1 + Real.log B) / H) → + total ≤ Real.exp (-(1 / 2 : ℝ) * L ^ (199 / 200 : ℝ)) := by + filter_upwards [eventually_badCatalogCost_exp_bound C hC, + eventually_bad_event_decay (13 + 7 * C) (by positivity)] with L hcost hdecay + intro s T VP VQ H B total hs hsupper hslots hP hQ hPupper hQupper hH hB hBupper htotal + exact hdecay s H B (badCatalogCost s T VP VQ) total hsupper hH hB hBupper + (hcost s T VP VQ hs hsupper hslots hP hQ hPupper hQupper) htotal + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/BadEventDecay.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/BadEventDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5b1b001adc80895dc7bd8256429e26eb74e1951 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/BadEventDecay.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.TwoPoint.Walks.RankDecay + +namespace OAI + +/-! A single prime saving dominates the short prohibited-word enumeration. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma eventually_short_word_cost (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, + C * L ^ (1 / 10 : ℝ) * (Real.log L) ^ 2 ≤ + (1 / 2 : ℝ) * L ^ (199 / 200 : ℝ) := by + have h := (isLittleO_log_rpow_rpow_atTop (2 : ℝ) + (s := (179 / 200 : ℝ)) (by norm_num)).bound + (show 0 < (1 / 2 : ℝ) / (C + 1) by positivity) + filter_upwards [eventually_ge_atTop 1, h] with L hL hh + have hLp : 0 < L := by linarith + rw [Real.norm_eq_abs, Real.rpow_two, abs_of_nonneg (sq_nonneg _), + Real.norm_eq_abs, abs_of_pos (Real.rpow_pos_of_pos hLp _)] at hh + have hs : C * (Real.log L) ^ 2 ≤ (1 / 2 : ℝ) * L ^ (179 / 200 : ℝ) := by + calc + _ ≤ (C + 1) * (Real.log L) ^ 2 := by nlinarith [sq_nonneg (Real.log L)] + _ ≤ (C + 1) * (((1 / 2 : ℝ) / (C + 1)) * L ^ (179 / 200 : ℝ)) := + mul_le_mul_of_nonneg_left hh (by positivity) + _ = _ := by field_simp [show C + 1 ≠ 0 by linarith] + have ht := mul_le_mul_of_nonneg_right hs (Real.rpow_nonneg hLp.le (1 / 10 : ℝ)) + have he : L ^ (179 / 200 : ℝ) * L ^ (1 / 10 : ℝ) = L ^ (199 / 200 : ℝ) := by + rw [← Real.rpow_add hLp] + norm_num + nlinarith + +/-- The complete short-word cost may include pattern and endpoint choices, +all reciprocal masses, and summation over lengths. No further saving is +used beyond the single nondegenerate last-prime relation. -/ +theorem eventually_bad_event_decay (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ (s : ℕ) (H B cost total : ℝ), + (s : ℝ) ≤ L ^ (1 / 10 : ℝ) → Real.exp (L ^ (199 / 200 : ℝ)) ≤ H → + 1 ≤ B → B ≤ Real.exp L → + cost ≤ Real.exp (C * s * (Real.log L) ^ 2) → + total ≤ cost * (H⁻¹ + (1 + Real.log B) / H) → + total ≤ Real.exp (-(1 / 2 : ℝ) * L ^ (199 / 200 : ℝ)) := by + filter_upwards [eventually_ge_atTop 2, + Real.tendsto_log_atTop.eventually (eventually_ge_atTop 1), + eventually_short_word_cost (C + 2) (by positivity)] with L hL hlog hshort + intro s H B cost total hs hH hB hBupper hcost htotal + have hLp : 0 < L := by linarith + have hHp : 0 < H := (Real.exp_pos _).trans_le hH + have hBp : 0 < B := by linarith + have hlogB : Real.log B ≤ L := by + have hh := Real.log_le_log hBp hBupper + simpa only [Real.log_exp] using hh + have hlogBpos : 0 ≤ Real.log B := Real.log_nonneg hB + have hinv : H⁻¹ ≤ Real.exp (-L ^ (199 / 200 : ℝ)) := by + rw [Real.exp_neg] + exact inv_anti₀ (Real.exp_pos _) hH + have hpoly : 2 + Real.log B ≤ Real.exp (2 * Real.log L) := by + have he : Real.exp (2 * Real.log L) = L ^ (2 : ℕ) := by + simpa only [Nat.cast_ofNat, Real.exp_log hLp] using Real.exp_nat_mul (Real.log L) 2 + rw [he] + nlinarith + have hbase : H⁻¹ + (1 + Real.log B) / H ≤ + Real.exp (2 * Real.log L - L ^ (199 / 200 : ℝ)) := by + calc + _ = (2 + Real.log B) * H⁻¹ := by ring + _ ≤ Real.exp (2 * Real.log L) * Real.exp (-L ^ (199 / 200 : ℝ)) := + mul_le_mul hpoly hinv (inv_nonneg.mpr hHp.le) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; rfl + have hone : 1 ≤ L ^ (1 / 10 : ℝ) := Real.one_le_rpow (by linarith) (by norm_num) + have hexp : C * s * (Real.log L) ^ 2 + 2 * Real.log L ≤ + (C + 2) * L ^ (1 / 10 : ℝ) * (Real.log L) ^ 2 := by + have hterm := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hs hC) (sq_nonneg (Real.log L)) + have hlog2 : Real.log L ≤ (Real.log L) ^ 2 := by nlinarith + nlinarith [mul_nonneg (sub_nonneg.mpr hone) (sq_nonneg (Real.log L))] + calc + total ≤ Real.exp (C * s * (Real.log L) ^ 2) * + (H⁻¹ + (1 + Real.log B) / H) := + htotal.trans (mul_le_mul_of_nonneg_right hcost (by positivity)) + _ ≤ Real.exp (C * s * (Real.log L) ^ 2) * + Real.exp (2 * Real.log L - L ^ (199 / 200 : ℝ)) := + mul_le_mul_of_nonneg_left hbase (Real.exp_pos _).le + _ = Real.exp (C * s * (Real.log L) ^ 2 + 2 * Real.log L - L ^ (199 / 200 : ℝ)) := by + rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := by apply Real.exp_le_exp.mpr; linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/BadWordRelations.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/BadWordRelations.lean new file mode 100644 index 0000000000000000000000000000000000000000..56a40ef8277a9680d46e42e5fb4115e2090cf3c4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/BadWordRelations.lean @@ -0,0 +1,185 @@ +import OAI.NumberTheory.TwoPoint.Walks.WordResampling +import OAI.NumberTheory.TwoPoint.Walks.WordRelations +import OAI.NumberTheory.TwoPoint.Bounds.OrderedPrimeSystems + +namespace OAI + +/-! One actual nondegenerate relation for each forward prohibited word. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +/-- The last transition of a prohibited word acquires a new prime. Its +contribution to the prohibited suffix is exactly the last step. -/ +theorem ForwardProhibited.exists_active {h s J : ℕ} {supply : ℕ → ℕ → Prop} + {w : List SignedStep} (hw : ForwardProhibited h s supply w) + (hsq : ∀ a ∈ w, Squarefree a.tuple) + (hcard : ∀ a ∈ w, a.tuple.primeFactors.card = J) + (hsupport : ∀ p j, TuplePrimeAt w p j → ¬p ∣ h ∧ ∀ a ∈ w, ¬p ∣ a.padding) : + ∃ z, ActivePrime h w z := by + have hlen : 3 ≤ w.length := hw.1 + have hinter : TuplePrimeIntervals w := hw.2.2.2.2.1 + obtain ⟨z, hz, hzprev⟩ := adjacent_tuple_new_prime w J hsq hcard hw.2.2.2.1 + (w.length - 2) (by omega) + have hlast : w.length - 2 + 1 = w.length - 1 := by omega + have hzlast : TuplePrimeAt w z (w.length - 1) := hlast ▸ hz + have hearly : ∀ i, i < w.length - 1 → ¬TuplePrimeAt w z i := by + intro i hi hzi + exact hzprev (hinter z i (w.length - 2) (w.length - 1) + (by omega) (by omega) (by omega) hzi hzlast) + refine ⟨z, hw.last_new_active hzlast hearly ?_⟩ + intro p i hp hi hnot + apply word_prime_support hsupport p i ?_ hi hnot + obtain ⟨j, hj⟩ := hp + exact ⟨j, hj.index_lt, hj⟩ + +abbrev BadRelationCode (N : ℕ) (ι : Type*) := ι × ι × Fin (N + 1) × Fin (N + 1) + +namespace BadRelationCode + +variable {N : ℕ} {ι : Type*} [DecidableEq ι] + +def Holds (d : BadRelationCode N ι) (w : LabeledPrimeWord ι) (h : ℕ) (x : ι → ℤ) : Prop := + d.2.1 ≠ d.1 ∧ primeRelationEvent (w.intervalRelation h d.2.2.1 d.2.2.2) d.1 d.2.1 x + +def toSystem (d : BadRelationCode N ι) (w : LabeledPrimeWord ι) (h : ℕ) + (hne : d.2.1 ≠ d.1) : OrderedPrimeSystem ι where + Index := Fin 1 + Term _ := Fin w.word.length + relation _ := w.intervalRelation h d.2.2.1 d.2.2.2 + selected _ := d.1 + control _ := d.2.1 + control_ne _ := hne + triangular i j hij := by have hi := i.isLt; have hj := j.isLt; omega + +lemma toSystem_size (d : BadRelationCode N ι) (w : LabeledPrimeWord ι) (h : ℕ) + (hne : d.2.1 ≠ d.1) : (d.toSystem w h hne).size = 1 := by + change Fintype.card (Fin 1) = 1 + exact Fintype.card_fin 1 + +end BadRelationCode + +/-- The numerical event retains every arithmetic assumption used to get +the last-step coefficient. The reciprocal sum may subsequently enlarge +to coincident numerical assignments. -/ +def ResampledProhibitedEvent {ι : Type*} [DecidableEq ι] + (w : LabeledPrimeWord ι) (h s J : ℕ) (supply : ℕ → ℕ → Prop) + (value : ι → ℕ) : Prop := + Function.Injective value ∧ (∀ i, (value i).Prime) ∧ + ForwardProhibited h s supply (w.resample value).word ∧ + (∀ a ∈ (w.resample value).word, Squarefree a.tuple) ∧ + (∀ a ∈ (w.resample value).word, a.tuple.primeFactors.card = J) ∧ + (∀ p j, TuplePrimeAt (w.resample value).word p j → + ¬p ∣ h ∧ ∀ a ∈ (w.resample value).word, ¬p ∣ a.padding) + +theorem resampled_prohibited_relation {ι : Type*} [DecidableEq ι] + {h s J N : ℕ} {supply : ℕ → ℕ → Prop} + (w : LabeledPrimeWord ι) (hN : w.word.length ≤ N) (value : ι → ℕ) + (hevent : ResampledProhibitedEvent w h s J supply value) : + ∃ d : BadRelationCode N ι, d.Holds w h (fun i => (value i : ℤ)) := by + rcases hevent with ⟨hinj, hprime, hpro, hsq, hcard, hsupport⟩ + obtain ⟨z, hz⟩ := hpro.exists_active hsq hcard hsupport + have hzseen : ∃ r, TuplePrimeAt (w.resample value).word z r := by + by_contra! hn + rcases hz with ⟨c, a, b, _, _, _, _, hnonzero⟩ + apply hnonzero + have he : wordPrimeContribution h (w.resample value).word z a b = 0 := by + unfold wordPrimeContribution + simp only [hn, ite_false, sum_const_zero] + rw [he] + exact dvd_zero _ + obtain ⟨rz, hrz⟩ := hzseen + obtain ⟨y, _, hy⟩ := (w.resample value).occurrence_has_label value hprime + (w.resample_realizes value) z ⟨rz, hrz.index_lt⟩ hrz + have hyactive : ActivePrime h (w.resample value).word (value y) := by simpa only [hy] using hz + obtain ⟨control, a, b, hne, hab, hb, he⟩ := (w.resample value).active_relation h value + hinj hprime (w.resample_realizes value) y hyactive + have hbn : b ≤ N := hb.trans (by simpa only [LabeledPrimeWord.resample_length] using hN) + refine ⟨⟨y, control, ⟨a, by omega⟩, ⟨b, by omega⟩⟩, hne, ?_⟩ + exact (primeRelationEvent_reindex (w.resamplePattern value).index _ _ + ((w.resamplePattern value).interval h a b) y control _).mp he + +theorem bad_relation_reciprocal_bound {ι : Type*} [Fintype ι] [DecidableEq ι] + (N h : ℕ) (w : LabeledPrimeWord ι) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hV : 1 ≤ primeHarmonicMass P) + (H B : ℕ) (hH : 0 < H) (hB : 1 ≤ B) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ B) : + (∑ x : ι → P, if ∃ d : BadRelationCode N ι, + d.Holds w h (integerPrimeAssignment Subtype.val x) + then ∏ i, ((x i).val : ℝ)⁻¹ else 0) ≤ + (Fintype.card ι ^ 2 * (N + 1) ^ 2 : ℕ) * primeHarmonicMass P ^ Fintype.card ι * + ((H : ℝ)⁻¹ + (1 + Real.log B) / H) := by + let D := {d : BadRelationCode N ι // d.2.1 ≠ d.1} + have hone (d : D) : + (∑ x : ι → P, if d.val.Holds w h (integerPrimeAssignment Subtype.val x) + then ∏ i, ((x i).val : ℝ)⁻¹ else 0) ≤ + primeHarmonicMass P ^ Fintype.card ι * ((H : ℝ)⁻¹ + (1 + Real.log B) / H) := by + have hs := (d.val.toSystem w h d.property).reciprocal_sum_bound P hP hV H B hH hB hlo hhi + rw [BadRelationCode.toSystem_size, pow_one] at hs + have he (x : ι → ℤ) : d.val.Holds w h x ↔ (d.val.toSystem w h d.property).Holds x := by + constructor + · intro hx _ + exact hx.2 + · intro hx + exact ⟨d.property, hx (0 : Fin 1)⟩ + simpa only [he] using hs + calc + _ ≤ ∑ d : D, ∑ x : ι → P, + if d.val.Holds w h (integerPrimeAssignment Subtype.val x) + then ∏ i, ((x i).val : ℝ)⁻¹ else 0 := by + rw [sum_comm] + apply sum_le_sum + intro x _ + by_cases hx : ∃ d : BadRelationCode N ι, d.Holds w h (integerPrimeAssignment Subtype.val x) + · rw [ite_eq_left hx] + obtain ⟨d, hd⟩ := hx + have hi := single_le_sum (f := fun d : D => + if d.val.Holds w h (integerPrimeAssignment Subtype.val x) + then ∏ i, ((x i).val : ℝ)⁻¹ else 0) + (fun _ _ => by split_ifs <;> positivity) (mem_univ (⟨d, hd.1⟩ : D)) + simpa only [ite_eq_left hd] using hi + · rw [ite_eq_right hx] + exact sum_nonneg (fun _ _ => by split_ifs <;> positivity) + _ ≤ (Fintype.card D : ℝ) * (primeHarmonicMass P ^ Fintype.card ι * + ((H : ℝ)⁻¹ + (1 + Real.log B) / H)) := by + simpa only [sum_const, card_univ, nsmul_eq_mul] using + (sum_le_sum (s := (univ : Finset D)) (fun d _ => hone d)) + _ ≤ _ := by + have hc : Fintype.card D ≤ Fintype.card ι ^ 2 * (N + 1) ^ 2 := by + apply (Fintype.card_le_of_injective Subtype.val Subtype.val_injective).trans_eq + simp only [BadRelationCode, Fintype.card_prod, Fintype.card_fin] + ring + have hlog : 0 ≤ Real.log (B : ℝ) := Real.log_nonneg (by exact_mod_cast hB) + calc + _ ≤ (Fintype.card ι ^ 2 * (N + 1) ^ 2 : ℕ) * + (primeHarmonicMass P ^ Fintype.card ι * ((H : ℝ)⁻¹ + (1 + Real.log B) / H)) := + mul_le_mul_of_nonneg_right (by exact_mod_cast hc) (by positivity) + _ = _ := by ring + +/-- The numerical prohibited event enters the fixed metadata union. The +ambient prime assignment may be enlarged after this inclusion is proved. -/ +theorem resampled_prohibited_reciprocal_bound {ι : Type*} [Fintype ι] [DecidableEq ι] + {s J : ℕ} {supply : ℕ → ℕ → Prop} + (N h : ℕ) (w : LabeledPrimeWord ι) (hN : w.word.length ≤ N) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hV : 1 ≤ primeHarmonicMass P) + (H B : ℕ) (hH : 0 < H) (hB : 1 ≤ B) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ B) : + (∑ x : ι → P, if ResampledProhibitedEvent w h s J supply (fun i => (x i).val) + then ∏ i, ((x i).val : ℝ)⁻¹ else 0) ≤ + (Fintype.card ι ^ 2 * (N + 1) ^ 2 : ℕ) * primeHarmonicMass P ^ Fintype.card ι * + ((H : ℝ)⁻¹ + (1 + Real.log B) / H) := by + apply le_trans _ (bad_relation_reciprocal_bound N h w P hP hV H B hH hB hlo hhi) + apply sum_le_sum + intro x _ + by_cases he : ResampledProhibitedEvent w h s J supply (fun i => (x i).val) + · have hd : ∃ d : BadRelationCode N ι, d.Holds w h (integerPrimeAssignment Subtype.val x) := + resampled_prohibited_relation w hN (fun i => (x i).val) he + rw [ite_eq_left he, ite_eq_left hd] + · rw [ite_eq_right he] + split_ifs <;> positivity + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/BernoulliTail.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/BernoulliTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4ea2bd7a3ee218191061fbbe647ebfc70425d78 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/BernoulliTail.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingSelectionLaw +import Mathlib.Analysis.SpecialFunctions.Exp + +namespace OAI + +/-! Exact exponential moments and elementary upper tails for the finite +independent Boolean laws used by the two prime-degree deletions. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma FiniteLaw.probability_lt_exp_bound {A : Type*} [Fintype A] + (μ : FiniteLaw A) (Z : A → ℝ) (a t : ℝ) (ht : 0 ≤ t) : + μ.probability (fun x => a < Z x) ≤ + Real.exp (-t * a) * μ.average (fun x => Real.exp (t * Z x)) := by + calc + _ ≤ μ.average (fun x => Real.exp (t * Z x) * Real.exp (-t * a)) := by + apply μ.average_mono + intro x + by_cases hx : a < Z x + · rw [ite_eq_left hx, ← Real.exp_add] + apply Real.one_le_exp_iff.mpr + nlinarith + · rw [ite_eq_right hx] + positivity + _ = _ := by rw [μ.average_mul_const]; ring + +noncomputable def booleanCount {ι : Type*} [Fintype ι] (a : ι → Bool) : ℝ := + ∑ i, if a i then 1 else 0 + +lemma booleanCount_eq_card {ι : Type*} [Fintype ι] (a : ι → Bool) : + booleanCount a = ((univ.filter (fun i => a i = true)).card : ℝ) := by + exact sum_boole (fun i => a i = true) univ + +lemma booleanLaw_exp_average (q t : ℝ) (hq0 : 0 ≤ q) (hq1 : q ≤ 1) : + (booleanLaw q hq0 hq1).average (fun b => Real.exp (t * (if b then 1 else 0))) = + 1 + q * (Real.exp t - 1) := by + simp [FiniteLaw.average, booleanLaw] + ring + +lemma independent_boolean_exp_average {ι : Type*} [Fintype ι] [DecidableEq ι] + (q : ι → ℝ) (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) (t : ℝ) : + (FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i))).average + (fun a => Real.exp (t * booleanCount a)) = + ∏ i, (1 + q i * (Real.exp t - 1)) := by + have he (a : ι → Bool) : Real.exp (t * booleanCount a) = + ∏ i, Real.exp (t * (if a i then 1 else 0)) := by + rw [booleanCount, mul_sum, Real.exp_sum] + simp_rw [he] + rw [FiniteLaw.independent_average_product + (fun i => booleanLaw (q i) (hq0 i) (hq1 i)) + (fun _ b => Real.exp (t * (if b then 1 else 0)))] + simp only [booleanLaw_exp_average] + +lemma independent_boolean_exp_bound {ι : Type*} [Fintype ι] [DecidableEq ι] + (q : ι → ℝ) (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) + (t M : ℝ) (ht : 0 ≤ t) (hM : (∑ i, q i) ≤ M) : + (FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i))).average + (fun a => Real.exp (t * booleanCount a)) ≤ Real.exp ((Real.exp t - 1) * M) := by + rw [independent_boolean_exp_average] + have hu : 0 ≤ Real.exp t - 1 := sub_nonneg.mpr (Real.one_le_exp_iff.mpr ht) + calc + _ ≤ ∏ i, Real.exp (q i * (Real.exp t - 1)) := by + apply prod_le_prod₀ + · intro i _ + exact add_nonneg zero_le_one (mul_nonneg (hq0 i) hu) + · intro i _ + simpa only [add_comm] using Real.add_one_le_exp (q i * (Real.exp t - 1)) + _ = Real.exp ((∑ i, q i) * (Real.exp t - 1)) := by + rw [sum_mul, Real.exp_sum] + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) + +/-- The entire bound is a finite product identity followed by exponential +Markov; no probability theorem is assumed. -/ +theorem independent_boolean_tail {ι : Type*} [Fintype ι] [DecidableEq ι] + (q : ι → ℝ) (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) + (t M a : ℝ) (ht : 0 ≤ t) (hM : (∑ i, q i) ≤ M) : + (FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i))).probability + (fun b => a < booleanCount b) ≤ + Real.exp ((Real.exp t - 1) * M - t * a) := by + apply (FiniteLaw.probability_lt_exp_bound _ _ a t ht).trans + calc + _ ≤ Real.exp (-t * a) * Real.exp ((Real.exp t - 1) * M) := + mul_le_mul_of_nonneg_left (independent_boolean_exp_bound q hq0 hq1 t M ht hM) + (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/BinCutoffGeometry.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/BinCutoffGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..f093e724cce358d5de2e41c5ffda1a5673c22bae --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/BinCutoffGeometry.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualPaddingWeights +import Mathlib.Algebra.Order.Floor.Semifield + +namespace OAI + +/-! The literal logarithmic bin places T/(dq) between X exp(-eta) +and X. Floor normalization introduces a scalar of norm at most one. -/ + +namespace TwoPointCorrelations + +lemma actualPaddingBin_cutoff (d q : ℕ) (hd : 0 < d) (hq : 0 < q) + (η X : ℝ) (hX : 0 < X) (j : ℤ) + (hb : actualPaddingBin η (Real.log d) j q) : + X * Real.exp (-η) ≤ (X * Real.exp ((j : ℝ) * η)) / (d * q : ℕ) ∧ + (X * Real.exp ((j : ℝ) * η)) / (d * q : ℕ) ≤ X := by + have hdR : (0 : ℝ) < d := by exact_mod_cast hd + have hqR : (0 : ℝ) < q := by exact_mod_cast hq + have hu : (0 : ℝ) < (d * q : ℕ) := by exact_mod_cast Nat.mul_pos hd hq + have hlog : Real.log (d * q : ℕ) = Real.log q + Real.log d := by + rw [Nat.cast_mul, Real.log_mul hdR.ne' hqR.ne'] + ring + have hl : Real.exp ((j : ℝ) * η) ≤ (d * q : ℕ) := by + calc + _ ≤ Real.exp (Real.log (d * q : ℕ)) := Real.exp_le_exp.mpr (by rw [hlog]; exact hb.1) + _ = _ := Real.exp_log hu + have hh : (d * q : ℕ) ≤ Real.exp (((j : ℝ) + 1) * η) := by + calc + _ = Real.exp (Real.log (d * q : ℕ)) := (Real.exp_log hu).symm + _ ≤ _ := Real.exp_le_exp.mpr (by rw [hlog]; exact hb.2.le) + constructor + · apply (le_div_iff₀ hu).mpr + have he : Real.exp (-η) * Real.exp (((j : ℝ) + 1) * η) = + Real.exp ((j : ℝ) * η) := by + rw [← Real.exp_add] + congr 1 + ring + calc + _ ≤ (X * Real.exp (-η)) * Real.exp (((j : ℝ) + 1) * η) := + mul_le_mul_of_nonneg_left hh (by positivity) + _ = _ := by rw [mul_assoc, he] + · apply (div_le_iff₀ hu).mpr + exact mul_le_mul_of_nonneg_left hl hX.le + +lemma floor_cutoff_weight_norm_le (T : ℝ) (hT : 0 < T) : + ‖(⌊T⌋₊ : ℂ) / (T : ℂ)‖ ≤ 1 := by + rw [norm_div, Complex.norm_natCast, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hT] + exact (div_le_one hT).mpr (Nat.floor_le hT.le) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/Bonferroni.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/Bonferroni.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c190ca40306a57dc08a124965f22e9bae5148b8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/Bonferroni.lean @@ -0,0 +1,236 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteProbability +import Mathlib.Data.Nat.Choose.Sum + +namespace OAI + +/-! The finite even-order sieve, before any independence or prime estimates. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def avoidsEvents {ι α : Type*} (P : Finset ι) (E : ι → α → Prop) (x : α) : Prop := + ∀ i ∈ P, ¬E i x + +def eventIntersection {ι α : Type*} (E : ι → α → Prop) (S : Finset ι) (x : α) : Prop := + ∀ i ∈ S, E i x + +noncomputable def eventIntersectionCount {ι α : Type*} + (P : Finset ι) (E : ι → α → Prop) (j : ℕ) (x : α) : ℝ := + ∑ S ∈ P.powersetCard j, if eventIntersection E S x then 1 else 0 + +noncomputable def truncatedEventCount {ι α : Type*} + (P : Finset ι) (E : ι → α → Prop) (r : ℕ) (x : α) : ℝ := + ∑ j ∈ range (r + 1), (-1 : ℝ) ^ j * eventIntersectionCount P E j x + +lemma eventIntersectionCount_eq_choose {ι α : Type*} + (P : Finset ι) (E : ι → α → Prop) (j : ℕ) (x : α) : + eventIntersectionCount P E j x = ((P.filter (fun i => E i x)).card.choose j : ℝ) := by + have hfilter : (P.powersetCard j).filter (fun S => eventIntersection E S x) = + (P.filter (fun i => E i x)).powersetCard j := by + apply Finset.ext + intro S + rw [Finset.mem_filter, Finset.mem_powersetCard, Finset.mem_powersetCard] + simp only [eventIntersection] + constructor + · rintro ⟨⟨hS, hcard⟩, hE⟩ + exact ⟨fun i hi => mem_filter.mpr ⟨hS hi, hE i hi⟩, hcard⟩ + · rintro ⟨hS, hcard⟩ + exact ⟨⟨fun i hi => (mem_filter.mp (hS hi)).1, hcard⟩, + fun i hi => (mem_filter.mp (hS hi)).2⟩ + unfold eventIntersectionCount + rw [← sum_filter, hfilter] + simp + +lemma truncatedEventCount_eq_choose {ι α : Type*} + (P : Finset ι) (E : ι → α → Prop) (r : ℕ) (x : α) : + truncatedEventCount P E r x = + ∑ j ∈ range (r + 1), (-1 : ℝ) ^ j * + ((P.filter (fun i => E i x)).card.choose j : ℝ) := by + simp only [truncatedEventCount, eventIntersectionCount_eq_choose] + +lemma avoidsEvents_iff_card_zero {ι α : Type*} + (P : Finset ι) (E : ι → α → Prop) (x : α) : + avoidsEvents P E x ↔ (P.filter (fun i => E i x)).card = 0 := by + simp only [avoidsEvents, card_eq_zero, filter_eq_empty_iff] + +lemma real_alternating_choose (n r : ℕ) : + (∑ j ∈ range (r + 1), (-1 : ℝ) ^ j * ((n + 1).choose j : ℝ)) = + (-1 : ℝ) ^ r * (n.choose r : ℝ) := by + exact_mod_cast (Int.alternating_sum_range_choose_eq_choose (n := n) (m := r)) + +lemma alternating_choose_zero (r : ℕ) : + (∑ j ∈ range (r + 1), (-1 : ℝ) ^ j * (Nat.choose 0 j : ℝ)) = 1 := by + rw [sum_eq_single 0] + · simp + · intro j _ hj + obtain ⟨j, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hj + simp + · intro h + exact False.elim (h (mem_range.mpr (Nat.zero_lt_succ r))) + +lemma even_binomial_lower (k r : ℕ) : + (if k = 0 then (1 : ℝ) else 0) ≤ + ∑ j ∈ range (2 * r + 1), (-1 : ℝ) ^ j * (k.choose j : ℝ) := by + cases k with + | zero => simp only [ite_true]; rw [alternating_choose_zero] + | succ k => + rw [real_alternating_choose k (2 * r)] + have he : (-1 : ℝ) ^ (2 * r) = 1 := by rw [pow_mul]; norm_num + simp only [Nat.succ_ne_zero, ite_false, he, one_mul] + positivity + +lemma odd_binomial_upper (k r : ℕ) : + (∑ j ∈ range ((2 * r + 1) + 1), (-1 : ℝ) ^ j * (k.choose j : ℝ)) ≤ + if k = 0 then (1 : ℝ) else 0 := by + cases k with + | zero => simp only [ite_true]; rw [alternating_choose_zero] + | succ k => + rw [real_alternating_choose k (2 * r + 1)] + have he : (-1 : ℝ) ^ (2 * r + 1) = -1 := by + rw [pow_succ, pow_mul] + norm_num + simp only [Nat.succ_ne_zero, ite_false, he, neg_one_mul] + exact neg_nonpos.mpr (Nat.cast_nonneg _) + +/-- Even truncation dominates the actual avoidance indicator pointwise. -/ +theorem bonferroni_even_pointwise {ι α : Type*} + (P : Finset ι) (E : ι → α → Prop) (r : ℕ) (x : α) : + (if avoidsEvents P E x then (1 : ℝ) else 0) ≤ truncatedEventCount P E (2 * r) x := by + rw [truncatedEventCount_eq_choose, avoidsEvents_iff_card_zero] + simpa using even_binomial_lower (P.filter (fun i => E i x)).card r + +/-- Odd truncation gives the opposite bound. -/ +theorem bonferroni_odd_pointwise {ι α : Type*} + (P : Finset ι) (E : ι → α → Prop) (r : ℕ) (x : α) : + truncatedEventCount P E (2 * r + 1) x ≤ + if avoidsEvents P E x then (1 : ℝ) else 0 := by + rw [truncatedEventCount_eq_choose, avoidsEvents_iff_card_zero] + simpa using odd_binomial_upper (P.filter (fun i => E i x)).card r + +lemma truncatedEventCount_odd {ι α : Type*} + (P : Finset ι) (E : ι → α → Prop) (r : ℕ) (x : α) : + truncatedEventCount P E (2 * r + 1) x = + truncatedEventCount P E (2 * r) x - eventIntersectionCount P E (2 * r + 1) x := by + unfold truncatedEventCount + rw [sum_range_succ] + have he : (-1 : ℝ) ^ (2 * r + 1) = -1 := by + rw [pow_succ, pow_mul] + norm_num + rw [he] + ring + +/-- The excess of the even truncation is bounded by the very next +intersection layer. No convergence argument is involved. -/ +theorem bonferroni_remainder_pointwise {ι α : Type*} + (P : Finset ι) (E : ι → α → Prop) (r : ℕ) (x : α) : + truncatedEventCount P E (2 * r) x ≤ + (if avoidsEvents P E x then (1 : ℝ) else 0) + + eventIntersectionCount P E (2 * r + 1) x := by + have hh := bonferroni_odd_pointwise P E r x + rw [truncatedEventCount_odd] at hh + linarith + +noncomputable def eventIntersectionMass {ι α : Type*} [Fintype α] + (μ : FiniteLaw α) (P : Finset ι) (E : ι → α → Prop) (j : ℕ) : ℝ := + ∑ S ∈ P.powersetCard j, μ.probability (eventIntersection E S) + +noncomputable def truncatedEventMass {ι α : Type*} [Fintype α] + (μ : FiniteLaw α) (P : Finset ι) (E : ι → α → Prop) (r : ℕ) : ℝ := + ∑ j ∈ range (r + 1), (-1 : ℝ) ^ j * eventIntersectionMass μ P E j + +lemma average_eventIntersectionCount {ι α : Type*} [Fintype α] + (μ : FiniteLaw α) (P : Finset ι) (E : ι → α → Prop) (j : ℕ) : + μ.average (eventIntersectionCount P E j) = eventIntersectionMass μ P E j := by + unfold eventIntersectionCount eventIntersectionMass FiniteLaw.probability FiniteLaw.average + simp only [mul_sum] + rw [sum_comm] + +lemma average_truncatedEventCount {ι α : Type*} [Fintype α] + (μ : FiniteLaw α) (P : Finset ι) (E : ι → α → Prop) (r : ℕ) : + μ.average (truncatedEventCount P E r) = truncatedEventMass μ P E r := by + unfold truncatedEventCount truncatedEventMass FiniteLaw.average + simp only [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro j _ + calc + _ = (-1 : ℝ) ^ j * μ.average (eventIntersectionCount P E j) := by + unfold FiniteLaw.average + rw [mul_sum] + apply sum_congr rfl + intro x _ + ring + _ = _ := by rw [average_eventIntersectionCount] + +theorem bonferroni_even {ι α : Type*} [Fintype α] + (μ : FiniteLaw α) (P : Finset ι) (E : ι → α → Prop) (r : ℕ) : + μ.probability (avoidsEvents P E) ≤ truncatedEventMass μ P E (2 * r) := by + rw [← average_truncatedEventCount] + exact μ.average_mono (bonferroni_even_pointwise P E r) + +theorem bonferroni_remainder {ι α : Type*} [Fintype α] + (μ : FiniteLaw α) (P : Finset ι) (E : ι → α → Prop) (r : ℕ) : + truncatedEventMass μ P E (2 * r) ≤ μ.probability (avoidsEvents P E) + + eventIntersectionMass μ P E (2 * r + 1) := by + rw [← average_truncatedEventCount, ← average_eventIntersectionCount] + have hh := μ.average_mono (bonferroni_remainder_pointwise P E r) + simpa only [FiniteLaw.probability, FiniteLaw.average, mul_add, sum_add_distrib] using hh + +/-- Total error in the finitely many intersection counts used by a sieve +truncation. Each subset appears just once. -/ +noncomputable def sieveIntersectionError {ι : Type*} + (P : Finset ι) (err : Finset ι → ℝ) (r : ℕ) : ℝ := + ∑ j ∈ range (r + 1), ∑ S ∈ P.powersetCard j, err S + +lemma truncatedEventMass_comparison {ι α β : Type*} [Fintype α] [Fintype β] + (μ : FiniteLaw α) (ν : FiniteLaw β) (P : Finset ι) + (E : ι → α → Prop) (F : ι → β → Prop) (r : ℕ) (err : Finset ι → ℝ) + (herr : ∀ S ∈ P.powerset, S.card ≤ r → + |μ.probability (eventIntersection E S) - + ν.probability (eventIntersection F S)| ≤ err S) : + truncatedEventMass μ P E r ≤ truncatedEventMass ν P F r + + sieveIntersectionError P err r := by + have heq : truncatedEventMass μ P E r - truncatedEventMass ν P F r = + ∑ j ∈ range (r + 1), ∑ S ∈ P.powersetCard j, + (-1 : ℝ) ^ j * (μ.probability (eventIntersection E S) - + ν.probability (eventIntersection F S)) := by + simp only [truncatedEventMass, eventIntersectionMass, mul_sum, + mul_sub, sum_sub_distrib] + have hb : truncatedEventMass μ P E r - truncatedEventMass ν P F r ≤ + sieveIntersectionError P err r := by + rw [heq] + apply sum_le_sum + intro j hj + apply sum_le_sum + intro S hS + obtain ⟨hSP, hcard⟩ := mem_powersetCard.mp hS + calc + _ ≤ |(-1 : ℝ) ^ j * (μ.probability (eventIntersection E S) - + ν.probability (eventIntersection F S))| := le_abs_self _ + _ = |μ.probability (eventIntersection E S) - + ν.probability (eventIntersection F S)| := by + simp only [abs_mul, abs_pow, abs_neg, abs_one, one_pow, one_mul] + _ ≤ err S := herr S (mem_powerset.mpr hSP) + (by rw [hcard]; exact Nat.le_of_lt_succ (mem_range.mp hj)) + linarith + +/-- Exact finite sieve transfer. An independent residue model can be +inserted only after its intersections have actually been counted. -/ +theorem bonferroni_transfer {ι α β : Type*} [Fintype α] [Fintype β] + (μ : FiniteLaw α) (ν : FiniteLaw β) (P : Finset ι) + (E : ι → α → Prop) (F : ι → β → Prop) (r : ℕ) (err : Finset ι → ℝ) + (herr : ∀ S ∈ P.powerset, S.card ≤ 2 * r → + |μ.probability (eventIntersection E S) - + ν.probability (eventIntersection F S)| ≤ err S) : + μ.probability (avoidsEvents P E) ≤ ν.probability (avoidsEvents P F) + + eventIntersectionMass ν P F (2 * r + 1) + sieveIntersectionError P err (2 * r) := by + have h₁ := bonferroni_even μ P E r + have h₂ := truncatedEventMass_comparison μ ν P E F (2 * r) err herr + have h₃ := bonferroni_remainder ν P F r + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/BoundedColumnCodes.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/BoundedColumnCodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..97a755b254e5f09ef546cb89b945c7b26e674051 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/BoundedColumnCodes.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.TwoPoint.Walks.ColumnDecoderAsymptotics + +namespace OAI + +/-! One code universe when segment, omitted-run and imperfect counts vary. -/ + +namespace TwoPointCorrelations + +open Finset Filter + +abbrev BoundedColumnDecoderCode (N segments omitted imperfect : ℕ) := + Σ s : Fin (segments + 1), Σ o : Fin (omitted + 1), Σ i : Fin (imperfect + 1), + ColumnDecoderCode N s.val o.val i.val + +/-- Taking the union over the permitted counts costs only three polynomial +factors. It does not impose common counts on different realizations. -/ +theorem card_boundedColumnDecoderCode_le (N segments omitted imperfect : ℕ) (hN : 1 ≤ N) : + Fintype.card (BoundedColumnDecoderCode N segments omitted imperfect) ≤ + ((segments + 1) * (omitted + 1) * (imperfect + 1)) * + (2 ^ (6 * N + 1) * N ^ (2 * segments + omitted + imperfect)) := by + simp only [BoundedColumnDecoderCode, Fintype.card_sigma] + calc + _ ≤ ∑ _s : Fin (segments + 1), ∑ _o : Fin (omitted + 1), ∑ _i : Fin (imperfect + 1), + (2 ^ (6 * N + 1) * N ^ (2 * segments + omitted + imperfect)) := by + apply sum_le_sum + intro s _ + apply sum_le_sum + intro o _ + apply sum_le_sum + intro i _ + apply (card_columnDecoderCode_le N s.val o.val i.val).trans + apply Nat.mul_le_mul_left + exact Nat.pow_le_pow_right hN (by omega) + _ = _ := by simp [mul_assoc] + +noncomputable def decodeBoundedColumnPattern {N segments omitted imperfect : ℕ} + (code : BoundedColumnDecoderCode N segments omitted imperfect) : Fin N → Fin N → Bool := + decodeColumnPattern code.2.2.2 + +/-- This is the full coefficient-independent image, including all permitted +segment and exceptional-position counts. -/ +theorem card_bounded_column_patterns (N segments omitted imperfect : ℕ) (hN : 1 ≤ N) : + Nat.card (Set.range (@decodeBoundedColumnPattern N segments omitted imperfect)) ≤ + ((segments + 1) * (omitted + 1) * (imperfect + 1)) * + (2 ^ (6 * N + 1) * N ^ (2 * segments + omitted + imperfect)) := by + let f := @decodeBoundedColumnPattern N segments omitted imperfect + have hr : Nat.card (Set.range f) ≤ Nat.card (BoundedColumnDecoderCode N segments omitted imperfect) := + Nat.card_le_card_of_surjective (fun c => (⟨f c, c, rfl⟩ : Set.range f)) (by + rintro ⟨_, c, rfl⟩ + exact ⟨c, rfl⟩) + exact hr.trans (by simpa only [Nat.card_eq_fintype_card] using + card_boundedColumnDecoderCode_le N segments omitted imperfect hN) + +/-- The union over all bounded counts still has an absolute exponential +cost. Fixed constants in the sublinear budget affect only the threshold. -/ +theorem eventually_bounded_column_code_exponential (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ k N segments omitted imperfect : ℕ, + L / 2 ≤ (k : ℝ) → (k : ℝ) ≤ L → 1 ≤ N → N ≤ 4 * k → + segments ≤ N → omitted ≤ N → imperfect ≤ N → + ((2 * segments + omitted + imperfect : ℕ) : ℝ) ≤ C * L ^ (0.92 : ℝ) → + (Fintype.card (BoundedColumnDecoderCode N segments omitted imperfect) : ℝ) ≤ + Real.exp (64 * k) := by + filter_upwards [eventually_column_decoder_exponential C hC] with L hcode + intro k N segments omitted imperfect hklo hkhi hN hNk hS hO hI hbudget + have heach (s : Fin (segments + 1)) (o : Fin (omitted + 1)) (i : Fin (imperfect + 1)) : + (Fintype.card (ColumnDecoderCode N s.val o.val i.val) : ℝ) ≤ Real.exp (52 * k) := by + apply hcode k N s.val o.val i.val hklo hkhi hN hNk + apply le_trans _ hbudget + exact_mod_cast (show 2 * s.val + o.val + i.val ≤ 2 * segments + omitted + imperfect by omega) + have hfactor (a : ℕ) (ha : a ≤ N) : (a : ℝ) + 1 ≤ Real.exp N := by + have h : (a : ℝ) ≤ N := by exact_mod_cast ha + linarith [Real.add_one_le_exp (N : ℝ)] + have hcounts : ((segments : ℝ) + 1) * (omitted + 1) * (imperfect + 1) ≤ + Real.exp (3 * N) := by + calc + _ ≤ Real.exp N * Real.exp N * Real.exp N := by + gcongr + · exact hfactor segments hS + · exact hfactor omitted hO + · exact hfactor imperfect hI + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + calc + _ = ∑ s : Fin (segments + 1), ∑ o : Fin (omitted + 1), ∑ i : Fin (imperfect + 1), + (Fintype.card (ColumnDecoderCode N s.val o.val i.val) : ℝ) := by + simp only [BoundedColumnDecoderCode, Fintype.card_sigma, Nat.cast_sum] + _ ≤ ∑ _s : Fin (segments + 1), ∑ _o : Fin (omitted + 1), ∑ _i : Fin (imperfect + 1), + Real.exp (52 * k) := by + exact sum_le_sum (fun s _ => sum_le_sum (fun o _ => sum_le_sum (fun i _ => heach s o i))) + _ = (((segments : ℝ) + 1) * (omitted + 1) * (imperfect + 1)) * Real.exp (52 * k) := by + simp [mul_assoc] + _ ≤ Real.exp (3 * N) * Real.exp (52 * k) := + mul_le_mul_of_nonneg_right hcounts (Real.exp_pos _).le + _ = Real.exp (3 * N + 52 * k) := (Real.exp_add _ _).symm + _ ≤ Real.exp (64 * k) := by + apply Real.exp_le_exp.mpr + have h : (N : ℝ) ≤ 4 * k := by exact_mod_cast hNk + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/BoundedPaddingUnion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/BoundedPaddingUnion.lean new file mode 100644 index 0000000000000000000000000000000000000000..601f6434e46f83be99d928eb4a50e91d56a5827d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/BoundedPaddingUnion.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.TwoPoint.Bounds.EncodedPaddingUnion +import OAI.NumberTheory.TwoPoint.Bounds.FiniteSupportAverage + +namespace OAI + +/-! The finite witness union includes all record lengths and all original main words. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem main_sum_bounded_padding_union_probability_le {D n : ℕ} (T : ℕ → ℕ) {P Q : Finset ℕ} + {ι : Type*} [Fintype ι] [DecidableEq ι] + (F : Finset (List SignedStep)) (S : List SignedStep → Finset ι) (p : ι → ℕ) (hinj : Function.Injective p) + (B h s J : ℕ) (supply : ℕ → ℕ → Prop) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (hP : ∀ q ∈ P, q.Prime) (hQ : ∀ q ∈ Q, q.Prime) + (hcover : ∀ q ∈ P ∪ Q, ∃ i, p i = q) + (hS : ∀ main ∈ F, ∀ i ∈ S main, p i ∈ wordDivisorPrimeSupport main) : + (∑ main ∈ F, (∏ i ∈ S main, (p i : ℝ)⁻¹) * + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).probability + (fun x => ∃ R : Fin (D + 1), ∃ d : WitnessRecord n R.val, + ∃ e : PrimeWordEncoding R.val (T R.val) P Q, + EncodedPaddingWitnessEvent (S main) d e main p B h s J supply x)) ≤ + ∑ R : Fin (D + 1), ∑ d : WitnessRecord n R.val, + ∑ e : PrimeWordEncoding R.val (T R.val) P Q, + if e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) (fun i => (d.1.2.2 i).val) + h s J supply then e.weight else 0 := by + let μ := FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i)) + calc + _ ≤ ∑ main ∈ F, ∑ R : Fin (D + 1), + (∏ i ∈ S main, (p i : ℝ)⁻¹) * μ.probability + (fun x => ∃ d : WitnessRecord n R.val, ∃ e : PrimeWordEncoding R.val (T R.val) P Q, + EncodedPaddingWitnessEvent (S main) d e main p B h s J supply x) := by + apply sum_le_sum + intro main _ + rw [← mul_sum] + exact mul_le_mul_of_nonneg_left (μ.probability_exists_le _) + (prod_nonneg (fun _ _ => by positivity)) + _ ≤ _ := by + rw [sum_comm] + apply sum_le_sum + intro R _ + exact main_sum_padding_witness_union_probability_le F S p hinj B h s J supply hp hpB hP hQ hcover hS + +theorem weighted_supported_padding_averages_le_catalog {D n : ℕ} (T : ℕ → ℕ) {P Q : Finset ℕ} + {ι : Type*} [Fintype ι] [DecidableEq ι] + (F : Finset (List SignedStep)) (S : List SignedStep → Finset ι) (p : ι → ℕ) (hinj : Function.Injective p) + (B h s J : ℕ) (supply : ℕ → ℕ → Prop) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (hP : ∀ q ∈ P, q.Prime) (hQ : ∀ q ∈ Q, q.Prime) + (hcover : ∀ q ∈ P ∪ Q, ∃ i, p i = q) + (hS : ∀ main ∈ F, ∀ i ∈ S main, p i ∈ wordDivisorPrimeSupport main) + (f : List SignedStep → (ι → Fin B) → ℝ) (C : ℝ) (hC : 0 ≤ C) + (hf : ∀ main ∈ F, ∀ x, |f main x| ≤ C) + (hsupport : ∀ main ∈ F, ∀ x, f main x ≠ 0 → + ∃ R : Fin (D + 1), ∃ d : WitnessRecord n R.val, + ∃ e : PrimeWordEncoding R.val (T R.val) P Q, + EncodedPaddingWitnessEvent (S main) d e main p B h s J supply x) : + (∑ main ∈ F, (∏ i ∈ S main, (p i : ℝ)⁻¹) * + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => |f main x|)) ≤ + C * ∑ R : Fin (D + 1), ∑ d : WitnessRecord n R.val, + ∑ e : PrimeWordEncoding R.val (T R.val) P Q, + if e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) (fun i => (d.1.2.2 i).val) + h s J supply then e.weight else 0 := by + let μ := FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i)) + let E (main : List SignedStep) (x : ι → Fin B) := + ∃ R : Fin (D + 1), ∃ d : WitnessRecord n R.val, + ∃ e : PrimeWordEncoding R.val (T R.val) P Q, EncodedPaddingWitnessEvent (S main) d e main p B h s J supply x + calc + _ ≤ ∑ main ∈ F, (∏ i ∈ S main, (p i : ℝ)⁻¹) * + (C * μ.probability (E main)) := by + apply sum_le_sum + intro main hm + exact mul_le_mul_of_nonneg_left + (μ.average_abs_le_support (f main) (E main) C (hf main hm) (hsupport main hm)) + (prod_nonneg (fun _ _ => by positivity)) + _ = C * ∑ main ∈ F, (∏ i ∈ S main, (p i : ℝ)⁻¹) * + μ.probability (E main) := by + rw [mul_sum] + apply sum_congr rfl + intro main _ + ring + _ ≤ _ := mul_le_mul_of_nonneg_left + (main_sum_bounded_padding_union_probability_le T F S p hinj B h s J supply hp hpB hP hQ hcover hS) hC + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/BoundedWitnessDecay.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/BoundedWitnessDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..702050b453842555618b519959ed3641b135e311 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/BoundedWitnessDecay.lean @@ -0,0 +1,110 @@ +import OAI.NumberTheory.TwoPoint.Walks.AttachedWitnessCatalog + +namespace OAI + +/-! The singleton saving absorbs all record lengths, including the empty-word case. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma PrimeWordEncoding.Witnesses.length_pos {R T n mainLength h s J : ℕ} + {P Q : Finset ℕ} {start len : Fin n → ℕ} {supply : ℕ → ℕ → Prop} + {e : PrimeWordEncoding R T P Q} + (he : e.Witnesses n mainLength start len h s J supply) (hn : 0 < n) : 0 < R := by + obtain ⟨_, _, _, _, _, _, _, hminimal, _⟩ := he.2.2 + have hl := (hminimal ⟨0, hn⟩).1.1 + have ht := List.length_take_le' (len ⟨0, hn⟩) (e.decode.drop (start ⟨0, hn⟩)) + have hd : (e.decode.drop (start ⟨0, hn⟩)).length ≤ e.decode.length := by + rw [List.length_drop] + exact Nat.sub_le _ _ + have heLen : e.decode.length = R := e.2.1.numericalWord_length _ + have hR : 3 ≤ R := hl.trans (ht.trans (hd.trans_eq heLen)) + omega + +lemma witnessLengthRecord_cost (D : ℕ) (L : ℝ) + (hL : 1 ≤ L) (hlog : 1 ≤ Real.log L) (hD : (D : ℝ) + 1 ≤ L ^ (2 : ℕ)) : + (Fintype.card (Fin (D + 1)) : ℝ) ≤ Real.exp (2 * L * (Real.log L) ^ 2) := by + have hLp : 0 < L := zero_lt_one.trans_le hL + have he : Real.exp (2 * Real.log L) = L ^ (2 : ℕ) := by + rw [show 2 * Real.log L = Real.log L + Real.log L by ring, + Real.exp_add, Real.exp_log hLp] + ring + calc + _ = (D : ℝ) + 1 := by simp + _ ≤ L ^ (2 : ℕ) := hD + _ = Real.exp (2 * Real.log L) := he.symm + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have hs : Real.log L ≤ (Real.log L) ^ 2 := by nlinarith + have hm := mul_le_mul_of_nonneg_right hL (sq_nonneg (Real.log L)) + nlinarith + +theorem eventually_bounded_witness_decay (C Cw : ℝ) (hC : 0 ≤ C) (hCw : 0 ≤ Cw) : + ∀ᶠ L : ℝ in atTop, ∀ (D n K M h s J H B : ℕ) (slots : ℕ → ℕ) + (P Q : Finset ℕ) (supply : ℕ → ℕ → Prop) (W : ℝ), + (D : ℝ) ≤ 4 * L → D ≤ M → + (∀ R ≤ D, (slots R : ℝ) ≤ C * R * Real.log L) → + (∀ R ≤ D, (slots R : ℝ) + 1 ≤ L ^ (2 : ℕ)) → + (D : ℝ) + 1 ≤ L ^ (2 : ℕ) → (∀ R ≤ D, slots R ≤ M + 1) → + 0 < n → n ≤ M + 1 → (n : ℝ) ≤ 4 * L → (M : ℝ) + 1 ≤ L ^ (2 : ℕ) → + 8 * K ≤ n → L ^ (1 / 12 : ℝ) / 32 ≤ (K : ℝ) → (K : ℝ) ≤ L → + (∀ p ∈ P, p.Prime) → 1 ≤ primeHarmonicMass P → + primeHarmonicMass P ≤ L ^ (2 : ℕ) → primeHarmonicMass Q ≤ L ^ (2 : ℕ) → + 1 ≤ B → (B : ℝ) ≤ Real.exp L → + (∀ p ∈ P, H ≤ p) → (∀ p ∈ P, p ≤ B) → + Real.exp (L ^ (199 / 200 : ℝ)) ≤ H → + 0 ≤ W → W ≤ Real.exp (Cw * L * (Real.log L) ^ 2) → + (∑ R : Fin (D + 1), ∑ d : WitnessRecord n R.val, + W * (∑ e : PrimeWordEncoding R.val (slots R.val) P Q, + if e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) (fun i => (d.1.2.2 i).val) + h s J supply then e.weight else 0)) ≤ Real.exp (-L ^ (21 / 20 : ℝ)) := by + filter_upwards [eventually_ge_atTop (1 : ℝ), + Real.tendsto_log_atTop.eventually (eventually_ge_atTop 1), + eventually_attached_witness_decay C (Cw + 2) hC (by positivity)] + with L hL hlog hdecay + intro D n K M h s J H B slots P Q supply W + hD hDM hslots hslotpoly hDp hslotM hn hnM hnL hM hsize hKlo hKhi hP hV hPup hQup + hB hBexp hlo hhi hH hW hWup + let W' := W * (Fintype.card (Fin (D + 1)) : ℝ) + have hW' : W' ≤ Real.exp ((Cw + 2) * L * (Real.log L) ^ 2) := by + calc + W' ≤ Real.exp (Cw * L * (Real.log L) ^ 2) * + Real.exp (2 * L * (Real.log L) ^ 2) := + mul_le_mul hWup (witnessLengthRecord_cost D L hL hlog hDp) + (by positivity) (by positivity) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + apply sum_le_of_card_mul_le + intro r + have hrD : r.val ≤ D := by omega + by_cases hr : 0 < r.val + · have hrL : (r.val : ℝ) ≤ 4 * L := + (by exact_mod_cast hrD : (r.val : ℝ) ≤ D).trans hD + have hrp : (r.val : ℝ) + 1 ≤ L ^ (2 : ℕ) := by + have hh : (r.val : ℝ) ≤ D := by exact_mod_cast hrD + linarith + have hb := hdecay r.val (slots r.val) n K M h s J H B P Q supply W' + hr hrL (hrD.trans hDM) (hslots _ hrD) (hslotpoly _ hrD) hrp + (hslotM _ hrD) hnM hnL hM hsize hKlo hKhi hP hV hPup hQup + hB hBexp hlo hhi hH (by dsimp [W']; positivity) hW' + calc + _ = ∑ d : WitnessRecord n r.val, W' * + (∑ e : PrimeWordEncoding r.val (slots r.val) P Q, + if e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) + (fun i => (d.1.2.2 i).val) h s J supply then e.weight else 0) := by + rw [mul_sum] + apply sum_congr rfl + intro d _ + dsimp only [W'] + ring + _ ≤ _ := hb + · have he (d : WitnessRecord n r.val) (e : PrimeWordEncoding r.val (slots r.val) P Q) : + ¬e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) + (fun i => (d.1.2.2 i).val) h s J supply := fun he => hr (he.length_pos hn) + simp only [he, ite_false, sum_const_zero, mul_zero] + exact (Real.exp_pos _).le + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CRTComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CRTComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..fb49ab4c45a8865dac9a358e6d3bf4f725bd092d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CRTComparison.lean @@ -0,0 +1,206 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResidueCounts +import Mathlib.Data.ZMod.QuotientRing +import Mathlib.Data.Fintype.Pi + +namespace OAI + +/-! +# Finite CRT marginals and contraction under independent randomization + +A selected finite set of pairwise coprime residue coordinates has the law +of one residue modulo their product. The exact interval count from +`ResidueCounts` gives total variation at most `D / (2N)`. Applying any +finite stochastic kernel preserves this bound; in particular one may add +independent finite randomness and project to any selected encoded bits. +These are the finite arithmetic and data-processing steps in `q:crt-bits`. +-/ + +open Finset + +namespace TwoPointCorrelations + +/-- Total variation between two finite real mass functions. -/ +noncomputable def finiteTotalVariation {α : Type*} [Fintype α] (f g : α → ℝ) : ℝ := + (∑ x, |f x - g x|) / 2 + +/-- Application of a finite transition kernel. -/ +noncomputable def kernelTransport {α β : Type*} [Fintype α] + (K : α → β → ℝ) (f : α → ℝ) (y : β) : ℝ := + ∑ x, f x * K x y + +lemma kernelTransport_nonneg {α β : Type*} [Fintype α] + (K : α → β → ℝ) (f : α → ℝ) (hK : ∀ x y, 0 ≤ K x y) + (hf : ∀ x, 0 ≤ f x) (y : β) : 0 ≤ kernelTransport K f y := + Finset.sum_nonneg (fun x _ => mul_nonneg (hf x) (hK x y)) + +lemma kernelTransport_sum {α β : Type*} [Fintype α] [Fintype β] + (K : α → β → ℝ) (f : α → ℝ) (hK : ∀ x, ∑ y, K x y = 1) : + ∑ y, kernelTransport K f y = ∑ x, f x := by + unfold kernelTransport + rw [Finset.sum_comm] + simp_rw [← Finset.mul_sum, hK, mul_one] + +/-- Adding independent randomness and then forgetting information cannot +increase total variation. -/ +theorem finiteTotalVariation_kernel {α β : Type*} [Fintype α] [Fintype β] + (K : α → β → ℝ) (f g : α → ℝ) (hK : ∀ x y, 0 ≤ K x y) + (hKsum : ∀ x, ∑ y, K x y = 1) : + finiteTotalVariation (kernelTransport K f) (kernelTransport K g) ≤ + finiteTotalVariation f g := by + have hpoint (y : β) : |kernelTransport K f y - kernelTransport K g y| ≤ + ∑ x, |f x - g x| * K x y := by + unfold kernelTransport + rw [← Finset.sum_sub_distrib] + calc + |∑ x, (f x * K x y - g x * K x y)| = |∑ x, (f x - g x) * K x y| := by + congr 1 + apply Finset.sum_congr rfl + intro x _ + ring + _ ≤ ∑ x, |(f x - g x) * K x y| := Finset.abs_sum_le_sum_abs _ _ + _ = _ := by simp_rw [abs_mul, abs_of_nonneg (hK _ _)] + have hsum := Finset.sum_le_sum (fun y (_ : y ∈ (Finset.univ : Finset β)) => hpoint y) + rw [Finset.sum_comm] at hsum + simp_rw [← Finset.mul_sum, hKsum, mul_one] at hsum + exact div_le_div_of_nonneg_right hsum (by norm_num) + +/-- A bounded observable has expectation difference at most twice TV. -/ +lemma finite_observable_difference {α : Type*} [Fintype α] + (f g u : α → ℝ) (hu : ∀ x, |u x| ≤ 1) : + |(∑ x, f x * u x) - ∑ x, g x * u x| ≤ 2 * finiteTotalVariation f g := by + rw [← Finset.sum_sub_distrib] + calc + |∑ x, (f x * u x - g x * u x)| = |∑ x, (f x - g x) * u x| := by + congr 1 + apply Finset.sum_congr rfl + intro x _ + ring + _ ≤ ∑ x, |(f x - g x) * u x| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ x, |f x - g x| := by + apply Finset.sum_le_sum + intro x _ + rw [abs_mul] + exact mul_le_of_le_one_right (abs_nonneg _) (hu x) + _ = 2 * finiteTotalVariation f g := by unfold finiteTotalVariation; ring + +/-- A deterministic map with independent uniform finite auxiliary randomness. -/ +noncomputable def finiteRandomKernel {α β J : Type*} [DecidableEq β] [Fintype J] + (F : α → J → β) (x : α) (y : β) : ℝ := + (∑ j, if F x j = y then (1 : ℝ) else 0) / Fintype.card J + +lemma finiteRandomKernel_nonneg {α β J : Type*} [DecidableEq β] [Fintype J] + (F : α → J → β) (x : α) (y : β) : 0 ≤ finiteRandomKernel F x y := by + unfold finiteRandomKernel + positivity + +lemma finiteRandomKernel_sum {α β J : Type*} [Fintype β] [DecidableEq β] + [Fintype J] [Nonempty J] (F : α → J → β) (x : α) : + ∑ y, finiteRandomKernel F x y = 1 := by + unfold finiteRandomKernel + rw [← Finset.sum_div, Finset.sum_comm] + simp + +instance modulusProduct_neZero {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] : NeZero (∏ i, s i) := + ⟨Finset.prod_ne_zero_iff.mpr (fun i _ => NeZero.ne (s i))⟩ + +/-- The actual joint residue law of an interval under the CRT equivalence. -/ +noncomputable def crtJointProbability {ι : Type*} [Fintype ι] [DecidableEq ι] (s : ι → ℕ) + [∀ i, NeZero (s i)] (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ZMod (∏ i, s i)) (N : ℕ) (r : ∀ i, ZMod (s i)) : ℝ := + residueProbability A N ((ZMod.prodEquivPi s hcop).symm r) + +/-- Uniform independent residue coordinates. -/ +noncomputable def crtUniform {ι : Type*} [Fintype ι] [DecidableEq ι] (s : ι → ℕ) + (_r : ∀ i, ZMod (s i)) : ℝ := 1 / (∏ i, s i : ℕ) + +lemma crtUniform_product {ι : Type*} [Fintype ι] [DecidableEq ι] (s : ι → ℕ) + (r : ∀ i, ZMod (s i)) : crtUniform s r = ∏ i, (1 / (s i : ℝ)) := by + simp [crtUniform, one_div, Nat.cast_prod, Finset.prod_inv_distrib] + +/-- This CRT-transported mass is the actual empirical joint residue law. -/ +lemma crtJointProbability_eq_count {ι : Type*} [Fintype ι] [DecidableEq ι] (s : ι → ℕ) + [∀ i, NeZero (s i)] (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ZMod (∏ i, s i)) (N : ℕ) (r : ∀ i, ZMod (s i)) : + crtJointProbability s hcop A N r = + (∑ j ∈ Finset.range N, + if ZMod.prodEquivPi s hcop (A + (j : ZMod (∏ i, s i))) = r + then (1 : ℝ) else 0) / N := by + unfold crtJointProbability residueProbability residueCount + rw [Nat.cast_sum] + congr 1 + apply Finset.sum_congr rfl + intro j _ + have heq : A + (j : ZMod (∏ i, s i)) = (ZMod.prodEquivPi s hcop).symm r ↔ + ZMod.prodEquivPi s hcop (A + (j : ZMod (∏ i, s i))) = r := + (ZMod.prodEquivPi s hcop).toEquiv.eq_symm_apply + simp only [Nat.cast_ite, Nat.cast_one, Nat.cast_zero, heq] + +/-- The CRT equivalence is the expected coordinatewise residue map. -/ +lemma crt_coordinates_add_nat {ι : Type*} [Fintype ι] [DecidableEq ι] (s : ι → ℕ) + [∀ i, NeZero (s i)] (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ZMod (∏ i, s i)) (j : ℕ) (i : ι) : + ZMod.prodEquivPi s hcop (A + (j : ZMod (∏ i, s i))) i = + ZMod.castHom (Finset.dvd_prod_of_mem s (Finset.mem_univ i)) (ZMod (s i)) A + + (j : ZMod (s i)) := by + simp only [ZMod.prodEquivPi_apply, map_add, map_natCast] + +lemma crtJointProbability_nonneg {ι : Type*} [Fintype ι] [DecidableEq ι] (s : ι → ℕ) + [∀ i, NeZero (s i)] (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ZMod (∏ i, s i)) (N : ℕ) (r : ∀ i, ZMod (s i)) : + 0 ≤ crtJointProbability s hcop A N r := by + unfold crtJointProbability residueProbability + positivity + +lemma crtJointProbability_sum {ι : Type*} [Fintype ι] [DecidableEq ι] (s : ι → ℕ) + [∀ i, NeZero (s i)] (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ZMod (∏ i, s i)) (N : ℕ) (hN : 0 < N) : + ∑ r, crtJointProbability s hcop A N r = 1 := by + unfold crtJointProbability + calc + _ = ∑ z : ZMod (∏ i, s i), residueProbability A N z := + (ZMod.prodEquivPi s hcop).symm.toEquiv.sum_comp (residueProbability A N) + _ = 1 := residueProbability_sum A N hN + +lemma crtJointProbability_totalVariation {ι : Type*} [Fintype ι] [DecidableEq ι] (s : ι → ℕ) + [∀ i, NeZero (s i)] (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ZMod (∏ i, s i)) (N : ℕ) : + finiteTotalVariation (crtJointProbability s hcop A N) (crtUniform s) = + residueTotalVariation A N := by + unfold finiteTotalVariation crtJointProbability crtUniform residueTotalVariation + congr 1 + exact (ZMod.prodEquivPi s hcop).symm.toEquiv.sum_comp + (fun z => |residueProbability A N z - 1 / (∏ i, s i : ℕ)|) + +/-- Selected CRT coordinates followed by any finite random encoding or +projection satisfy the interval discrepancy bound. -/ +theorem crt_kernel_totalVariation {ι β : Type*} [Fintype ι] [DecidableEq ι] [Fintype β] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ZMod (∏ i, s i)) (N : ℕ) (hN : 0 < N) + (K : (∀ i, ZMod (s i)) → β → ℝ) + (hK : ∀ r y, 0 ≤ K r y) (hKsum : ∀ r, ∑ y, K r y = 1) : + finiteTotalVariation (kernelTransport K (crtJointProbability s hcop A N)) + (kernelTransport K (crtUniform s)) ≤ (∏ i, s i : ℕ) / (2 * (N : ℝ)) := by + apply (finiteTotalVariation_kernel K _ _ hK hKsum).trans + rw [crtJointProbability_totalVariation] + exact residueTotalVariation_le A N hN + +/-- Independent finite auxiliary variables and a projection are a special +case, so in particular selecting encoded bit marginals cannot increase TV. -/ +theorem crt_random_projection_totalVariation {ι β J : Type*} [Fintype ι] [DecidableEq ι] + [Fintype β] [DecidableEq β] [Fintype J] [Nonempty J] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ZMod (∏ i, s i)) (N : ℕ) (hN : 0 < N) + (F : (∀ i, ZMod (s i)) → J → β) : + finiteTotalVariation + (kernelTransport (finiteRandomKernel F) (crtJointProbability s hcop A N)) + (kernelTransport (finiteRandomKernel F) (crtUniform s)) ≤ + (∏ i, s i : ℕ) / (2 * (N : ℝ)) := + crt_kernel_totalVariation s hcop A N hN _ (finiteRandomKernel_nonneg F) + (finiteRandomKernel_sum F) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CatalogVertexIndicator.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CatalogVertexIndicator.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7bfac7f1f8cc75ddf2f33fd34c7cef6b64bdb88 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CatalogVertexIndicator.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.TwoPoint.Walks.AttachedCatalogAvoidance + +namespace OAI + +/-! Equality of the finite residue-catalog indicator with the actual integer vertex mask. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma witnessAvoidance_eq_indicator {ι A W : Type*} [Fintype W] + (I : W → (ι → A) → Bool) (x : ι → A) : + witnessAvoidance I x = if ∀ w, I w x = false then 1 else 0 := by + unfold witnessAvoidance + split_ifs with hI + · apply prod_eq_one + intro w _ + simp only [hI w, Bool.false_eq_true, ite_false, sub_zero] + · obtain ⟨w, hw⟩ := not_forall.mp hI + have ht : I w x = true := Bool.eq_true_of_not_eq_false hw + apply prod_eq_zero (mem_univ w) + simp [ht] + +lemma witnessAvoidance_eq_one_of_ne_zero {ι A W : Type*} [Fintype W] + (I : W → (ι → A) → Bool) (x : ι → A) (hx : witnessAvoidance I x ≠ 0) : + witnessAvoidance I x = 1 := by + rw [witnessAvoidance_eq_indicator] at hx ⊢ + split_ifs with hI + · rfl + · simp [hI] at hx + +theorem attachedCatalogAvoidance_eq_indicator {h J M : ℕ} + (F : ProhibitedPrimeFamily h J M) (s B D : ℕ) (main : List SignedStep) + (hD : main.length ≤ D) (x : ↥(F.P ∪ F.Q) → Fin B) (n : ℤ) + (hn : ∀ p : ↥(F.P ∪ F.Q), (n : ZMod p.val) = ((x p).val : ZMod p.val)) : + attachedCatalogAvoidance F s B D main x = + if ∀ v ≤ main.length, ¬ProhibitedSite h s (fun d q => (d, q) ∈ F.pairs) + (n + wordDisplacement h (main.take v)) then 1 else 0 := by + split_ifs with hkeep + · exact witnessAvoidance_eq_one_of_ne_zero _ x + ((attachedCatalogAvoidance_ne_zero_iff F s B D main hD x n hn).mpr hkeep) + · by_contra hne + exact hkeep ((attachedCatalogAvoidance_ne_zero_iff F s B D main hD x n hn).mp hne) + +theorem attachedCatalogAvoidance_eq_vertex_product {h J M : ℕ} + (F : ProhibitedPrimeFamily h J M) (s B D : ℕ) (main : List SignedStep) + (hD : main.length ≤ D) (x : ↥(F.P ∪ F.Q) → Fin B) (n : ℤ) + (hn : ∀ p : ↥(F.P ∪ F.Q), (n : ZMod p.val) = ((x p).val : ZMod p.val)) : + attachedCatalogAvoidance F s B D main x = + ∏ v : Fin (main.length + 1), + if ProhibitedSite h s (fun d q => (d, q) ∈ F.pairs) + (n + wordDisplacement h (main.take v.val)) then (0 : ℝ) else 1 := by + rw [attachedCatalogAvoidance_eq_indicator F s B D main hD x n hn] + split_ifs with hkeep + · symm + apply prod_eq_one + intro v _ + exact ite_eq_right (hkeep v.val (Nat.le_of_lt_succ v.isLt)) + · push Not at hkeep + obtain ⟨v, hv, hbad⟩ := hkeep + symm + exact prod_eq_zero (mem_univ (⟨v, by omega⟩ : Fin (main.length + 1))) (ite_eq_left hbad) + +theorem attachedCatalogAvoidance_eq_departure_product {h J M : ℕ} + (F : ProhibitedPrimeFamily h J M) (s B D : ℕ) (main : List SignedStep) + (hD : main.length ≤ D) (hlen : 0 < main.length) (hclosed : wordDisplacement h main = 0) + (x : ↥(F.P ∪ F.Q) → Fin B) (n : ℤ) + (hn : ∀ p : ↥(F.P ∪ F.Q), (n : ZMod p.val) = ((x p).val : ZMod p.val)) : + attachedCatalogAvoidance F s B D main x = + ∏ v : Fin main.length, + if ProhibitedSite h s (fun d q => (d, q) ∈ F.pairs) + (n + wordDisplacement h (main.take v.val)) then (0 : ℝ) else 1 := by + have he : (∀ v ≤ main.length, ¬ProhibitedSite h s (fun d q => (d, q) ∈ F.pairs) + (n + wordDisplacement h (main.take v))) ↔ + (∀ v < main.length, ¬ProhibitedSite h s (fun d q => (d, q) ∈ F.pairs) + (n + wordDisplacement h (main.take v))) := by + constructor + · exact fun hh v hv => hh v hv.le + · intro hh v hv + rcases lt_or_eq_of_le hv with hv | rfl + · exact hh v hv + · simpa only [List.take_length, hclosed, add_zero, List.take_zero, + wordDisplacement_nil] using hh 0 hlen + rw [attachedCatalogAvoidance_eq_indicator F s B D main hD x n hn] + simp only [he] + split_ifs with hkeep + · symm + apply prod_eq_one + intro v _ + exact ite_eq_right (hkeep v.val v.isLt) + · push Not at hkeep + obtain ⟨v, hv, hbad⟩ := hkeep + symm + exact prod_eq_zero (mem_univ (⟨v, hv⟩ : Fin main.length)) (ite_eq_left hbad) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CenterBandExpansion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenterBandExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..e79bed06260e5f92c8cc64660e5c405197419a93 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenterBandExpansion.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Walks.RetainedDivisorMass +import OAI.NumberTheory.TwoPoint.Basic + +namespace OAI + +/-! Exact expansion of the center-band factors. Each nonempty choice of +constant factors leaves an ordinary divisibility condition for the retained +prime product, and carries precisely one reciprocal removed-prime product. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def natDivisibilityIndicator (d n : ℕ) : ℂ := if d ∣ n then 1 else 0 + +lemma primeProduct_dvd_iff (S : Finset ℕ) (hS : ∀ p ∈ S, Nat.Prime p) (n : ℕ) : + (∏ p ∈ S, p) ∣ n ↔ ∀ p ∈ S, p ∣ n := by + constructor + · intro h p hp + exact (dvd_prod_of_mem (fun p : ℕ => p) hp).trans h + · intro h + by_cases hn : n = 0 + · simp [hn] + · have hsub : S ⊆ n.primeFactors := fun p hp => (hS p hp).mem_primeFactors (h p hp) hn + exact (prod_dvd_prod_of_subset S n.primeFactors (fun p : ℕ => p) hsub).trans + (Nat.prod_primeFactors_dvd n) + +lemma natDivisibilityIndicator_product (S : Finset ℕ) + (hS : ∀ p ∈ S, Nat.Prime p) (n : ℕ) : + (∏ p ∈ S, natDivisibilityIndicator p n) = + natDivisibilityIndicator (∏ p ∈ S, p) n := by + by_cases hd : (∏ p ∈ S, p) ∣ n + · have hp := (primeProduct_dvd_iff S hS n).mp hd + unfold natDivisibilityIndicator + simp only [hd, ite_true] + exact prod_eq_one (fun p hpS => ite_eq_left (hp p hpS)) + · have hn : ¬∀ p ∈ S, p ∣ n := fun h => hd ((primeProduct_dvd_iff S hS n).mpr h) + push Not at hn + obtain ⟨p, hp, hpn⟩ := hn + have hz : (∏ p ∈ S, natDivisibilityIndicator p n) = 0 := + prod_eq_zero hp (by simp [natDivisibilityIndicator, hpn]) + rw [hz] + simp only [natDivisibilityIndicator, hd, ite_false] + +theorem centerBand_expansion (S : Finset ℕ) (hS : ∀ p ∈ S, Nat.Prime p) + (θ : ℂ) (n : ℕ) : + (∏ p ∈ S, (natDivisibilityIndicator p n - θ / (p : ℂ))) = + ∑ W ∈ S.powerset, ((-θ) ^ W.card / ((∏ p ∈ W, p : ℕ) : ℂ)) * + natDivisibilityIndicator (∏ p ∈ S \ W, p) n := by + rw [prod_sub] + apply sum_congr rfl + intro W _ + rw [natDivisibilityIndicator_product (S \ W) + (fun p hp => hS p (mem_sdiff.mp hp).1) n] + rw [prod_div_distrib, prod_const, ← Nat.cast_prod, neg_pow] + ring + +/-- A nonempty removed-prime set contributes a nontrivial factor `w>1`. -/ +lemma primeSubset_product_one_lt (W : Finset ℕ) (hW : ∀ p ∈ W, Nat.Prime p) + (hne : W.Nonempty) : 1 < ∏ p ∈ W, p := by + obtain ⟨p, hp⟩ := hne + have hpos : 0 < ∏ p ∈ W, p := prod_pos (fun q hq => (hW q hq).pos) + have hle : p ≤ ∏ q ∈ W, q := Nat.le_of_dvd hpos (dvd_prod_of_mem (fun q : ℕ => q) hp) + exact (hW p hp).one_lt.trans_le hle + +lemma primeSubset_factorization (S W : Finset ℕ) (hW : W ⊆ S) : + (∏ p ∈ S \ W, p) * (∏ p ∈ W, p) = ∏ p ∈ S, p := by + rw [← prod_union sdiff_disjoint, sdiff_union_of_subset hW] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CenterBandReindex.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenterBandReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..615280dcea53efdb406509eec5c895654330183c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenterBandReindex.lean @@ -0,0 +1,196 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CenterBandExpansion + +namespace OAI + +/-! Exact reindexing of the center-band expansion into retained and +removed prime subsets. Every original term is represented once. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem centerBand_nonraw_expansion (D : Finset ℕ) + (hD : ∀ p ∈ D, Nat.Prime p) (θ : ℂ) (n : ℕ) : + (∏ p ∈ D, (natDivisibilityIndicator p n - θ / (p : ℂ))) - + natDivisibilityIndicator (∏ p ∈ D, p) n = + ∑ W ∈ D.powerset.filter Finset.Nonempty, + ((-θ) ^ W.card / ((∏ p ∈ W, p : ℕ) : ℂ)) * + natDivisibilityIndicator (∏ p ∈ D \ W, p) n := by + let F : Finset ℕ → ℂ := fun W => + ((-θ) ^ W.card / ((∏ p ∈ W, p : ℕ) : ℂ)) * + natDivisibilityIndicator (∏ p ∈ D \ W, p) n + have hF : F ∅ = natDivisibilityIndicator (∏ p ∈ D, p) n := by simp [F] + have hfilter : D.powerset.filter Finset.Nonempty = D.powerset.erase ∅ := by + ext W + simp only [mem_filter, mem_erase, nonempty_iff_ne_empty] + exact and_comm + rw [centerBand_expansion D hD θ n, hfilter] + change (∑ W ∈ D.powerset, F W) - _ = ∑ W ∈ D.powerset.erase ∅, F W + rw [← sum_erase_add D.powerset F (empty_mem_powerset D), hF] + ring + +lemma primeIndicator_union (U V : Finset ℕ) (hU : ∀ p ∈ U, Nat.Prime p) + (hV : ∀ p ∈ V, Nat.Prime p) (hd : Disjoint U V) (n : ℕ) : + natDivisibilityIndicator (∏ p ∈ U, p) n * + natDivisibilityIndicator (∏ p ∈ V, p) n = + natDivisibilityIndicator (∏ p ∈ U ∪ V, p) n := by + rw [← natDivisibilityIndicator_product U hU n, + ← natDivisibilityIndicator_product V hV n, ← prod_union hd] + apply natDivisibilityIndicator_product + intro p hp + rcases mem_union.mp hp with hp | hp + · exact hU p hp + · exact hV p hp + +/-- Only the selected center band is centered. The untouched core factors +combine with the retained center factors into the exact divisor `D\W`. -/ +theorem partialCenterBand_expansion (D T : Finset ℕ) + (hD : ∀ p ∈ D, Nat.Prime p) (θ : ℂ) (n : ℕ) : + natDivisibilityIndicator (∏ p ∈ D \ T, p) n * + (∏ p ∈ D ∩ T, (natDivisibilityIndicator p n - θ / (p : ℂ))) = + ∑ W ∈ (D ∩ T).powerset, + ((-θ) ^ W.card / ((∏ p ∈ W, p : ℕ) : ℂ)) * + natDivisibilityIndicator (∏ p ∈ D \ W, p) n := by + rw [centerBand_expansion (D ∩ T) (fun p hp => hD p (mem_inter.mp hp).1) θ n, mul_sum] + apply sum_congr rfl + intro W hW + have hWT : W ⊆ T := (mem_powerset.mp hW).trans inter_subset_right + have hd : Disjoint (D \ T) ((D ∩ T) \ W) := by + apply disjoint_left.mpr + intro p hp hq + exact (mem_sdiff.mp hp).2 (mem_inter.mp (mem_sdiff.mp hq).1).2 + have heq : (D \ T) ∪ ((D ∩ T) \ W) = D \ W := by + ext p + simp only [mem_union, mem_sdiff, mem_inter] + constructor + · rintro (⟨hpD, hpT⟩ | ⟨⟨hpD, hpT⟩, hpW⟩) + · exact ⟨hpD, fun hpW => hpT (hWT hpW)⟩ + · exact ⟨hpD, hpW⟩ + · rintro ⟨hpD, hpW⟩ + by_cases hpT : p ∈ T + · exact Or.inr ⟨⟨hpD, hpT⟩, hpW⟩ + · exact Or.inl ⟨hpD, hpT⟩ + calc + _ = ((-θ) ^ W.card / ((∏ p ∈ W, p : ℕ) : ℂ)) * + (natDivisibilityIndicator (∏ p ∈ D \ T, p) n * + natDivisibilityIndicator (∏ p ∈ (D ∩ T) \ W, p) n) := by ring + _ = _ := by + rw [primeIndicator_union (D \ T) ((D ∩ T) \ W) + (fun p hp => hD p (mem_sdiff.mp hp).1) + (fun p hp => hD p (mem_inter.mp (mem_sdiff.mp hp).1).1) hd n, heq] + +theorem partialCenterBand_nonraw_expansion (D T : Finset ℕ) + (hD : ∀ p ∈ D, Nat.Prime p) (θ : ℂ) (n : ℕ) : + natDivisibilityIndicator (∏ p ∈ D \ T, p) n * + (∏ p ∈ D ∩ T, (natDivisibilityIndicator p n - θ / (p : ℂ))) - + natDivisibilityIndicator (∏ p ∈ D, p) n = + ∑ W ∈ (D ∩ T).powerset.filter Finset.Nonempty, + ((-θ) ^ W.card / ((∏ p ∈ W, p : ℕ) : ℂ)) * + natDivisibilityIndicator (∏ p ∈ D \ W, p) n := by + let F : Finset ℕ → ℂ := fun W => + ((-θ) ^ W.card / ((∏ p ∈ W, p : ℕ) : ℂ)) * + natDivisibilityIndicator (∏ p ∈ D \ W, p) n + have hF : F ∅ = natDivisibilityIndicator (∏ p ∈ D, p) n := by simp [F] + have hfilter : (D ∩ T).powerset.filter Finset.Nonempty = (D ∩ T).powerset.erase ∅ := by + ext W + simp only [mem_filter, mem_erase, nonempty_iff_ne_empty] + exact and_comm + rw [partialCenterBand_expansion D T hD θ n, hfilter] + change (∑ W ∈ (D ∩ T).powerset, F W) - _ = ∑ W ∈ (D ∩ T).powerset.erase ∅, F W + rw [← sum_erase_add (D ∩ T).powerset F (empty_mem_powerset (D ∩ T)), hF] + ring + +lemma powerset_inter_filter (D T : Finset ℕ) : + (D ∩ T).powerset = T.powerset.filter (fun W => W ⊆ D) := by + ext W + simp only [mem_powerset, mem_filter] + constructor + · intro h + exact ⟨fun p hp => (mem_inter.mp (h hp)).2, + fun p hp => (mem_inter.mp (h hp)).1⟩ + · rintro ⟨hT, hD⟩ p hp + exact mem_inter.mpr ⟨hD hp, hT hp⟩ + +lemma sum_powerset_retained (S W : Finset ℕ) (hW : W ⊆ S) + (F : Finset ℕ → ℂ) : + (∑ D ∈ S.powerset.filter (fun D => W ⊆ D), F (D \ W)) = + ∑ U ∈ (S \ W).powerset, F U := by + apply sum_bij (fun D _ => D \ W) + · intro D hD + apply mem_powerset.mpr + intro p hp + exact mem_sdiff.mpr ⟨(mem_powerset.mp (mem_filter.mp hD).1) (mem_sdiff.mp hp).1, + (mem_sdiff.mp hp).2⟩ + · intro D hD E hE heq + calc + D = (D \ W) ∪ W := (sdiff_union_of_subset (mem_filter.mp hD).2).symm + _ = (E \ W) ∪ W := congrArg (fun V : Finset ℕ => V ∪ W) heq + _ = E := sdiff_union_of_subset (mem_filter.mp hE).2 + · intro U hU + have hUS : U ⊆ S := (mem_powerset.mp hU).trans sdiff_subset + have hUW : ∀ p ∈ U, p ∉ W := fun p hp => (mem_sdiff.mp (mem_powerset.mp hU hp)).2 + refine ⟨U ∪ W, mem_filter.mpr ⟨mem_powerset.mpr (union_subset hUS hW), subset_union_right⟩, ?_⟩ + ext p + simp only [mem_sdiff, mem_union] + constructor + · rintro ⟨hp | hp, hn⟩ + · exact hp + · exact False.elim (hn hp) + · intro hp + exact ⟨Or.inl hp, hUW p hp⟩ + · intro D _ + rfl + +/-- The removed-prime choice can be made first; the retained subset then +runs through the complementary pool. No cardinal multiplicity is added. -/ +theorem centerBand_reindex (S T : Finset ℕ) (hT : T ⊆ S) + (F : Finset ℕ → Finset ℕ → ℂ) : + (∑ D ∈ S.powerset, ∑ W ∈ (D ∩ T).powerset, F (D \ W) W) = + ∑ W ∈ T.powerset, ∑ U ∈ (S \ W).powerset, F U W := by + calc + _ = ∑ D ∈ S.powerset, ∑ W ∈ T.powerset, + if W ⊆ D then F (D \ W) W else 0 := by + apply sum_congr rfl + intro D _ + rw [powerset_inter_filter, sum_filter] + _ = ∑ W ∈ T.powerset, ∑ D ∈ S.powerset, + if W ⊆ D then F (D \ W) W else 0 := sum_comm + _ = _ := by + apply sum_congr rfl + intro W hW + rw [← sum_filter] + exact sum_powerset_retained S W ((mem_powerset.mp hW).trans hT) (fun U => F U W) + +lemma powerset_sdiff_filter (S W : Finset ℕ) : + (S \ W).powerset = S.powerset.filter (fun U => Disjoint U W) := by + ext U + simp only [mem_powerset, mem_filter] + constructor + · intro h + exact ⟨fun p hp => (mem_sdiff.mp (h hp)).1, + disjoint_left.mpr (fun p hp hpW => (mem_sdiff.mp (h hp)).2 hpW)⟩ + · rintro ⟨hU, hd⟩ p hp + exact mem_sdiff.mpr ⟨hU hp, fun hpW => disjoint_left.mp hd hp hpW⟩ + +/-- The retained-prime product is the outer summation variable used in +the analytic transfer. Removed and retained primes are disjoint exactly. -/ +theorem centerBand_reindex_retained (S T : Finset ℕ) (hT : T ⊆ S) + (F : Finset ℕ → Finset ℕ → ℂ) : + (∑ D ∈ S.powerset, ∑ W ∈ (D ∩ T).powerset, F (D \ W) W) = + ∑ U ∈ S.powerset, ∑ W ∈ (T \ U).powerset, F U W := by + rw [centerBand_reindex S T hT F] + simp_rw [powerset_sdiff_filter, sum_filter] + rw [sum_comm] + apply sum_congr rfl + intro U _ + apply sum_congr rfl + intro W _ + by_cases hd : Disjoint U W + · simp only [hd, hd.symm, ite_true] + · have hd' : ¬Disjoint W U := fun hw => hd hw.symm + simp only [hd, hd', ite_false] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CenterDegree.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenterDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..b0608acabc5a33c48a2cbfe6a05b0eeee53b3171 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenterDegree.lean @@ -0,0 +1,122 @@ +import Mathlib.Analysis.MeanInequalities +import Mathlib.Data.Fintype.Pi +import Mathlib.Tactic + +namespace OAI + +/-! +# Degree control for products of prime centers + +The argument is uniform in the indicators, so it applies both to integer +residues and to independent product residues. One prime is chosen from each +family, and the total number of lit prime coordinates controls the sum of +squared tuple weights. +-/ + +namespace TwoPointCorrelations + +open Finset + +lemma nonneg_product_le_power_card {ι : Type*} [Fintype ι] + (b : ι → ℝ) (C : ℝ) (hb : ∀ i, 0 ≤ b i) + (hsum : ∑ i, b i ≤ C * Fintype.card ι) : + ∏ i, b i ≤ C ^ Fintype.card ι := by + classical + by_cases hn : Fintype.card ι = 0 + · have : IsEmpty ι := Fintype.card_eq_zero_iff.mp hn + simp + have hp : 0 < (Fintype.card ι : ℝ) := by exact_mod_cast Nat.pos_of_ne_zero hn + have hmean := Real.geom_mean_le_arith_mean (univ : Finset ι) (fun _ => (1 : ℝ)) b + (fun _ _ => zero_le_one) (by simpa using hp) (fun i _ => hb i) + simp only [Real.rpow_one, sum_const, card_univ, nsmul_eq_mul, mul_one, one_mul] at hmean + have hbound : (∏ i, b i) ^ ((Fintype.card ι : ℝ)⁻¹) ≤ C := + hmean.trans ((div_le_iff₀ hp).mpr hsum) + have hpow := pow_le_pow_left₀ (Real.rpow_nonneg (prod_nonneg (fun i _ => hb i)) _) hbound + (Fintype.card ι) + rw [Real.rpow_inv_natCast_pow (prod_nonneg (fun i _ => hb i)) hn] at hpow + exact hpow + +noncomputable def centerMagnitude (θ : ℝ) (lit : Bool) : ℝ := + |(if lit then 1 else 0) - θ| + +lemma centerMagnitude_nonneg (θ : ℝ) (lit : Bool) : 0 ≤ centerMagnitude θ lit := + abs_nonneg _ + +lemma centerMagnitude_le_one (θ : ℝ) (lit : Bool) (hθ : 0 ≤ θ) (hθ1 : θ ≤ 1) : + centerMagnitude θ lit ≤ 1 := by + cases lit <;> simp [centerMagnitude, abs_of_nonneg, abs_of_nonpos, hθ, sub_nonneg.mpr hθ1] + all_goals linarith + +lemma centerMagnitude_le_indicator_add (θ : ℝ) (lit : Bool) (hθ : 0 ≤ θ) (hθ1 : θ ≤ 1) : + centerMagnitude θ lit ≤ (if lit then 1 else 0) + θ := by + cases lit <;> simp [centerMagnitude, abs_of_nonneg, abs_of_nonpos, hθ, sub_nonneg.mpr hθ1] + all_goals linarith + +lemma center_family_sum_le {α : Type*} [Fintype α] + (θ : α → ℝ) (lit : α → Bool) (hθ : ∀ p, 0 ≤ θ p) (hθ1 : ∀ p, θ p ≤ 1) : + (∑ p, centerMagnitude (θ p) (lit p)) ≤ + (∑ p, if lit p then (1 : ℝ) else 0) + ∑ p, θ p := by + rw [← sum_add_distrib] + exact sum_le_sum (fun p _ => centerMagnitude_le_indicator_add _ _ (hθ p) (hθ1 p)) + +lemma squared_center_products_le_product + {ι : Type*} [Fintype ι] [DecidableEq ι] {P : ι → Type*} [∀ i, Fintype (P i)] + (θ : (i : ι) → P i → ℝ) (lit : (i : ι) → P i → Bool) + (hθ : ∀ i p, 0 ≤ θ i p) (hθ1 : ∀ i p, θ i p ≤ 1) : + (∑ x : (i : ι) → P i, (∏ i, centerMagnitude (θ i (x i)) (lit i (x i))) ^ 2) ≤ + ∏ i, ((∑ p : P i, if lit i p then (1 : ℝ) else 0) + ∑ p, θ i p) := by + classical + calc + _ ≤ ∑ x : (i : ι) → P i, ∏ i, centerMagnitude (θ i (x i)) (lit i (x i)) := by + apply sum_le_sum + intro x _ + have h0 : 0 ≤ ∏ i, centerMagnitude (θ i (x i)) (lit i (x i)) := + prod_nonneg (fun i _ => centerMagnitude_nonneg _ _) + have h1 : (∏ i, centerMagnitude (θ i (x i)) (lit i (x i))) ≤ 1 := + prod_le_one₀ (fun i _ => centerMagnitude_nonneg _ _) (fun i _ => + centerMagnitude_le_one _ _ (hθ i _) (hθ1 i _)) + simpa only [pow_two, mul_one] using mul_le_mul_of_nonneg_left h1 h0 + _ = ∏ i, ∑ p, centerMagnitude (θ i p) (lit i p) := + (Fintype.prod_sum (fun i p => centerMagnitude (θ i p) (lit i p))).symm + _ ≤ _ := by + apply prod_le_prod₀ + · intro i _ + exact sum_nonneg (fun p _ => centerMagnitude_nonneg _ _) + · intro i _ + exact center_family_sum_le (θ i) (lit i) (hθ i) (hθ1 i) + +lemma sum_degree_budget {ι : Type*} [Fintype ι] (ω V : ι → ℝ) (W : ℝ) + (hV : ∀ i, V i ≤ 2 * W) + (hdegree : ∑ i, ω i ≤ 6 * W * Fintype.card ι) : + ∑ i, (ω i + V i) ≤ (8 * W) * Fintype.card ι := by + have hv : (∑ i, V i) ≤ (2 * W) * Fintype.card ι := by + calc + _ ≤ ∑ _i : ι, 2 * W := sum_le_sum (fun i _ => hV i) + _ = _ := by simp; ring + rw [sum_add_distrib] + exact (add_le_add hdegree hv).trans_eq (by ring) + +/-- The sitewise estimate `sum_d a_d(n)^2 ≤ (8W)^J`, with actual +one-prime-per-family products and a total lit-prime degree at most `6WJ`. -/ +theorem squared_center_products_le + {ι : Type*} [Fintype ι] [DecidableEq ι] {P : ι → Type*} [∀ i, Fintype (P i)] + (θ : (i : ι) → P i → ℝ) (lit : (i : ι) → P i → Bool) + (W : ℝ) + (hθ : ∀ i p, 0 ≤ θ i p) (hθ1 : ∀ i p, θ i p ≤ 1) + (hV : ∀ i, ∑ p, θ i p ≤ 2 * W) + (hdegree : (∑ i, ∑ p : P i, if lit i p then (1 : ℝ) else 0) ≤ + 6 * W * Fintype.card ι) : + (∑ x : (i : ι) → P i, (∏ i, centerMagnitude (θ i (x i)) (lit i (x i))) ^ 2) ≤ + (8 * W) ^ Fintype.card ι := by + classical + apply (squared_center_products_le_product θ lit hθ hθ1).trans + apply nonneg_product_le_power_card + · intro i + exact add_nonneg (sum_nonneg (fun p _ => by split_ifs <;> norm_num)) + (sum_nonneg (fun p _ => hθ i p)) + · exact sum_degree_budget (fun i => ∑ p : P i, if lit i p then (1 : ℝ) else 0) + (fun i => ∑ p, θ i p) W hV hdegree + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredBinIdentity.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredBinIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..150cbbfda8204d29969cc2fccc6d8b25631a7ce6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredBinIdentity.lean @@ -0,0 +1,44 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FullTupleBinIdentity +import OAI.NumberTheory.TwoPoint.Walks.CanonicalPartialCentering + +namespace OAI + +/-! The graph bin and the analytic centering bin are the same finite sum, +with the literal real denominator and no floor-normalization error. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma prefix_scalar_real_denominator (f : ℕ → ℂ) (N : ℕ) (T : ℝ) : + ((N : ℂ) / (T : ℂ)) * (positivePrefix f N / (N : ℂ)) = + positivePrefix f N / (T : ℂ) := by + by_cases hN : N = 0 + · subst N + simp only [positivePrefix, range_zero, sum_empty, Nat.cast_zero, zero_div, mul_zero] + · have hNC : (N : ℂ) ≠ 0 := by exact_mod_cast hN + field_simp + +lemma weighted_uncut_sub_full_bin {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (R : Finset ℕ) (hR : ∀ q ∈ R, 0 < q) (L η : ℝ) (j : ℤ) + (h l b : ℕ) [NeZero l] (hh : 0 < h) (T : ℝ) : + ((⌊T⌋₊ : ℂ) / (T : ℂ)) * + uncutPrimePrefix P R (numericalBinEligible L η j) h (progressionEdgeGate h l b) ⌊T⌋₊ - + fullNumericalBin (primeTupleDivisors P) R L η j l (b : ZMod l) h T = + tupleNonrawBin P R actualPaddingCoefficient (numericalBinEligible L η j) + l (b : ZMod l) h T := by + rw [uncutPrimePrefix_centered P hprime hdisjoint R hR _ h l b _ hh, + prefix_scalar_real_denominator, fullNumericalBin_tuple P hprime hdisjoint] + rw [positivePrefix_sum_finite, sum_div] + simp only [positivePrefix_const_mul, tupleNonrawBin, mul_div_assoc] + rw [← sum_sub_distrib] + apply sum_congr rfl + intro q _ + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredTupleProfiles.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredTupleProfiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c2c4e5b1667b56b0162e9b5f6e19e3983dd2947 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredTupleProfiles.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.TwoPoint.Walks.PartialTupleProfiles + +namespace OAI + +/-! The actual centered tuple average is the signed sum of the supply +subsets. The empty subset is precisely the full-divisibility term. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma tuple_center_padding_expansion {J : ℕ} (p : Fin J → ℕ) + (hprime : ∀ j, (p j).Prime) (hinj : Function.Injective p) + (q n : ℕ) (hcop : ∀ j, q.Coprime (p j)) (F : ℂ) : + natDivisibilityIndicator q n * + (∏ j, (natDivisibilityIndicator (p j) n - 1 / (p j : ℂ))) * F = + ∑ I ∈ (univ : Finset (Fin J)).powerset, + ((-1 : ℂ) ^ I.card / ((∏ i : I, p i : ℕ) : ℂ)) * + natDivisibilityIndicator (q * ∏ j : {j // j ∉ I}, p j) n * F := by + rw [tupleCenter_expansion p hprime hinj n, mul_sum, sum_mul] + apply sum_congr rfl + intro I _ + have hc : q.Coprime (∏ j : {j // j ∉ I}, p j) := + Nat.coprime_prod_right_iff.mpr (fun j _ => hcop j) + rw [← natDivisibilityIndicator_mul q _ n hc] + ring + +noncomputable def tupleCenteredProfile {J : ℕ} (P : Fin J → Finset ℕ) + (q : ℕ) (eligible : ℕ → ℕ → Prop) (l : ℕ) [NeZero l] + (b : ZMod l) (h n : ℕ) : ℂ := + ∑ x : (j : Fin J) → P j, + if eligible (∏ j, (x j).val) q then + natDivisibilityIndicator q n * + (centeredTuple (∏ j, (x j).val).primeFactors (n : ℤ) : ℂ) * + (progressionSequence liouville l (b * ((q * ∏ j, (x j).val : ℕ) : ZMod l)) n * + liouville (n + h * (q * ∏ j, (x j).val))) + else 0 + +lemma tupleCenteredProfile_expansion {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (q : ℕ) (hcop : ∀ j, ∀ p ∈ P j, q.Coprime p) + (eligible : ℕ → ℕ → Prop) (l : ℕ) [NeZero l] (b : ZMod l) (h n : ℕ) : + tupleCenteredProfile P q eligible l b h n = + ∑ I ∈ (univ : Finset (Fin J)).powerset, + (-1 : ℂ) ^ I.card * tuplePartialProfile P I q eligible l b h n := by + simp only [tupleCenteredProfile, tuplePartialProfile, mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro x _ + by_cases he : eligible (∏ j, (x j).val) q + · simp only [he, ite_true] + rw [centeredTuple_nat_eq P hprime hdisjoint] + have hx := tuple_center_padding_expansion (fun j => (x j).val) + (fun j => hprime j _ (x j).property) (selectedPrimeValues_injective x hdisjoint) + q n (fun j => hcop j _ (x j).property) + (progressionSequence liouville l (b * ((q * ∏ j, (x j).val : ℕ) : ZMod l)) n * + liouville (n + h * (q * ∏ j, (x j).val))) + apply hx.trans + apply sum_congr rfl + intro I _ + ring + · simp only [he, ite_false, mul_zero, sum_const_zero] + +lemma tupleCenteredProfile_nonraw {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (q : ℕ) (hcop : ∀ j, ∀ p ∈ P j, q.Coprime p) + (eligible : ℕ → ℕ → Prop) (l : ℕ) [NeZero l] (b : ZMod l) (h n : ℕ) : + tupleCenteredProfile P q eligible l b h n - tuplePartialProfile P ∅ q eligible l b h n = + ∑ I ∈ (univ : Finset (Fin J)).powerset.filter Finset.Nonempty, + (-1 : ℂ) ^ I.card * tuplePartialProfile P I q eligible l b h n := by + rw [tupleCenteredProfile_expansion P hprime hdisjoint q hcop eligible l b h n] + let F : Finset (Fin J) → ℂ := fun I => + (-1 : ℂ) ^ I.card * tuplePartialProfile P I q eligible l b h n + have he : (univ : Finset (Fin J)).powerset.filter Finset.Nonempty = + (univ : Finset (Fin J)).powerset.erase ∅ := by + ext I + simp only [mem_filter, mem_erase, nonempty_iff_ne_empty] + exact and_comm + rw [he] + change (∑ I ∈ (univ : Finset (Fin J)).powerset, F I) - _ = + ∑ I ∈ (univ : Finset (Fin J)).powerset.erase ∅, F I + rw [← sum_erase_add _ F (empty_mem_powerset _)] + simp only [F, card_empty, pow_zero, one_mul, add_sub_cancel_right] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredWitnessCatalog.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredWitnessCatalog.lean new file mode 100644 index 0000000000000000000000000000000000000000..fcdcab8f5b678e5965118a386f9ee8f893716383 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredWitnessCatalog.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Walks.WeightedWordEnvelope +import OAI.NumberTheory.TwoPoint.Bounds.BoundedPaddingUnion + +namespace OAI + +/-! Sum full centered-word averages against the numerical witness catalog. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem centered_words_le_witness_catalog {ι τ : Type*} + [Fintype ι] [Fintype τ] [DecidableEq ι] {D n : ℕ} (slots : ℕ → ℕ) + (P Q : Finset ℕ) (F : Finset (List SignedStep)) + (p : ι → ℕ) (hinj : Function.Injective p) (B h s J : ℕ) + (supply : ℕ → ℕ → Prop) (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (hP : ∀ q ∈ P, q.Prime) (hQ : ∀ q ∈ Q, q.Prime) + (hcover : ∀ q ∈ P ∪ Q, ∃ i, p i = q) + (label : List SignedStep → τ → ι) (target : List SignedStep → τ → Fin B) + (base : ι → Fin B) (R G : List SignedStep → (ι → Fin B) → ℝ) + (C : List SignedStep → ℝ) (K : ℝ) (hK : 0 ≤ K) + (htarget : ∀ main ∈ F, ∀ t, (target main t).val < p (label main t)) + (hR : ∀ main ∈ F, ∀ x, 0 ≤ R main x) + (hRC : ∀ main ∈ F, ∀ x, R main x ≤ C main) + (hC : ∀ main ∈ F, 0 ≤ C main) + (hG : ∀ main ∈ F, ∀ x, |G main x| ≤ 1) + (hcost : ∀ main ∈ F, + C main * 2 ^ (Fintype.card τ + (singletonLabels (label main)).card) ≤ K) + (hRdep : ∀ main ∈ F, ∀ x y, + (∀ i, i ∉ univ.image (label main) → x i = y i) → R main x = R main y) + (hS : ∀ main ∈ F, ∀ i ∈ univ.image (label main), p i ∈ wordDivisorPrimeSupport main) + (hsupport : ∀ main ∈ F, ∀ x, + centeredWordEnvelope (label main) (target main) base (R main) (G main) x ≠ 0 → + ∃ r : Fin (D + 1), ∃ d : WitnessRecord n r.val, + ∃ e : PrimeWordEncoding r.val (slots r.val) P Q, + EncodedPaddingWitnessEvent (univ.image (label main)) d e main p B h s J supply x) : + (∑ main ∈ F, + |(FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => R main x * (∏ t, + ((if x (label main t) = target main t then (1 : ℝ) else 0) - + (p (label main t) : ℝ)⁻¹)) * G main x)|) ≤ + K * ∑ r : Fin (D + 1), ∑ d : WitnessRecord n r.val, + ∑ e : PrimeWordEncoding r.val (slots r.val) P Q, + if e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) + (fun i => (d.1.2.2 i).val) h s J supply then e.weight else 0 := by + let μ := FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i)) + let envelope (main : List SignedStep) := + centeredWordEnvelope (label main) (target main) base (R main) (G main) + calc + _ ≤ ∑ main ∈ F, (∏ i ∈ univ.image (label main), (p i : ℝ)⁻¹) * + μ.average (fun x => |envelope main x|) := by + apply sum_le_sum + intro main hm + have hb := uniform_weighted_centered_word_envelope B p hp hpB (label main) + (target main) base (htarget main hm) (R main) (G main) (hR main hm) (hRdep main hm) + have he : (fun x => |envelope main x|) = envelope main := by + funext x + exact abs_of_nonneg (centeredWordEnvelope_nonneg _ _ _ _ _ (hR main hm) x) + rw [he] + exact hb + _ ≤ _ := by + apply weighted_supported_padding_averages_le_catalog slots F + (fun main => univ.image (label main)) p hinj B h s J supply hp hpB hP hQ + hcover hS envelope K hK _ hsupport + intro main hm x + rw [abs_of_nonneg (centeredWordEnvelope_nonneg _ _ _ _ _ (hR main hm) x)] + exact (centeredWordEnvelope_le (label main) (target main) base (R main) (G main) + (C main) (hC main hm) (hRC main hm) (hG main hm) x).trans (hcost main hm) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredWordExpansion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredWordExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1c65fca331ab940698196c0a78c2126a39b397f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredWordExpansion.lean @@ -0,0 +1,151 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualDesignations +import OAI.NumberTheory.TwoPoint.Bounds.ResidueTraceBound + +namespace OAI + +/-! Split an actual centered word into its singleton factors and lit designations. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {ι τ A : Type*} [Fintype ι] [Fintype τ] [DecidableEq ι] + +def singletonSlots (label : τ → ι) : Finset τ := + univ.filter (fun t => label t ∈ singletonLabels label) + +def nonsingletonSlots (label : τ → ι) : Finset τ := + univ.filter (fun t => label t ∈ nonsingletonLabels label) + +lemma singleton_occurrence_exists (label : τ → ι) (i : singletonLabels label) : + ∃ t, label t = i.val := by + have hc := (mem_filter.mp i.property).2 + have hn : (labelOccurrences label i.val).Nonempty := card_pos.mp (by omega) + obtain ⟨t, ht⟩ := hn + exact ⟨t, (mem_filter.mp ht).2⟩ + +noncomputable def singletonRepresentative (label : τ → ι) (i : singletonLabels label) : τ := + Classical.choose (singleton_occurrence_exists label i) + +lemma singletonRepresentative_label (label : τ → ι) (i : singletonLabels label) : + label (singletonRepresentative label i) = i.val := + Classical.choose_spec (singleton_occurrence_exists label i) + +lemma singleton_occurrence_unique (label : τ → ι) (i : singletonLabels label) + (t : τ) (ht : label t = i.val) : t = singletonRepresentative label i := by + obtain ⟨a, ha⟩ := card_eq_one.mp (mem_filter.mp i.property).2 + have htmem : t ∈ labelOccurrences label i.val := mem_filter.mpr ⟨mem_univ _, ht⟩ + have hrmem : singletonRepresentative label i ∈ labelOccurrences label i.val := + mem_filter.mpr ⟨mem_univ _, singletonRepresentative_label label i⟩ + rw [ha, mem_singleton] at htmem hrmem + exact htmem.trans hrmem.symm + +noncomputable def singletonTarget (label : τ → ι) (target : τ → A) (base : ι → A) : ι → A := + fun i => if hi : i ∈ singletonLabels label + then target (singletonRepresentative label ⟨i, hi⟩) else base i + +lemma singletonTarget_at (label : τ → ι) (target : τ → A) (base : ι → A) + (t : τ) (ht : label t ∈ singletonLabels label) : + singletonTarget label target base (label t) = target t := by + simp only [singletonTarget, dite_eq_left ht] + rw [← singleton_occurrence_unique label ⟨label t, ht⟩ t rfl] + +lemma singletonSlots_product (label : τ → ι) (f : τ → ℝ) : + (∏ t ∈ singletonSlots label, f t) = + ∏ i : singletonLabels label, f (singletonRepresentative label i) := by + apply prod_bij (fun t ht => (⟨label t, (mem_filter.mp ht).2⟩ : singletonLabels label)) + · intro t ht + exact mem_univ _ + · intro t ht u hu he + have htu : label t = label u := congrArg Subtype.val he + exact (singleton_occurrence_unique label ⟨label t, (mem_filter.mp ht).2⟩ t rfl).trans + (singleton_occurrence_unique label ⟨label t, (mem_filter.mp ht).2⟩ u htu.symm).symm + · intro i _ + refine ⟨singletonRepresentative label i, ?_, ?_⟩ + · exact mem_filter.mpr ⟨mem_univ _, (singletonRepresentative_label label i).symm ▸ i.property⟩ + · exact Subtype.ext (singletonRepresentative_label label i) + · intro t ht + rw [← singleton_occurrence_unique label ⟨label t, (mem_filter.mp ht).2⟩ t rfl] + +lemma centered_singleton_product [DecidableEq A] + (label : τ → ι) (target : τ → A) (base x : ι → A) (θ : ι → ℝ) : + (∏ t ∈ singletonSlots label, + ((if x (label t) = target t then (1 : ℝ) else 0) - θ (label t))) = + ∏ i ∈ singletonLabels label, + ((if x i = singletonTarget label target base i then (1 : ℝ) else 0) - θ i) := by + rw [singletonSlots_product] + rw [← Finset.prod_coe_sort (s := singletonLabels label) (f := fun i : ι => + ((if x i = singletonTarget label target base i then (1 : ℝ) else 0) - θ i))] + apply prod_congr rfl + intro i _ + simp only [singletonRepresentative_label, singletonTarget, dite_eq_left i.property] + +lemma centered_word_split [DecidableEq A] + (label : τ → ι) (target : τ → A) (base x : ι → A) (θ : ι → ℝ) : + (∏ t, ((if x (label t) = target t then (1 : ℝ) else 0) - θ (label t))) = + (∏ t ∈ nonsingletonSlots label, + ((if x (label t) = target t then (1 : ℝ) else 0) - θ (label t))) * + ∏ i ∈ singletonLabels label, + ((if x i = singletonTarget label target base i then (1 : ℝ) else 0) - θ i) := by + rw [← centered_singleton_product label target base x θ] + have he : singletonSlots label = univ.filter (fun t => t ∉ nonsingletonSlots label) := by + ext t + have hp : 0 < (labelOccurrences label (label t)).card := + card_pos.mpr ⟨t, mem_filter.mpr ⟨mem_univ _, rfl⟩⟩ + simp only [singletonSlots, nonsingletonSlots, singletonLabels, nonsingletonLabels, + mem_filter, mem_univ, true_and] + omega + rw [he] + have hcomp : univ.filter (fun t => t ∉ nonsingletonSlots label) = + (nonsingletonSlots label)ᶜ := by ext t; simp + rw [hcomp] + exact (prod_mul_prod_compl (nonsingletonSlots label) (fun t : τ => + ((if x (label t) = target t then (1 : ℝ) else 0) - θ (label t)))).symm + +/-- Every singleton remains centered while only nonsingleton occurrences +are expanded. This is an identity of signed word contributions. -/ +lemma centered_word_designation_expansion [DecidableEq A] + (label : τ → ι) (target : τ → A) (base x : ι → A) (θ : ι → ℝ) + (R : ℝ) (G : (ι → A) → ℝ) : + R * (∏ t, ((if x (label t) = target t then (1 : ℝ) else 0) - θ (label t))) * G x = + ∑ U ∈ (nonsingletonSlots label).powerset, + (R * ((-1 : ℝ) ^ U.card * ∏ t ∈ U, θ (label t))) * + ((∏ t ∈ nonsingletonSlots label \ U, + if x (label t) = target t then (1 : ℝ) else 0) * + ((∏ i ∈ singletonLabels label, + ((if x i = singletonTarget label target base i then (1 : ℝ) else 0) - θ i)) * G x)) := by + rw [centered_word_split label target base x θ, + centered_occurrence_expansion (nonsingletonSlots label) label target θ x] + simp only [sum_mul, mul_sum] + apply sum_congr rfl + intro U _ + ring + +/-- Averaging precedes the triangle inequality; no absolute value is +introduced while expanding the signed nonsingleton terms. -/ +theorem centered_word_expectation [Fintype A] [DecidableEq A] + (μ : FiniteLaw (ι → A)) (label : τ → ι) (target : τ → A) + (base : ι → A) (θ : ι → ℝ) (R : ℝ) (G : (ι → A) → ℝ) : + μ.average (fun x => R * + (∏ t, ((if x (label t) = target t then (1 : ℝ) else 0) - θ (label t))) * G x) = + ∑ U ∈ (nonsingletonSlots label).powerset, μ.average (fun x => + (R * ((-1 : ℝ) ^ U.card * ∏ t ∈ U, θ (label t))) * + ((∏ t ∈ nonsingletonSlots label \ U, + if x (label t) = target t then (1 : ℝ) else 0) * + ((∏ i ∈ singletonLabels label, + ((if x i = singletonTarget label target base i then (1 : ℝ) else 0) - θ i)) * G x))) := by + simp_rw [centered_word_designation_expansion label target base _ θ R G] + simp only [FiniteLaw.average, mul_sum] + rw [sum_comm] + +lemma singleton_disjoint_designated (label : τ → ι) (U : Finset τ) : + Disjoint (singletonLabels label) ((nonsingletonSlots label \ U).image label) := by + apply disjoint_left.mpr + intro i hi hiL + obtain ⟨t, ht, rfl⟩ := mem_image.mp hiL + exact singleton_not_nonsingleton label _ hi ((mem_filter.mp (mem_sdiff.mp ht).1).2) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredWordMajorant.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredWordMajorant.lean new file mode 100644 index 0000000000000000000000000000000000000000..b708eaec92e27a0f03244aba217fc7accc49c73e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CenteredWordMajorant.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CenteredWordExpansion + +namespace OAI + +/-! Apply exact uniform singleton centering to the complete signed word. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {ι τ : Type*} [Fintype ι] [Fintype τ] [DecidableEq ι] + +lemma uniform_singleton_target_lt (B : ℕ) (p : ι → ℕ) (label : τ → ι) + (target : τ → Fin B) (base : ι → Fin B) + (htarget : ∀ t, (target t).val < p (label t)) (i : ι) + (hi : i ∈ singletonLabels label) : + (singletonTarget label target base i).val < p i := by + simp only [singletonTarget, dite_eq_left hi] + simpa only [singletonRepresentative_label] using + htarget (singletonRepresentative label ⟨i, hi⟩) + +/-- Contradictory lit tests vanish even with all singleton factors retained. -/ +lemma uniform_word_designation_zero (B : ℕ) (p : ι → ℕ) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (label : τ → ι) (target : τ → Fin B) (base : ι → Fin B) + (htarget : ∀ t, (target t).val < p (label t)) (U : Finset τ) + (R : ℝ) (G : (ι → Fin B) → ℝ) + (hL : ¬LitConsistent (nonsingletonSlots label \ U) label target) : + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => (R * ((-1 : ℝ) ^ U.card * ∏ t ∈ U, (p (label t) : ℝ)⁻¹)) * + ((∏ t ∈ nonsingletonSlots label \ U, + if x (label t) = target t then (1 : ℝ) else 0) * + ((∏ i ∈ singletonLabels label, + ((if x i = singletonTarget label target base i then (1 : ℝ) else 0) - + (p i : ℝ)⁻¹)) * G x))) = 0 := by + have hprod (x : ι → Fin B) : + (∏ i ∈ singletonLabels label, + ((if x i = singletonTarget label target base i then (1 : ℝ) else 0) - + (uniformResidueLaw B (p i) (hp i) (hpB i)).weight + (singletonTarget label target base i))) = + ∏ i ∈ singletonLabels label, + ((if x i = singletonTarget label target base i then (1 : ℝ) else 0) - (p i : ℝ)⁻¹) := by + apply prod_congr rfl + intro i hi + rw [uniformResidueLaw_weight B (p i) (hp i) (hpB i) _ + (uniform_singleton_target_lt B p label target base htarget i hi)] + have hz := designated_residue_zero + (fun i => uniformResidueLaw B (p i) (hp i) (hpB i)) (singletonLabels label) + (nonsingletonSlots label \ U) label target (singletonTarget label target base) + (R * ((-1 : ℝ) ^ U.card * ∏ t ∈ U, (p (label t) : ℝ)⁻¹)) G hL + simpa only [hprod] using hz + +/-- Full-word majorant. Absolute values are introduced only after the +signed expansion and exact singleton integrations have been performed. -/ +theorem uniform_centered_word_majorant (B : ℕ) (p : ι → ℕ) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (label : τ → ι) (target : τ → Fin B) (base : ι → Fin B) + (htarget : ∀ t, (target t).val < p (label t)) + (R : ℝ) (hR : 0 ≤ R) (G : (ι → Fin B) → ℝ) : + |(FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => R * (∏ t, + ((if x (label t) = target t then (1 : ℝ) else 0) - (p (label t) : ℝ)⁻¹)) * G x)| ≤ + ∑ U ∈ (nonsingletonSlots label).powerset, + if LitConsistent (nonsingletonSlots label \ U) label target then + R * designatedReciprocal p (singletonLabels label) (nonsingletonSlots label \ U) U label * + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => |selectedMixedDifference (singletonLabels label) + (singletonTarget label target base) + (fun x => G (forceCoordinates ((nonsingletonSlots label \ U).image label) + (litForcedTarget (nonsingletonSlots label \ U) label target base) x)) x|) + else 0 := by + rw [centered_word_expectation _ label target base (fun i => (p i : ℝ)⁻¹) R G] + apply (abs_sum_le_sum_abs _ _).trans + apply sum_le_sum + intro U _ + by_cases hL : LitConsistent (nonsingletonSlots label \ U) label target + · rw [ite_eq_left hL] + exact uniform_designated_trace_bound B p hp hpB (singletonLabels label) + (nonsingletonSlots label \ U) U label target (singletonTarget label target base) base + R G hR hL (singleton_disjoint_designated label U) + (uniform_singleton_target_lt B p label target base htarget) + (fun t _ => htarget t) + · rw [ite_eq_right hL, + uniform_word_designation_zero B p hp hpB label target base htarget U R G hL, abs_zero] + +/-- The crude mixed-difference bound can be used after the signed +singleton integration, retaining every exact reciprocal coefficient. -/ +theorem uniform_centered_word_crude_bound (B : ℕ) (p : ι → ℕ) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (label : τ → ι) (target : τ → Fin B) (base : ι → Fin B) + (htarget : ∀ t, (target t).val < p (label t)) + (R : ℝ) (hR : 0 ≤ R) (G : (ι → Fin B) → ℝ) (hG : ∀ x, |G x| ≤ 1) : + |(FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => R * (∏ t, + ((if x (label t) = target t then (1 : ℝ) else 0) - (p (label t) : ℝ)⁻¹)) * G x)| ≤ + ∑ U ∈ (nonsingletonSlots label).powerset, + R * designatedReciprocal p (singletonLabels label) (nonsingletonSlots label \ U) U label * + 2 ^ (singletonLabels label).card := by + apply (uniform_centered_word_majorant B p hp hpB label target base htarget R hR G).trans + apply sum_le_sum + intro U _ + have hcoef : 0 ≤ R * designatedReciprocal p (singletonLabels label) + (nonsingletonSlots label \ U) U label := by + unfold designatedReciprocal + positivity + split_ifs + · apply mul_le_mul_of_nonneg_left _ hcoef + apply (FiniteLaw.average_mono _ (fun x => + selectedMixedDifference_bound (singletonLabels label) (singletonTarget label target base) + _ (fun y => hG _) x)).trans_eq + exact FiniteLaw.average_const _ _ + · exact mul_nonneg hcoef (by positivity) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CharacterTwists.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CharacterTwists.lean new file mode 100644 index 0000000000000000000000000000000000000000..caf8c1de1021fcd5b7a5e44c82b7e22240b03e4a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CharacterTwists.lean @@ -0,0 +1,113 @@ +import OAI.NumberTheory.TwoPoint.Basic +import OAI.NumberTheory.TwoPoint.PretentiousDistance + +namespace OAI + +/-! +# Dirichlet character twists preserve uniform nonpretentiousness + +Characters with different moduli are multiplied after changing both levels +to the product modulus. The resulting character equals the pointwise product +on every natural number, including the nonunit classes. This gives an exact +identity of pretentious distances and preserves the original height cutoff. +-/ + +namespace TwoPointCorrelations + +open scoped ComplexConjugate +open Filter + +/-- Product of two characters, viewed at their common product modulus. -/ +noncomputable def productCharacters {q r : ℕ} (χ : DirichletCharacter ℂ q) + (ψ : DirichletCharacter ℂ r) : DirichletCharacter ℂ (q * r) := + χ.changeLevel (Nat.dvd_mul_right q r) * ψ.changeLevel (Nat.dvd_mul_left r q) + +/-- Conjugation of the values of a Dirichlet character. -/ +def conjugateCharacter {q : ℕ} (χ : DirichletCharacter ℂ q) : DirichletCharacter ℂ q := + χ.ringHomComp (starRingEnd ℂ) + +@[simp] lemma conjugateCharacter_apply {q : ℕ} (χ : DirichletCharacter ℂ q) (n : ZMod q) : + conjugateCharacter χ n = conj (χ n) := rfl + +/-- Changing both character levels to their product preserves their pointwise +product, even when the argument is not a unit modulo the product. -/ +lemma productCharacters_apply_nat {q r : ℕ} (χ : DirichletCharacter ℂ q) + (ψ : DirichletCharacter ℂ r) (n : ℕ) : + productCharacters χ ψ (n : ZMod (q * r)) = χ (n : ZMod q) * ψ (n : ZMod r) := by + unfold productCharacters + simp only [MulChar.coeToFun_mul, Pi.mul_apply] + by_cases hcop : n.Coprime (q * r) + · have hχ := DirichletCharacter.changeLevel_eq_cast_of_dvd' χ + (Nat.dvd_mul_right q r) hcop.isCoprime + have hψ := DirichletCharacter.changeLevel_eq_cast_of_dvd' ψ + (Nat.dvd_mul_left r q) hcop.isCoprime + simpa only [Int.cast_natCast] using congrArg₂ (· * ·) hχ hψ + · have hunit : ¬IsUnit (n : ZMod (q * r)) := by + simpa only [ZMod.isUnit_iff_coprime] using hcop + rw [MulChar.map_nonunit _ hunit, zero_mul] + by_cases hnq : n.Coprime q + · have hnr : ¬n.Coprime r := by + intro hnr + exact hcop (hnq.mul_right hnr) + have hunitr : ¬IsUnit (n : ZMod r) := by + simpa only [ZMod.isUnit_iff_coprime] using hnr + rw [MulChar.map_nonunit ψ hunitr, mul_zero] + · have hunitq : ¬IsUnit (n : ZMod q) := by + simpa only [ZMod.isUnit_iff_coprime] using hnq + rw [MulChar.map_nonunit χ hunitq, zero_mul] + +/-- Multiplication by a fixed Dirichlet character. -/ +noncomputable def twistByCharacter {q : ℕ} (f : ℕ → ℂ) + (χ : DirichletCharacter ℂ q) (n : ℕ) : ℂ := f n * χ (n : ZMod q) + +lemma characterTwist_productCharacters {q r : ℕ} (χ : DirichletCharacter ℂ q) + (ψ : DirichletCharacter ℂ r) (t : ℝ) (n : ℕ) : + characterTwist (productCharacters χ ψ) t n = + characterTwist χ t n * ψ (n : ZMod r) := by + unfold characterTwist + rw [productCharacters_apply_nat] + ring + +/-- The same real twist height appears on both sides, including at primes +dividing either character modulus. -/ +lemma squaredDistance_twistByCharacter {q r : ℕ} (f : ℕ → ℂ) + (ψ : DirichletCharacter ℂ r) (χ : DirichletCharacter ℂ q) (t : ℝ) (N : ℕ) : + squaredDistance (TwoPointCorrelations.twistByCharacter f ψ) (characterTwist χ t) N = + squaredDistance f (characterTwist (productCharacters χ (conjugateCharacter ψ)) t) N := by + unfold squaredDistance + apply Finset.sum_congr rfl + intro p hp + rw [characterTwist_productCharacters] + simp only [TwoPointCorrelations.twistByCharacter, map_mul, conjugateCharacter_apply, Complex.conj_conj] + congr 2 + congr 1 + ring + +lemma UniformlyNonpretentious.twistByCharacter {r : ℕ} {f : ℕ → ℂ} + (hf : UniformlyNonpretentious f) (ψ : DirichletCharacter ℂ r) (hr : 0 < r) : + UniformlyNonpretentious (TwoPointCorrelations.twistByCharacter f ψ) := by + intro q hq χ K + filter_upwards [hf (q * r) (Nat.mul_pos hq hr) + (productCharacters χ (conjugateCharacter ψ)) K] with N hN + intro t ht + rw [squaredDistance_twistByCharacter] + exact hN t ht + +lemma OneBounded.twistByCharacter {q : ℕ} {f : ℕ → ℂ} + (hf : OneBounded f) (χ : DirichletCharacter ℂ q) : OneBounded (TwoPointCorrelations.twistByCharacter f χ) := by + intro n hn + unfold TwoPointCorrelations.twistByCharacter + rw [norm_mul] + exact (mul_le_mul (hf n hn) (χ.norm_le_one _) (norm_nonneg _) zero_le_one).trans_eq + (by norm_num) + +lemma Multiplicative.twistByCharacter {q : ℕ} {f : ℕ → ℂ} + (hf : Multiplicative f) (χ : DirichletCharacter ℂ q) : + Multiplicative (TwoPointCorrelations.twistByCharacter f χ) := by + intro m n hm hn hcop + simp only [TwoPointCorrelations.twistByCharacter, hf m n hm hn hcop, Nat.cast_mul, map_mul] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CodedWitnessFiber.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CodedWitnessFiber.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0b9c69c6bf6b36ca1220a22fe7e2e0b420a9002 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CodedWitnessFiber.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TwoPoint.Bounds.NumericalWitnessEvent +import OAI.NumberTheory.TwoPoint.Bounds.SplitWitnessSum + +namespace OAI + +/-! Actual numerical main/witness segments satisfy the fixed-code reciprocal bound. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem CrudeWordCode.witness_fiber_reciprocal_bound {R N n K M h s J : ℕ} + {supply : ℕ → ℕ → Prop} (c : CrudeWordCode R N R) + (hc : c.KindConsistent) (hi : c.RowInjective) (hRM : R ≤ M) + (mainLength : ℕ) (start len : Fin n → ℕ) (P Q : Finset ℕ) + (E : (c.tupleClasses → P) → ({z : c.usedClasses // z ∉ c.tupleClasses} → Q) → Prop) + (hE : ∀ a b, E a b → + let w := c.numericalWord (joinCoordinates c.tupleClasses + (fun i => (a i).val) (fun j => (b j).val)) + NumericalWitnessEvent (w.take mainLength) + (fun i => (w.drop (start i)).take (len i)) (fun i => (a i).val) h s J supply) + (hsize : 8 * K ≤ n) (hP : ∀ p ∈ P, p.Prime) (hV : 1 ≤ primeHarmonicMass P) + (H B : ℕ) (hH : 0 < H) (hB : 1 ≤ B) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ B) + (hdelta : (H : ℝ)⁻¹ + (1 + Real.log B) / H ≤ 1) : + (∑ b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q, + ∑ a : c.tupleClasses → P, if E a b then + (∏ i, ((a i).val : ℝ)⁻¹) * (∏ j, ((b j).val : ℝ)⁻¹) else 0) ≤ + (Fintype.card (WitnessSystemData n M c.tupleClasses) : ℝ) * + primeHarmonicMass P ^ Fintype.card c.tupleClasses * + primeHarmonicMass Q ^ Fintype.card {z : c.usedClasses // z ∉ c.tupleClasses} * + ((H : ℝ)⁻¹ + (1 + Real.log B) / H) ^ K := by + let main := fun b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q => + (c.labeledWord (fun j => (b j).val)).segment 0 mainLength + let word := fun b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q => + fun i => (c.labeledWord (fun j => (b j).val)).segment (start i) (len i) + have hm (b) : (main b).word.length ≤ M := by + dsimp [main] + rw [LabeledPrimeWord.segment_length, c.labeledWord_length] + omega + have hw (b) (i) : (word b i).word.length ≤ M := by + dsimp [word] + rw [LabeledPrimeWord.segment_length, c.labeledWord_length] + omega + apply split_witness_reciprocal_bound (h := h) (s := s) (J := J) + (supply := supply) P Q main word hsize hm hw E ?_ + hP hV H B hH hB hlo hhi hdelta + intro a b he + rw [has_resampled_witnesses_iff] + dsimp [main, word] + simp only [c.segment_resample_word hc hi, List.drop_zero] + exact hE a b he + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CommonResidueLift.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CommonResidueLift.lean new file mode 100644 index 0000000000000000000000000000000000000000..27f8e80280c947076d7ba21e35f90cc7e4e1c7ad --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CommonResidueLift.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CRTComparison +import Mathlib.RingTheory.Coprime.Lemmas + +namespace OAI + +/-! One integer realizes all coordinates of a common residue configuration. -/ + +namespace TwoPointCorrelations + +open Finset + +/-- This is a simultaneous lift of the entire configuration. It is used +after forming a hybrid, so different witness sites keep the same origin. -/ +theorem exists_common_integer_residue {ι : Type*} [Fintype ι] [DecidableEq ι] + (p : ι → ℕ) [∀ i, NeZero (p i)] + (hcop : Pairwise (fun i j => (p i).Coprime (p j))) + (r : ∀ i, ZMod (p i)) : + ∃ n : ℤ, ∀ i, (n : ZMod (p i)) = r i := by + let y : ZMod (∏ i, p i) := (ZMod.prodEquivPi p hcop).symm r + refine ⟨(y.val : ℤ), ?_⟩ + intro i + calc + ((y.val : ℤ) : ZMod (p i)) = + ZMod.prodEquivPi p hcop ((y.val : ℕ) : ZMod (∏ i, p i)) i := by + simp only [Int.cast_natCast, ZMod.prodEquivPi_apply, map_natCast] + _ = ZMod.prodEquivPi p hcop y i := by rw [ZMod.natCast_zmod_val] + _ = r i := congrFun ((ZMod.prodEquivPi p hcop).apply_symm_apply r) i + +/-- Prime divisibility at any offset is read from that same lifted origin. -/ +lemma residue_offset_divisibility {p : ℕ} (r : ZMod p) (n offset : ℤ) + (hn : (n : ZMod p) = r) : + (p : ℤ) ∣ n + offset ↔ r = -(offset : ZMod p) := by + rw [← ZMod.intCast_zmod_eq_zero_iff_dvd, Int.cast_add, hn, add_eq_zero_iff_eq_neg] + +/-- The conjunction of all prime-power coordinate tests is exactly +divisibility by their product. No independence across sites is required. -/ +lemma residue_product_divisibility {ι : Type*} [Fintype ι] [DecidableEq ι] + (p : ι → ℕ) (hcop : Pairwise (fun i j => (p i).Coprime (p j))) + (r : ∀ i, ZMod (p i)) (n offset : ℤ) (hn : ∀ i, (n : ZMod (p i)) = r i) + (S : Finset ι) : + ((∏ i ∈ S, p i : ℕ) : ℤ) ∣ n + offset ↔ + ∀ i ∈ S, r i = -(offset : ZMod (p i)) := by + rw [Nat.cast_prod] + constructor + · intro hd i hi + apply (residue_offset_divisibility (r i) n offset (hn i)).mp + exact (dvd_prod_of_mem (fun j => (p j : ℤ)) hi).trans hd + · intro ht + apply prod_dvd_of_coprime + · intro i _ j _ hij + exact (hcop hij).cast (R := ℤ) + · intro i hi + exact (residue_offset_divisibility (r i) n offset (hn i)).mpr (ht i hi) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComparisonRelationSelection.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComparisonRelationSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..364ab6bce9b3dee23c4ae1d7a791135d19df9304 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComparisonRelationSelection.lean @@ -0,0 +1,158 @@ +import OAI.NumberTheory.TwoPoint.Walks.WordRelations + +namespace OAI + +/-! Exact triangular comparison systems selected from positive witness words. -/ + +namespace TwoPointCorrelations + +open Finset + +/-- Earlier partners give a comparison system ordered by increasing +attachment, with the actual private labels as selected variables. -/ +theorem select_earlier_comparison_relations {n h : ℕ} {ι : Type*} [DecidableEq ι] + (main : LabeledPrimeWord ι) (word : Fin n → LabeledPrimeWord ι) + (value : ι → ℕ) (hinj : Function.Injective value) (hprime : ∀ j, (value j).Prime) + (hm : main.Realizes value) (hw : ∀ i, (word i).Realizes value) + (hsq : ∀ i t, t ∈ (word i).word → Squarefree t.tuple) + (mark : Fin n → ι) (attachment position : Fin n → ℕ) + (horder : Monotone attachment) (hbound : ∀ i, attachment i ≤ main.word.length) + (hprivate : ∀ i j, j ≠ i → value (mark i) ∉ wordPrimeSupport (word j).word) + (hmain : ∀ i v, TuplePrimeAt main.word (value (mark i)) v → v = position i) + (x : ℤ) (hpositive : ∀ i, PositiveWord h (x + wordDisplacement h + (main.word.take (attachment i))) (word i).word) + (R : Finset (Fin n)) (partner : R → Fin n) (hpartner : ∀ i, partner i < i.val) + (ri rj prime : R → ℕ) (hpos : ∀ i : R, attachment i ≤ position i) + (hocc : ∀ i : R, TuplePrimeAt (word i).word (prime i) (ri i)) + (hocc' : ∀ i : R, TuplePrimeAt (word (partner i)).word (prime i) (rj i)) + (hnonzero : ∀ i : R, ¬(prime i : ℤ) ∣ + wordPrimeContribution h (word i).word (value (mark i)) 0 (ri i)) : + ∃ control : R → ι, + (∀ i : R, value (control i) = prime i ∧ control i ≠ mark i ∧ + primeRelationEvent + (comparisonRelation main (word i) (word (partner i)) h + (attachment (partner i)) (attachment i) (ri i) (rj i)) + (mark i) (control i) (fun z => (value z : ℤ))) ∧ + ∀ i j : R, i.val < j.val → + mark j ∉ primeRelationSupport + (comparisonRelation main (word i) (word (partner i)) h + (attachment (partner i)) (attachment i) (ri i) (rj i)) ∧ + control i ≠ mark j := by + classical + have hc (i : R) : ∃ c : ι, value c = prime i := by + obtain ⟨c, _, hc⟩ := (word i).occurrence_has_label value hprime (hw i) (prime i) + ⟨ri i, (hocc i).index_lt⟩ (hocc i) + exact ⟨c, hc⟩ + choose control hcontrol using hc + have hshared (i : R) : ∀ k, prime i ≠ value (mark k) := by + apply shared_prime_ne_private (fun i => (word i).word) (fun i => value (mark i)) hprivate + (ne_of_gt (hpartner i)) + · exact (mem_wordPrimeSupport_iff _ _ (hsq i)).mpr ⟨ri i, hocc i⟩ + · exact (mem_wordPrimeSupport_iff _ _ (hsq (partner i))).mpr ⟨rj i, hocc' i⟩ + refine ⟨control, ?_, ?_⟩ + · intro i + refine ⟨hcontrol i, ?_, ?_⟩ + · intro heq + exact hshared i i (by simpa only [heq] using (hcontrol i).symm) + · apply comparisonRelation_event main (word i) (word (partner i)) h + (attachment (partner i)) (attachment i) (ri i) (rj i) value hinj hprime hm + (hw i) (hw (partner i)) (hbound i) (horder (hpartner i).le) x + (mark i) (control i) (hpositive i) (hpositive (partner i)) + (by simpa only [hcontrol i] using hocc i) + (by simpa only [hcontrol i] using hocc' i) + rw [earlier_comparison_private_contribution main.word (fun i => (word i).word) + (fun i => value (mark i)) attachment position hsq hprivate hmain + (hpartner i) (hpos i) (ri i) (rj i)] + simpa only [hcontrol i] using hnonzero i + · intro i j hij + have he := earlier_comparison_excludes_later (fun i => (word i).word) + (fun i => value (mark i)) attachment position horder hprivate (hpartner i) hij (hpos j) + constructor + · apply comparisonRelation_not_mem main (word i) (word (partner i)) h + (attachment (partner i)) (attachment i) (ri i) (rj i) value hinj hprime hm + (hw i) (hw (partner i)) (mark j) + · intro r har hri hpr + exact he.2.2 r (mem_Ico.mpr ⟨har, hri⟩) (hmain j r hpr) + · intro r hpr + exact he.1 ((mem_wordPrimeSupport_iff _ _ (hsq i)).mpr ⟨r, hpr⟩) + · intro r hpr + exact he.2.1 ((mem_wordPrimeSupport_iff _ _ (hsq (partner i))).mpr ⟨r, hpr⟩) + · intro heq + exact hshared i j (by simpa only [heq] using (hcontrol i).symm) + +/-- Later partners give the same system in the reverse witness order. +The selected contribution changes sign, which preserves nondivisibility. -/ +theorem select_later_comparison_relations {n h : ℕ} {ι : Type*} [DecidableEq ι] + (main : LabeledPrimeWord ι) (word : Fin n → LabeledPrimeWord ι) + (value : ι → ℕ) (hinj : Function.Injective value) (hprime : ∀ j, (value j).Prime) + (hm : main.Realizes value) (hw : ∀ i, (word i).Realizes value) + (hsq : ∀ i t, t ∈ (word i).word → Squarefree t.tuple) + (mark : Fin n → ι) (attachment position : Fin n → ℕ) + (horder : Monotone attachment) (hbound : ∀ i, attachment i ≤ main.word.length) + (hprivate : ∀ i j, j ≠ i → value (mark i) ∉ wordPrimeSupport (word j).word) + (hmain : ∀ i v, TuplePrimeAt main.word (value (mark i)) v → v = position i) + (x : ℤ) (hpositive : ∀ i, PositiveWord h (x + wordDisplacement h + (main.word.take (attachment i))) (word i).word) + (R : Finset (Fin n)) (partner : R → Fin n) (hpartner : ∀ i, i.val < partner i) + (ri rj prime : R → ℕ) (hpos : ∀ i : R, position i < attachment i) + (hocc : ∀ i : R, TuplePrimeAt (word i).word (prime i) (ri i)) + (hocc' : ∀ i : R, TuplePrimeAt (word (partner i)).word (prime i) (rj i)) + (hnonzero : ∀ i : R, ¬(prime i : ℤ) ∣ + wordPrimeContribution h (word i).word (value (mark i)) 0 (ri i)) : + ∃ control : R → ι, + (∀ i : R, value (control i) = prime i ∧ control i ≠ mark i ∧ + primeRelationEvent + (comparisonRelation main (word (partner i)) (word i) h + (attachment i) (attachment (partner i)) (rj i) (ri i)) + (mark i) (control i) (fun z => (value z : ℤ))) ∧ + ∀ i j : R, j.val < i.val → + mark j ∉ primeRelationSupport + (comparisonRelation main (word (partner i)) (word i) h + (attachment i) (attachment (partner i)) (rj i) (ri i)) ∧ + control i ≠ mark j := by + classical + have hc (i : R) : ∃ c : ι, value c = prime i := by + obtain ⟨c, _, hc⟩ := (word i).occurrence_has_label value hprime (hw i) (prime i) + ⟨ri i, (hocc i).index_lt⟩ (hocc i) + exact ⟨c, hc⟩ + choose control hcontrol using hc + have hshared (i : R) : ∀ k, prime i ≠ value (mark k) := by + apply shared_prime_ne_private (fun i => (word i).word) (fun i => value (mark i)) hprivate + (ne_of_lt (hpartner i)) + · exact (mem_wordPrimeSupport_iff _ _ (hsq i)).mpr ⟨ri i, hocc i⟩ + · exact (mem_wordPrimeSupport_iff _ _ (hsq (partner i))).mpr ⟨rj i, hocc' i⟩ + refine ⟨control, ?_, ?_⟩ + · intro i + refine ⟨hcontrol i, ?_, ?_⟩ + · intro heq + exact hshared i i (by simpa only [heq] using (hcontrol i).symm) + · apply comparisonRelation_event main (word (partner i)) (word i) h + (attachment i) (attachment (partner i)) (rj i) (ri i) value hinj hprime hm + (hw (partner i)) (hw i) (hbound (partner i)) (horder (hpartner i).le) x + (mark i) (control i) (hpositive (partner i)) (hpositive i) + (by simpa only [hcontrol i] using hocc' i) + (by simpa only [hcontrol i] using hocc i) + rw [later_comparison_private_contribution main.word (fun i => (word i).word) + (fun i => value (mark i)) attachment position hsq hprivate hmain + (hpartner i) (hpos i) (ri i) (rj i)] + rw [dvd_neg] + simpa only [hcontrol i] using hnonzero i + · intro i j hji + have he := later_comparison_excludes_earlier (fun i => (word i).word) + (fun i => value (mark i)) attachment position horder hprivate (hpartner i) hji (hpos j) + constructor + · apply comparisonRelation_not_mem main (word (partner i)) (word i) h + (attachment i) (attachment (partner i)) (rj i) (ri i) value hinj hprime hm + (hw (partner i)) (hw i) (mark j) + · intro r har hri hpr + exact he.2.2 r (mem_Ico.mpr ⟨har, hri⟩) (hmain j r hpr) + · intro r hpr + exact he.2.1 ((mem_wordPrimeSupport_iff _ _ (hsq (partner i))).mpr ⟨r, hpr⟩) + · intro r hpr + exact he.1 ((mem_wordPrimeSupport_iff _ _ (hsq i)).mpr ⟨r, hpr⟩) + · intro heq + exact hshared i j (by simpa only [heq] using (hcontrol i).symm) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexBinGeometry.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexBinGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..4dc28fccd9f74af1d50ddd68d73d093d4cbfc123 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexBinGeometry.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.TwoPoint.Walks.CanonicalComplexBin +import OAI.NumberTheory.TwoPoint.Bounds.BinCutoffGeometry + +namespace OAI + +/-! A literal logarithmic bin supplies the integer short range used by five-color orientation. -/ + +namespace TwoPointCorrelations + +noncomputable def logBinStep (h : ℕ) (η : ℝ) (j : ℤ) : ℤ := + ⌈(h : ℝ) * Real.exp ((j : ℝ) * η)⌉ + +lemma logBinStep_pos (h : ℕ) (hh : 0 < h) (η : ℝ) (j : ℤ) : + 0 < logBinStep h η j := by + apply Int.ceil_pos.mpr + exact mul_pos (by exact_mod_cast hh) (Real.exp_pos _) + +lemma actualPaddingBin_short_shift (h d q : ℕ) (hh : 0 < h) (hd : 0 < d) (hq : 0 < q) + (η : ℝ) (hη : Real.exp η < 2) (j : ℤ) + (hb : actualPaddingBin η (Real.log d) j q) : + logBinStep h η j ≤ (h * q * d : ℕ) ∧ + (h * q * d : ℕ) < 2 * logBinStep h η j := by + have hdR : (0 : ℝ) < d := by exact_mod_cast hd + have hqR : (0 : ℝ) < q := by exact_mod_cast hq + have hhR : (0 : ℝ) < h := by exact_mod_cast hh + have hlog : Real.log (d * q : ℕ) = Real.log q + Real.log d := by + rw [Nat.cast_mul, Real.log_mul hdR.ne' hqR.ne'] + ring + have hp : (0 : ℝ) < (d * q : ℕ) := by exact_mod_cast Nat.mul_pos hd hq + have hlo : Real.exp ((j : ℝ) * η) ≤ (d * q : ℕ) := by + rw [← Real.exp_log hp] + exact Real.exp_le_exp.mpr (by rw [hlog]; exact hb.1) + have hhi : (d * q : ℕ) < Real.exp ((j : ℝ) * η) * Real.exp η := by + rw [← Real.exp_add] + calc + _ = Real.exp (Real.log (d * q : ℕ)) := (Real.exp_log hp).symm + _ < _ := Real.exp_lt_exp.mpr (by rw [hlog]; nlinarith [hb.2]) + have hc : (h : ℝ) * Real.exp ((j : ℝ) * η) ≤ (logBinStep h η j : ℝ) := + Int.le_ceil _ + constructor + · apply Int.ceil_le.mpr + push_cast + have he := mul_le_mul_of_nonneg_left hlo hhR.le + push_cast at he + nlinarith + · have he := mul_lt_mul_of_pos_left hhi hhR + have hex := mul_lt_mul_of_pos_left hη (Real.exp_pos ((j : ℝ) * η)) + have hexh := mul_lt_mul_of_pos_left hex hhR + have hr : ((h * q * d : ℕ) : ℝ) < 2 * (logBinStep h η j : ℝ) := by + push_cast at he ⊢ + nlinarith + exact_mod_cast hr + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexBinSummation.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexBinSummation.lean new file mode 100644 index 0000000000000000000000000000000000000000..97e9a19d802df00ed22a2a7ffb151e04cba012d9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexBinSummation.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexBinGeometry +import OAI.NumberTheory.TwoPoint.Walks.CanonicalRetainedMass +import OAI.NumberTheory.TwoPoint.Walks.RetainedBinSummation + +namespace OAI + +/-! Sum arbitrary complex directed bins against their actual reciprocal divisor mass. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def canonicalComplexPrefix (h : ℕ) (E : Finset ℕ) (W L : ℝ) + (eligible : ℕ → ℕ → Prop) (hL : 1 ≤ L) (hW : 1 ≤ W) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) (F G : ℤ → ℂ) (N : ℕ) : ℂ := + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let active := fun d q => (d, q) ∈ data.pairs + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ active z + retainedComplexPrefix P Q Qp actualPaddingCoefficient active L (Real.exp (4 * J)) W + (fun _ => actualPaddingDegreeCut Qp L) h (fun _ _ _ => True) keep F G N + +theorem ModFiveThetaInput.eventually_canonical_complex_bin_sum + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ + ∀ (h : ℕ) (_hh : 0 < h) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) (W : ℝ) (hW : 1 ≤ W), + ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → Real.exp η < 2 → + ∀ (bins : Finset ℤ) (eligible : ℤ → ℕ → ℕ → Prop), + (∀ j ∈ bins, ∀ d q, eligible j d q → PaddingPairEligible L η d q) → + (∀ j ∈ bins, ∀ d q, eligible j d q → 0 < d ∧ 0 < q) → + (∀ j ∈ bins, ∀ d q, eligible j d q → actualPaddingBin η (Real.log d) j q) → + ∀ (F G : ℤ → ℂ), (∀ n, ‖F n‖ ≤ 1) → (∀ n, ‖G n‖ ≤ 1) → + ∀ (N : ℤ → ℕ) (v : ℤ → ℂ), + (∀ j ∈ bins, Real.exp (L ^ A / 2) ≤ (N j : ℝ)) → + (∀ j ∈ bins, ‖v j‖ ≤ 1) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let R := Real.exp 1 * (2 * (Real.exp (4 * J) * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + ‖∑ j ∈ bins, v j * canonicalComplexPrefix h E W L (eligible j) hL hW hE F G (N j)‖ / + totalPaddingBinMass (primeTupleDivisors P) (paddingPrimeSupply E L) L η ≤ + (480 * bins.card / L) * (R / W ^ J) + 480 * bins.card * Real.exp (-L) := by + obtain ⟨A, hA, hb⟩ := hprime.eventually_canonical_complex_bin hBr + refine ⟨A, hA, ?_⟩ + intro h hh E hE W hW + filter_upwards [hb h hh E hE W hW, hprime.eventually_canonical_retained_mass E W hW] + with L hb hm + intro hL η hη hηone hηtwo bins eligible he hpos hbin F G hF hG N v hN hv + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let S := paddingTiltNormalizer (paddingPrimeSupply E L) + let V := ∏ j, primeHarmonicMass (P j) + let R := Real.exp 1 * (2 * (Real.exp (4 * J) * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + have hmass := hm hL η hη + have hbound (j : ℤ) (hj : j ∈ bins) : + ‖v j * canonicalComplexPrefix h E W L (eligible j) hL hW hE F G (N j)‖ ≤ + 3 * (1 : ℝ) ^ 2 * S * (80 * R) / L + 3 * (80 * Real.exp (-L)) := by + have hs : ∀ d q, eligible j d q → + logBinStep h η j ≤ (h * q * d : ℕ) ∧ + (h * q * d : ℕ) < 2 * logBinStep h η j := by + intro d q hdq + exact actualPaddingBin_short_shift h d q hh (hpos j hj d q hdq).1 + (hpos j hj d q hdq).2 η hηtwo j (hbin j hj d q hdq) + have ht := hb hL η hη hηone (eligible j) (he j hj) + (logBinStep h η j) (logBinStep_pos h hh η j) hs F G hF hG (N j) (hN j hj) + have hnorm : ‖v j * canonicalComplexPrefix h E W L (eligible j) hL hW hE F G (N j)‖ ≤ + ‖canonicalComplexPrefix h E W L (eligible j) hL hW hE F G (N j)‖ := by + rw [norm_mul] + exact mul_le_of_le_one_left (norm_nonneg _) (hv j hj) + have hval : ‖canonicalComplexPrefix h E W L (eligible j) hL hW hE F G (N j)‖ ≤ + 240 * S * R / L + 240 * Real.exp (-L) := ht + apply (hnorm.trans hval).trans_eq + ring + have hr := retained_bin_sum_mass_lower bins + (fun j => v j * canonicalComplexPrefix h E W L (eligible j) hL hW hE F G (N j)) + S V (totalPaddingBinMass (primeTupleDivisors P) (paddingPrimeSupply E L) L η) + L 1 (80 * R) (80 * Real.exp (-L)) W J (paddingTiltNormalizer_one_le _) hW + hmass.1 (by linarith) hmass.2 (by positivity) (by positivity) hbound + convert hr using 1; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexBinWindows.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexBinWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..6949f9fb7540e977a7d355bd966b293de27dd3bf --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexBinWindows.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.TwoPoint.Walks.CanonicalPartialWindows + +namespace OAI + +/-! Enlarging a closed-low logarithmic bin by one bin on its left gives +the strict-low convention in the rough-shift theorem. -/ + +namespace TwoPointCorrelations + +noncomputable def enlargedBinStart (η : ℝ) (j : ℤ) (u : ℕ) : ℝ := + Real.exp (((j : ℝ) - 1) * η) / (u : ℝ) + +lemma enlargedBinStart_pos (η : ℝ) (j : ℤ) (u : ℕ) (hu : 0 < u) : + 0 < enlargedBinStart η j u := + div_pos (Real.exp_pos _) (by exact_mod_cast hu) + +lemma enlarged_partial_bin_window (q t z : ℕ) (hq : 0 < q) (ht : 0 < t) (hz : 0 < z) + (η : ℝ) (hη : 0 < η) (j : ℤ) + (hbin : actualPaddingBin η (Real.log (t * z : ℕ)) j q) : + enlargedBinStart η j (q * t) < (z : ℝ) ∧ + (z : ℝ) ≤ Real.exp (2 * η) * enlargedBinStart η j (q * t) := by + have hw := partial_bin_window q t z hq ht hz η j hbin + have hup : (0 : ℝ) < (q * t : ℕ) := by exact_mod_cast Nat.mul_pos hq ht + have hl : enlargedBinStart η j (q * t) < + Real.exp ((j : ℝ) * η) / (q * t : ℕ) := by + apply div_lt_div_of_pos_right _ hup + exact Real.exp_lt_exp.mpr (by linarith) + refine ⟨hl.trans_le hw.1, hw.2.trans_eq ?_⟩ + unfold enlargedBinStart + rw [← mul_div_assoc, ← mul_div_assoc] + congr 1 + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + +lemma enlargedBinStart_upper (η : ℝ) (hη : 0 ≤ η) (j : ℤ) (u : ℕ) (hu : 0 < u) + (U : ℝ) (hU : Real.exp ((j : ℝ) * η) ≤ U) : enlargedBinStart η j u ≤ U := by + have hu1 : (1 : ℝ) ≤ u := by exact_mod_cast hu + calc + _ ≤ Real.exp (((j : ℝ) - 1) * η) := + div_le_self (Real.exp_pos _).le hu1 + _ ≤ Real.exp ((j : ℝ) * η) := Real.exp_le_exp.mpr (by nlinarith) + _ ≤ U := hU + +lemma rough_bin_forces_start_lower {H M τ z : ℝ} (hτ : 0 < τ) + (hz : H ≤ z) (hupper : z ≤ τ * M) : H / τ ≤ M := by + apply (div_le_iff₀ hτ).mpr + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexBlockTesting.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexBlockTesting.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d43a62972e1843fa943dc14966dfd4606080911 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexBlockTesting.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.TwoPoint.Walks.RetainedComplexRows +import OAI.NumberTheory.TwoPoint.Bounds.ActualBilinearTesting + +namespace OAI + +/-! Ten actual compressed-graph tests control each directed complex block. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def ambientComplexBlockTest {J : ℕ} (P : Fin J → Finset ℕ) + (M : ℕ) (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (keep : ℤ → Prop) (F G : ℤ → ℂ) (t : ℕ) : ℂ := + let c : ℤ := (t + 2 : ℕ) + let vf := paddingTestVector Qp L (fun i : Fin M => (i.val : ℤ) + c) (fun n => star (F n)) + let vg := paddingTestVector Qp L (fun i : Fin M => (i.val : ℤ) + c) G + inner ℂ vf (primeBlockCompression P M Q u eligible (actualPaddingVertex Qp) + L K W extra h (fun d n m => gate d (n + c) (m + c)) keep c vg) + +lemma retainedComplexBlock_ten_tests {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (M : ℕ) (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (hgate : ∀ d n m, gate d n m ↔ gate d m n) + (keep : ℤ → Prop) (D : ℤ) (hD : 0 < D) + (hshift : ∀ d : (j : Fin J) → P j, ∀ q ∈ Q, eligible (∏ j, (d j).val) q → + D ≤ (h * q * ∏ j, (d j).val : ℕ) ∧ (h * q * ∏ j, (d j).val : ℕ) < 2 * D) + (F G : ℤ → ℂ) (t : ℕ) : + retainedComplexBlock P M Q Qp u eligible L K W extra h gate keep F G t = + ∑ c : ForwardColorCode, ambientComplexBlockTest P M Q Qp u eligible L K W extra h + gate keep (fun n => if sourceColor D c n then F n else 0) + (fun n => if targetColor D c n then G n else 0) t := by + have hg : ∀ d (i j : Fin M), + (gate d ((i.val : ℤ) + (t + 2 : ℕ)) ((j.val : ℤ) + (t + 2 : ℕ)) ∧ + keep ((i.val : ℤ) + (t + 2 : ℕ)) ∧ keep ((j.val : ℤ) + (t + 2 : ℕ))) ↔ + (gate d ((j.val : ℤ) + (t + 2 : ℕ)) ((i.val : ℤ) + (t + 2 : ℕ)) ∧ + keep ((j.val : ℤ) + (t + 2 : ℕ)) ∧ keep ((i.val : ℤ) + (t + 2 : ℕ))) := by + intro d i j + rw [hgate] + tauto + have hi := projected_prime_directed_identity P hprime hdisjoint + (fun i : Fin M => (i.val : ℤ) + (t + 2 : ℕ)) Q Qp u eligible L K W extra h + (fun d i j => gate d ((i.val : ℤ) + (t + 2 : ℕ)) ((j.val : ℤ) + (t + 2 : ℕ)) ∧ + keep ((i.val : ℤ) + (t + 2 : ℕ)) ∧ keep ((j.val : ℤ) + (t + 2 : ℕ))) hg D hD hshift F G + exact hi + +lemma uniformAverage_norm_sum_le {C Ω : Type*} [Fintype C] [Fintype Ω] + (T : C → Ω → ℂ) (B : ℝ) (hT : ∀ c, uniformAverage (fun x => ‖T c x‖) ≤ B) : + uniformAverage (fun x => ‖∑ c, T c x‖) ≤ Fintype.card C * B := by + calc + _ ≤ uniformAverage (fun x => ∑ c, ‖T c x‖) := by + unfold uniformAverage + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + exact sum_le_sum (fun x _ => norm_sum_le _ _) + _ = ∑ c, uniformAverage (fun x => ‖T c x‖) := by + unfold uniformAverage + rw [sum_comm, sum_div] + _ ≤ ∑ _c : C, B := sum_le_sum (fun c _ => hT c) + _ = _ := by simp + +lemma retainedComplexBlock_average_le {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (M N : ℕ) (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (hgate : ∀ d n m, gate d n m ↔ gate d m n) + (keep : ℤ → Prop) (D : ℤ) (hD : 0 < D) + (hshift : ∀ d : (j : Fin J) → P j, ∀ q ∈ Q, eligible (∏ j, (d j).val) q → + D ≤ (h * q * ∏ j, (d j).val : ℕ) ∧ (h * q * ∏ j, (d j).val : ℕ) < 2 * D) + (F G : ℤ → ℂ) (B : ℝ) + (htest : ∀ c : ForwardColorCode, uniformAverage (fun t : Fin N => + ‖ambientComplexBlockTest P M Q Qp u eligible L K W extra h gate keep + (fun n => if sourceColor D c n then F n else 0) + (fun n => if targetColor D c n then G n else 0) t.val‖) ≤ B) : + uniformAverage (fun t : Fin N => + ‖retainedComplexBlock P M Q Qp u eligible L K W extra h gate keep F G t.val‖) ≤ + 10 * B := by + simp_rw [retainedComplexBlock_ten_tests P hprime hdisjoint M Q Qp u eligible L K W + extra h gate hgate keep D hD hshift F G] + have hb := uniformAverage_norm_sum_le _ B htest + simpa [ForwardColorCode] using hb + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexCanonicalDeletion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexCanonicalDeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..37c6201db5e95f996ddf692c150148e568490785 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexCanonicalDeletion.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexBinSummation +import OAI.NumberTheory.TwoPoint.Bounds.ComplexDeletionPrefix +import OAI.NumberTheory.TwoPoint.Walks.CanonicalCorrelationDeletion + +namespace OAI + +/-! The actual complex uncut correlation is controlled by the existing two endpoint costs. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def canonicalComplexUncutPrefix (h : ℕ) (E : Finset ℕ) (W L : ℝ) + (eligible : ℕ → ℕ → Prop) (F G : ℤ → ℂ) (N : ℕ) : ℂ := + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let R := boundedPaddingDivisors (paddingPrimeSupply E L) ⌊100 * Real.log L⌋₊ + untwistedUncutPrefix P R eligible h (fun _ _ _ => True) F G N + +lemma canonical_complex_uncut_sub_retained_prefix (h : ℕ) (E : Finset ℕ) + (W L η : ℝ) (hL : 1 ≤ L) (hW : 1 ≤ W) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (c : ℕ → ℝ) (eligible : ℤ → ℕ → ℕ → Prop) (j : ℤ) (N : ℕ) + (F G : ℤ → ℂ) (hF : ∀ n, ‖F n‖ ≤ 1) (hG : ∀ n, ‖G n‖ ≤ 1) + (hbin : ∀ d q, eligible j d q → actualPaddingBin η (c d) j q) : + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + let R := boundedPaddingDivisors Q ⌊100 * Real.log L⌋₊ + let bad := fun k n => ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ (canonicalTraceFamily h E W L (eligible k) hL hW hE).pairs) n + ‖canonicalComplexUncutPrefix h E W L (eligible j) F G N - + canonicalComplexPrefix h E W L (eligible j) hL hW hE F G N‖ ≤ + (∑ d ∈ primeTupleDivisors P, ∑ q ∈ R, + uniformAverage (fun x : Fin N => positiveDeletionAtom (primeTuplePool P) Q R + η c L (Real.exp (4 * J)) W eligible bad j d q ((x.val + 1 : ℕ) : ℤ))) + + (∑ d ∈ primeTupleDivisors P, ∑ q ∈ R, + uniformAverage (fun x : Fin N => positiveDeletionAtom (primeTuplePool P) Q R + η c L (Real.exp (4 * J)) W eligible bad j d q + (((x.val + 1 : ℕ) : ℤ) + (h * q * d : ℕ)))) := by + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + let R := boundedPaddingDivisors Q ⌊100 * Real.log L⌋₊ + let bad := fun k n => ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ (canonicalTraceFamily h E W L (eligible k) hL hW hE).pairs) n + let active := fun d q => (d, q) ∈ (canonicalTraceFamily h E W L (eligible j) hL hW hE).pairs + have hp : ∀ i, ∀ p ∈ P i, p.Prime := centeredPrimeBands_prime _ _ _ _ + have hd : ∀ i k, k ≠ i → Disjoint (P i) (P k) := centeredPrimeBands_disjoint _ _ _ _ + (Real.rpow_nonneg (zero_le_one.trans hL) _) (zero_le_one.trans hW) + have hcongr := untwistedRetainedPrefix_congr_eligible P R Q actualPaddingCoefficient + active (eligible j) L (Real.exp (4 * J)) W (fun _ => actualPaddingDegreeCut Q L) + h (fun _ _ _ => True) (fun z => ¬bad j z) F G N + (fun d hd q hq => canonicalTraceFamily_pair_on_pool h E W L (eligible j) hL hW hE d q hd hq) + change ‖untwistedUncutPrefix P R (eligible j) h (fun _ _ _ => True) F G N - + retainedComplexPrefix P R Q actualPaddingCoefficient active L (Real.exp (4 * J)) W + (fun _ => actualPaddingDegreeCut Q L) h (fun _ _ _ => True) + (fun z => ¬bad j z) F G N‖ ≤ _ + rw [retainedComplexPrefix_eq_numerical P hp hd R Q actualPaddingCoefficient active + L (Real.exp (4 * J)) W (fun _ => actualPaddingDegreeCut Q L) h (fun _ _ _ => True) + (fun z => ¬bad j z) F G N (by linarith), hcongr] + exact complex_uncut_sub_retained_prefix_le P hp hd R Q η c L (Real.exp (4 * J)) W + eligible h (fun _ _ _ => True) bad j N F G hF hG (fun d _ q _ => hbin d q) + +lemma canonical_complex_weighted_correlation_deletion (h : ℕ) (E : Finset ℕ) + (W L η : ℝ) (hL : 1 ≤ L) (hW : 1 ≤ W) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) (bins : Finset ℤ) + (c : ℕ → ℝ) (eligible : ℤ → ℕ → ℕ → Prop) (N : ℤ → ℕ) (v : ℤ → ℂ) + (F G : ℤ → ℂ) (hF : ∀ n, ‖F n‖ ≤ 1) (hG : ∀ n, ‖G n‖ ≤ 1) + (hbin : ∀ j ∈ bins, ∀ d q, eligible j d q → actualPaddingBin η (c d) j q) + (hv : ∀ j ∈ bins, ‖v j‖ ≤ 1) : + ‖(∑ j ∈ bins, v j * canonicalComplexUncutPrefix h E W L (eligible j) F G (N j)) - + (∑ j ∈ bins, v j * canonicalComplexPrefix h E W L (eligible j) hL hW hE F G (N j))‖ ≤ + canonicalShiftedSourceDeletion h E W L η (Real.exp (4 * primeSupplyCount W L)) + hL hW hE bins c eligible (fun _ _ _ => 0) (fun _ => 1) N + + canonicalShiftedSourceDeletion h E W L η (Real.exp (4 * primeSupplyCount W L)) + hL hW hE bins c eligible (fun _ d q => (h * q * d : ℕ)) (fun _ => 1) N := by + rw [← sum_sub_distrib] + simp_rw [← mul_sub] + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ j ∈ bins, ‖canonicalComplexUncutPrefix h E W L (eligible j) F G (N j) - + canonicalComplexPrefix h E W L (eligible j) hL hW hE F G (N j)‖ := by + apply sum_le_sum + intro j hj + rw [norm_mul] + simpa only [one_mul] using mul_le_mul_of_nonneg_right (hv j hj) (norm_nonneg _) + _ ≤ ∑ j ∈ bins, _ := sum_le_sum (fun j hj => + canonical_complex_uncut_sub_retained_prefix h E W L η hL hW hE c eligible j (N j) F G hF hG (hbin j hj)) + _ = _ := by + simp only [canonicalShiftedSourceDeletion, Nat.cast_one, prefix_start_one_add, + sum_add_distrib, add_zero] + + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexCenteredBridge.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexCenteredBridge.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6468b6b982f252b75bc3b0f12bc9e3a7c9aa6a2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexCenteredBridge.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexCanonicalDeletion +import OAI.NumberTheory.TwoPoint.Bounds.ComplexCenteringSum +import OAI.NumberTheory.TwoPoint.Bounds.ComplexPartialProfiles +import OAI.NumberTheory.TwoPoint.Bounds.CenteredBinIdentity + +namespace OAI + +/-! The uncut complex graph is the literal centered tuple correlation. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma untwistedUncutPrefix_centered {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (Q : Finset ℕ) (eligible : ℕ → ℕ → Prop) (h N : ℕ) (F G : ℕ → ℂ) : + untwistedUncutPrefix P Q eligible h (fun _ _ _ => True) + (fun z => F z.toNat) (fun z => G z.toNat) N = + positivePrefix (fun n => ∑ q ∈ Q, (actualPaddingCoefficient q : ℂ) * + tupleComplexCenteredProfile P q eligible F G h n) N / (N : ℂ) := by + unfold untwistedUncutPrefix + congr 1 + unfold positivePrefix + apply sum_congr rfl + intro n _ + dsimp only + rw [primeTupleDivisors, sum_image] + · rw [sum_comm] + apply sum_congr rfl + intro q hq + simp only [tupleComplexCenteredProfile, mul_sum] + apply sum_congr rfl + intro x _ + rw [uncutNumericalEdge_untwist Q eligible h (fun _ _ _ => True) + (fun z => F z.toNat) (fun z => G z.toNat) (∏ j, (x j).val) q + (n + 1 : ℕ) _ (by omega) (by positivity)] + simp only [true_and, hq, Int.toNat_natCast, and_true, + Int.natCast_dvd_natCast, Complex.ofReal_mul] + have hm : ((n + 1 : ℕ) : ℤ) + (h * q * ∏ j, (x j).val : ℕ) = + ((n + 1 + h * (q * ∏ j, (x j).val) : ℕ) : ℤ) := by push_cast; ring + rw [hm] + simp only [Int.toNat_natCast] + unfold natDivisibilityIndicator + split_ifs <;> simp_all + ring + · intro x _ y _ hxy + exact primeTuple_injective hprime hdisjoint hxy + +lemma tupleComplexPartialProfile_empty {J : ℕ} (P : Fin J → Finset ℕ) + (q : ℕ) (eligible : ℕ → ℕ → Prop) (F G : ℕ → ℂ) (h n : ℕ) : + tupleComplexPartialProfile P ∅ q eligible F G h n = + ∑ x : (j : Fin J) → P j, + if eligible (∏ j, (x j).val) q then + natDivisibilityIndicator (q * ∏ j, (x j).val) n * + (F n * G (n + h * (q * ∏ j, (x j).val))) + else 0 := by + unfold tupleComplexPartialProfile + apply sum_congr rfl + intro x _ + have he : (∏ j : {j // j ∉ (∅ : Finset (Fin J))}, (x j).val) = + ∏ j, (x j).val := (prod_subtype univ (by simp) (fun j => (x j).val)).symm + simp only [Fintype.prod_empty, Nat.cast_one, inv_one, one_mul, he] + +noncomputable def fullComplexBin {J : ℕ} (P : Fin J → Finset ℕ) + (Q : Finset ℕ) (eligible : ℕ → ℕ → Prop) (F G : ℕ → ℂ) (h : ℕ) (T : ℝ) : ℂ := + ∑ q ∈ Q, (actualPaddingCoefficient q : ℂ) * + (positivePrefix (tupleComplexPartialProfile P ∅ q eligible F G h) ⌊T⌋₊ / (T : ℂ)) + +noncomputable def nonrawComplexBin {J : ℕ} (P : Fin J → Finset ℕ) + (Q : Finset ℕ) (eligible : ℕ → ℕ → Prop) (F G : ℕ → ℂ) (h : ℕ) (T : ℝ) : ℂ := + ∑ q ∈ Q, (actualPaddingCoefficient q : ℂ) * + ((positivePrefix (tupleComplexCenteredProfile P q eligible F G h) ⌊T⌋₊ - + positivePrefix (tupleComplexPartialProfile P ∅ q eligible F G h) ⌊T⌋₊) / (T : ℂ)) + +lemma weighted_complex_uncut_sub_full {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (Q : Finset ℕ) (eligible : ℕ → ℕ → Prop) (F G : ℕ → ℂ) (h : ℕ) (T : ℝ) : + ((⌊T⌋₊ : ℂ) / (T : ℂ)) * untwistedUncutPrefix P Q eligible h (fun _ _ _ => True) + (fun z => F z.toNat) (fun z => G z.toNat) ⌊T⌋₊ - + fullComplexBin P Q eligible F G h T = nonrawComplexBin P Q eligible F G h T := by + rw [untwistedUncutPrefix_centered P hprime hdisjoint, + prefix_scalar_real_denominator, positivePrefix_sum_finite, sum_div] + simp only [positivePrefix_const_mul, fullComplexBin, nonrawComplexBin, mul_div_assoc] + rw [← sum_sub_distrib] + apply sum_congr rfl + intro q _ + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexCenteringSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexCenteringSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..90408ba4780c9d7043be58c7150ba378319295ac --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexCenteringSum.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexTupleProfiles +import OAI.NumberTheory.TwoPoint.Bounds.PartialCenteringSum + +namespace OAI + +/-! Average the exact complex partial-centering errors with their padding-dependent cost. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma tupleComplexCenteredProfile_nonraw_prefix {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (q : ℕ) (hcop : ∀ j, ∀ p ∈ P j, q.Coprime p) + (eligible : ℕ → ℕ → Prop) (F G : ℕ → ℂ) (h X : ℕ) : + (positivePrefix (tupleComplexCenteredProfile P q eligible F G h) X - + positivePrefix (tupleComplexPartialProfile P ∅ q eligible F G h) X) / (X : ℂ) = + ∑ I ∈ (univ : Finset (Fin J)).powerset.filter Finset.Nonempty, + (-1 : ℂ) ^ I.card * + (positivePrefix (tupleComplexPartialProfile P I q eligible F G h) X / (X : ℂ)) := by + have hp : positivePrefix (fun n => tupleComplexCenteredProfile P q eligible F G h n - + tupleComplexPartialProfile P ∅ q eligible F G h n) X = + positivePrefix (tupleComplexCenteredProfile P q eligible F G h) X - + positivePrefix (tupleComplexPartialProfile P ∅ q eligible F G h) X := by + simp only [positivePrefix, sum_sub_distrib] + rw [← hp] + simp_rw [tupleComplexCenteredProfile_nonraw P hprime hdisjoint q hcop eligible F G h] + rw [positivePrefix_sum_finite, sum_div] + apply sum_congr rfl + intro I _ + rw [positivePrefix_const_mul] + ring + +lemma complex_partial_centering_sum_bound {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (hmass : ∀ j, 1 ≤ primeHarmonicMass (P j)) + (Q : Finset ℕ) (weight : ℕ → ℝ) (hweight : ∀ q ∈ Q, 0 ≤ weight q) + (hcop : ∀ q ∈ Q, ∀ j, ∀ p ∈ P j, q.Coprime p) + (eligible : ℕ → ℕ → Prop) (F G : ℕ → ℂ) (h X : ℕ) + (E : ℕ → ℝ) (hE : ∀ q ∈ Q, 0 ≤ E q) + (hbound : ∀ q ∈ Q, ∀ I ∈ (univ : Finset (Fin J)).powerset.filter Finset.Nonempty, + ‖positivePrefix (tupleComplexPartialProfile P I q eligible F G h) X / (X : ℂ)‖ ≤ + E q * ((1 / (q : ℝ)) * ∏ j : {j // j ∉ I}, primeHarmonicMass (P j))) : + ‖∑ q ∈ Q, (weight q : ℂ) * + ((positivePrefix (tupleComplexCenteredProfile P q eligible F G h) X - + positivePrefix (tupleComplexPartialProfile P ∅ q eligible F G h) X) / (X : ℂ))‖ ≤ + (2 : ℝ) ^ J * (∑ q ∈ Q, weight q / (q : ℝ) * E q) * + ∏ j, primeHarmonicMass (P j) := by + let V := ∏ j, primeHarmonicMass (P j) + have hV : 0 ≤ V := prod_nonneg fun j _ => zero_le_one.trans (hmass j) + have hc : (((univ : Finset (Fin J)).powerset.filter Finset.Nonempty).card : ℝ) ≤ + (2 : ℝ) ^ J := by + have hn := card_le_card (filter_subset (s := (univ : Finset (Fin J)).powerset) + (p := Finset.Nonempty)) + simpa only [card_powerset, card_univ, Fintype.card_fin, Nat.cast_pow, Nat.cast_ofNat] using + (show (((univ : Finset (Fin J)).powerset.filter Finset.Nonempty).card : ℝ) ≤ + ((univ : Finset (Fin J)).powerset.card : ℝ) by exact_mod_cast hn) + calc + _ ≤ ∑ q ∈ Q, ‖(weight q : ℂ) * + ((positivePrefix (tupleComplexCenteredProfile P q eligible F G h) X - + positivePrefix (tupleComplexPartialProfile P ∅ q eligible F G h) X) / (X : ℂ))‖ := + norm_sum_le _ _ + _ ≤ ∑ q ∈ Q, weight q * ((2 : ℝ) ^ J * (E q * (1 / (q : ℝ)) * V)) := by + apply sum_le_sum + intro q hq + have hEq := hE q hq + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hweight q hq), + tupleComplexCenteredProfile_nonraw_prefix P hprime hdisjoint q (hcop q hq)] + apply mul_le_mul_of_nonneg_left _ (hweight q hq) + calc + _ ≤ ∑ I ∈ (univ : Finset (Fin J)).powerset.filter Finset.Nonempty, + ‖(-1 : ℂ) ^ I.card * + (positivePrefix (tupleComplexPartialProfile P I q eligible F G h) X / (X : ℂ))‖ := + norm_sum_le _ _ + _ ≤ ∑ _I ∈ (univ : Finset (Fin J)).powerset.filter Finset.Nonempty, + E q * (1 / (q : ℝ)) * V := by + apply sum_le_sum + intro I hI + simp only [norm_mul, norm_pow, norm_neg, norm_one, one_pow, one_mul] + apply (hbound q hq I hI).trans + have hv := complement_product_le (fun j => primeHarmonicMass (P j)) hmass I + dsimp only [V] + calc + _ = (E q * (1 / (q : ℝ))) * ∏ j : {j // j ∉ I}, primeHarmonicMass (P j) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left hv (by positivity) + _ ≤ (2 : ℝ) ^ J * (E q * (1 / (q : ℝ)) * V) := by + simp only [sum_const, nsmul_eq_mul] + exact mul_le_mul_of_nonneg_right hc (by positivity) + _ = _ := by + rw [mul_sum, sum_mul] + apply sum_congr rfl + intro q _ + dsimp only [V] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexDeletionPrefix.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexDeletionPrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa2052bad816bc7aba87e7df3b3241ff1a1aea04 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexDeletionPrefix.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexNumericalPrefix + +namespace OAI + +/-! The existing positive endpoint costs control ordinary complex prefix loss. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem complex_uncut_sub_retained_prefix_le {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ i, ∀ p ∈ P i, p.Prime) + (hdisjoint : ∀ i k, k ≠ i → Disjoint (P i) (P k)) + (R Q : Finset ℕ) (η : ℝ) (c : ℕ → ℝ) (L K W : ℝ) + (eligible : ℤ → ℕ → ℕ → Prop) (h : ℕ) (gate : ℕ → ℤ → ℤ → Prop) + (bad : ℤ → ℤ → Prop) (j : ℤ) (N : ℕ) + (F G : ℤ → ℂ) (hF : ∀ n, ‖F n‖ ≤ 1) (hG : ∀ n, ‖G n‖ ≤ 1) + (hsub : ∀ d ∈ primeTupleDivisors P, ∀ q ∈ R, + eligible j d q → actualPaddingBin η (c d) j q) : + ‖untwistedUncutPrefix P R (eligible j) h gate F G N - + untwistedRetainedPrefix P R Q actualPaddingCoefficient (eligible j) L K W + (fun _ => actualPaddingDegreeCut Q L) h gate (fun z => ¬bad j z) F G N‖ ≤ + (∑ d ∈ primeTupleDivisors P, ∑ q ∈ R, + uniformAverage (fun x : Fin N => positiveDeletionAtom (primeTuplePool P) Q R + η c L K W eligible bad j d q ((x.val + 1 : ℕ) : ℤ))) + + (∑ d ∈ primeTupleDivisors P, ∑ q ∈ R, + uniformAverage (fun x : Fin N => positiveDeletionAtom (primeTuplePool P) Q R + η c L K W eligible bad j d q (((x.val + 1 : ℕ) : ℤ) + (h * q * d : ℕ)))) := by + unfold untwistedUncutPrefix untwistedRetainedPrefix + have hb (n : ℕ) : + ‖(∑ d ∈ primeTupleDivisors P, ∑ q ∈ R, + liouvilleUntwist F G n ((n : ℤ) + (h * q * d : ℕ)) * + uncutNumericalEdge R (eligible j) h gate d q n ((n : ℤ) + (h * q * d : ℕ))) - + (∑ d ∈ primeTupleDivisors P, ∑ q ∈ R, + liouvilleUntwist F G n ((n : ℤ) + (h * q * d : ℕ)) * + retainedNumericalEdge P R Q actualPaddingCoefficient (eligible j) L K W + (fun _ => actualPaddingDegreeCut Q L) h gate (fun z => ¬bad j z) + d q n ((n : ℤ) + (h * q * d : ℕ)))‖ ≤ + ∑ d ∈ primeTupleDivisors P, ∑ q ∈ R, + (positiveDeletionAtom (primeTuplePool P) Q R η c L K W eligible bad j d q n + + positiveDeletionAtom (primeTuplePool P) Q R η c L K W eligible bad j d q + ((n : ℤ) + (h * q * d : ℕ))) := by + simp only [← sum_sub_distrib] + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro d hd + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro q _ + exact complex_uncut_sub_retained_edge_le P R Q η c L K W eligible h gate bad j d q n + (hsub d hd) (primeTupleDivisors_arithmetic P hprime hdisjoint hd).2.1 F G hF hG + have hp := normalized_prefix_difference_le _ _ _ N hb + apply hp.trans_eq + have hadd (f g : Fin N → ℝ) : uniformAverage (fun x => f x + g x) = + uniformAverage f + uniformAverage g := by + simp only [uniformAverage, sum_add_distrib, add_div] + simp only [uniformAverage_finset_sum, hadd, sum_add_distrib] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexFinalScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexFinalScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7bdca0e0f682b9aa72aca0a94f407474fffa226 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexFinalScale.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexBinSummation +import OAI.NumberTheory.TwoPoint.Walks.RetainedFinalScale + +namespace OAI + +/-! The complex retained graph has an exponentially vanishing normalized contribution. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma exists_fixed_spectral_parameter_ge (C W₀ : ℝ) (hC : 0 ≤ C) : + ∃ W : ℝ, 10 ≤ W ∧ W₀ ≤ W ∧ + Real.exp 5 * (C / Real.sqrt W) ≤ Real.exp (-1) := by + obtain ⟨W, hW, hc⟩ := exists_fixed_spectral_parameter C hC + refine ⟨max W W₀, hW.trans (le_max_left _ _), le_max_right _ _, ?_⟩ + apply le_trans _ hc + gcongr + exact le_max_left _ _ + +lemma exp_neg_nat_exp_lt_two (J : ℕ) (hJ : 1 ≤ J) : + Real.exp (Real.exp (-(J : ℝ))) < 2 := by + have hj : Real.exp (-(J : ℝ)) ≤ Real.exp (-1) := by + apply Real.exp_le_exp.mpr + exact_mod_cast (show -(J : ℤ) ≤ -1 by omega) + have hlog : Real.exp (-(J : ℝ)) < Real.log 2 := by + have := Real.log_two_gt_d9 + have := Real.exp_neg_one_lt_half + linarith + calc + _ < Real.exp (Real.log 2) := Real.exp_lt_exp.mpr hlog + _ = _ := Real.exp_log (by norm_num) + +theorem ModFiveThetaInput.eventually_canonical_complex_saving + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ (W : ℝ) (hW : 10 ≤ W), + Real.exp 5 * ((2 * Real.exp 150) / Real.sqrt W) ≤ Real.exp (-1) → + ∀ (h : ℕ) (_hh : 0 < h) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E), + ∀ᶠ L : ℝ in atTop, ∀ hL : 1 ≤ L, + let J := primeSupplyCount W L + let η := Real.exp (-(J : ℝ)) + let bins := paddingBinIndices L η + ∀ eligible : ℤ → ℕ → ℕ → Prop, + (∀ j ∈ bins, ∀ d q, eligible j d q → PaddingPairEligible L η d q) → + (∀ j ∈ bins, ∀ d q, eligible j d q → 0 < d ∧ 0 < q) → + (∀ j ∈ bins, ∀ d q, eligible j d q → actualPaddingBin η (Real.log d) j q) → + ∀ (F G : ℤ → ℂ), (∀ n, ‖F n‖ ≤ 1) → (∀ n, ‖G n‖ ≤ 1) → + ∀ (N : ℤ → ℕ) (v : ℤ → ℂ), + (∀ j ∈ bins, Real.exp (L ^ A / 2) ≤ (N j : ℝ)) → + (∀ j ∈ bins, ‖v j‖ ≤ 1) → + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + ‖∑ j ∈ bins, v j * canonicalComplexPrefix h E W L (eligible j) hL + (by linarith) hE F G (N j)‖ / + totalPaddingBinMass (primeTupleDivisors P) (paddingPrimeSupply E L) L η ≤ + (80 * (1212 * Real.exp 1 + 606)) * Real.exp (-(J : ℝ)) := by + obtain ⟨A, hA, hb⟩ := hprime.eventually_canonical_complex_bin_sum hBr + refine ⟨A, hA, ?_⟩ + intro W hW hchoice h hh E hE + have hWone : 1 ≤ W := by linarith + filter_upwards [hb h hh E hE W hWone, eventually_bin_error_saving W hWone, + eventually_primeSupplyCount_pos W (by linarith), eventually_ge_atTop (1 : ℝ)] + with L hb herr hJ hL + intro hL' + dsimp only + let J := primeSupplyCount W L + let η := Real.exp (-(J : ℝ)) + have hη : 0 < η := Real.exp_pos _ + have hηone : η ≤ 1 := Real.exp_le_one_iff.mpr (by + dsimp only [J] + exact neg_nonpos.mpr (Nat.cast_nonneg _)) + have hηtwo : Real.exp η < 2 := exp_neg_nat_exp_lt_two J hJ + intro eligible he hpos hbin F G hF hG N v hN hv + have hbound := hb hL' η hη hηone hηtwo (paddingBinIndices L η) eligible he hpos hbin + F G hF hG N v hN hv + have hs := retained_spectral_scale L W J 1 (paddingBinIndices L η).card (by linarith) + (by linarith) (Nat.cast_nonneg _) (paddingBinIndices_card_linear L η hL hη hηone) + hchoice herr + simp only [Nat.cast_one, one_pow, mul_one] at hs + apply hbound.trans + calc + _ = 80 * ((6 * (paddingBinIndices L η).card / L) * + ((Real.exp 1 * (2 * (Real.exp (4 * J) * + (2 * Real.exp 150 * Real.sqrt W) ^ J))) / W ^ J) + + 6 * (paddingBinIndices L η).card * Real.exp (-L)) := by ring + _ ≤ 80 * ((1212 * Real.exp 1 + 606) * Real.exp (-(J : ℝ))) := + mul_le_mul_of_nonneg_left hs (by norm_num) + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexFullDilation.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexFullDilation.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a7ef3cfb368fa0cc295836587a31d83f8dca36c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexFullDilation.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexCenteredBridge + +namespace OAI + +/-! The full-divisibility part of the complex bin is the exact dilated correlation. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma tupleComplexPartialProfile_empty_prefix {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) (q : ℕ) (hq : 0 < q) + (eligible : ℕ → ℕ → Prop) (F G : ℕ → ℂ) (h N : ℕ) : + positivePrefix (tupleComplexPartialProfile P ∅ q eligible F G h) N = + ∑ x : (j : Fin J) → P j, if eligible (∏ j, (x j).val) q then + positivePrefix (fun m => F ((q * ∏ j, (x j).val) * m) * + G ((q * ∏ j, (x j).val) * (m + h))) (N / (q * ∏ j, (x j).val)) + else 0 := by + change positivePrefix (fun n => tupleComplexPartialProfile P ∅ q eligible F G h n) N = _ + simp_rw [tupleComplexPartialProfile_empty] + rw [positivePrefix_sum_finite] + apply sum_congr rfl + intro x _ + rw [positivePrefix_ite_const] + by_cases he : eligible (∏ j, (x j).val) q + · simp only [he, ite_true] + have hu : 0 < q * ∏ j, (x j).val := + Nat.mul_pos hq (prod_pos (fun j _ => (hprime j _ (x j).property).pos)) + rw [divisibility_positivePrefix _ _ _ hu] + congr 1 + funext m + rw [show (q * ∏ j, (x j).val) * m + h * (q * ∏ j, (x j).val) = + (q * ∏ j, (x j).val) * (m + h) by ring] + · simp only [he, ite_false] + +lemma fullComplexBin_eq_dilated {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (Q : Finset ℕ) (hQ : ∀ q ∈ Q, 0 < q) + (eligible : ℕ → ℕ → Prop) (F G : ℕ → ℂ) (h : ℕ) (T : ℝ) : + fullComplexBin P Q eligible F G h T = + ∑ q ∈ Q, ∑ d ∈ primeTupleDivisors P, if eligible d q then + (actualPaddingCoefficient q : ℂ) * + (positivePrefix (fun m => F ((q * d) * m) * G ((q * d) * (m + h))) + (⌊T⌋₊ / (q * d)) / (T : ℂ)) + else 0 := by + unfold fullComplexBin + apply sum_congr rfl + intro q hq + rw [tupleComplexPartialProfile_empty_prefix P hprime q (hQ q hq), sum_div, mul_sum, + primeTupleDivisors, sum_image] + · apply sum_congr rfl + intro x _ + split_ifs <;> simp only [zero_div, mul_zero] + · intro x _ y _ hxy + exact primeTuple_injective hprime hdisjoint hxy + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexGraphUpper.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexGraphUpper.lean new file mode 100644 index 0000000000000000000000000000000000000000..8fe9da07baf6ed55425478d483995fe3c22f0f40 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexGraphUpper.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexFinalScale +import OAI.NumberTheory.TwoPoint.Bounds.ComplexCanonicalDeletion +import OAI.NumberTheory.TwoPoint.Bounds.FinalCorrelationBound + +namespace OAI + +/-! The complete uncut complex graph is small: the retained graph and the +two endpoint deletion errors share the same exponential saving. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem complex_graph_fixed_scale (hP : ModFiveThetaInput) + (hBr : BravermanDepth22Input) : + ∃ (A : ℕ) (W : ℝ), 1000 ≤ A ∧ 10 ≤ W ∧ + ∀ (h : ℕ), 0 < h → ∀ (E : Finset ℕ) + (_hE : ∀ p, p.Prime → p ∣ h → p ∈ E), + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, ∀ _hL : 1 ≤ L, + let J := primeSupplyCount W L + let η := Real.exp (-(J : ℝ)) + let bins := paddingBinIndices L η + ∀ eligible : ℤ → ℕ → ℕ → Prop, + (∀ j ∈ bins, ∀ d q, eligible j d q → PaddingPairEligible L η d q) → + (∀ j ∈ bins, ∀ d q, eligible j d q → 0 < d ∧ 0 < q) → + (∀ j ∈ bins, ∀ d q, eligible j d q → actualPaddingBin η (Real.log d) j q) → + ∀ (F G : ℤ → ℂ), (∀ n, ‖F n‖ ≤ 1) → (∀ n, ‖G n‖ ≤ 1) → + ∀ (N : ℤ → ℕ) (v : ℤ → ℂ), + (∀ j ∈ bins, Real.exp (L ^ A / 2) ≤ (N j : ℝ)) → + (∀ j ∈ bins, ‖v j‖ ≤ 1) → + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + ‖∑ j ∈ bins, v j * canonicalComplexUncutPrefix h E W L (eligible j) F G (N j)‖ / + totalPaddingBinMass (primeTupleDivisors P) (paddingPrimeSupply E L) L η ≤ + C * η := by + obtain ⟨As, hAs, hs⟩ := hP.eventually_canonical_complex_saving hBr + obtain ⟨Ad, hAd, hd⟩ := hBr.eventually_canonical_shifted_source_deletion_uniform hP + obtain ⟨W, hW, hchoice⟩ := exists_fixed_spectral_parameter (2 * Real.exp 150) (by positivity) + let A := As + Ad + have hA : 1000 ≤ A := by dsimp only [A]; omega + have hWone : 1 ≤ W := by linarith + refine ⟨A, W, hA, hW, ?_⟩ + intro h hh E hE + obtain ⟨Cd, hCd, hd⟩ := hd h E hE W 3 hW (by norm_num) + let Cs : ℝ := 80 * (1212 * Real.exp 1 + 606) + refine ⟨Cs + 4 * (Cd + 4), by dsimp only [Cs]; positivity, ?_⟩ + filter_upwards [hs W hW hchoice h hh E hE, hd, + hP.eventually_canonical_retained_mass E W hWone, + eventually_rare_error_saving W hWone, eventually_ge_atTop (101 : ℝ)] + with L hs hd hm hr hlarge + intro hL + dsimp only + let J := primeSupplyCount W L + let η := Real.exp (-(J : ℝ)) + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + let M := paddingTiltNormalizer Q * ∏ j, primeHarmonicMass (P j) + let S₀ := totalPaddingBinMass (primeTupleDivisors P) Q L η + let bins := paddingBinIndices L η + have hη : 0 < η := Real.exp_pos _ + have hηone : η ≤ 1 := Real.exp_le_one_iff.mpr (neg_nonpos.mpr (Nat.cast_nonneg J)) + intro eligible he hpos hbin F G hF hG N v hN hv + have hN' (A' : ℕ) (hA' : A' ≤ A) (j : ℤ) (hj : j ∈ bins) : + Real.exp (L ^ A' / 2) ≤ (N j : ℝ) := + (Real.exp_le_exp.mpr (div_le_div_of_nonneg_right + (pow_le_pow_right₀ hL hA') (by norm_num))).trans (hN j hj) + have hmass := hm hL η hη + have hV : 1 ≤ ∏ j, primeHarmonicMass (P j) := (one_le_pow₀ hWone).trans hmass.1 + have hM : 0 < M := mul_pos (paddingTiltNormalizer_pos Q) (by linarith) + have hmS : M / 2 ≤ S₀ := hmass.2 + have hS₀ : 0 < S₀ := (half_pos hM).trans_le hmS + let raw := ∑ j ∈ bins, v j * canonicalComplexUncutPrefix h E W L (eligible j) F G (N j) + let retained := ∑ j ∈ bins, + v j * canonicalComplexPrefix h E W L (eligible j) hL hWone hE F G (N j) + let cost := fun site => canonicalShiftedSourceDeletion h E W L η (Real.exp (4 * J)) + hL hWone hE bins (fun d => Real.log d) eligible site (fun _ => 1) N + have hret : ‖retained‖ / S₀ ≤ Cs * η := + hs hL eligible he hpos hbin F G hF hG N v (hN' As (by dsimp only [A]; omega)) hv + have hdelete : ‖raw - retained‖ ≤ cost (fun _ _ _ => 0) + + cost (fun _ d q => (h * q * d : ℕ)) := + canonical_complex_weighted_correlation_deletion h E W L η hL hWone hE bins + (fun d => Real.log d) eligible N v F G hF hG hbin hv + have hc (site : ℤ → ℕ → ℕ → ℤ) : cost site / M ≤ (Cd + 4) * η := by + have hx := hd hL η (Real.exp (4 * J)) hη hηone (Real.exp_pos _) bins + (fun d => Real.log d) eligible + (paddingBinIndices_card_polynomial L W hlarge hWone) he hbin site (fun _ => 1) N + (hN' Ad (by dsimp only [A]; omega)) + exact hx.trans (quantitative_deletion_small L W Cd J hL hWone hCd.le + (primeSupplyCount_final_budget L W hL hWone) hr) + have hdel : ‖raw - retained‖ ≤ 2 * M * ((Cd + 4) * η) := by + have h₁ := (div_le_iff₀ hM).mp (hc (fun _ _ _ => 0)) + have h₂ := (div_le_iff₀ hM).mp (hc (fun _ d q => (h * q * d : ℕ))) + nlinarith + have hrbound := (div_le_iff₀ hS₀).mp hret + have hmb := mul_le_mul_of_nonneg_right (show M ≤ 2 * S₀ by linarith) + (show 0 ≤ 2 * ((Cd + 4) * η) by positivity) + apply (div_le_iff₀ hS₀).mpr + have htri : ‖raw‖ ≤ ‖raw - retained‖ + ‖retained‖ := by + simpa only [sub_add_cancel] using norm_add_le (raw - retained) retained + change ‖raw‖ ≤ _ + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexNumericalEdges.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexNumericalEdges.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c3b9e0a5fb9a114e7d060244bbe632bc8b0db00 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexNumericalEdges.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexPrefixBound +import OAI.NumberTheory.TwoPoint.Walks.RetainedDeletionBridge + +namespace OAI + +/-! Transfer the existing positive deletion costs to arbitrary complex factors. +Liouville's unit values serve only as an exact algebraic change of test functions. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def liouvilleUntwist (F G : ℤ → ℂ) (n m : ℤ) : ℂ := + (F n * integerLiouville n) * (G m * integerLiouville m) + +lemma liouvilleUntwist_norm_le (F G : ℤ → ℂ) + (hF : ∀ n, ‖F n‖ ≤ 1) (hG : ∀ n, ‖G n‖ ≤ 1) (n m : ℤ) : + ‖liouvilleUntwist F G n m‖ ≤ 1 := by + unfold liouvilleUntwist + simp only [norm_mul] + have ha := mul_le_mul (hF n) (integerLiouville_norm_le_one n) + (norm_nonneg (integerLiouville n)) (by norm_num : (0 : ℝ) ≤ 1) + have hb := mul_le_mul (hG m) (integerLiouville_norm_le_one m) + (norm_nonneg (integerLiouville m)) (by norm_num : (0 : ℝ) ≤ 1) + have hab := mul_le_mul ha hb + (mul_nonneg (norm_nonneg (G m)) (norm_nonneg (integerLiouville m))) + (by norm_num : (0 : ℝ) ≤ 1 * 1) + simpa only [one_mul] using hab + +lemma liouvilleUntwist_cancel (F G : ℤ → ℂ) (n m : ℤ) (hn : 0 < n) (hm : 0 < m) + (z : ℂ) : liouvilleUntwist F G n m * (z * integerLiouville n * integerLiouville m) = + z * F n * G m := by + have hn0 : n.toNat ≠ 0 := by omega + have hm0 : m.toNat ≠ 0 := by omega + have hn2 : integerLiouville n ^ 2 = 1 := liouville_sq hn0 + have hm2 : integerLiouville m ^ 2 = 1 := liouville_sq hm0 + calc + _ = z * F n * G m * integerLiouville n ^ 2 * integerLiouville m ^ 2 := by + unfold liouvilleUntwist + ring + _ = _ := by rw [hn2, hm2, mul_one, mul_one] + +lemma retainedComplexPrimeEdge_eq_untwist {J : ℕ} (P : Fin J → Finset ℕ) + (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (keep : ℤ → Prop) (F G : ℤ → ℂ) + (e : ((j : Fin J) → P j) × Q) (n m : ℤ) (hn : 0 < n) (hm : 0 < m) (hL : L ≠ 0) : + retainedComplexPrimeEdge P Q Qp u eligible L K W extra h gate keep F G e n m / (L : ℂ) = + liouvilleUntwist F G n m * retainedNumericalEdge P Q Qp u eligible L K W extra h + gate keep (∏ j, (e.1 j).val) e.2.val n m := by + unfold retainedComplexPrimeEdge retainedNumericalEdge retainedLiouvilleEdge retainedRealEdge + split_ifs + · rw [liouvilleUntwist_cancel F G n m hn hm] + push_cast + field_simp [Complex.ofReal_ne_zero.mpr hL] + all_goals simp + +lemma uncutNumericalEdge_untwist (R : Finset ℕ) (eligible : ℕ → ℕ → Prop) + (h : ℕ) (gate : ℕ → ℤ → ℤ → Prop) (F G : ℤ → ℂ) + (d q : ℕ) (n m : ℤ) (hn : 0 < n) (hm : 0 < m) : + liouvilleUntwist F G n m * uncutNumericalEdge R eligible h gate d q n m = + if gate d n m ∧ q ∈ R ∧ eligible d q ∧ (q : ℤ) ∣ n ∧ + m = n + (h * q * d : ℕ) then + (actualPaddingCoefficient q * centeredTuple d.primeFactors n : ℝ) * F n * G m + else 0 := by + unfold uncutNumericalEdge + split_ifs + · exact liouvilleUntwist_cancel F G n m hn hm _ + · simp + +lemma complex_uncut_sub_retained_edge_le {J : ℕ} (P : Fin J → Finset ℕ) + (R Q : Finset ℕ) (η : ℝ) (c : ℕ → ℝ) (L K W : ℝ) + (eligible : ℤ → ℕ → ℕ → Prop) (h : ℕ) (gate : ℕ → ℤ → ℤ → Prop) + (bad : ℤ → ℤ → Prop) (j : ℤ) (d q : ℕ) (n : ℤ) + (hsub : ∀ r ∈ R, eligible j d r → actualPaddingBin η (c d) j r) + (hd : d.primeFactors.card = J) (F G : ℤ → ℂ) + (hF : ∀ n, ‖F n‖ ≤ 1) (hG : ∀ n, ‖G n‖ ≤ 1) : + let m := n + (h * q * d : ℕ) + ‖liouvilleUntwist F G n m * uncutNumericalEdge R (eligible j) h gate d q n m - + liouvilleUntwist F G n m * retainedNumericalEdge P R Q actualPaddingCoefficient + (eligible j) L K W (fun _ => actualPaddingDegreeCut Q L) h gate + (fun z => ¬bad j z) d q n m‖ ≤ + positiveDeletionAtom (primeTuplePool P) Q R η c L K W eligible bad j d q n + + positiveDeletionAtom (primeTuplePool P) Q R η c L K W eligible bad j d q m := by + dsimp only + rw [← mul_sub, norm_mul] + apply (mul_le_of_le_one_left (norm_nonneg _) (liouvilleUntwist_norm_le F G hF hG n _)).trans + exact uncut_sub_retained_edge_le P R Q η c L K W eligible h gate bad j d q n hsub hd + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexNumericalPrefix.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexNumericalPrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..a02c1a8b498dc7dfc106d17af3c4221cf4c6e7c9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexNumericalPrefix.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexNumericalEdges +import OAI.NumberTheory.TwoPoint.Bounds.PrefixDeletionBridge +import OAI.NumberTheory.TwoPoint.Walks.RetainedEligibility + +namespace OAI + +/-! Numerical divisor reindexing of the arbitrary complex retained prefix. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def untwistedRetainedPrefix {J : ℕ} (P : Fin J → Finset ℕ) + (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (keep : ℤ → Prop) (F G : ℤ → ℂ) (N : ℕ) : ℂ := + positivePrefix (fun n => ∑ d ∈ primeTupleDivisors P, ∑ q ∈ Q, + liouvilleUntwist F G n ((n : ℤ) + (h * q * d : ℕ)) * + retainedNumericalEdge P Q Qp u eligible L K W extra h gate keep d q n + ((n : ℤ) + (h * q * d : ℕ))) N / (N : ℂ) + +noncomputable def untwistedUncutPrefix {J : ℕ} (P : Fin J → Finset ℕ) + (Q : Finset ℕ) (eligible : ℕ → ℕ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (F G : ℤ → ℂ) (N : ℕ) : ℂ := + positivePrefix (fun n => ∑ d ∈ primeTupleDivisors P, ∑ q ∈ Q, + liouvilleUntwist F G n ((n : ℤ) + (h * q * d : ℕ)) * + uncutNumericalEdge Q eligible h gate d q n ((n : ℤ) + (h * q * d : ℕ))) N / (N : ℂ) + +lemma retainedComplex_row_eq_numerical {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ i, ∀ p ∈ P i, p.Prime) + (hdisjoint : ∀ i k, k ≠ i → Disjoint (P i) (P k)) + (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (keep : ℤ → Prop) (F G : ℤ → ℂ) + (n : ℤ) (hn : 0 < n) (hL : L ≠ 0) : + (∑ e : ((j : Fin J) → P j) × Q, + retainedComplexPrimeEdge P Q Qp u eligible L K W extra h gate keep F G e n + (n + (h * e.2.val * ∏ j, (e.1 j).val : ℕ))) / (L : ℂ) = + ∑ d ∈ primeTupleDivisors P, ∑ q ∈ Q, + liouvilleUntwist F G n (n + (h * q * d : ℕ)) * + retainedNumericalEdge P Q Qp u eligible L K W extra h gate keep d q n + (n + (h * q * d : ℕ)) := by + rw [sum_div, Fintype.sum_prod_type, primeTupleDivisors, sum_image] + · apply sum_congr rfl + intro d _ + calc + _ = ∑ q : Q, liouvilleUntwist F G n (n + (h * q.val * ∏ j, (d j).val : ℕ)) * + retainedNumericalEdge P Q Qp u eligible L K W extra h gate keep + (∏ j, (d j).val) q.val n (n + (h * q.val * ∏ j, (d j).val : ℕ)) := by + apply sum_congr rfl + intro q _ + exact retainedComplexPrimeEdge_eq_untwist P Q Qp u eligible L K W extra h gate keep + F G (d, q) n _ hn (by omega) hL + _ = _ := sum_coe_sort Q (fun q => + liouvilleUntwist F G n (n + (h * q * ∏ j, (d j).val : ℕ)) * + retainedNumericalEdge P Q Qp u eligible L K W extra h gate keep + (∏ j, (d j).val) q n (n + (h * q * ∏ j, (d j).val : ℕ))) + · intro d _ e _ hde + exact primeTuple_injective hprime hdisjoint hde + +lemma retainedComplexPrefix_eq_numerical {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ i, ∀ p ∈ P i, p.Prime) + (hdisjoint : ∀ i k, k ≠ i → Disjoint (P i) (P k)) + (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (keep : ℤ → Prop) (F G : ℤ → ℂ) (N : ℕ) + (hL : L ≠ 0) : + retainedComplexPrefix P Q Qp u eligible L K W extra h gate keep F G N = + untwistedRetainedPrefix P Q Qp u eligible L K W extra h gate keep F G N := by + unfold retainedComplexPrefix untwistedRetainedPrefix + rw [div_right_comm] + congr 1 + unfold positivePrefix + rw [sum_div] + apply sum_congr rfl + intro n _ + exact retainedComplex_row_eq_numerical P hprime hdisjoint Q Qp u eligible L K W extra h + gate keep F G (n + 1 : ℕ) (by omega) hL + +lemma untwistedRetainedPrefix_congr_eligible {J : ℕ} (P : Fin J → Finset ℕ) + (R Q : Finset ℕ) (u : ℕ → ℝ) (e f : ℕ → ℕ → Prop) (L K W : ℝ) + (extra : ℕ → ℤ → Prop) (h : ℕ) (gate : ℕ → ℤ → ℤ → Prop) + (keep : ℤ → Prop) (F G : ℤ → ℂ) (N : ℕ) + (hef : ∀ d ∈ primeTupleDivisors P, ∀ q ∈ R, e d q ↔ f d q) : + untwistedRetainedPrefix P R Q u e L K W extra h gate keep F G N = + untwistedRetainedPrefix P R Q u f L K W extra h gate keep F G N := by + unfold untwistedRetainedPrefix + congr 2 + funext n + apply sum_congr rfl + intro d hd + apply sum_congr rfl + intro q hq + rw [retainedNumericalEdge_congr_eligible P R Q u e f L K W extra h gate keep + d q n ((n : ℤ) + (h * q * d : ℕ)) hq (hef d hd)] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPairSelection.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPairSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ca0f94c3a745271c1a8750c0bfee2b2104cc9b7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPairSelection.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexRawSelection +import OAI.NumberTheory.TwoPoint.Bounds.PairModulusDefect + +namespace OAI + +/-! Phase selection on the literal finite numerical pair family. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def eligibleComplexPairs (D Q : Finset ℕ) + (eligible : ℕ → ℕ → Prop) : Finset (ℕ × ℕ) := + (D ×ˢ retainedPrimeDivisors Q).filter (fun dq => eligible dq.1 dq.2) + +noncomputable def complexPairWeight (dq : ℕ × ℕ) : ℝ := + (4 : ℝ) ^ dq.2.primeFactors.card / (dq.1 * dq.2 : ℕ) + +lemma complexPairWeight_nonneg (dq : ℕ × ℕ) : 0 ≤ complexPairWeight dq := by + unfold complexPairWeight + positivity + +lemma eligibleComplexPairs_sum {M : Type*} [AddCommMonoid M] + (D Q : Finset ℕ) (eligible : ℕ → ℕ → Prop) (F : ℕ × ℕ → M) : + (∑ dq ∈ eligibleComplexPairs D Q eligible, F dq) = + ∑ d ∈ D, ∑ q ∈ retainedPrimeDivisors Q, if eligible d q then F (d, q) else 0 := by + rw [eligibleComplexPairs, sum_filter, sum_product] + +lemma eligibleComplexPairs_mass (D Q : Finset ℕ) (L η : ℝ) (hη : 0 < η) : + (∑ dq ∈ eligibleComplexPairs D Q (PaddingPairEligible L η), complexPairWeight dq) = + totalPaddingBinMass D Q L η := by + rw [eligibleComplexPairs_sum, totalPaddingBinMass_eq D Q L η hη] + rfl + +lemma eligibleComplexPairs_defect_le {f g : ℕ → ℂ} + (hf : OneBounded f) (hg : OneBounded g) + (D Q : Finset ℕ) (hD : ∀ d ∈ D, 0 < d) (hQ : ∀ p ∈ Q, p.Prime) + (eligible : ℕ → ℕ → Prop) : + (∑ dq ∈ eligibleComplexPairs D Q eligible, complexPairWeight dq * + (1 - ‖f (dq.1 * dq.2) * g (dq.1 * dq.2)‖)) ≤ + ∑ d ∈ D, ∑ q ∈ retainedPrimeDivisors Q, + (4 : ℝ) ^ q.primeFactors.card / (d * q : ℕ) * (1 - ‖f (d * q) * g (d * q)‖) := by + rw [eligibleComplexPairs_sum] + apply sum_le_sum + intro d hd + apply sum_le_sum + intro q hq + by_cases he : eligible d q + · simp only [he, ite_true, complexPairWeight, le_refl] + · simp only [he, ite_false] + apply mul_nonneg (by positivity) + have hu := Nat.mul_pos (hD d hd) (retainedPrimeDivisor_pos Q hQ hq) + rw [norm_mul] + exact sub_nonneg.mpr ((mul_le_mul (hf _ hu) (hg _ hu) + (norm_nonneg _) zero_le_one).trans (by norm_num)) + +lemma exists_eligible_pair_phase {f g : ℕ → ℂ} (D Q : Finset ℕ) + (L η : ℝ) (hη : 0 < η) + (hdefect : (∑ dq ∈ eligibleComplexPairs D Q (PaddingPairEligible L η), + complexPairWeight dq * (1 - ‖f (dq.1 * dq.2) * g (dq.1 * dq.2)‖)) ≤ + totalPaddingBinMass D Q L η / 2) : + ∃ A ⊆ eligibleComplexPairs D Q (PaddingPairEligible L η), + totalPaddingBinMass D Q L η / 8 ≤ + ‖∑ dq ∈ A, (complexPairWeight dq : ℂ) * + (f (dq.1 * dq.2) * g (dq.1 * dq.2))‖ := by + have hm := eligibleComplexPairs_mass D Q L η hη + obtain ⟨A, hA, hbound⟩ := exists_weighted_phase_subset + (eligibleComplexPairs D Q (PaddingPairEligible L η)) complexPairWeight + (fun dq => f (dq.1 * dq.2) * g (dq.1 * dq.2)) + (fun dq _ => complexPairWeight_nonneg dq) (by rwa [hm]) + exact ⟨A, hA, by rwa [hm] at hbound⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPartialBounds.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPartialBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..81de77e1de3da9862f8079e75454822b70c61425 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPartialBounds.lean @@ -0,0 +1,50 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexPartialProfiles +import OAI.NumberTheory.TwoPoint.Bounds.QuantitativeTupleBins +import OAI.NumberTheory.TwoPoint.Bounds.WeightedShiftAverage + +namespace OAI + +/-! Exact reciprocal normalization of the complex partial-tuple profiles. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma complexRoughProfile_average (F G : ℕ → ℂ) (Z : Finset ℕ) (h Y : ℕ) : + positivePrefix (complexRoughProfile F G Z h) Y / (Y : ℂ) = + weightedRoughShiftAverage F G Z (fun _ => 1) h Y := by + have he : complexRoughProfile F G Z h = weightedRoughShiftProfile F G Z (fun _ => 1) h := by + funext n + simp only [weightedRoughShiftProfile, complexRoughProfile, one_div] + rw [weightedRoughShiftAverage, he] + +lemma complex_partial_tuple_prefix_bound {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ i, ∀ p ∈ P i, p.Prime) + (hdisjoint : ∀ i j, j ≠ i → Disjoint (P i) (P j)) + (I : Finset (Fin J)) (q : ℕ) (hq : 0 < q) + (eligible : ℕ → ℕ → Prop) (F G : ℕ → ℂ) (h X : ℕ) + (hX : 0 < X) (E : ℝ) (hE : 0 ≤ E) + (hb : ∀ y : (j : {j // j ∉ I}) → P j, + ‖weightedRoughShiftAverage + (fun n => F ((q * ∏ j, (y j).val) * n)) + (fun n => G ((q * ∏ j, (y j).val) * n)) + ((primeTupleSlice P I).filter (fun z => eligible ((∏ j, (y j).val) * z) q)) + (fun _ => 1) h (X / (q * ∏ j, (y j).val))‖ ≤ E) : + ‖positivePrefix (tupleComplexPartialProfile P I q eligible F G h) X / (X : ℂ)‖ ≤ + E * ((1 / (q : ℝ)) * ∏ j : {j // j ∉ I}, primeHarmonicMass (P j)) := by + rw [tupleComplexPartialProfile_prefix P hprime hdisjoint I q hq] + have he := indexed_rescaled_prefix_bound + (fun y : (j : {j // j ∉ I}) → P j => q * ∏ j, (y j).val) + (fun y => complexRoughProfile + (fun n => F ((q * ∏ j, (y j).val) * n)) + (fun n => G ((q * ∏ j, (y j).val) * n)) + ((primeTupleSlice P I).filter (fun z => eligible ((∏ j, (y j).val) * z) q)) h) + X E hX hE + (fun y => Nat.mul_pos hq (prod_pos fun j _ => (hprime j _ (y j).property).pos)) + (fun y => by rw [complexRoughProfile_average]; exact hb y) + simpa only [Nat.cast_mul, Nat.cast_prod, retained_tuple_reciprocal_sum] using he + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPartialProfiles.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPartialProfiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5ffd3d4ecec74a972d3e6df68a54bc68d40154f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPartialProfiles.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexTupleProfiles + +namespace OAI + +/-! Exact retained/removed tuple reindexing and divisibility extraction for complex tests. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def complexRoughProfile (F G : ℕ → ℂ) (Z : Finset ℕ) (h n : ℕ) : ℂ := + ∑ z ∈ Z, (z : ℂ)⁻¹ * (F n * G (n + h * z)) + +noncomputable def complexPartialProfile (F G : ℕ → ℂ) (u : ℕ) (Z : Finset ℕ) + (h n : ℕ) : ℂ := + natDivisibilityIndicator u n * ∑ z ∈ Z, (z : ℂ)⁻¹ * (F n * G (n + h * u * z)) + +lemma complexPartialProfile_prefix (F G : ℕ → ℂ) (u : ℕ) (Z : Finset ℕ) + (h X : ℕ) (hu : 0 < u) : + positivePrefix (complexPartialProfile F G u Z h) X = + positivePrefix (complexRoughProfile (fun n => F (u * n)) (fun n => G (u * n)) Z h) + (X / u) := by + unfold complexPartialProfile + rw [divisibility_positivePrefix _ u X hu] + congr 1 + funext n + unfold complexRoughProfile + apply sum_congr rfl + intro z _ + rw [show u * n + h * u * z = u * (n + h * z) by ring] + +lemma tupleComplexPartialProfile_reindex {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (I : Finset (Fin J)) (q : ℕ) (eligible : ℕ → ℕ → Prop) + (F G : ℕ → ℂ) (h n : ℕ) : + tupleComplexPartialProfile P I q eligible F G h n = + ∑ y : (j : {j // j ∉ I}) → P j, + complexPartialProfile F G (q * ∏ j, (y j).val) + ((primeTupleSlice P I).filter (fun z => eligible ((∏ j, (y j).val) * z) q)) h n := by + let H : ℕ → ℕ → ℂ := fun t z => + if eligible (t * z) q then (z : ℂ)⁻¹ * + (natDivisibilityIndicator (q * t) n * + (F n * G (n + h * (q * t * z)))) else 0 + have hs := primeTupleSlice_split_sum P I hprime hdisjoint H + have hleft : tupleComplexPartialProfile P I q eligible F G h n = + ∑ x : (j : Fin J) → P j, + H (∏ j : {j // j ∉ I}, (x j).val) (∏ i : I, (x i).val) := by + apply sum_congr rfl + intro x _ + have he : (∏ j : {j // j ∉ I}, (x j).val) * (∏ i : I, (x i).val) = + ∏ j, (x j).val := by + have hI := prod_coe_sort I (fun j : Fin J => (x j).val) + have hIc := (prod_subtype (p := fun j : Fin J => j ∉ I) (F := inferInstance) (univ \ I) (by simp) (fun j : Fin J => (x j).val)).symm + rw [hI, hIc, ← prod_union sdiff_disjoint, sdiff_union_of_subset (subset_univ I)] + dsimp only [H] + simp only [mul_assoc, he] + rw [hleft, hs] + apply sum_congr rfl + intro y _ + rw [complexPartialProfile, mul_sum, sum_filter] + apply sum_congr rfl + intro z _ + dsimp only [H] + split_ifs + · simp only [mul_assoc] + ring + · simp + +lemma tupleComplexPartialProfile_prefix {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (I : Finset (Fin J)) (q : ℕ) (hq : 0 < q) (eligible : ℕ → ℕ → Prop) + (F G : ℕ → ℂ) (h X : ℕ) + : + positivePrefix (tupleComplexPartialProfile P I q eligible F G h) X = + ∑ y : (j : {j // j ∉ I}) → P j, + positivePrefix (complexRoughProfile (fun m => F ((q * ∏ j, (y j).val) * m)) + (fun m => G ((q * ∏ j, (y j).val) * m)) + ((primeTupleSlice P I).filter (fun z => eligible ((∏ j, (y j).val) * z) q)) h) + (X / (q * ∏ j, (y j).val)) := by + simp only [positivePrefix, tupleComplexPartialProfile_reindex P hprime hdisjoint] + rw [sum_comm] + apply sum_congr rfl + intro y _ + exact complexPartialProfile_prefix F G _ _ h X + (Nat.mul_pos hq (prod_pos fun j _ => (hprime j _ (y j).property).pos)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPolarization.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPolarization.lean new file mode 100644 index 0000000000000000000000000000000000000000..26b80ae5a76968cc083b272650938fd82da4c884 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPolarization.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MatrixAction + +namespace OAI + +/-! Four bounded quadratic tests recover an arbitrary complex bilinear test. -/ + +namespace TwoPointCorrelations + +open scoped ComplexConjugate + +section Hilbert + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℂ E] + +noncomputable def halfPair (u v : E) (z : ℂ) : E := (2 : ℂ)⁻¹ • (u + z • v) + +theorem complex_polarization_four (T : E →L[ℂ] E) (u v : E) : + inner ℂ u (T v) = + inner ℂ (halfPair u v 1) (T (halfPair u v 1)) - + inner ℂ (halfPair u v (-1)) (T (halfPair u v (-1))) - + Complex.I * inner ℂ (halfPair u v Complex.I) (T (halfPair u v Complex.I)) + + Complex.I * inner ℂ (halfPair u v (-Complex.I)) (T (halfPair u v (-Complex.I))) := by + simp only [halfPair, map_smul, map_add, inner_smul_left, inner_smul_right, + inner_add_left, inner_add_right, inner_neg_left, inner_neg_right, + map_inv₀, map_ofNat, map_neg, Complex.conj_I, one_smul, neg_smul] + ring_nf + simp [Complex.I_sq] + ring + +theorem complex_polarization_norm (T : E →L[ℂ] E) (u v : E) : + ‖inner ℂ u (T v)‖ ≤ + ‖inner ℂ (halfPair u v 1) (T (halfPair u v 1))‖ + + ‖inner ℂ (halfPair u v (-1)) (T (halfPair u v (-1)))‖ + + ‖inner ℂ (halfPair u v Complex.I) (T (halfPair u v Complex.I))‖ + + ‖inner ℂ (halfPair u v (-Complex.I)) (T (halfPair u v (-Complex.I)))‖ := by + rw [complex_polarization_four] + calc + _ ≤ ‖inner ℂ (halfPair u v 1) (T (halfPair u v 1)) - + inner ℂ (halfPair u v (-1)) (T (halfPair u v (-1))) - + Complex.I * inner ℂ (halfPair u v Complex.I) (T (halfPair u v Complex.I))‖ + + ‖Complex.I * inner ℂ (halfPair u v (-Complex.I)) (T (halfPair u v (-Complex.I)))‖ := + norm_add_le _ _ + _ ≤ (‖inner ℂ (halfPair u v 1) (T (halfPair u v 1)) - + inner ℂ (halfPair u v (-1)) (T (halfPair u v (-1)))‖ + + ‖Complex.I * inner ℂ (halfPair u v Complex.I) (T (halfPair u v Complex.I))‖) + + ‖Complex.I * inner ℂ (halfPair u v (-Complex.I)) (T (halfPair u v (-Complex.I)))‖ := + add_le_add (norm_sub_le _ _) le_rfl + _ ≤ _ := by + simp only [norm_mul, Complex.norm_I, one_mul] + linarith [norm_sub_le + (inner ℂ (halfPair u v 1) (T (halfPair u v 1))) + (inner ℂ (halfPair u v (-1)) (T (halfPair u v (-1))))] + +end Hilbert + +noncomputable def halfPairFunction {α : Type*} (f g : α → ℂ) (z : ℂ) : α → ℂ := + fun x => (f x + z * g x) / 2 + +lemma halfPairFunction_norm_le {α : Type*} (f g : α → ℂ) (z : ℂ) + (hf : ∀ x, ‖f x‖ ≤ 1) (hg : ∀ x, ‖g x‖ ≤ 1) (hz : ‖z‖ ≤ 1) (x : α) : + ‖halfPairFunction f g z x‖ ≤ 1 := by + have htwo : ‖(2 : ℂ)‖ = (2 : ℝ) := by norm_num + rw [halfPairFunction, norm_div, htwo] + apply (div_le_one (by norm_num : (0 : ℝ) < 2)).mpr + calc + ‖f x + z * g x‖ ≤ ‖f x‖ + ‖z * g x‖ := norm_add_le _ _ + _ ≤ 1 + 1 := add_le_add (hf x) (by rw [norm_mul]; exact + (mul_le_mul hz (hg x) (norm_nonneg _) zero_le_one).trans_eq (by ring)) + _ = 2 := by norm_num + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPrefixBound.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPrefixBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0329f50b57cc1f4c88d3c8a7ccacf4a3833a149 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexPrefixBound.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexBlockTesting + +namespace OAI + +/-! Normalize the actual directed block bound to the ordinary retained prefix. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma retainedComplexPrimeEdge_active_step_eq {J : ℕ} (P : Fin J → Finset ℕ) + (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (keep : ℤ → Prop) (F G : ℤ → ℂ) + (e : ((j : Fin J) → P j) × Q) (n : ℤ) : + retainedComplexPrimeEdge P Q Qp u eligible L K W extra h gate keep F G e n + (n + retainedPrimeStep eligible h e) = + retainedComplexPrimeEdge P Q Qp u eligible L K W extra h gate keep F G e n + (n + (h * e.2.val * ∏ j, (e.1 j).val : ℕ)) := by + by_cases he : eligible (∏ j, (e.1 j).val) e.2.val + · rw [retainedPrimeStep, ite_eq_left he] + · simp [retainedComplexPrimeEdge, retainedRealEdge, he] + +noncomputable def retainedComplexPrefix {J : ℕ} (P : Fin J → Finset ℕ) + (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (keep : ℤ → Prop) (F G : ℤ → ℂ) (N : ℕ) : ℂ := + (positivePrefix (fun n => ∑ e : ((j : Fin J) → P j) × Q, + retainedComplexPrimeEdge P Q Qp u eligible L K W extra h gate keep F G e n + ((n : ℤ) + (h * e.2.val * ∏ j, (e.1 j).val : ℕ))) N / (N : ℂ)) / (L : ℂ) + +theorem retainedComplexPrefix_bound {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (M R N : ℕ) (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (keep : ℤ → Prop) (F G : ℤ → ℂ) + (hF : ∀ n, ‖F n‖ ≤ 1) (hG : ∀ n, ‖G n‖ ≤ 1) + (hM : 0 < M) (hN : 0 < N) (hL : 0 < L) (hK : 0 ≤ K) (hW : 0 ≤ W) + (hu : ∀ q ∈ Q, 0 ≤ u q) (hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W) + (hr : ∀ e : ((j : Fin J) → P j) × Q, retainedPrimeStep eligible h e ≤ R) + (B : ℝ) (havg : uniformAverage (fun t : Fin N => + ‖retainedComplexBlock P M Q Qp u eligible L K W extra h gate keep F G t.val‖) ≤ B) : + ‖retainedComplexPrefix P Q Qp u eligible L K W extra h gate keep F G N‖ ≤ + B / (L * M) + (R : ℝ) / M * + (K / L * (5 : ℝ) ^ (400 * Real.log L) * (8 * W) ^ J) + + 2 * (M : ℝ) / N * (K / L * (5 : ℝ) ^ (400 * Real.log L) * (8 * W) ^ J) := by + let C := K * (5 : ℝ) ^ (400 * Real.log L) * (8 * W) ^ J + have hC : 0 ≤ C := by dsimp [C]; positivity + have hrow (n : ℕ) (_hn : 0 < n) : + (∑ e : ((j : Fin J) → P j) × Q, + ‖retainedComplexPrimeEdge P Q Qp u eligible L K W extra h gate keep F G e n + ((n : ℤ) + retainedPrimeStep eligible h e)‖) ≤ C := by + simp only [retainedComplexPrimeEdge_active_step_eq] + exact retainedComplexPrimeEdge_row_bound P hprime hdisjoint Q Qp u eligible L K W + extra h gate keep F G hF hG hL hK hW hu hV n + have hb := retainedComplexBlock_prefix_bound P M R N Q Qp u eligible L K W extra h + gate keep F G hM hN B C hC hr hrow havg + simp only [retainedComplexPrimeEdge_active_step_eq] at hb + unfold retainedComplexPrefix + rw [norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hL] + apply (div_le_div_of_nonneg_right hb hL.le).trans + dsimp [C] + apply le_of_eq + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexRawComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexRawComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..49473ceba6814c61a3573f76bdbf19a5bf91a55c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexRawComparison.lean @@ -0,0 +1,110 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexFullDilation +import OAI.NumberTheory.TwoPoint.Bounds.MultiplicativeExtraction +import OAI.NumberTheory.TwoPoint.Bounds.NearbyCutoffs +import Mathlib.Algebra.Order.Floor.Semifield + +namespace OAI + +/-! Raw complex correlations retain the actual prime-dependent extraction cost. +This is essential when the padding includes small primes. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma correlation_oneBounded {f g : ℕ → ℂ} (hf : OneBounded f) + (hg : OneBounded g) (h : ℕ) : OneBounded (fun n => f n * g (n + h)) := by + intro n hn + rw [norm_mul] + exact (mul_le_mul (hf n hn) (hg (n + h) (by omega)) (norm_nonneg _) zero_le_one).trans + (by norm_num) + +lemma dilated_correlation_extraction {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf : OneBounded f) (hg : OneBounded g) + (u h : ℕ) (hu : 0 < u) (P : Finset ℕ) + (hP : ∀ p ∈ P, p.Prime) + (hcover : ∀ p, p.Prime → p ∣ u → p ∈ P) + (T : ℝ) (hT : 0 < T) : + ‖positivePrefix (fun n => f (u * n) * g (u * (n + h))) ⌊T / u⌋₊ / (T : ℂ) - + (f u * g u) * (positivePrefix (fun n => f n * g (n + h)) ⌊T / u⌋₊ / + (T : ℂ))‖ ≤ + (1 / (u : ℝ)) * (4 * (∑ p ∈ P, 1 / (p : ℝ))) + 4 * P.card / T := by + have he : positivePrefix (fun n => f (u * n) * g (u * (n + h))) ⌊T / u⌋₊ - + (f u * g u) * positivePrefix (fun n => f n * g (n + h)) ⌊T / u⌋₊ = + positivePrefix (multiplicativeExtractionGap f g u h) ⌊T / u⌋₊ := by + unfold positivePrefix multiplicativeExtractionGap + rw [mul_sum, ← sum_sub_distrib] + apply sum_congr rfl + intro n _ + ring + rw [← mul_div_assoc, ← sub_div, he, norm_div, Complex.norm_real, + Real.norm_eq_abs, abs_of_pos hT] + have huR : (0 : ℝ) < u := by exact_mod_cast hu + have hfloor : (⌊T / u⌋₊ : ℝ) ≤ T / u := Nat.floor_le (div_nonneg hT.le huR.le) + apply (div_le_iff₀ hT).mpr + calc + _ ≤ 4 * (⌊T / u⌋₊ : ℝ) * (∑ p ∈ P, 1 / (p : ℝ)) + 4 * P.card := + multiplicativeExtraction_sum_bound hfm hgm hf hg u h _ hu P hP hcover + _ ≤ 4 * (T / u) * (∑ p ∈ P, 1 / (p : ℝ)) + 4 * P.card := by + gcongr + _ = _ := by field_simp + +lemma dilated_correlation_bin_error {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf : OneBounded f) (hg : OneBounded g) + (u h : ℕ) (hu : 0 < u) (P : Finset ℕ) + (hP : ∀ p ∈ P, p.Prime) + (hcover : ∀ p, p.Prime → p ∣ u → p ∈ P) + (X T η : ℝ) (hX : 0 < X) (hη : 0 ≤ η) + (hlo : X * Real.exp (-η) ≤ T / u) (hhi : T / u ≤ X) : + ‖positivePrefix (fun n => f (u * n) * g (u * (n + h))) (⌊T⌋₊ / u) / + (T : ℂ) - + ((f u * g u) / (u : ℂ)) * + (positivePrefix (fun n => f n * g (n + h)) ⌊X⌋₊ / (X : ℂ))‖ ≤ + (1 / (u : ℝ)) * ((4 * (∑ p ∈ P, 1 / (p : ℝ))) + 2 * η + 1 / X) + + 4 * P.card / T := by + have huR : (0 : ℝ) < u := by exact_mod_cast hu + have hY : 0 < T / u := (mul_pos hX (Real.exp_pos _)).trans_le hlo + have hT : 0 < T := (div_pos_iff_of_pos_right huR).mp hY + have huC : (u : ℂ) ≠ 0 := by exact_mod_cast hu.ne' + have hTC : (T : ℂ) ≠ 0 := by exact_mod_cast hT.ne' + let C := f u * g u + let A := positivePrefix (fun n => f n * g (n + h)) ⌊T / u⌋₊ / ((T / u : ℝ) : ℂ) + let B := positivePrefix (fun n => f n * g (n + h)) ⌊X⌋₊ / (X : ℂ) + have hC : ‖C‖ ≤ 1 := by + dsimp [C] + rw [norm_mul] + exact (mul_le_mul (hf u hu) (hg u hu) (norm_nonneg _) zero_le_one).trans (by norm_num) + have hnear : ‖A - B‖ ≤ 2 * η + 1 / X := + real_prefix_log_bin _ (correlation_oneBounded hf hg h) X (T / u) η hX hη hlo hhi + have hscale : C * (positivePrefix (fun n => f n * g (n + h)) ⌊T / u⌋₊ / + (T : ℂ)) = (C / (u : ℂ)) * A := by + dsimp [A] + push_cast + field_simp [huC, hTC] + rw [← Nat.floor_div_natCast] + have he := dilated_correlation_extraction hfm hgm hf hg u h hu P hP hcover T hT + change ‖_ - (C / (u : ℂ)) * B‖ ≤ _ + calc + _ ≤ ‖positivePrefix (fun n => f (u * n) * g (u * (n + h))) ⌊T / u⌋₊ / + (T : ℂ) - (C / (u : ℂ)) * A‖ + ‖(C / (u : ℂ)) * (A - B)‖ := by + have heq : positivePrefix (fun n => f (u * n) * g (u * (n + h))) ⌊T / u⌋₊ / + (T : ℂ) - (C / (u : ℂ)) * B = + (positivePrefix (fun n => f (u * n) * g (u * (n + h))) ⌊T / u⌋₊ / + (T : ℂ) - (C / (u : ℂ)) * A) + (C / (u : ℂ)) * (A - B) := by ring + rw [heq] + exact norm_add_le _ _ + _ ≤ ((1 / (u : ℝ)) * (4 * (∑ p ∈ P, 1 / (p : ℝ))) + 4 * P.card / T) + + (1 / (u : ℝ)) * (2 * η + 1 / X) := by + apply add_le_add + · simpa only [← hscale, C] using he + · rw [norm_mul, norm_div, Complex.norm_natCast] + exact mul_le_mul (div_le_div_of_nonneg_right hC huR.le) hnear + (norm_nonneg _) (by positivity) + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexRawSelection.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexRawSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..2bef7c0c778155037efbc226297116a05f0c87cb --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexRawSelection.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexRawComparison +import OAI.NumberTheory.TwoPoint.Bounds.PhaseSelection + +namespace OAI + +/-! Numerical phase selection and the raw lower bound use the whole reciprocal +mass. No phase or nonvanishing condition is imposed on individual primes. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma exists_weighted_phase_subset {ι : Type*} (S : Finset ι) (w : ι → ℝ) + (z : ι → ℂ) (hw : ∀ i ∈ S, 0 ≤ w i) + (hdefect : (∑ i ∈ S, w i * (1 - ‖z i‖)) ≤ (∑ i ∈ S, w i) / 2) : + ∃ A ⊆ S, (∑ i ∈ S, w i) / 8 ≤ ‖∑ i ∈ A, (w i : ℂ) * z i‖ := by + obtain ⟨A, hAS, hA⟩ := exists_subfamily_complex_mass S (fun i => (w i : ℂ) * z i) + refine ⟨A, hAS, ?_⟩ + have he : (∑ i ∈ S, w i * (1 - ‖z i‖)) = + (∑ i ∈ S, w i) - ∑ i ∈ S, w i * ‖z i‖ := by + rw [← sum_sub_distrib] + apply sum_congr rfl + intro i _ + ring + have hn : (∑ i ∈ S, ‖(w i : ℂ) * z i‖) = ∑ i ∈ S, w i * ‖z i‖ := by + apply sum_congr rfl + intro i hi + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hw i hi)] + rw [hn] at hA + rw [he] at hdefect + linarith + +lemma weighted_dilated_correlation_comparison {ι : Type*} {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf : OneBounded f) (hg : OneBounded g) + (S : Finset ι) (w : ι → ℝ) (u : ι → ℕ) (P : ι → Finset ℕ) + (T : ι → ℝ) (h : ℕ) (X η : ℝ) + (hw : ∀ i ∈ S, 0 ≤ w i) (hu : ∀ i ∈ S, 0 < u i) + (hP : ∀ i ∈ S, ∀ p ∈ P i, p.Prime) + (hcover : ∀ i ∈ S, ∀ p, p.Prime → p ∣ u i → p ∈ P i) + (hX : 0 < X) (hη : 0 ≤ η) + (hlo : ∀ i ∈ S, X * Real.exp (-η) ≤ T i / u i) + (hhi : ∀ i ∈ S, T i / u i ≤ X) : + ‖(∑ i ∈ S, (w i : ℂ) * + (positivePrefix (fun n => f (u i * n) * g (u i * (n + h))) + (⌊T i⌋₊ / u i) / (T i : ℂ))) - + (∑ i ∈ S, (w i : ℂ) * ((f (u i) * g (u i)) / (u i : ℂ))) * + (positivePrefix (fun n => f n * g (n + h)) ⌊X⌋₊ / (X : ℂ))‖ ≤ + ∑ i ∈ S, w i * ((1 / (u i : ℝ)) * + ((4 * (∑ p ∈ P i, 1 / (p : ℝ))) + 2 * η + 1 / X) + + 4 * (P i).card / T i) := by + rw [sum_mul, ← sum_sub_distrib] + simp_rw [mul_assoc, ← mul_sub] + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro i hi + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hw i hi)] + exact mul_le_mul_of_nonneg_left + (dilated_correlation_bin_error hfm hgm hf hg (u i) h (hu i hi) (P i) + (hP i hi) (hcover i hi) X (T i) η hX hη (hlo i hi) (hhi i hi)) (hw i hi) + +lemma raw_norm_lower_bound (R C M : ℂ) (mass γ : ℝ) + (_hmass : 0 ≤ mass) (hγ : 0 ≤ γ) + (hC : mass / 8 ≤ ‖C‖) (hM : γ ≤ ‖M‖) + (herr : ‖R - C * M‖ ≤ γ * mass / 16) : + γ * mass / 16 ≤ ‖R‖ := by + have hprod : (mass / 8) * γ ≤ ‖C * M‖ := by + rw [norm_mul] + exact mul_le_mul hC hM hγ (norm_nonneg C) + have htriangle : ‖C * M‖ ≤ ‖R‖ + ‖R - C * M‖ := by + calc + _ = ‖R - (R - C * M)‖ := by congr 1; ring + _ ≤ _ := norm_sub_le _ _ + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexTupleProfiles.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexTupleProfiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac125a3e19b95fca75f25e1676419bc092c7491d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ComplexTupleProfiles.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CenteredTupleProfiles + +namespace OAI + +/-! Exact centered tuple expansion for arbitrary complex sequences. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def tupleComplexPartialProfile {J : ℕ} (P : Fin J → Finset ℕ) + (I : Finset (Fin J)) (q : ℕ) (eligible : ℕ → ℕ → Prop) + (F G : ℕ → ℂ) (h n : ℕ) : ℂ := + ∑ x : (j : Fin J) → P j, + if eligible (∏ j, (x j).val) q then + ((∏ i : I, (x i).val : ℕ) : ℂ)⁻¹ * + (natDivisibilityIndicator (q * ∏ j : {j // j ∉ I}, (x j).val) n * + (F n * G (n + h * (q * ∏ j, (x j).val)))) + else 0 + +noncomputable def tupleComplexCenteredProfile {J : ℕ} (P : Fin J → Finset ℕ) + (q : ℕ) (eligible : ℕ → ℕ → Prop) (F G : ℕ → ℂ) (h n : ℕ) : ℂ := + ∑ x : (j : Fin J) → P j, + if eligible (∏ j, (x j).val) q then + natDivisibilityIndicator q n * + (centeredTuple (∏ j, (x j).val).primeFactors (n : ℤ) : ℂ) * + (F n * G (n + h * (q * ∏ j, (x j).val))) + else 0 + +lemma tupleComplexCenteredProfile_expansion {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (q : ℕ) (hcop : ∀ j, ∀ p ∈ P j, q.Coprime p) + (eligible : ℕ → ℕ → Prop) (F G : ℕ → ℂ) (h n : ℕ) : + tupleComplexCenteredProfile P q eligible F G h n = + ∑ I ∈ (univ : Finset (Fin J)).powerset, + (-1 : ℂ) ^ I.card * tupleComplexPartialProfile P I q eligible F G h n := by + simp only [tupleComplexCenteredProfile, tupleComplexPartialProfile, mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro x _ + by_cases he : eligible (∏ j, (x j).val) q + · simp only [he, ite_true] + rw [centeredTuple_nat_eq P hprime hdisjoint] + have hx := tuple_center_padding_expansion (fun j => (x j).val) + (fun j => hprime j _ (x j).property) (selectedPrimeValues_injective x hdisjoint) + q n (fun j => hcop j _ (x j).property) + (F n * G (n + h * (q * ∏ j, (x j).val))) + apply hx.trans + apply sum_congr rfl + intro I _ + ring + · simp only [he, ite_false, mul_zero, sum_const_zero] + +lemma tupleComplexCenteredProfile_nonraw {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (q : ℕ) (hcop : ∀ j, ∀ p ∈ P j, q.Coprime p) + (eligible : ℕ → ℕ → Prop) (F G : ℕ → ℂ) (h n : ℕ) : + tupleComplexCenteredProfile P q eligible F G h n - tupleComplexPartialProfile P ∅ q eligible F G h n = + ∑ I ∈ (univ : Finset (Fin J)).powerset.filter Finset.Nonempty, + (-1 : ℂ) ^ I.card * tupleComplexPartialProfile P I q eligible F G h n := by + rw [tupleComplexCenteredProfile_expansion P hprime hdisjoint q hcop eligible F G h n] + let H : Finset (Fin J) → ℂ := fun I => + (-1 : ℂ) ^ I.card * tupleComplexPartialProfile P I q eligible F G h n + have he : (univ : Finset (Fin J)).powerset.filter Finset.Nonempty = + (univ : Finset (Fin J)).powerset.erase ∅ := by + ext I + simp only [mem_filter, mem_erase, nonempty_iff_ne_empty] + exact and_comm + rw [he] + change (∑ I ∈ (univ : Finset (Fin J)).powerset, H I) - _ = + ∑ I ∈ (univ : Finset (Fin J)).powerset.erase ∅, H I + rw [← sum_erase_add _ H (empty_mem_powerset _)] + simp only [H, card_empty, pow_zero, one_mul, add_sub_cancel_right] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CompressedRuns.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CompressedRuns.lean new file mode 100644 index 0000000000000000000000000000000000000000..a42cfc7c60900528022816d6c1cfe3210fe71a04 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CompressedRuns.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RunSegments +import OAI.NumberTheory.TwoPoint.Walks.ColumnRunEncoding +import Mathlib.Data.List.Destutter +import Mathlib.Data.List.NodupEquivFin + +namespace OAI + +/-! Actual constant-run compression of a perfect block. -/ + +namespace TwoPointCorrelations + +variable {α : Type*} [DecidableEq α] + +/-- The decoder's greedy run heads are exactly the library's constant-run +compression, so its sublist and adjacent-inequality properties apply. -/ +theorem destutter'_eq_columnRunHeads (a : α) (l : List α) : + l.destutter' (· ≠ ·) a = a :: columnRunHeads (l.map some) (some a) := by + induction l generalizing a with + | nil => rfl + | cons b rest ih => + by_cases h : a = b + · subst b + simpa [List.destutter', columnRunHeads] using ih a + · simpa [List.destutter', columnRunHeads, h] using congrArg (List.cons a) (ih b) + +theorem columnRunHeads_eq_destutter (l : List α) : + columnRunHeads (l.map some) none = l.destutter (· ≠ ·) := by + cases l with + | nil => rfl + | cons a rest => + rw [List.destutter_cons', destutter'_eq_columnRunHeads] + simp [columnRunHeads] + +omit [DecidableEq α] in +/-- A subsequence with unequal adjacent entries has no repeated label when +all occurrences in the original block are interval-shaped. -/ +theorem sublist_chain_nodup_of_intervals (l runs : List α) (hsub : runs.Sublist l) + (hchain : runs.IsChain (· ≠ ·)) + (hinterval : ∀ i j k : Fin l.length, i ≤ j → j ≤ k → + l.get i = l.get k → l.get j = l.get i) : runs.Nodup := by + obtain ⟨e, he⟩ := List.sublist_iff_exists_fin_orderEmbedding_get_eq.mp hsub + have hchange : ∀ i j : Fin runs.length, i.val + 1 = j.val → l.get (e i) ≠ l.get (e j) := by + intro i j hij + rw [← he i, ← he j] + have hj : i.val + 1 < runs.length := by omega + have hc := (List.isChain_iff_getElem.mp hchain) i.val hj + simpa only [List.get_eq_getElem, hij] using hc + have hinj := run_labels_injective l.get hinterval e e.strictMono hchange + apply List.nodup_iff_injective_get.mpr + intro i j hij + apply hinj + change l.get (e i) = l.get (e j) + rw [← he i, ← he j, hij] + +/-- Each numerical label contributes at most one compressed run in a +perfect block. This is proved for the actual run-head algorithm. -/ +theorem columnRunHeads_nodup (l : List α) + (hinterval : ∀ i j k : Fin l.length, i ≤ j → j ≤ k → + l.get i = l.get k → l.get j = l.get i) : + (columnRunHeads (l.map some) none).Nodup := by + rw [columnRunHeads_eq_destutter] + exact sublist_chain_nodup_of_intervals l _ (List.destutter_sublist (R := (· ≠ ·)) l) + (List.isChain_destutter (R := (· ≠ ·)) l) hinterval + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ConditionalComplexCore.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ConditionalComplexCore.lean new file mode 100644 index 0000000000000000000000000000000000000000..a32037e4632d425267785635703f6b8a8dcb8ffd --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ConditionalComplexCore.lean @@ -0,0 +1,137 @@ +import OAI.NumberTheory.TwoPoint.Walks.CanonicalRawSelection +import OAI.NumberTheory.TwoPoint.Walks.SelectedRawBinsLower +import OAI.NumberTheory.TwoPoint.Walks.CanonicalComplexLimits +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeCenteringTotal +import OAI.NumberTheory.TwoPoint.Bounds.PrimeDefectBias +import OAI.NumberTheory.TwoPoint.Bounds.QuantitativeFinalWindows + +namespace OAI + +/-! Conditional ordinary two-point cancellation. The only hypotheses beyond +the original multiplicative functions are the four cited published inputs. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical Topology + +theorem conditional_complex_positive_core (hP : ModFiveThetaInput) + (hBr : BravermanDepth22Input) (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf : ∀ n, ‖f n‖ ≤ 1) (hg : ∀ n, ‖g n‖ ≤ 1) + (hnp : UniformlyNonpretentious f ∨ UniformlyNonpretentious g) + (h : ℕ) (hh : 0 < h) : + Tendsto (fun N : ℕ => positivePrefix (fun n => f n * g (n + h)) N / (N : ℂ)) + atTop (𝓝 0) := by + have hfb : OneBounded f := fun n _ => hf n + have hgb : OneBounded g := fun n _ => hg n + by_contra hn + have hfail : ¬∀ ε : ℝ, 0 < ε → ∀ᶠ N : ℕ in atTop, + ‖positivePrefix (fun n => f n * g (n + h)) N / (N : ℂ)‖ < ε := by + intro hall + apply hn + rw [Metric.tendsto_nhds] + simpa only [dist_zero_right] using hall + push Not at hfail + obtain ⟨γ, hγ, hfreq⟩ := hfail + obtain ⟨hsf, hsg⟩ := persistent_correlation_prime_defects hfm hgm hfb hgb h hn + obtain ⟨hf1, hg1⟩ := persistent_correlation_one_values hfm hgm h hn + obtain ⟨Ag, W, hAg, hW, hgraph⟩ := complex_graph_fixed_scale hP hBr + have hWone : 1 ≤ W := by linarith + have hWp : 0 < W := by linarith + obtain ⟨E, hE, hselect⟩ := canonical_raw_pair_selection hP hfm hgm hf1 hg1 hfb hgb + hsf hsg h hh W γ hWone hγ + obtain ⟨Cg, hCg, hgraph⟩ := hgraph h hh E hE + obtain ⟨Cc, hCc, hcenter⟩ := qualitative_canonical_nonraw_total hP hM hMRT + hfm hgm hfb hgb hnp h hh E W hWone + have hηsmall := (canonical_eta_tendsto_zero W hWp).eventually + (gt_mem_nhds (by positivity : (0 : ℝ) < γ / 128)) + have herrors := (canonical_complex_error_tendsto_zero W Cg Cc hWp).eventually + (gt_mem_nhds (by positivity : (0 : ℝ) < γ / 16)) + obtain ⟨L, hgraphL, hcenterL, hselectL, hmassL, hηL, herrL, hLlarge⟩ := + (hgraph.and (hcenter.and (hselect.and + ((hP.eventually_canonical_retained_mass E W hWone).and + (hηsmall.and (herrors.and (eventually_ge_atTop (2 : ℝ)))))))).exists + have hL : 1 ≤ L := by linarith + let J := primeSupplyCount W L + let η := Real.exp (-(J : ℝ)) + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + let R := boundedPaddingDivisors Q ⌊100 * Real.log L⌋₊ + let D := primeTupleDivisors P + let S₀ := totalPaddingBinMass D Q L η + let M := paddingTiltNormalizer Q * ∏ j, primeHarmonicMass (P j) + let bins := paddingBinIndices L η + have hη : 0 < η := Real.exp_pos _ + obtain ⟨hS₀, A, hA, hphase, hweight, hcost⟩ := hselectL hL η hη + have hp : ∀ j, ∀ p ∈ P j, p.Prime := centeredPrimeBands_prime _ _ _ _ + have hd : ∀ j k, k ≠ j → Disjoint (P j) (P k) := centeredPrimeBands_disjoint _ _ _ _ + (Real.rpow_nonneg (zero_le_one.trans hL) _) (zero_le_one.trans hWone) + have hq : ∀ p ∈ Q, p.Prime := fun _ hp => paddingPrimeSupply_prime hp + have hD : ∀ d ∈ D, 0 < d := by + intro d hd' + exact Nat.pos_of_ne_zero (primeTupleDivisors_arithmetic P hp hd hd').1.ne_zero + have hR : ∀ q ∈ R, 0 < q := fun q hq' => retainedPrimeDivisor_pos Q hq (mem_filter.mp hq').1 + let b := fun dq : ℕ × ℕ => paddingBin η 0 (Real.log (dq.1 * dq.2 : ℕ)) + let eligible := selectedPairBin η A + have hAb : A ⊆ D ×ˢ R := selected_pairs_bounded_padding D Q A L η hL hA + have hb : ∀ dq ∈ A, b dq ∈ bins := fun _ hdq => selectedPairBin_index D Q A L η hA hdq + have hprop (j : ℤ) (d q : ℕ) (he : eligible j d q) := + selectedPairBin_properties D Q hD hq A L η hη hA he + have he : ∀ j ∈ bins, ∀ d q, eligible j d q → PaddingPairEligible L η d q := + fun j _ d q he => (hprop j d q he).2.2.1 + have hpos : ∀ j ∈ bins, ∀ d q, eligible j d q → 0 < d ∧ 0 < q := + fun j _ d q he => ⟨(hprop j d q he).1, (hprop j d q he).2.1⟩ + have hbin : ∀ j ∈ bins, ∀ d q, eligible j d q → actualPaddingBin η (Real.log d) j q := + fun j _ d q he => (hprop j d q he).2.2.2 + have hlower := selected_raw_bins_lower hfm hgm hfb hgb D Q hD hq L η γ hη hγ + A hA h hS₀ hphase hcost hηL.le + have hcent := hcenterL R (filter_subset _ _) + have hlarge : ∀ᶠ X : ℝ in atTop, Real.exp (L ^ Ag) ≤ X := eventually_ge_atTop _ + have hevent : ∀ᶠ X : ℝ in atTop, + γ ≤ ‖positivePrefix (fun n => f n * g (n + h)) ⌊X⌋₊ / (X : ℂ)‖ → False := by + filter_upwards [hlower, hcent, hlarge] with X hlower hcent hX + intro hbiased + have hXp : 0 < X := (Real.exp_pos _).trans_le hX + let T := fun j : ℤ => X * Real.exp ((j : ℝ) * η) + let N := fun j : ℤ => ⌊T j⌋₊ + let v := fun j : ℤ => (N j : ℂ) / (T j : ℂ) + let raw := ∑ j ∈ bins, v j * canonicalComplexUncutPrefix h E W L (eligible j) + (fun n => f n.toNat) (fun n => g n.toNat) (N j) + let full := selectedRawMean A (fun dq => T (b dq)) f g h + have hv : ∀ j ∈ bins, ‖v j‖ ≤ 1 := fun j _ => + floor_cutoff_weight_norm_le (T j) (mul_pos hXp (Real.exp_pos _)) + have hN : ∀ j ∈ bins, Real.exp (L ^ Ag / 2) ≤ (N j : ℝ) := fun j hj => + (final_bin_windows L X η Ag hLlarge hAg hX hη j hj).2 + have hupper : ‖raw‖ / S₀ ≤ Cg * η := + hgraphL hL eligible he hpos hbin (fun n => f n.toNat) (fun n => g n.toNat) + (fun n => hf n.toNat) (fun n => hg n.toNat) N v hN hv + have hid : raw - full = ∑ j ∈ bins, nonrawComplexBin P R (eligible j) f g h (T j) := + selected_uncut_sub_raw P hp hd R hR A hAb bins b hb f g h T + have hcerr : ‖raw - full‖ ≤ Cc * L ^ (-3 / 40 : ℝ) * M := by + rw [hid] + simpa only [one_mul, M, mul_assoc] using + hcent eligible (fun _ => (1 : ℂ)) hbin (fun _ _ => by norm_num) + have hmS : M / 2 ≤ S₀ := (hmassL hL η hη).2 + have hCm := mul_le_mul_of_nonneg_left (show M ≤ 2 * S₀ by linarith) + (show 0 ≤ Cc * L ^ (-3 / 40 : ℝ) by positivity) + have hgnum := (div_le_iff₀ hS₀).mp hupper + have hl := hlower hbiased + change γ * S₀ / 16 ≤ ‖full‖ at hl + have htri : ‖full‖ ≤ ‖raw‖ + ‖raw - full‖ := by + calc + _ = ‖raw - (raw - full)‖ := by congr 1; ring + _ ≤ _ := norm_sub_le _ _ + have hstrict := mul_lt_mul_of_pos_right herrL hS₀ + nlinarith + have heventN := tendsto_natCast_atTop_atTop.eventually hevent + have hbad : ∀ᶠ N : ℕ in atTop, + ¬γ ≤ ‖positivePrefix (fun n => f n * g (n + h)) N / (N : ℂ)‖ := by + filter_upwards [heventN] with N hN + simpa only [Nat.floor_natCast, Complex.ofReal_natCast] using hN + exact hfreq hbad + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ConditionalElliott.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ConditionalElliott.lean new file mode 100644 index 0000000000000000000000000000000000000000..02e9a8fdb93feba1bfd28746fdb50fd0d82c4c4e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ConditionalElliott.lean @@ -0,0 +1,36 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ConditionalComplexCore +import OAI.NumberTheory.TwoPoint.Bounds.PositiveNormalization +import OAI.NumberTheory.TwoPoint.Bounds.ProgressionDeduction + +namespace OAI + +/-! Theorem 1.2 and Corollary 1.3 of the manuscript, conditionally on the +explicit published short-sum, prime-distribution and circuit inputs. -/ + +namespace TwoPointCorrelations + +theorem conditional_unshiftedCorrectedElliott (hP : ModFiveThetaInput) + (hBr : BravermanDepth22Input) (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) : UnshiftedCorrectedElliott := by + intro f g hfm hgm hf hg hnp h hh + have hnp' : UniformlyNonpretentious (positiveNormalization f) ∨ + UniformlyNonpretentious (positiveNormalization g) := + hnp.imp (fun hn => hn.positiveNormalization hf) (fun hn => hn.positiveNormalization hg) + have hc := conditional_complex_positive_core hP hBr hM hMRT + hfm.positiveNormalization hgm.positiveNormalization + (positiveNormalization_norm hf) (positiveNormalization_norm hg) hnp' h hh + simpa only [positiveNormalization_prefix, correlationSum_eq_positivePrefix] using hc + +theorem conditional_binaryCorrectedElliott (hP : ModFiveThetaInput) + (hBr : BravermanDepth22Input) (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) : BinaryCorrectedElliott := + (conditional_unshiftedCorrectedElliott hP hBr hM hMRT).binary + +theorem conditional_affineCorrectedElliott (hP : ModFiveThetaInput) + (hBr : BravermanDepth22Input) (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) : AffineCorrectedElliott := + (conditional_binaryCorrectedElliott hP hBr hM hMRT).affine + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ConditionalLiouville.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ConditionalLiouville.lean new file mode 100644 index 0000000000000000000000000000000000000000..3dec6b4471e2c5f2605c9ad2067f4b5d7cb88efd --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ConditionalLiouville.lean @@ -0,0 +1,50 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QuantitativeFixedScale +import OAI.NumberTheory.TwoPoint.Bounds.ProgressionMeanIdentity +import OAI.NumberTheory.TwoPoint.QuantitativeAffineTransfer +import OAI.NumberTheory.TwoPoint.Bounds.LogSavingScale + +namespace OAI + +/-! The manuscript's quantitative main theorem, conditional only on the +named published prime, circuit, and Liouville short-sum inputs. -/ + +namespace TwoPointCorrelations + +open Filter + +theorem conditional_liouville_progression (hP : ModFiveThetaInput) + (hBr : BravermanDepth22Input) (hM : PrimeReciprocalInput) + (hMRT : MRTLiouvilleShortInput) : + ∃ c : ℝ, 0 < c ∧ ∀ h l b : ℕ, 0 < h → 0 < l → + ∃ C : ℝ, 0 < C ∧ ∀ᶠ X : ℝ in atTop, + ‖progressionSum liouville liouville h l b ⌊X⌋₊‖ ≤ + C * X / (Real.log X) ^ c := by + obtain ⟨A, W, hA, hW, hb⟩ := quantitative_fixed_scale hP hBr hM hMRT + have hAp : 0 < A := by omega + have hWp : 0 < W := by linarith + let c : ℝ := 1 / (1200 * W * A) + refine ⟨c, log_saving_exponent_pos W A hWp hAp, ?_⟩ + intro h l b hh hl + let : NeZero l := ⟨by omega⟩ + obtain ⟨C, hC, hb⟩ := hb h l hh + refine ⟨C * Real.exp 1, by positivity, ?_⟩ + filter_upwards [(final_log_scale_tendsto A hAp).eventually hb, + eventually_ge_atTop (Real.exp 1)] with X hb hX + have hXone : 1 ≤ X := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hX + have hXp : 0 < X := (Real.exp_pos _).trans_le hX + have hm := hb X (by rw [final_log_scale_exact X A hXone (by omega)]) b + rw [progressionLiouvilleMean_eq, norm_div, Complex.norm_real, + Real.norm_eq_abs, abs_of_pos hXp] at hm + have hs := mul_le_mul_of_nonneg_left (primeSupplyCount_log_saving X W A hX hWp hAp) hC.le + have hm' := (div_le_iff₀ hXp).mp (hm.trans hs) + change ‖progressionSum liouville liouville h l b ⌊X⌋₊‖ ≤ _ + convert hm' using 1; ring + +theorem conditional_liouvilleLogSaving (hP : ModFiveThetaInput) + (hBr : BravermanDepth22Input) (hM : PrimeReciprocalInput) + (hMRT : MRTLiouvilleShortInput) : LiouvilleLogSaving := + liouvilleLogSaving_of_progression (conditional_liouville_progression hP hBr hM hMRT) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CoordinateEmbedding.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CoordinateEmbedding.lean new file mode 100644 index 0000000000000000000000000000000000000000..58b00c76ccae31f511133cc17e6c31914ad94661 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CoordinateEmbedding.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TwoPoint.Walks.SelectedPairRank +import OAI.NumberTheory.TwoPoint.Bounds.FormalDepartures +import Mathlib.LinearAlgebra.Pi + +namespace OAI + +/-! Removing unused prime labels preserves the selected-pair rank. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {α β ρ : Type*} [Fintype α] [Fintype β] + +lemma extendByZero_basis (e : α → β) (he : Function.Injective e) (a : α) : + Function.ExtendByZero.linearMap ℝ e (Pi.basisFun ℝ α a) = Pi.basisFun ℝ β (e a) := by + classical + ext b + by_cases hb : ∃ c, e c = b + · obtain ⟨c, rfl⟩ := hb + change Function.extend e (Pi.basisFun ℝ α a) 0 (e c) = _ + rw [he.extend_apply] + simp [Pi.basisFun_apply, Pi.single_apply, he.eq_iff] + · change Function.extend e (Pi.basisFun ℝ α a) 0 b = _ + rw [Function.extend_apply' _ _ _ hb] + have hne : b ≠ e a := fun h => hb ⟨a, h.symm⟩ + simp [Pi.basisFun_apply, hne] + +omit [Fintype α] [Fintype β] in +lemma extendByZero_injective (e : α → β) (he : Function.Injective e) : + Function.Injective (Function.ExtendByZero.linearMap ℝ e) := by + intro x y hxy + funext a + have h := congrFun hxy (e a) + simpa only [Function.ExtendByZero.linearMap_apply, he.extend_apply] using h + +lemma formalDeparture_extend (e : α → β) (he : Function.Injective e) + (label : ℕ → α) (coefficient : ℕ → ℝ) (n : ℕ) : + Function.ExtendByZero.linearMap ℝ e (formalDeparture label coefficient n) = + formalDeparture (e ∘ label) coefficient n := by + unfold formalDeparture + simp only [map_sum, map_smul, extendByZero_basis e he, Function.comp_apply] + +/-- In particular, a rank witness in the ambient prime pool is equivalent +to the witness on its observed equality classes. -/ +theorem selected_rank_rename_iff (e : α → β) (he : Function.Injective e) + (label : ℕ → α) (coefficient : ℕ → ℝ) (left right : ρ → ℕ) (control : ρ → α) : + LinearIndependent ℝ (Sum.elim + (fun i => formalDeparture label coefficient (left i) - formalDeparture label coefficient (right i)) + (fun i => Pi.basisFun ℝ α (control i))) ↔ + LinearIndependent ℝ (Sum.elim + (fun i => formalDeparture (e ∘ label) coefficient (left i) - + formalDeparture (e ∘ label) coefficient (right i)) + (fun i => Pi.basisFun ℝ β (e (control i)))) := by + let E := Function.ExtendByZero.linearMap ℝ e + have hfamily : (E ∘ Sum.elim + (fun i => formalDeparture label coefficient (left i) - formalDeparture label coefficient (right i)) + (fun i => Pi.basisFun ℝ α (control i))) = Sum.elim + (fun i => formalDeparture (e ∘ label) coefficient (left i) - + formalDeparture (e ∘ label) coefficient (right i)) + (fun i => Pi.basisFun ℝ β (e (control i))) := by + funext i + rcases i with i | i + · exact (map_sub E _ _).trans (congrArg₂ (· - ·) + (formalDeparture_extend e he label coefficient (left i)) + (formalDeparture_extend e he label coefficient (right i))) + · exact extendByZero_basis e he (control i) + constructor + · intro h + rw [← hfamily] + exact h.map' E (LinearMap.ker_eq_bot.mpr (extendByZero_injective e he)) + · intro h + rw [← hfamily] at h + exact LinearIndependent.of_comp E h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CoordinateFiberSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CoordinateFiberSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f63033884866bcb5ace8520020bbf0b10b63013 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CoordinateFiberSum.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FamilyPatternSum + +namespace OAI + +/-! Sum one coordinate first, retaining the weighted sum of all other coordinates. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def outsideCoordinate {I : Type*} {β : I → Type*} (j : I) (w : ∀ i, β i) : + (i : {i // i ≠ j}) → β i := fun i => w i + +lemma update_eq_of_outside_eq {I : Type*} [DecidableEq I] {β : I → Type*} + (j : I) (u v : ∀ i, β i) (h : outsideCoordinate j u = outsideCoordinate j v) : + Function.update u j (v j) = v := by + funext i + by_cases hi : i = j + · subst i + simp + · rw [Function.update_of_ne hi] + exact congrFun h ⟨i, hi⟩ + +theorem coordinate_fiber_sum_bound {I : Type*} [Fintype I] [DecidableEq I] + {β : I → Type*} [∀ i, DecidableEq (β i)] + (F : Finset (∀ i, β i)) (j : I) (weight : (i : I) → β i → ℝ) + (hw : ∀ i x, 0 ≤ weight i x) (M : ℝ) + (hfiber : ∀ x ∈ F.image (outsideCoordinate j), + (∑ v ∈ (F.filter (fun w => outsideCoordinate j w = x)).image (fun w => w j), + weight j v) ≤ M) : + (∑ w ∈ F, ∏ i, weight i (w i)) ≤ + M * ∑ x ∈ F.image (outsideCoordinate j), ∏ i, weight i.val (x i) := by + let fiber (x : (i : {i // i ≠ j}) → β i) := + F.filter (fun w => outsideCoordinate j w = x) + have hsplit (w : ∀ i, β i) : + (∏ i, weight i (w i)) = weight j (w j) * + ∏ i : {i // i ≠ j}, weight i.val (outsideCoordinate j w i) := by + rw [← mul_prod_erase univ (fun i => weight i (w i)) (mem_univ j)] + congr 1 + exact prod_subtype (univ.erase j) (by simp) (fun i => weight i (w i)) + have hinj (x : (i : {i // i ≠ j}) → β i) : + Set.InjOn (fun w : ∀ i, β i => w j) (fiber x) := by + intro u hu v hv he + funext i + by_cases hi : i = j + · subst i + exact he + · have ho := (mem_filter.mp hu).2.trans (mem_filter.mp hv).2.symm + exact congrFun ho ⟨i, hi⟩ + calc + _ = ∑ x ∈ F.image (outsideCoordinate j), ∑ w ∈ fiber x, ∏ i, weight i (w i) := + (sum_fiberwise_of_maps_to (fun w hw => mem_image_of_mem _ hw) _).symm + _ = ∑ x ∈ F.image (outsideCoordinate j), + (∑ w ∈ fiber x, weight j (w j)) * ∏ i, weight i.val (x i) := by + apply sum_congr rfl + intro x hx + rw [sum_mul] + apply sum_congr rfl + intro w hw' + rw [hsplit, (mem_filter.mp hw').2] + _ ≤ ∑ x ∈ F.image (outsideCoordinate j), M * ∏ i, weight i.val (x i) := by + apply sum_le_sum + intro x hx + apply mul_le_mul_of_nonneg_right _ (prod_nonneg (fun i _ => hw _ _)) + rw [← sum_image (hinj x)] + exact hfiber x hx + _ = _ := (mul_sum _ _ _).symm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CoordinateProjection.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CoordinateProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..e35de2bf39ae2ce25be937bd947cbd3e51a2fa52 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CoordinateProjection.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MatrixAction +import OAI.NumberTheory.TwoPoint.Bounds.SpectralTransfer + +namespace OAI + +/-! The orthogonal projection deleting the high-degree vertices. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {V : Type*} [Fintype V] [DecidableEq V] + +noncomputable def coordinateProjection (keep : V → Prop) : + EuclideanSpace ℂ V →L[ℂ] EuclideanSpace ℂ V := + matrixOperator (Matrix.diagonal (fun i => if keep i then (1 : ℂ) else 0)) + +lemma coordinateProjection_apply (keep : V → Prop) (v : EuclideanSpace ℂ V) (i : V) : + coordinateProjection keep v i = if keep i then v i else 0 := by + change (∑ j, Matrix.diagonal (fun i => if keep i then (1 : ℂ) else 0) i j * v j) = _ + simp [Matrix.diagonal_apply] + +lemma coordinateProjection_selfAdjoint (keep : V → Prop) : + IsSelfAdjoint (coordinateProjection keep) := by + apply matrixOperator_selfAdjoint + intro i j + by_cases hij : i = j + · subst j + by_cases hi : keep i <;> simp [hi] + · simp [hij, Ne.symm hij] + +lemma coordinateProjection_idempotent (keep : V → Prop) : + coordinateProjection keep * coordinateProjection keep = coordinateProjection keep := by + ext v i + change coordinateProjection keep (coordinateProjection keep v) i = coordinateProjection keep v i + simp only [coordinateProjection_apply] + split_ifs <;> rfl + +lemma coordinateProjection_support (keep : V → Prop) (v : EuclideanSpace ℂ V) + (hv : coordinateProjection keep v = v) (i : V) (hi : v i ≠ 0) : keep i := by + by_contra hkeep + have he := congrArg (fun w : EuclideanSpace ℂ V => w i) hv + rw [coordinateProjection_apply, ite_eq_right hkeep] at he + exact hi he.symm + +lemma coordinateProjection_norm_le (keep : V → Prop) (v : EuclideanSpace ℂ V) : + ‖coordinateProjection keep v‖ ≤ ‖v‖ := + projection_norm_apply_le _ (coordinateProjection_selfAdjoint keep) + (coordinateProjection_idempotent keep) v + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CoordinateSampling.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CoordinateSampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..f814f12ecdc3e9cc4acae29114ea157ae1a8e8f2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CoordinateSampling.lean @@ -0,0 +1,180 @@ +import OAI.NumberTheory.TwoPoint.Walks.DisjointCoordinates +import OAI.NumberTheory.TwoPoint.Bounds.IndependentSampling + +namespace OAI + +/-! Factor the full independent law into controls, pivots and outside coordinates. -/ + +namespace TwoPointCorrelations + +open Finset Matrix + +namespace FiniteLaw + +variable {ι κ A : Type*} [Fintype ι] [DecidableEq ι] + [Fintype κ] [DecidableEq κ] [Fintype A] + +/-- A bijection of coordinate names preserves a constant independent law. -/ +lemma independent_average_equiv (e : ι ≃ κ) (μ : FiniteLaw A) + (f : (κ → A) → ℝ) : + (independent (fun _ : κ => μ)).average f = + (independent (fun _ : ι => μ)).average (fun x => f (fun k => x (e.symm k))) := by + let E : (ι → A) ≃ (κ → A) := Equiv.arrowCongr e (Equiv.refl A) + calc + _ = ∑ x : ι → A, (independent (fun _ : κ => μ)).weight (E x) * f (E x) := + (E.sum_comp (fun x => (independent (fun _ : κ => μ)).weight x * f x)).symm + _ = _ := by + apply sum_congr rfl + intro x _ + change (∏ k, μ.weight (x (e.symm k))) * f (fun k => x (e.symm k)) = + (∏ i, μ.weight (x i)) * f (fun k => x (e.symm k)) + exact congrArg (fun r => r * f (fun k => x (e.symm k))) + (e.symm.prod_comp (fun i => μ.weight (x i))) + +/-- Independence on a sum of coordinate types is the product of the two +independent laws. -/ +lemma independent_average_sum (μ : FiniteLaw A) (f : (ι ⊕ κ → A) → ℝ) : + (independent (fun _ : ι ⊕ κ => μ)).average f = + (independent (fun _ : ι => μ)).average (fun x => + (independent (fun _ : κ => μ)).average (fun y => f (Sum.elim x y))) := by + let E := Equiv.sumArrowEquivProdArrow ι κ A + calc + _ = ∑ xy : (ι → A) × (κ → A), + (independent (fun _ : ι ⊕ κ => μ)).weight (Sum.elim xy.1 xy.2) * + f (Sum.elim xy.1 xy.2) := + (E.symm.sum_comp (fun x => (independent (fun _ : ι ⊕ κ => μ)).weight x * f x)).symm + _ = _ := by + simp only [Fintype.sum_prod_type, independent, Fintype.prod_sum_type, + Sum.elim_inl, Sum.elim_inr, average, mul_sum] + apply sum_congr rfl + intro x _ + apply sum_congr rfl + intro y _ + ring + +end FiniteLaw + +variable {α ρ A : Type*} [Fintype α] [DecidableEq α] [Fintype ρ] [DecidableEq ρ] + +abbrev OutsideIndex (control pivot : ρ → α) := {z : α // z ∈ outsideCoordinates control pivot} + +def coordinateIndex (control pivot : ρ → α) : ρ ⊕ (ρ ⊕ OutsideIndex control pivot) → α := + Sum.elim control (Sum.elim pivot Subtype.val) + +omit [DecidableEq ρ] in +lemma coordinateIndex_bijective (control pivot : ρ → α) + (hc : Function.Injective control) (hp : Function.Injective pivot) + (hdisjoint : ∀ i j, pivot i ≠ control j) : + Function.Bijective (coordinateIndex control pivot) := by + classical + have hout (z : OutsideIndex control pivot) : + (∀ i, (z : α) ≠ control i) ∧ (∀ i, (z : α) ≠ pivot i) := by + have hz : (z : α) ∉ controlCoordinates control ∧ (z : α) ∉ controlCoordinates pivot := by + simpa only [outsideCoordinates, mem_compl, mem_union, not_or] using z.property + constructor + · intro i h + exact hz.1 (mem_image.mpr ⟨i, mem_univ _, h.symm⟩) + · intro i h + exact hz.2 (mem_image.mpr ⟨i, mem_univ _, h.symm⟩) + constructor + · intro x y hxy + rcases x with i | (i | z) <;> rcases y with j | (j | z') + · exact congrArg Sum.inl (hc hxy) + · exact False.elim (hdisjoint j i hxy.symm) + · exact False.elim ((hout z').1 i hxy.symm) + · exact False.elim (hdisjoint i j hxy) + · exact congrArg (Sum.inr ∘ Sum.inl) (hp hxy) + · exact False.elim ((hout z').2 i hxy.symm) + · exact False.elim ((hout z).1 j hxy) + · exact False.elim ((hout z).2 j hxy) + · exact congrArg (Sum.inr ∘ Sum.inr) (Subtype.ext hxy) + · intro z + by_cases hz : z ∈ controlCoordinates control + · obtain ⟨i, _, rfl⟩ := mem_image.mp hz + exact ⟨Sum.inl i, rfl⟩ + · by_cases hz' : z ∈ controlCoordinates pivot + · obtain ⟨i, _, rfl⟩ := mem_image.mp hz' + exact ⟨Sum.inr (Sum.inl i), rfl⟩ + · exact ⟨Sum.inr (Sum.inr ⟨z, by simp [outsideCoordinates, hz, hz']⟩), rfl⟩ + +noncomputable def coordinateEquiv (control pivot : ρ → α) + (hc : Function.Injective control) (hp : Function.Injective pivot) + (hdisjoint : ∀ i j, pivot i ≠ control j) : + ρ ⊕ (ρ ⊕ OutsideIndex control pivot) ≃ α := + Equiv.ofBijective (coordinateIndex control pivot) (coordinateIndex_bijective control pivot hc hp hdisjoint) + +noncomputable def coordinateAssignment (control pivot : ρ → α) + (hc : Function.Injective control) (hp : Function.Injective pivot) + (hdisjoint : ∀ i j, pivot i ≠ control j) + (base : OutsideIndex control pivot → A) (c y : ρ → A) : α → A := + fun z => Sum.elim c (Sum.elim y base) ((coordinateEquiv control pivot hc hp hdisjoint).symm z) + +omit [DecidableEq ρ] in +lemma coordinateAssignment_index (control pivot : ρ → α) + (hc : Function.Injective control) (hp : Function.Injective pivot) + (hdisjoint : ∀ i j, pivot i ≠ control j) + (base : OutsideIndex control pivot → A) (c y : ρ → A) + (z : ρ ⊕ (ρ ⊕ OutsideIndex control pivot)) : + coordinateAssignment control pivot hc hp hdisjoint base c y + (coordinateIndex control pivot z) = Sum.elim c (Sum.elim y base) z := by + exact congrArg (Sum.elim c (Sum.elim y base)) + ((coordinateEquiv control pivot hc hp hdisjoint).symm_apply_apply z) + +/-- Full product-law factorization, with the outside coordinates averaged +last in the proof and moved to the outermost expectation in the result. -/ +theorem independent_average_three [Fintype A] + (control pivot : ρ → α) (hc : Function.Injective control) (hp : Function.Injective pivot) + (hdisjoint : ∀ i j, pivot i ≠ control j) (μ : FiniteLaw A) (f : (α → A) → ℝ) : + (FiniteLaw.independent (fun _ : α => μ)).average f = + (FiniteLaw.independent (fun _ : OutsideIndex control pivot => μ)).average (fun base => + (FiniteLaw.independent (fun _ : ρ => μ)).average (fun c => + (FiniteLaw.independent (fun _ : ρ => μ)).average (fun y => + f (coordinateAssignment control pivot hc hp hdisjoint base c y)))) := by + classical + rw [FiniteLaw.independent_average_equiv (coordinateEquiv control pivot hc hp hdisjoint)] + rw [FiniteLaw.independent_average_sum] + simp_rw [FiniteLaw.independent_average_sum] + change (FiniteLaw.independent (fun _ : ρ => μ)).average (fun c => + (FiniteLaw.independent (fun _ : ρ => μ)).average (fun y => + (FiniteLaw.independent (fun _ : OutsideIndex control pivot => μ)).average (fun base => + f (coordinateAssignment control pivot hc hp hdisjoint base c y)))) = _ + calc + _ = (FiniteLaw.independent (fun _ : ρ => μ)).average (fun c => + (FiniteLaw.independent (fun _ : OutsideIndex control pivot => μ)).average (fun base => + (FiniteLaw.independent (fun _ : ρ => μ)).average (fun y => + f (coordinateAssignment control pivot hc hp hdisjoint base c y)))) := by + apply congrArg (FiniteLaw.independent (fun _ : ρ => μ)).average + funext c + exact FiniteLaw.average_comm _ _ _ + _ = _ := FiniteLaw.average_comm _ _ _ + +omit [DecidableEq ρ] in +/-- Evaluation of the joined samples is the exact integer assignment used +in the row-splitting theorem. -/ +lemma coordinateAssignment_integer (control pivot : ρ → α) + (hc : Function.Injective control) (hp : Function.Injective pivot) + (hdisjoint : ∀ i j, pivot i ≠ control j) (value : A → ℤ) + (base : OutsideIndex control pivot → A) (c y : ρ → A) : + (fun z => value (coordinateAssignment control pivot hc hp hdisjoint base c y z)) = + splitAssignment control pivot + (fun z => if hz : z ∈ outsideCoordinates control pivot then value (base ⟨z, hz⟩) else 0) + (fun i => value (c i)) (fun i => value (y i)) := by + classical + funext z + obtain ⟨j, rfl⟩ := (coordinateEquiv control pivot hc hp hdisjoint).surjective z + change value (coordinateAssignment control pivot hc hp hdisjoint base c y + (coordinateIndex control pivot j)) = _ + rw [coordinateAssignment_index] + change _ = splitAssignment control pivot _ _ _ (coordinateIndex control pivot j) + rcases j with i | (i | z) + · change value (c i) = splitAssignment control pivot _ _ _ (control i) + rw [splitAssignment_control control pivot _ hc] + · change value (y i) = splitAssignment control pivot _ _ _ (pivot i) + rw [splitAssignment_pivot control pivot _ hp hdisjoint] + · change value (base z) = splitAssignment control pivot _ _ _ (z : α) + rw [splitAssignment_outside control pivot _ _ _ z.property] + simp only [dite_true, z.property] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CoprimeExceptionDensity.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CoprimeExceptionDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc1b1d32d0d824288d0f4d4bdc67e9b76cdc658f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CoprimeExceptionDensity.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResidueCounts +import OAI.NumberTheory.TwoPoint.Basic +import Mathlib.Algebra.BigOperators.Field + +namespace OAI + +/-! The finite coprimality-exception count used when extracting a fixed +divisor from two multiplicative functions. No independence between the +two residue conditions is assumed. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def shiftedDivisorCount (p a Y : ℕ) : ℕ := + ∑ v ∈ range Y, if p ∣ a + v then 1 else 0 + +lemma shiftedDivisorCount_eq_residueCount (p a Y : ℕ) [NeZero p] : + shiftedDivisorCount p a Y = residueCount (a : ZMod p) Y 0 := by + unfold shiftedDivisorCount residueCount + simp only [← Nat.cast_add, ZMod.natCast_eq_zero_iff] + +lemma shiftedDivisorCount_le (p a Y : ℕ) (hp : 0 < p) : + (shiftedDivisorCount p a Y : ℝ) ≤ (Y : ℝ) / p + 1 := by + let _ : NeZero p := ⟨hp.ne'⟩ + rw [shiftedDivisorCount_eq_residueCount] + have hb := (abs_le.mp (residueCount_discrepancy (a : ZMod p) 0 Y)).2 + linarith + +def coprimeExceptionCount (u d Y : ℕ) : ℕ := + ∑ v ∈ range Y, if ¬u.Coprime ((v + 1) * (v + 1 + d)) then 1 else 0 + +lemma coprimeExceptionCount_le_divisorCounts (u d Y : ℕ) (P : Finset ℕ) + (hcover : ∀ p, Nat.Prime p → p ∣ u → p ∈ P) : + coprimeExceptionCount u d Y ≤ + ∑ p ∈ P, (shiftedDivisorCount p 1 Y + shiftedDivisorCount p (1 + d) Y) := by + unfold coprimeExceptionCount shiftedDivisorCount + calc + _ ≤ ∑ v ∈ range Y, ∑ p ∈ P, + ((if p ∣ 1 + v then 1 else 0) + (if p ∣ 1 + d + v then 1 else 0)) := by + apply sum_le_sum + intro v _ + by_cases hv : u.Coprime ((v + 1) * (v + 1 + d)) + · calc + _ = 0 := ite_eq_right (fun hnot => hnot hv) + _ ≤ _ := Nat.zero_le _ + · simp only [hv, not_false_eq_true, ite_true] + obtain ⟨p, hp, hpu, hpn⟩ := Nat.Prime.not_coprime_iff_dvd.mp hv + have hpP := hcover p hp hpu + have hsingle : + ((if p ∣ 1 + v then 1 else 0) + (if p ∣ 1 + d + v then 1 else 0)) ≤ + ∑ p ∈ P, ((if p ∣ 1 + v then 1 else 0) + + (if p ∣ 1 + d + v then 1 else 0)) := + single_le_sum (f := fun p : ℕ => + ((if p ∣ 1 + v then 1 else 0) + (if p ∣ 1 + d + v then 1 else 0) : ℕ)) + (fun _ _ => Nat.zero_le _) hpP + apply le_trans _ hsingle + rcases hp.dvd_mul.mp hpn with hpn | hpn + · have ht : p ∣ 1 + v := by simpa only [Nat.add_comm] using hpn + simp only [ht, ite_true] + omega + · have ht : p ∣ 1 + d + v := by + convert hpn using 1 + omega + simp only [ht, ite_true] + omega + _ = _ := by + rw [sum_comm] + apply sum_congr rfl + intro p _ + exact sum_add_distrib + +theorem coprimeExceptionCount_bound (u d Y : ℕ) (P : Finset ℕ) + (hP : ∀ p ∈ P, Nat.Prime p) + (hcover : ∀ p, Nat.Prime p → p ∣ u → p ∈ P) : + (coprimeExceptionCount u d Y : ℝ) ≤ + 2 * (Y : ℝ) * (∑ p ∈ P, 1 / (p : ℝ)) + 2 * P.card := by + have hnat := coprimeExceptionCount_le_divisorCounts u d Y P hcover + calc + _ ≤ ∑ p ∈ P, ((shiftedDivisorCount p 1 Y : ℝ) + + (shiftedDivisorCount p (1 + d) Y : ℝ)) := by exact_mod_cast hnat + _ ≤ ∑ p ∈ P, (2 * (Y : ℝ) * (1 / (p : ℝ)) + 2) := by + apply sum_le_sum + intro p hp + have h₁ := shiftedDivisorCount_le p 1 Y (hP p hp).pos + have h₂ := shiftedDivisorCount_le p (1 + d) Y (hP p hp).pos + calc + _ ≤ ((Y : ℝ) / p + 1) + ((Y : ℝ) / p + 1) := add_le_add h₁ h₂ + _ = _ := by ring + _ = _ := by rw [sum_add_distrib, mul_sum]; simp [mul_comm] + +theorem coprimeExceptionDensity_bound (u d Y : ℕ) (hY : 0 < Y) (P : Finset ℕ) + (hP : ∀ p ∈ P, Nat.Prime p) + (hcover : ∀ p, Nat.Prime p → p ∣ u → p ∈ P) : + (coprimeExceptionCount u d Y : ℝ) / Y ≤ + 2 * (∑ p ∈ P, 1 / (p : ℝ)) + 2 * P.card / (Y : ℝ) := by + have hY' : (0 : ℝ) < Y := by exact_mod_cast hY + apply (div_le_iff₀ hY').mpr + have hb := coprimeExceptionCount_bound u d Y P hP hcover + convert hb using 1 + field_simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CosineLogIntegral.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CosineLogIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..4cf6354f3aefbf71cbb0d0341ece7fc2972926f2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CosineLogIntegral.lean @@ -0,0 +1,200 @@ +import OAI.NumberTheory.TwoPoint.Bounds.OscillatoryThetaError + +namespace OAI + +/-! The elementary logarithmic oscillatory integral behind the padding +prime estimate. All constants are absolute. -/ + +namespace TwoPointCorrelations + +open MeasureTheory +open scoped Classical + +lemma integral_inverse_square (a b : ℝ) (ha : 0 < a) (hab : a ≤ b) : + (∫ y in a..b, (y ^ 2)⁻¹) = a⁻¹ - b⁻¹ := by + have hderiv : ∀ y ∈ Set.uIcc a b, HasDerivAt (fun y : ℝ => -y⁻¹) ((y ^ 2)⁻¹) y := by + intro y hy + have hy' : y ∈ Set.Icc a b := by simpa only [Set.uIcc_of_le hab] using hy + have hy0 : y ≠ 0 := (ha.trans_le hy'.1).ne' + convert! (hasDerivAt_inv hy0).neg using 1 + simp + have hc : ContinuousOn (fun y : ℝ => (y ^ 2)⁻¹) (Set.Icc a b) := by + intro y hy + have hy0 : y ≠ 0 := (ha.trans_le hy.1).ne' + exact ((continuousAt_id.pow 2).inv₀ (pow_ne_zero 2 hy0)).continuousWithinAt + have hh := intervalIntegral.integral_eq_sub_of_hasDerivAt hderiv + (hc.intervalIntegrable_of_Icc hab) + linarith + +lemma cosine_log_tail (T a b : ℝ) (hT : 0 < T) (ha : 0 < a) (hab : a ≤ b) + (hTa : 1 ≤ T * a) : + |∫ y in a..b, Real.cos (T * y) / y| ≤ 3 := by + have hb : 0 < b := ha.trans_le hab + have hpos (y : ℝ) (hy : y ∈ Set.Icc a b) : 0 < y := ha.trans_le hy.1 + have hu (y : ℝ) : HasDerivAt (fun y => Real.sin (T * y) / T) (Real.cos (T * y)) y := by + have hh := ((Real.hasDerivAt_sin (T * y)).comp y ((hasDerivAt_id y).const_mul T)).div_const T + convert hh using 1 + · simp only [Function.comp_def, mul_comm T] + · field_simp + have hv (y : ℝ) (hy : y ∈ Set.uIcc a b) : + HasDerivAt (fun y : ℝ => y⁻¹) (-(y ^ 2)⁻¹) y := by + apply hasDerivAt_inv + have hy' : y ∈ Set.Icc a b := by simpa only [Set.uIcc_of_le hab] using hy + exact (ha.trans_le hy'.1).ne' + have hcos : IntervalIntegrable (fun y => Real.cos (T * y) / y) volume a b := by + apply ContinuousOn.intervalIntegrable_of_Icc (h := hab) + intro y hy + exact (by fun_prop (disch := exact (hpos y hy).ne') : + ContinuousAt (fun y => Real.cos (T * y) / y) y).continuousWithinAt + have htail : IntervalIntegrable (fun y => Real.sin (T * y) / (T * y ^ 2)) volume a b := by + apply ContinuousOn.intervalIntegrable_of_Icc (h := hab) + intro y hy + have hy0 := (hpos y hy).ne' + exact (by fun_prop (disch := positivity) : + ContinuousAt (fun y => Real.sin (T * y) / (T * y ^ 2)) y).continuousWithinAt + have hvin : IntervalIntegrable (fun y : ℝ => -(y ^ 2)⁻¹) volume a b := by + apply ContinuousOn.intervalIntegrable_of_Icc (h := hab) + intro y hy + exact (((continuousAt_id.pow 2).inv₀ (pow_ne_zero 2 (hpos y hy).ne')).neg).continuousWithinAt + have hparts := intervalIntegral.integral_deriv_mul_eq_sub + (fun y (_ : y ∈ Set.uIcc a b) => hu y) hv + ((by fun_prop : Continuous (fun y => Real.cos (T * y))).intervalIntegrable a b) hvin + have heq : (∫ y in a..b, Real.cos (T * y) / y) - + (∫ y in a..b, Real.sin (T * y) / (T * y ^ 2)) = + Real.sin (T * b) / (T * b) - Real.sin (T * a) / (T * a) := by + rw [← intervalIntegral.integral_sub hcos htail] + convert hparts using 1 + · apply intervalIntegral.integral_congr + intro y _ + simp only [div_eq_mul_inv, mul_inv_rev] + ring + · field_simp + have hendpoint (y : ℝ) (hy : a ≤ y) : |Real.sin (T * y) / (T * y)| ≤ 1 := by + have hy0 : 0 < y := ha.trans_le hy + rw [abs_div, abs_of_pos (mul_pos hT hy0)] + apply (div_le_one (mul_pos hT hy0)).mpr + exact (Real.abs_sin_le_one _).trans (hTa.trans (mul_le_mul_of_nonneg_left hy hT.le)) + have hg : IntervalIntegrable (fun y : ℝ => T⁻¹ * (y ^ 2)⁻¹) volume a b := by + apply ContinuousOn.intervalIntegrable_of_Icc (h := hab) + intro y hy + exact (((continuousAt_id.pow 2).inv₀ (pow_ne_zero 2 (hpos y hy).ne')).const_mul _).continuousWithinAt + have hi : |∫ y in a..b, Real.sin (T * y) / (T * y ^ 2)| ≤ 1 := by + have hh := intervalIntegral.norm_integral_le_of_norm_le + (f := fun y : ℝ => Real.sin (T * y) / (T * y ^ 2)) + (g := fun y : ℝ => T⁻¹ * (y ^ 2)⁻¹) hab + (Filter.Eventually.of_forall (fun y hy => by + rw [Real.norm_eq_abs, abs_div, abs_of_pos (mul_pos hT (sq_pos_of_pos (hpos y ⟨hy.1.le, hy.2⟩)))] + calc + _ ≤ 1 / (T * y ^ 2) := div_le_div_of_nonneg_right (Real.abs_sin_le_one _) + (mul_nonneg hT.le (sq_nonneg y)) + _ = _ := by simp [div_eq_mul_inv, mul_inv_rev, mul_comm])) hg + rw [Real.norm_eq_abs, intervalIntegral.integral_const_mul, integral_inverse_square a b ha hab] at hh + have hsmall : T⁻¹ * a⁻¹ ≤ 1 := by + rw [← mul_inv_rev] + exact (inv_le_one₀ (mul_pos ha hT)).mpr (by nlinarith) + have hnonneg : 0 ≤ T⁻¹ * b⁻¹ := by positivity + nlinarith + have htriangle := abs_sub (Real.sin (T * b) / (T * b)) (Real.sin (T * a) / (T * a)) + have htriangle' := abs_add_le + (Real.sin (T * b) / (T * b) - Real.sin (T * a) / (T * a)) + (∫ y in a..b, Real.sin (T * y) / (T * y ^ 2)) + have hformula : (∫ y in a..b, Real.cos (T * y) / y) = + (Real.sin (T * b) / (T * b) - Real.sin (T * a) / (T * a)) + + (∫ y in a..b, Real.sin (T * y) / (T * y ^ 2)) := by linarith + rw [hformula] + linarith [hendpoint a le_rfl, hendpoint b hab] + +lemma logarithmic_oscillation_nonneg (t a b : ℝ) (ha : 0 < a) (hab : a ≤ b) : + 0 ≤ ∫ y in a..b, (1 - Real.cos (t * y)) / y := by + apply intervalIntegral.integral_nonneg hab + intro y hy + exact div_nonneg (sub_nonneg.mpr (Real.cos_le_one _)) (ha.trans_le hy.1).le + +lemma logarithmic_oscillation_lower_pos (T L : ℝ) (hT : 0 < T) (hT2 : T ≤ 2) + (hL : 1 ≤ L) : + Real.log (1 + L * T) - 5 ≤ ∫ y in (1 : ℝ)..L, (1 - Real.cos (T * y)) / y := by + let A := max 1 T⁻¹ + have hA1 : 1 ≤ A := le_max_left _ _ + have hA : 0 < A := zero_lt_one.trans_le hA1 + have hLp : 0 < L := zero_lt_one.trans_le hL + have hTA : 1 ≤ T * A := by + calc + 1 = T * T⁻¹ := (mul_inv_cancel₀ hT.ne').symm + _ ≤ _ := mul_le_mul_of_nonneg_left (le_max_right _ _) hT.le + have hAT : A * T ≤ 2 := by + by_cases hh : 1 ≤ T⁻¹ + · simp only [A, max_eq_right hh] + rw [inv_mul_cancel₀ hT.ne'] + norm_num + · simpa only [A, max_eq_left (le_of_not_ge hh), one_mul] using hT2 + by_cases hLA : L < A + · have hsmall : L * T < 1 := by + rcases lt_max_iff.mp hLA with hh | hh + · exact False.elim (not_lt_of_ge hL hh) + · have hm := mul_lt_mul_of_pos_right hh hT + simpa only [inv_mul_cancel₀ hT.ne'] using hm + have hlog := Real.log_le_sub_one_of_pos (by positivity : 0 < 1 + L * T) + have hnonneg := logarithmic_oscillation_nonneg T 1 L (by norm_num) hL + linarith + have hAL : A ≤ L := le_of_not_gt hLA + have hcont (a b : ℝ) (ha : 0 < a) : + ContinuousOn (fun y => (1 - Real.cos (T * y)) / y) (Set.Icc a b) := by + intro y hy + have hy0 := (ha.trans_le hy.1).ne' + exact (by fun_prop (disch := assumption) : + ContinuousAt (fun y => (1 - Real.cos (T * y)) / y) y).continuousWithinAt + have hhead : IntervalIntegrable (fun y => (1 - Real.cos (T * y)) / y) volume 1 A := + (hcont 1 A (by norm_num)).intervalIntegrable_of_Icc hA1 + have htail : IntervalIntegrable (fun y => (1 - Real.cos (T * y)) / y) volume A L := + (hcont A L hA).intervalIntegrable_of_Icc hAL + have hrestrict : (∫ y in A..L, (1 - Real.cos (T * y)) / y) ≤ + ∫ y in (1 : ℝ)..L, (1 - Real.cos (T * y)) / y := by + rw [← intervalIntegral.integral_add_adjacent_intervals hhead htail] + have hh := logarithmic_oscillation_nonneg T 1 A (by norm_num) hA1 + linarith + have hi : (∫ y in A..L, (1 - Real.cos (T * y)) / y) = + Real.log (L / A) - ∫ y in A..L, Real.cos (T * y) / y := by + have hi₁ : IntervalIntegrable (fun y : ℝ => 1 / y) volume A L := by + apply ContinuousOn.intervalIntegrable_of_Icc (h := hAL) + intro y hy + exact (continuousAt_const.div continuousAt_id (hA.trans_le hy.1).ne').continuousWithinAt + have hi₂ : IntervalIntegrable (fun y : ℝ => Real.cos (T * y) / y) volume A L := by + apply ContinuousOn.intervalIntegrable_of_Icc (h := hAL) + intro y hy + have hy0 := (hA.trans_le hy.1).ne' + exact (by fun_prop (disch := assumption) : + ContinuousAt (fun y => Real.cos (T * y) / y) y).continuousWithinAt + rw [← integral_one_div_of_pos hA hLp, ← intervalIntegral.integral_sub hi₁ hi₂] + apply intervalIntegral.integral_congr + intro y _ + ring + have hcos := (abs_le.mp (cosine_log_tail T A L hT hA hAL hTA)).2 + have hratio : 1 ≤ L / A := (le_div_iff₀ hA).mpr (by simpa using hAL) + have hsize : 1 + L * T ≤ 3 * (L / A) := by + have hh := mul_le_mul_of_nonneg_right hAT (div_nonneg hLp.le hA.le) + have he : (A * T) * (L / A) = L * T := by field_simp + rw [he] at hh + linarith + have hlog : Real.log (1 + L * T) ≤ Real.log (L / A) + 2 := by + have hh := Real.log_le_log (by positivity : 0 < 1 + L * T) hsize + rw [Real.log_mul (by norm_num : (3 : ℝ) ≠ 0) (div_pos hLp hA).ne'] at hh + have hc := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 3) + linarith + rw [hi] at hrestrict + linarith + +theorem logarithmic_oscillation_lower (t L : ℝ) (ht : |t| ≤ 2) (hL : 1 ≤ L) : + Real.log (1 + L * |t|) - 5 ≤ ∫ y in (1 : ℝ)..L, (1 - Real.cos (t * y)) / y := by + by_cases ht0 : t = 0 + · subst t + simp + have hh := logarithmic_oscillation_lower_pos |t| L (abs_pos.mpr ht0) ht hL + have hcos (y : ℝ) : Real.cos (|t| * y) = Real.cos (t * y) := by + rcases le_or_gt 0 t with ht' | ht' + · rw [abs_of_nonneg ht'] + · rw [abs_of_neg ht', neg_mul, Real.cos_neg] + simpa only [hcos] using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeColumnPatterns.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeColumnPatterns.lean new file mode 100644 index 0000000000000000000000000000000000000000..e006422a253867f1c0963528a7c35d518faad4bf --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeColumnPatterns.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.TwoPoint.Walks.ColumnRepresentatives +import OAI.NumberTheory.TwoPoint.Walks.ColumnHarmonicSum +import OAI.NumberTheory.TwoPoint.Walks.RankEnumeration + +namespace OAI + +/-! Complete column equality patterns have only one representative index per slot. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +abbrev CrudeColumnPatternCode (J R : ℕ) := Fin J → Fin R → Fin R + +def decodeCrudeColumnPattern {J R : ℕ} (c : CrudeColumnPatternCode J R) + (j : Fin J) (i k : Fin R) : Bool := decide (c j i = c j k) + +theorem crude_column_pattern_cover {J R : ℕ} {P : Fin J → Finset ℕ} + (w : ColumnPrimeAssignment J R P) : + ∃ c : CrudeColumnPatternCode J R, ∀ j i k, + decodeCrudeColumnPattern c j i k = decide (w j i = w j k) := by + refine ⟨fun j => columnRepresentative (w j) ∅, ?_⟩ + intro j i k + exact decide_eq_decide.mpr (columnRepresentative_eq_iff (w j) ∅ i k) + +lemma card_crudeColumnPatternCode (J R : ℕ) : + Fintype.card (CrudeColumnPatternCode J R) = R ^ (R * J) := by + simp only [CrudeColumnPatternCode, Fintype.card_fun, Fintype.card_fin, pow_mul] + +theorem crude_column_pattern_count_bound (J R : ℕ) (L C : ℝ) + (hL : 0 < L) (hJ : (J : ℝ) ≤ C * Real.log L) + (hR : (R : ℝ) + 1 ≤ L ^ (2 : ℕ)) : + (Fintype.card (CrudeColumnPatternCode J R) : ℝ) ≤ + Real.exp (2 * C * R * (Real.log L) ^ 2) := by + have hlog : Real.log ((R : ℝ) + 1) ≤ 2 * Real.log L := by + have h := Real.log_le_log (by positivity : (0 : ℝ) < R + 1) hR + simpa only [Real.log_pow, Nat.cast_ofNat] using h + have hlogL : 0 ≤ Real.log L := by + have hp : (1 : ℝ) ≤ L ^ (2 : ℕ) := (by linarith : (1 : ℝ) ≤ R + 1).trans hR + have hone : 1 ≤ L := by nlinarith + exact Real.log_nonneg hone + rw [card_crudeColumnPatternCode] + push_cast + calc + _ ≤ ((R : ℝ) + 1) ^ (R * J) := pow_le_pow_left₀ (by positivity) (by linarith) _ + _ = Real.exp (((R * J : ℕ) : ℝ) * Real.log ((R : ℝ) + 1)) := by + rw [Real.exp_nat_mul, Real.exp_log (by positivity : (0 : ℝ) < R + 1)] + _ ≤ Real.exp (((R * J : ℕ) : ℝ) * (2 * Real.log L)) := + Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left hlog (by positivity)) + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have ht := mul_le_mul_of_nonneg_left hJ (show 0 ≤ 2 * R * Real.log L by positivity) + push_cast + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeHarmonicMass.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeHarmonicMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f6d325b188eefbc11ad4b77451928cb53af81fc --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeHarmonicMass.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeReciprocalLaw +import Mathlib.NumberTheory.Harmonic.Bounds +import Mathlib.Analysis.SpecialFunctions.Pow.Real + +namespace OAI + +/-! Elementary harmonic and padding-weight bounds for the crude enumeration. -/ + +namespace TwoPointCorrelations + +open Finset + +/-- Enlarging primes to all positive integers already gives enough mass +control for the negligible-word estimates. -/ +lemma primeHarmonicMass_le_one_add_log (P : Finset ℕ) (B : ℕ) + (hpos : ∀ p ∈ P, 1 ≤ p) (hB : ∀ p ∈ P, p ≤ B) : + primeHarmonicMass P ≤ 1 + Real.log B := by + have heq : primeHarmonicMass P = ∑ p ∈ P, (p : ℝ)⁻¹ := by + simpa only [primeHarmonicMass, Finset.attach_eq_univ] using + (Finset.sum_attach P (fun p : ℕ => (p : ℝ)⁻¹)) + rw [heq] + calc + _ ≤ ∑ p ∈ Icc 1 B, (p : ℝ)⁻¹ := by + apply sum_le_sum_of_subset_of_nonneg + · exact fun p hp => mem_Icc.mpr ⟨hpos p hp, hB p hp⟩ + · intro p _ _ + positivity + _ = (harmonic B : ℝ) := by + simp only [harmonic_eq_sum_Icc, Rat.cast_sum, Rat.cast_inv, Rat.cast_natCast] + _ ≤ _ := harmonic_le_one_add_log B + +lemma primeHarmonicMass_le_one_add_scale (P : Finset ℕ) (B : ℕ) (L : ℝ) + (hpos : ∀ p ∈ P, 1 ≤ p) (hB : ∀ p ∈ P, p ≤ B) + (hBpos : 0 < B) (hscale : (B : ℝ) ≤ Real.exp L) : + primeHarmonicMass P ≤ 1 + L := by + apply (primeHarmonicMass_le_one_add_log P B hpos hB).trans + have h := Real.log_le_log (by exact_mod_cast hBpos) hscale + rw [Real.log_exp] at h + linarith + +/-- The actual padding weight `u(q)=4^ω(q)`. -/ +noncomputable def crudePaddingWeight (q : ℕ) : ℝ := 4 ^ q.primeFactors.card + +lemma crudePaddingWeight_le (q : ℕ) (L : ℝ) (hL : 0 < L) + (hq : (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) : + crudePaddingWeight q ≤ L ^ (100 * Real.log 4) := by + have hfour : (0 : ℝ) < 4 := by norm_num + unfold crudePaddingWeight + calc + _ = Real.exp ((q.primeFactors.card : ℝ) * Real.log 4) := by + rw [Real.exp_nat_mul, Real.exp_log hfour] + _ ≤ Real.exp (Real.log L * (100 * Real.log 4)) := by + apply Real.exp_le_exp.mpr + have hl4 : 0 ≤ Real.log 4 := Real.log_nonneg (by norm_num) + nlinarith [mul_le_mul_of_nonneg_left hq hl4] + _ = _ := (Real.rpow_def_of_pos hL _).symm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeNumericalWordSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeNumericalWordSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd5b7090e53b97439bf640c79aa0a46b49618201 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeNumericalWordSum.lean @@ -0,0 +1,161 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeWordEncoding +import OAI.NumberTheory.TwoPoint.Bounds.BadCatalogCost +import OAI.NumberTheory.TwoPoint.Bounds.CrudeTraceWeights + +namespace OAI + +/-! Complete reciprocal counting for actual numerical tuple and padding words. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma split_assignment_reciprocal_sum {ι : Type*} [Fintype ι] [DecidableEq ι] + (S : Finset ι) (P Q : Finset ℕ) : + (∑ a : S → P, ∑ b : {i // i ∉ S} → Q, + ∏ i, ((joinCoordinates S (fun z => (a z).val) (fun z => (b z).val) i : ℕ) : ℝ)⁻¹) = + primeHarmonicMass P ^ Fintype.card S * + primeHarmonicMass Q ^ Fintype.card {i // i ∉ S} := by + simp only [reciprocal_product_join] + calc + _ = (∑ a : S → P, ∏ i, ((a i).val : ℝ)⁻¹) * + (∑ b : {i // i ∉ S} → Q, ∏ i, ((b i).val : ℝ)⁻¹) := by + exact (sum_mul_sum _ _ _ _).symm + _ = _ := by rw [sum_reciprocal_assignments, sum_reciprocal_assignments] + +lemma primeWordEncoding_weight_sum (R T : ℕ) (P Q : Finset ℕ) : + (∑ e : PrimeWordEncoding R T P Q, e.weight) = + ∑ n : Fin (T + 1), ∑ c : CrudeWordCode R n.val R, + primeHarmonicMass P ^ Fintype.card c.tupleClasses * + primeHarmonicMass Q ^ Fintype.card {z : c.usedClasses // z ∉ c.tupleClasses} := by + rw [Fintype.sum_sigma] + apply sum_congr rfl + intro n _ + rw [Fintype.sum_sigma] + apply sum_congr rfl + intro c _ + rw [Fintype.sum_prod_type] + change (∑ a : c.tupleClasses → P, ∑ b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q, + ∏ z : c.usedClasses, + ((joinCoordinates c.tupleClasses (fun z => (a z).val) (fun z => (b z).val) z : ℕ) : ℝ)⁻¹) = _ + exact split_assignment_reciprocal_sum c.tupleClasses P Q + +/-- Both prime supplies may be enlarged, but distinct abstract classes +continue to pay distinct reciprocal factors, including after collisions. -/ +theorem primeWordEncoding_weight_le (R T : ℕ) (P Q : Finset ℕ) (U : ℝ) + (hU : 1 ≤ U) (hP : primeHarmonicMass P ≤ U) (hQ : primeHarmonicMass Q ≤ U) : + (∑ e : PrimeWordEncoding R T P Q, e.weight) ≤ + (∑ n : Fin (T + 1), (Fintype.card (CrudeWordCode R n.val R) : ℝ)) * U ^ T := by + rw [primeWordEncoding_weight_sum, sum_mul] + apply sum_le_sum + intro n _ + calc + _ ≤ ∑ _c : CrudeWordCode R n.val R, U ^ T := by + apply sum_le_sum + intro c _ + exact (c.class_mass_le (by unfold primeHarmonicMass; positivity) + (by unfold primeHarmonicMass; positivity) hP hQ hU).trans + (pow_le_pow_right₀ hU (by omega)) + _ = _ := by simp + +/-- A bound for the original numerical words, before any equality-pattern +or prime assignment is enlarged. This is the crude catalog estimate used +by the many-unlit and witness cases. -/ +theorem numerical_word_reciprocal_sum_le (R T : ℕ) (P Q : Finset ℕ) + (F : Finset (Fin R → SignedStep)) (weight : List SignedStep → ℝ) (W U : ℝ) + (hW : 0 ≤ W) (hU : 1 ≤ U) + (hP : primeHarmonicMass P ≤ U) (hQ : primeHarmonicMass Q ≤ U) + (hweight : ∀ w ∈ F, weight (List.ofFn w) ≤ W) + (hT : ∀ w ∈ F, Fintype.card (ActualPrimeSlot w) ≤ T) + (ht : ∀ w ∈ F, ∀ i, Squarefree (w i).tuple) + (hq : ∀ w ∈ F, ∀ i, Squarefree (w i).padding) + (htP : ∀ w ∈ F, ∀ i, (w i).tuple.primeFactors ⊆ P) + (hqQ : ∀ w ∈ F, ∀ i, (w i).padding.primeFactors ⊆ Q) + (hd : ∀ w ∈ F, ∀ i j, Disjoint (w i).tuple.primeFactors (w j).padding.primeFactors) : + (∑ w ∈ F, weight (List.ofFn w) * + ∏ p ∈ wordDivisorPrimeSupport (List.ofFn w), (p : ℝ)⁻¹) ≤ + W * (∑ n : Fin (T + 1), (Fintype.card (CrudeWordCode R n.val R) : ℝ)) * U ^ T := by + let mass (w : List SignedStep) := ∏ p ∈ wordDivisorPrimeSupport w, (p : ℝ)⁻¹ + have hcover : ∀ w ∈ F.image List.ofFn, ∃ e : PrimeWordEncoding R T P Q, + e.decode = w ∧ weight w * mass w ≤ W * e.weight := by + intro v hv + obtain ⟨w, hw, rfl⟩ := mem_image.mp hv + obtain ⟨e, he, _, _, _, hmass⟩ := PrimeWordEncoding.covers w (hT w hw) + (ht w hw) (hq w hw) (htP w hw) (hqQ w hw) (hd w hw) + refine ⟨e, he, ?_⟩ + rw [hmass] + exact mul_le_mul_of_nonneg_right (hweight w hw) (by dsimp [mass]; positivity) + calc + _ = ∑ w ∈ F.image List.ofFn, weight w * mass w := by + rw [sum_image (fun _ _ _ _ he => List.ofFn_injective he)] + _ ≤ ∑ e : PrimeWordEncoding R T P Q, W * e.weight := + finite_decoding_weight_bound (F.image List.ofFn) PrimeWordEncoding.decode + (fun w => weight w * mass w) (fun e => W * e.weight) + (fun e => mul_nonneg hW e.weight_nonneg) hcover + _ = W * ∑ e : PrimeWordEncoding R T P Q, e.weight := (mul_sum _ _ _).symm + _ ≤ W * ((∑ n : Fin (T + 1), (Fintype.card (CrudeWordCode R n.val R) : ℝ)) * U ^ T) := + mul_le_mul_of_nonneg_left (primeWordEncoding_weight_le R T P Q U hU hP hQ) hW + _ = _ := by ring + +/-- Explicit exponential form of the complete code and reciprocal cost. -/ +theorem crude_numerical_cost_exp_bound (R T b : ℕ) + (L C U : ℝ) (hR : 1 ≤ R) (hL : 0 < L) (hlog : 1 ≤ Real.log L) + (hslots : (T : ℝ) ≤ C * R * Real.log L) + (hT : (T : ℝ) + 1 ≤ L ^ (2 : ℕ)) (hRpoly : (R : ℝ) + 1 ≤ L ^ (2 : ℕ)) + (hU : 1 ≤ U) (hUP : U ≤ L ^ b) : + (∑ n : Fin (T + 1), (Fintype.card (CrudeWordCode R n.val R) : ℝ)) * U ^ T ≤ + Real.exp ((3 + 5 * C + b * C) * R * (Real.log L) ^ 2) := by + have hcode (n : Fin (T + 1)) : + (Fintype.card (CrudeWordCode R n.val R) : ℝ) ≤ + Real.exp ((1 + 5 * C) * R * (Real.log L) ^ 2) := by + have hn : n.val ≤ T := by omega + have hnr : (n.val : ℝ) ≤ T := by exact_mod_cast hn + exact short_crudeWordCode_bound R n.val R L C hlog le_rfl + (hnr.trans hslots) (by linarith) hRpoly + have hcount : (∑ n : Fin (T + 1), (Fintype.card (CrudeWordCode R n.val R) : ℝ)) ≤ + Real.exp ((3 + 5 * C) * R * (Real.log L) ^ 2) := by + calc + _ ≤ ((T : ℝ) + 1) * Real.exp ((1 + 5 * C) * R * (Real.log L) ^ 2) := by + simpa only [sum_const, card_univ, Fintype.card_fin, nsmul_eq_mul, Nat.cast_add, Nat.cast_one] using + (sum_le_sum (s := (univ : Finset (Fin (T + 1)))) (fun n _ => hcode n)) + _ ≤ Real.exp (2 * R * (Real.log L) ^ 2) * + Real.exp ((1 + 5 * C) * R * (Real.log L) ^ 2) := by + apply mul_le_mul_of_nonneg_right _ (Real.exp_pos _).le + exact hT.trans (by + simpa using short_polynomial_exp_bound R 2 L hR hL hlog) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + have hmass : U ^ T ≤ Real.exp ((b : ℝ) * C * R * (Real.log L) ^ 2) := by + calc + _ ≤ (L ^ b) ^ T := pow_le_pow_left₀ (by linarith) hUP _ + _ = Real.exp ((T : ℝ) * b * Real.log L) := by + rw [← pow_mul, ← Real.exp_log hL, ← Real.exp_nat_mul, Real.log_exp] + congr 1 + push_cast + ring + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have ht := mul_le_mul_of_nonneg_right hslots + (show 0 ≤ (b : ℝ) * Real.log L by positivity) + nlinarith + calc + _ ≤ Real.exp ((3 + 5 * C) * R * (Real.log L) ^ 2) * + Real.exp ((b : ℝ) * C * R * (Real.log L) ^ 2) := + mul_le_mul hcount hmass (by positivity) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +/-- The numerical assignment sum inherits the explicit code-cost bound. -/ +theorem primeWordEncoding_weight_exp_bound (R T b : ℕ) (P Q : Finset ℕ) + (L C U : ℝ) (hR : 1 ≤ R) (hL : 0 < L) (hlog : 1 ≤ Real.log L) + (hslots : (T : ℝ) ≤ C * R * Real.log L) + (hT : (T : ℝ) + 1 ≤ L ^ (2 : ℕ)) (hRpoly : (R : ℝ) + 1 ≤ L ^ (2 : ℕ)) + (hU : 1 ≤ U) (hUP : U ≤ L ^ b) + (hP : primeHarmonicMass P ≤ U) (hQ : primeHarmonicMass Q ≤ U) : + (∑ e : PrimeWordEncoding R T P Q, e.weight) ≤ + Real.exp ((3 + 5 * C + b * C) * R * (Real.log L) ^ 2) := + (primeWordEncoding_weight_le R T P Q U hU hP hQ).trans + (crude_numerical_cost_exp_bound R T b L C U hR hL hlog hslots hT hRpoly hU hUP) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeTraceCatalog.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeTraceCatalog.lean new file mode 100644 index 0000000000000000000000000000000000000000..64dfc90ae4aa6d50c7f3fb251b1170c181db65a0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeTraceCatalog.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CrudeNumericalWordSum + +namespace OAI + +/-! The complete numerical trace catalog has the required crude exponential cost. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +/-- This includes signs, all equality patterns, numerical tuple/padding +primes, the step weights, singleton multiplicities, and external dimensions. -/ +theorem crude_trace_catalog_exp_bound (R T S : ℕ) (P Q : Finset ℕ) + (F : Finset (Fin R → SignedStep)) (L C Cexternal Csingle external : ℝ) + (hR : 1 ≤ R) (hL : 1 ≤ L) (hlog : 1 ≤ Real.log L) (hRscale : (R : ℝ) ≤ 2 * L) + (hC : 0 ≤ C) (hCe : 0 ≤ Cexternal) + (hS : (S : ℝ) ≤ Csingle * L * Real.log L) + (hext : external ≤ Real.exp (Cexternal * L)) + (hslots : (T : ℝ) ≤ C * R * Real.log L) + (hT : (T : ℝ) + 1 ≤ L ^ (2 : ℕ)) (hRpoly : (R : ℝ) + 1 ≤ L ^ (2 : ℕ)) + (hP : primeHarmonicMass P ≤ L ^ (2 : ℕ)) (hQ : primeHarmonicMass Q ≤ L ^ (2 : ℕ)) + (hactual : ∀ w ∈ F, Fintype.card (ActualPrimeSlot w) ≤ T) + (ht : ∀ w ∈ F, ∀ i, Squarefree (w i).tuple) + (hq : ∀ w ∈ F, ∀ i, Squarefree (w i).padding) + (htP : ∀ w ∈ F, ∀ i, (w i).tuple.primeFactors ⊆ P) + (hqQ : ∀ w ∈ F, ∀ i, (w i).padding.primeFactors ⊆ Q) + (hd : ∀ w ∈ F, ∀ i j, Disjoint (w i).tuple.primeFactors (w j).padding.primeFactors) + (hpad : ∀ w ∈ F, ∀ i, ((w i).padding.primeFactors.card : ℝ) ≤ 100 * Real.log L) : + (∑ w ∈ F, crudeTraceWeight R S (fun i => (w i).padding) L external * + ∏ p ∈ wordDivisorPrimeSupport (List.ofFn w), (p : ℝ)⁻¹) ≤ + Real.exp ((Cexternal + Csingle + 408 + 14 * C) * L * (Real.log L) ^ 2) := by + let W := Real.exp ((Cexternal + Csingle + 402) * L * (Real.log L) ^ 2) + have hW : 0 ≤ W := (Real.exp_pos _).le + have hweight (w) (hw : w ∈ F) : + crudeTraceWeight R S (fun i => (w i).padding) L external ≤ W := + crudeTraceWeight_exp_bound R S (fun i => (w i).padding) L external Cexternal Csingle + hL hlog hRscale hS hCe hext (hpad w hw) + have hm := numerical_word_reciprocal_sum_le R T P Q F (fun _ => 1) 1 (L ^ (2 : ℕ)) + (by norm_num) (one_le_pow₀ hL) hP hQ (fun _ _ => le_rfl) + hactual ht hq htP hqQ hd + simp only [one_mul] at hm + have hc := crude_numerical_cost_exp_bound R T 2 L C (L ^ (2 : ℕ)) hR + (lt_of_lt_of_le zero_lt_one hL) hlog hslots hT hRpoly (one_le_pow₀ hL) le_rfl + have hc' : (∑ w ∈ F, ∏ p ∈ wordDivisorPrimeSupport (List.ofFn w), (p : ℝ)⁻¹) ≤ + Real.exp ((6 + 14 * C) * L * (Real.log L) ^ 2) := by + apply (hm.trans hc).trans + apply Real.exp_le_exp.mpr + norm_num only [Nat.cast_ofNat] + have hh := mul_le_mul_of_nonneg_right hRscale + (show 0 ≤ (3 + 7 * C) * (Real.log L) ^ 2 by positivity) + nlinarith + calc + _ ≤ ∑ w ∈ F, W * ∏ p ∈ wordDivisorPrimeSupport (List.ofFn w), (p : ℝ)⁻¹ := by + apply sum_le_sum + intro w hw + exact mul_le_mul_of_nonneg_right (hweight w hw) (by positivity) + _ = W * ∑ w ∈ F, ∏ p ∈ wordDivisorPrimeSupport (List.ofFn w), (p : ℝ)⁻¹ := + (mul_sum _ _ _).symm + _ ≤ W * Real.exp ((6 + 14 * C) * L * (Real.log L) ^ 2) := + mul_le_mul_of_nonneg_left hc' hW + _ = _ := by dsimp [W]; rw [← Real.exp_add]; congr 1; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeTraceWeights.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeTraceWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..d61f79a2ba8393a9220e3a2b4aba38e83cbe56d2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeTraceWeights.lean @@ -0,0 +1,118 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CrudeHarmonicMass + +namespace OAI + +/-! Padding, mixed-difference, and external factors in the crude trace count. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma crudePaddingWeight_exp_bound (q : ℕ) (L : ℝ) (hL : 1 ≤ L) + (hq : (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) : + crudePaddingWeight q ≤ Real.exp (200 * Real.log L) := by + have hl : 0 ≤ Real.log L := Real.log_nonneg hL + have hlog2 : Real.log 2 ≤ 1 := by + have ht := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + linarith + have hlog4 : Real.log 4 ≤ 2 := by + have heq : Real.log 4 = 2 * Real.log 2 := by + simpa only [Real.log_pow, Nat.cast_ofNat] using congrArg Real.log + (show (4 : ℝ) = 2 ^ (2 : ℕ) by norm_num) + linarith + have hp : (q.primeFactors.card : ℝ) * Real.log 4 ≤ 200 * Real.log L := by + calc + _ ≤ (100 * Real.log L) * Real.log 4 := + mul_le_mul_of_nonneg_right hq (Real.log_nonneg (by norm_num)) + _ ≤ (100 * Real.log L) * 2 := + mul_le_mul_of_nonneg_left hlog4 (by positivity) + _ = _ := by ring + unfold crudePaddingWeight + rw [← Real.exp_log (by norm_num : (0 : ℝ) < 4), ← Real.exp_nat_mul] + exact Real.exp_le_exp.mpr hp + +lemma crudePaddingFactors_exp_bound (R : ℕ) (q : Fin R → ℕ) (L : ℝ) + (hL : 1 ≤ L) (hq : ∀ i, ((q i).primeFactors.card : ℝ) ≤ 100 * Real.log L) : + (∏ i, L * crudePaddingWeight (q i)) ≤ Real.exp (201 * R * Real.log L) := by + have hLp : 0 < L := lt_of_lt_of_le zero_lt_one hL + have hi (i : Fin R) : L * crudePaddingWeight (q i) ≤ + Real.exp (201 * Real.log L) := by + calc + _ ≤ L * Real.exp (200 * Real.log L) := + mul_le_mul_of_nonneg_left (crudePaddingWeight_exp_bound (q i) L hL (hq i)) hLp.le + _ = Real.exp (201 * Real.log L) := by + conv_lhs => lhs; rw [← Real.exp_log hLp] + rw [← Real.exp_add] + congr 1 + ring + calc + _ ≤ ∏ _i : Fin R, Real.exp (201 * Real.log L) := + prod_le_prod₀ (fun _ _ => by unfold crudePaddingWeight; positivity) (fun i _ => hi i) + _ = Real.exp (201 * R * Real.log L) := by + rw [prod_const, card_univ, Fintype.card_fin, ← Real.exp_nat_mul] + congr 1 + ring + +/-- The positive trace factors left after discarding all denominator +cutoffs. This includes the full mixed-difference multiplicity. -/ +noncomputable def crudeTraceWeight (R S : ℕ) (q : Fin R → ℕ) (L external : ℝ) : ℝ := + external * 2 ^ S * ∏ i, L * crudePaddingWeight (q i) + +lemma crudeTraceWeight_nonneg (R S : ℕ) (q : Fin R → ℕ) (L external : ℝ) + (hL : 0 ≤ L) (hexternal : 0 ≤ external) : + 0 ≤ crudeTraceWeight R S q L external := by + unfold crudeTraceWeight crudePaddingWeight + positivity + +/-- Fixed exponential dimension factors and all step weights are +absorbed by an explicit `L log² L` cost. -/ +theorem crudeTraceWeight_exp_bound (R S : ℕ) (q : Fin R → ℕ) + (L external Cexternal Csingle : ℝ) + (hL : 1 ≤ L) (hlog : 1 ≤ Real.log L) + (hR : (R : ℝ) ≤ 2 * L) (hS : (S : ℝ) ≤ Csingle * L * Real.log L) + (hCexternal : 0 ≤ Cexternal) + (hext : external ≤ Real.exp (Cexternal * L)) + (hq : ∀ i, ((q i).primeFactors.card : ℝ) ≤ 100 * Real.log L) : + crudeTraceWeight R S q L external ≤ + Real.exp ((Cexternal + Csingle + 402) * L * (Real.log L) ^ 2) := by + have hpad := crudePaddingFactors_exp_bound R q L hL hq + have hlog2 : Real.log 2 ≤ 1 := by + have ht := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + linarith + have htwo : (2 : ℝ) ^ S ≤ Real.exp (Csingle * L * (Real.log L) ^ 2) := by + rw [← Real.exp_log (by norm_num : (0 : ℝ) < 2), ← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + have hSpos : 0 ≤ Csingle * L * Real.log L := (Nat.cast_nonneg S).trans hS + calc + _ ≤ (S : ℝ) := by nlinarith + _ ≤ Csingle * L * Real.log L := hS + _ ≤ Csingle * L * (Real.log L) ^ 2 := by + have ht := mul_le_mul_of_nonneg_left hlog hSpos + nlinarith + have hext' : external ≤ Real.exp (Cexternal * L * (Real.log L) ^ 2) := by + apply hext.trans + apply Real.exp_le_exp.mpr + have ht : 1 ≤ (Real.log L) ^ 2 := by nlinarith + nlinarith [mul_le_mul_of_nonneg_left ht (show 0 ≤ Cexternal * L by positivity)] + have hpad' : (∏ i, L * crudePaddingWeight (q i)) ≤ + Real.exp (402 * L * (Real.log L) ^ 2) := by + apply hpad.trans + apply Real.exp_le_exp.mpr + have ht := mul_le_mul_of_nonneg_right hR (show 0 ≤ 201 * Real.log L by linarith) + have hu := mul_le_mul_of_nonneg_left hlog (show 0 ≤ 402 * L * Real.log L by positivity) + nlinarith + unfold crudeTraceWeight + calc + _ ≤ Real.exp (Cexternal * L * (Real.log L) ^ 2) * + Real.exp (Csingle * L * (Real.log L) ^ 2) * + Real.exp (402 * L * (Real.log L) ^ 2) := by + apply mul_le_mul _ hpad' (by unfold crudePaddingWeight; positivity) (by positivity) + exact mul_le_mul hext' htwo (by positivity) (by positivity) + _ = _ := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeWordCounting.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeWordCounting.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7a3d84b784278e935c1601a2c921957dfef1869 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CrudeWordCounting.lean @@ -0,0 +1,132 @@ +import OAI.NumberTheory.TwoPoint.Walks.ColumnRepresentatives +import OAI.NumberTheory.TwoPoint.Bounds.FiniteProbability +import Mathlib.SetTheory.Cardinal.Finite +import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics + +namespace OAI + +/-! Finite descriptions used by the reciprocal crude count. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +/-- A partition is recorded by a representative slot for each slot. -/ +noncomputable def slotPartitionCode (N : ℕ) (s : Setoid (Fin N)) : Fin N → Fin N := + columnRepresentative (fun i => @Quotient.mk _ s i) ∅ + +lemma slotPartitionCode_eq_iff (N : ℕ) (s : Setoid (Fin N)) (i j : Fin N) : + slotPartitionCode N s i = slotPartitionCode N s j ↔ s.r i j := by + exact (columnRepresentative_eq_iff (fun i => @Quotient.mk _ s i) ∅ i j).trans Quotient.eq + +lemma slotPartitionCode_injective (N : ℕ) : Function.Injective (slotPartitionCode N) := by + intro s t h + apply Setoid.ext + intro i j + rw [← slotPartitionCode_eq_iff N s, ← slotPartitionCode_eq_iff N t, h] + +/-- The elementary Bell-number bound used in `q:crude-count`. -/ +theorem card_slotPartitions_le (N : ℕ) : Nat.card (Setoid (Fin N)) ≤ N ^ N := by + have h := Nat.card_le_card_of_injective (slotPartitionCode N) (slotPartitionCode_injective N) + simpa only [Nat.card_eq_fintype_card, Fintype.card_fun, Fintype.card_fin] using h + +/-- Signs, a partition code, bounded records per slot, and lit designations. -/ +abbrev CrudeWordCode (R N D : ℕ) := + (Fin R → Bool) × (Fin N → Fin N) × (Fin N → Fin D) × (Fin N → Bool) + +theorem card_crudeWordCode (R N D : ℕ) : + Fintype.card (CrudeWordCode R N D) = 2 ^ R * (N ^ N * (D ^ N * 2 ^ N)) := by + simp only [CrudeWordCode, Fintype.card_prod, Fintype.card_fun, Fintype.card_bool, + Fintype.card_fin] + +/-- A column and an ordered list of candidate lit pairs have at most this +many descriptions. Repeated or invalid descriptions only enlarge the bound. -/ +abbrev RankPairChoices (J R r : ℕ) := Fin J × (Fin r → Fin R × Fin R) + +theorem card_rankPairChoices (J R r : ℕ) : + Fintype.card (RankPairChoices J R r) = J * R ^ (2 * r) := by + simp only [RankPairChoices, Fintype.card_prod, Fintype.card_fun, Fintype.card_fin] + congr 1 + rw [← pow_two, ← pow_mul] + +/-- A finite union bound for arbitrary events under the concrete finite law. -/ +theorem FiniteLaw.probability_exists_le {A I : Type*} [Fintype A] [Fintype I] + (μ : FiniteLaw A) (E : I → A → Prop) : + μ.probability (fun x => ∃ i, E i x) ≤ ∑ i, μ.probability (E i) := by + classical + unfold FiniteLaw.probability + rw [← μ.average_sum] + apply μ.average_mono + intro x + by_cases hx : ∃ i, E i x + · obtain ⟨i, hi⟩ := hx + simp only [ite_eq_left (show ∃ j, E j x from ⟨i, hi⟩)] + apply (le_trans ?_ (single_le_sum (f := fun i => if E i x then (1 : ℝ) else 0) + (fun j _ => by split_ifs <;> norm_num) (mem_univ i))) + simp [hi] + · simp only [ite_eq_right hx] + exact sum_nonneg (fun i _ => by split_ifs <;> norm_num) + +/-- Uniform bounds may be summed over the explicit column/pair records. -/ +theorem rank_pair_union_bound {A : Type*} [Fintype A] + (μ : FiniteLaw A) (J R r : ℕ) (E : RankPairChoices J R r → A → Prop) + (B : ℝ) (hB : ∀ c, μ.probability (E c) ≤ B) : + μ.probability (fun x => ∃ c, E c x) ≤ (J * R ^ (2 * r) : ℕ) * B := by + apply (μ.probability_exists_le E).trans + calc + _ ≤ ∑ _c : RankPairChoices J R r, B := sum_le_sum (fun c _ => hB c) + _ = _ := by simp only [sum_const, card_univ, nsmul_eq_mul, card_rankPairChoices] + +lemma card_crudeWordCode_exp (R N D : ℕ) : + (Fintype.card (CrudeWordCode R N D) : ℝ) ≤ + Real.exp (R * Real.log 2 + N * Real.log (N + 1) + + N * Real.log (D + 1) + N * Real.log 2) := by + have hp (n k : ℕ) : (n : ℝ) ^ k ≤ Real.exp ((k : ℝ) * Real.log (n + 1)) := by + rw [Real.exp_nat_mul, Real.exp_log (by positivity : (0 : ℝ) < n + 1)] + exact pow_le_pow_left₀ (Nat.cast_nonneg _) (by linarith) k + have htwo (k : ℕ) : (2 : ℝ) ^ k = Real.exp ((k : ℝ) * Real.log 2) := by + rw [Real.exp_nat_mul, Real.exp_log (by norm_num : (0 : ℝ) < 2)] + rw [card_crudeWordCode] + push_cast + calc + _ ≤ (2 : ℝ) ^ R * (Real.exp ((N : ℝ) * Real.log (N + 1)) * + (Real.exp ((N : ℝ) * Real.log (D + 1)) * 2 ^ N)) := by + gcongr + · exact hp N N + · exact hp D N + _ = _ := by rw [htwo, htwo, ← Real.exp_add, ← Real.exp_add, ← Real.exp_add]; congr 1; ring + +/-- The slot bound `N ≤ C R log L` and polynomial record alphabets yield +the manuscript's `exp (O(R log² L))` count with an explicit coefficient. -/ +theorem crudeWordCode_bound (R N D d : ℕ) (L C : ℝ) + (hL : 1 ≤ Real.log L) (hRN : R ≤ N) + (hslots : (N : ℝ) ≤ C * R * Real.log L) + (hN : (N : ℝ) + 1 ≤ L ^ (2 : ℕ)) + (hD : (D : ℝ) + 1 ≤ L ^ d) : + (Fintype.card (CrudeWordCode R N D) : ℝ) ≤ + Real.exp (((d : ℝ) + 4) * C * R * (Real.log L) ^ 2) := by + have htwo : Real.log 2 ≤ 1 := by + have h := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + linarith + have hlog2 : Real.log 2 ≤ Real.log L := htwo.trans hL + have hlogN : Real.log ((N : ℝ) + 1) ≤ 2 * Real.log L := by + have h := Real.log_le_log (by positivity : (0 : ℝ) < N + 1) hN + simpa only [Real.log_pow, Nat.cast_ofNat] using h + have hlogD : Real.log ((D : ℝ) + 1) ≤ (d : ℝ) * Real.log L := by + have h := Real.log_le_log (by positivity : (0 : ℝ) < D + 1) hD + simpa only [Real.log_pow] using h + have h1 : (R : ℝ) * Real.log 2 ≤ N * Real.log L := + mul_le_mul (by exact_mod_cast hRN) hlog2 (Real.log_nonneg (by norm_num)) (Nat.cast_nonneg _) + have h2 := mul_le_mul_of_nonneg_left hlogN (show (0 : ℝ) ≤ N by positivity) + have h3 := mul_le_mul_of_nonneg_left hlogD (show (0 : ℝ) ≤ N by positivity) + have h4 := mul_le_mul_of_nonneg_left hlog2 (show (0 : ℝ) ≤ N by positivity) + have h5 := mul_le_mul_of_nonneg_right hslots (show 0 ≤ Real.log L by linarith) + apply (card_crudeWordCode_exp R N D).trans + apply Real.exp_le_exp.mpr + nlinarith [mul_nonneg (show 0 ≤ (d : ℝ) + 4 by positivity) + (sub_nonneg.mpr h5)] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/CutoffDivisorTransfer.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/CutoffDivisorTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..42fb0c99913bed57cedc1533277116d798aa1773 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/CutoffDivisorTransfer.lean @@ -0,0 +1,110 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughCutoffAverage + +namespace OAI + +/-! Finite retained-divisor assembly for the actual two-cutoff averages. +The original nonpretentious factor may be either member of the pair. -/ + +namespace TwoPointCorrelations + +open Finset Filter MeasureTheory +open scoped Classical + +theorem qualitative_cutoff_rough_shifts_either (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f g : ℕ → ℂ} + (hf : OneBounded f) (hg : OneBounded g) + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hnp : UniformlyNonpretentious f ∨ UniformlyNonpretentious g) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ P Q : Finset ℕ, (∀ p ∈ P, Nat.Prime p) → (∀ p ∈ Q, Nat.Prime p) → + ∀ (M τ : ℝ), 1 < τ → τ < 2 → + Real.exp (B ^ (9999 / 10000 : ℝ)) / τ ≤ M → M ≤ Real.exp (C₀ * B) → + ∀ᶠ Y : ℕ in atTop, ∀ (l : ℕ) [NeZero l] (a : ZMod l) (μ σ ν ρ : ℝ) + (w₁ w₂ : ℝ → ℂ), Integrable w₁ → Integrable w₂ → + ∀ (Z : Finset ℕ) (c : ℕ → ℂ), + (∀ z ∈ Z, M < (z : ℝ) ∧ (z : ℝ) ≤ τ * M ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + (∀ z ∈ Z, ‖c z‖ ≤ 1) → + ‖cutoffRoughAverage f g l a P Q μ σ ν ρ w₁ w₂ Z c h Y‖ ≤ + (C * B ^ (-10001 / 10000 : ℝ)) * (∫ t, ‖w₁ t‖) * (∫ s, ‖w₂ s‖) := by + rcases hnp with hnp | hnp + · obtain ⟨C, hC, hb⟩ := qualitative_cutoff_rough_shifts hM hMRT hnp hf hfm h hh C₀ hC₀ + refine ⟨C, hC, ?_⟩ + filter_upwards [hb] with B hb + intro P Q hP _ M τ hτ₁ hτ₂ hMlower hMupper + filter_upwards [hb P hP M τ hτ₁ hτ₂ hMlower hMupper] with Y hy + intro l _ a μ σ ν ρ w₁ w₂ hw₁ hw₂ Z c hZ hc + exact hy g hg l a Q μ σ ν ρ w₁ w₂ hw₁ hw₂ Z c hZ hc + · obtain ⟨C, hC, hb⟩ := qualitative_cutoff_rough_shifts_right hM hMRT hnp hg hgm h hh C₀ hC₀ + refine ⟨C, hC, ?_⟩ + filter_upwards [hb] with B hb + intro P Q _ hQ M τ hτ₁ hτ₂ hMlower hMupper + filter_upwards [hb Q hQ M τ hτ₁ hτ₂ hMlower hMupper] with Y hy + intro l _ a μ σ ν ρ w₁ w₂ hw₁ hw₂ Z c hZ hc + exact hy f hf l a P μ σ ν ρ w₁ w₂ hw₁ hw₂ Z c hZ hc + +structure RoughCoefficients where + support : Finset ℕ + coefficient : ℕ → ℂ + +def RoughCoefficients.InBin (d : RoughCoefficients) (M τ P₀ : ℝ) : Prop := + (∀ z ∈ d.support, M < (z : ℝ) ∧ (z : ℝ) ≤ τ * M ∧ HasNoPrimeFactorBelow P₀ z) ∧ + (∀ z ∈ d.support, ‖d.coefficient z‖ ≤ 1) + +noncomputable def cutoffRoughProfile (f g : ℕ → ℂ) (l : ℕ) [NeZero l] + (a : ZMod l) (P Q : Finset ℕ) (μ σ ν ρ : ℝ) (w₁ w₂ : ℝ → ℂ) + (d : RoughCoefficients) (h : ℕ) : ℕ → ℂ := + weightedRoughShiftProfile + (progressionSequence (fun n => f n * primeCountCutoff P μ σ w₁ n) l a) + (fun n => g n * primeCountCutoff Q ν ρ w₂ n) d.support d.coefficient h + +/-- The actual cutoff terms at scales `floor(X/u)` retain exactly the +reciprocal divisor mass. The finite coefficient family remains uniform. -/ +theorem qualitative_cutoff_divisor_transfer (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f g : ℕ → ℂ} + (hf : OneBounded f) (hg : OneBounded g) + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hnp : UniformlyNonpretentious f ∨ UniformlyNonpretentious g) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (U : Finset ℕ) (a : ℕ → ℂ) (H τ : ℝ) (P Q : ℕ → Finset ℕ), + (∀ u ∈ U, ∀ p ∈ P u, Nat.Prime p) → + (∀ u ∈ U, ∀ p ∈ Q u, Nat.Prime p) → + 1 < τ → τ < 2 → (∀ u ∈ U, 0 < u) → + (∀ u ∈ U, Real.exp (B ^ (9999 / 10000 : ℝ)) / τ ≤ H / (u : ℝ)) → + (∀ u ∈ U, H / (u : ℝ) ≤ Real.exp (C₀ * B)) → + ∀ (l : ℕ) [NeZero l] (residue : ℕ → ZMod l) (μ σ ν ρ : ℕ → ℝ) + (w₁ w₂ : ℝ → ℂ), Integrable w₁ → Integrable w₂ → + ∀ᶠ X : ℕ in atTop, ∀ d : ℕ → RoughCoefficients, + (∀ u ∈ U, (d u).InBin (H / (u : ℝ)) τ + (Real.exp (B ^ (9999 / 10000 : ℝ)))) → + ‖(∑ u ∈ U, a u * positivePrefix + (cutoffRoughProfile f g l (residue u) (P u) (Q u) (μ u) (σ u) (ν u) (ρ u) + w₁ w₂ (d u) h) (X / u)) / (X : ℂ)‖ ≤ + ((C * B ^ (-10001 / 10000 : ℝ)) * (∫ t, ‖w₁ t‖) * (∫ s, ‖w₂ s‖)) * + (∑ u ∈ U, ‖a u‖ / (u : ℝ)) := by + obtain ⟨C, hC, hb⟩ := qualitative_cutoff_rough_shifts_either hM hMRT hf hg hfm hgm hnp h hh C₀ hC₀ + refine ⟨C, hC, ?_⟩ + filter_upwards [hb, eventually_ge_atTop 0] with B hb hB + intro U a H τ P Q hP hQ hτ₁ hτ₂ hU hMlower hMupper l _ residue μ σ ν ρ w₁ w₂ hw₁ hw₂ + let F : ℕ → RoughCoefficients → ℕ → ℂ := fun u d => + cutoffRoughProfile f g l (residue u) (P u) (Q u) (μ u) (σ u) (ν u) (ρ u) w₁ w₂ d h + let Valid : ℕ → RoughCoefficients → Prop := fun u d => + d.InBin (H / (u : ℝ)) τ (Real.exp (B ^ (9999 / 10000 : ℝ))) + have hF : ∀ u ∈ U, ∀ᶠ Y : ℕ in atTop, ∀ d : RoughCoefficients, + Valid u d → ‖positivePrefix (F u d) Y / (Y : ℂ)‖ ≤ + (C * B ^ (-10001 / 10000 : ℝ)) * (∫ t, ‖w₁ t‖) * (∫ s, ‖w₂ s‖) := by + intro u hu + filter_upwards [hb (P u) (Q u) (hP u hu) (hQ u hu) (H / (u : ℝ)) τ + hτ₁ hτ₂ (hMlower u hu) (hMupper u hu)] with Y hy + intro d hd + exact hy l (residue u) (μ u) (σ u) (ν u) (ρ u) w₁ w₂ hw₁ hw₂ + d.support d.coefficient hd.1 hd.2 + exact finite_rescaled_prefix_bound U a F Valid _ + (mul_nonneg (mul_nonneg (mul_nonneg hC.le (Real.rpow_nonneg hB _)) + (integral_nonneg (fun _ => norm_nonneg _))) (integral_nonneg (fun _ => norm_nonneg _))) hU hF + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DecoderComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DecoderComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b3af7419305eca041eea0d4b3010b6943b0de21 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DecoderComparison.lean @@ -0,0 +1,139 @@ +import OAI.NumberTheory.TwoPoint.Bounds.EncodedCoefficients +import OAI.NumberTheory.TwoPoint.Circuits.CircuitEncoding + +namespace OAI + +/-! Uniform decoding-error estimates for the finite jitter construction. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma uniformAverage_mono {α : Type*} [Fintype α] {f g : α → ℝ} + (h : ∀ x, f x ≤ g x) : uniformAverage f ≤ uniformAverage g := + div_le_div_of_nonneg_right (Finset.sum_le_sum (fun x _ => h x)) (Nat.cast_nonneg _) + +lemma uniformAverage_sum {α ι : Type*} [Fintype α] [Fintype ι] (f : ι → α → ℝ) : + uniformAverage (fun x => ∑ i, f i x) = ∑ i, uniformAverage (f i) := by + unfold uniformAverage + rw [Finset.sum_comm, Finset.sum_div] + +lemma abs_uniformAverage_sub_le {α : Type*} [Fintype α] (f g h : α → ℝ) + (hfg : ∀ x, |f x - g x| ≤ h x) : + |uniformAverage f - uniformAverage g| ≤ uniformAverage h := by + unfold uniformAverage + rw [← sub_div, ← Finset.sum_sub_distrib, abs_div, + show |(Fintype.card α : ℝ)| = (Fintype.card α : ℝ) from abs_of_nonneg (Nat.cast_nonneg _)] + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + exact (Finset.abs_sum_le_sum_abs _ _).trans (Finset.sum_le_sum (fun x _ => hfg x)) + +lemma uniformAverage_coordinate {ι : Type*} [Fintype ι] [DecidableEq ι] + (β : ι → Type*) [∀ i, Fintype (β i)] [∀ i, Nonempty (β i)] (i : ι) + (f : β i → ℝ) : + uniformAverage (fun x : ∀ j, β j => f (x i)) = uniformAverage f := by + let e := Equiv.piSplitAt i β + calc + _ = uniformAverage (fun x : β i × (∀ j : {j // j ≠ i}, β j) => f x.1) := + uniformAverage_equiv e (fun x => f x.1) + _ = _ := by + rw [uniformAverage_prod (fun (x : β i) (_y : ∀ j : {j // j ≠ i}, β j) => f x)] + simp only [uniformAverage_const] + +noncomputable def decodedResidues {m : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (B : ℕ) (x : Fin m → BooleanCube B) : ∀ i, ZMod (s i) := + fun i => ZMod.finEquiv (s i) (decodeBits (NeZero.pos (s i)) (x i)) + +lemma decodedResidues_jitter {m B : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (r : ∀ i, ZMod (s i)) (j : Fin m → Fin (2 ^ B)) (i : Fin m) : + decodedResidues s B (crtJitterBits s B r j) i = + ZMod.finEquiv (s i) (jitterDecode (NeZero.pos (s i)) (by positivity) + (jitterCode ((ZMod.finEquiv (s i)).symm (r i)) (j i))) := by + change ZMod.finEquiv (s i) (decodeBits (NeZero.pos (s i)) + (jitterBits ((ZMod.finEquiv (s i)).symm (r i)) (j i))) = _ + rw [decode_jitterBits] + +lemma decoded_coordinate_error {m B : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (r : ∀ i, ZMod (s i)) (i : Fin m) : + uniformAverage (fun j : Fin m → Fin (2 ^ B) => + if decodedResidues s B (crtJitterBits s B r j) i ≠ r i then (1 : ℝ) else 0) ≤ + (s i : ℝ) / (2 ^ B : ℕ) := by + let : Nonempty (Fin (2 ^ B)) := ⟨⟨0, by positivity⟩⟩ + simp_rw [decodedResidues_jitter] + rw [uniformAverage_coordinate (fun _ : Fin m => Fin (2 ^ B)) i + (fun j => if ZMod.finEquiv (s i) (jitterDecode (NeZero.pos (s i)) (by positivity) + (jitterCode ((ZMod.finEquiv (s i)).symm (r i)) j)) ≠ r i then (1 : ℝ) else 0)] + have heq (j : Fin (2 ^ B)) : + (ZMod.finEquiv (s i) (jitterDecode (NeZero.pos (s i)) (by positivity) + (jitterCode ((ZMod.finEquiv (s i)).symm (r i)) j)) ≠ r i) ↔ + jitterDecode (NeZero.pos (s i)) (by positivity) + (jitterCode ((ZMod.finEquiv (s i)).symm (r i)) j) ≠ + (ZMod.finEquiv (s i)).symm (r i) := by + exact not_congr (ZMod.finEquiv (s i)).toEquiv.eq_symm_apply.symm + simp_rw [heq] + simpa only [uniformAverage, Fintype.card_fin] using + jitterDecode_error (NeZero.pos (s i)) (by positivity) ((ZMod.finEquiv (s i)).symm (r i)) + +noncomputable def eventIndicator {α : Type*} (E : α → Bool) (x : α) : ℝ := if E x then 1 else 0 + +lemma eventIndicator_difference_le_coordinate_errors {m : ℕ} (s : Fin m → ℕ) + (E : (∀ i, ZMod (s i)) → Bool) (r d : ∀ i, ZMod (s i)) : + |eventIndicator E r - eventIndicator E d| ≤ + ∑ i : Fin m, if d i ≠ r i then (1 : ℝ) else 0 := by + by_cases heq : d = r + · subst d + simp + · have hex : ∃ i, d i ≠ r i := by + by_contra h + push Not at h + exact heq (funext h) + obtain ⟨i, hi⟩ := hex + have hsum : (1 : ℝ) ≤ ∑ j : Fin m, if d j ≠ r j then (1 : ℝ) else 0 := by + have h := Finset.single_le_sum + (s := (Finset.univ : Finset (Fin m))) (a := i) + (f := fun j => if d j ≠ r j then (1 : ℝ) else 0) + (by intro j _; split_ifs <;> norm_num) (Finset.mem_univ i) + change (if d i ≠ r i then (1 : ℝ) else 0) ≤ _ at h + rw [ite_eq_left hi] at h + exact h + have hdiff : |eventIndicator E r - eventIndicator E d| ≤ 1 := by + cases hr : E r <;> cases hd : E d <;> norm_num [eventIndicator, hr, hd] + exact hdiff.trans hsum + +/-- Every event has decoding error at most the sum of the coordinate errors. +This statement imposes no circuit assumption; circuits enter only in the +comparison of the encoded distributions. -/ +theorem decoder_event_error {m B : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (E : (∀ i, ZMod (s i)) → Bool) (r : ∀ i, ZMod (s i)) : + |eventIndicator E r - uniformAverage (fun j : Fin m → Fin (2 ^ B) => + eventIndicator E (decodedResidues s B (crtJitterBits s B r j)))| ≤ + ∑ i : Fin m, (s i : ℝ) / (2 ^ B : ℕ) := by + let : Nonempty (Fin (2 ^ B)) := ⟨⟨0, by positivity⟩⟩ + have h := abs_uniformAverage_sub_le + (fun _j : Fin m → Fin (2 ^ B) => eventIndicator E r) + (fun j => eventIndicator E (decodedResidues s B (crtJitterBits s B r j))) + (fun j => ∑ i : Fin m, + if decodedResidues s B (crtJitterBits s B r j) i ≠ r i then (1 : ℝ) else 0) + (fun _ => eventIndicator_difference_le_coordinate_errors s E r _) + rw [uniformAverage_const, uniformAverage_sum] at h + exact h.trans (Finset.sum_le_sum (fun i _ => decoded_coordinate_error s r i)) + +/-- The same decoder bound holds after averaging over an arbitrary finite +law of origins represented as a uniformly sampled finite map. -/ +theorem decoder_event_error_averaged {α : Type*} [Fintype α] [Nonempty α] + {m B : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (E : (∀ i, ZMod (s i)) → Bool) (r : α → ∀ i, ZMod (s i)) : + |uniformAverage (fun x => eventIndicator E (r x)) - + uniformAverage (fun x => uniformAverage (fun j : Fin m → Fin (2 ^ B) => + eventIndicator E (decodedResidues s B (crtJitterBits s B (r x) j))))| ≤ + ∑ i : Fin m, (s i : ℝ) / (2 ^ B : ℕ) := by + have h := abs_uniformAverage_sub_le + (fun x => eventIndicator E (r x)) + (fun x => uniformAverage (fun j : Fin m → Fin (2 ^ B) => + eventIndicator E (decodedResidues s B (crtJitterBits s B (r x) j)))) + (fun _x : α => ∑ i : Fin m, (s i : ℝ) / (2 ^ B : ℕ)) + (fun x => decoder_event_error s E (r x)) + simpa only [uniformAverage_const] using h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DegreeCostComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DegreeCostComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..677f024d95c3e76f89e3ed1c447bcfdb23f3ce2e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DegreeCostComparison.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeDegreeCircuit +import OAI.NumberTheory.TwoPoint.Bounds.PositivePrimeCostComparison + +namespace OAI + +/-! Finite-interval transfer of the literal prime-degree deletion. +The padding-divisor indicator is kept, so its reciprocal saving is +available in the residue-model bound. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem BravermanDepth22Input.eventually_degree_cost_comparison + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M) + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (S V : Finset ℕ), S ⊆ data.P ∪ data.Q → V ⊆ data.P ∪ data.Q → + (S.card : ℝ) ≤ L ^ 2 → + ∀ (q : ℕ), q ∈ retainedPrimeDivisors data.Q → + (q.primeFactors.card : ℝ) ≤ 100 * Real.log L → + ∀ (T : ℝ), 0 ≤ T → T ≤ 400 * Real.log L → + ∀ (site : ℤ) (a N : ℕ), Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let F := fun n : ℤ => actualPaddingCoefficient q * positivePrimeWeight S (n + site) * + if (q : ℤ) ∣ n + site ∧ T < (actualPaddingDegree V (n + site) : ℝ) then 1 else 0 + |uniformAverage (fun x : Fin N => F (a + x.val)) - + (data.residueLaw B hB).average (fun x => F (data.residueOrigin x))| ≤ + Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_positive_prime_cost_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hb, eventually_ge_atTop (4800 : ℝ)] with L hb hL + intro h J M B data hB hpool hBL S V hS hV hSL q hq hqdegree T hT hTL site a N hN + let U := data.P ∪ data.Q + let hQU : data.Q ⊆ U := subset_union_right + let literal : Fin (Fintype.card U) → U × ℤ := + fun i => ((Fintype.equivFin U).symm i, site) + let index := primeSubsetIndex U S hS + let pindex := primeSubsetIndex U V hV + let qindex := primeSubsetIndex U q.primeFactors + ((retainedPrimeDivisor_factors data.Q data.primeQ hq).trans hQU) + let c := degreeDivisorCircuit pindex qindex (⌊T⌋₊ + 1) + let bad := fun n : ℤ => (q : ℤ) ∣ n + site ∧ + T < (actualPaddingDegree V (n + site) : ℝ) + have hindex (i : Fin (Fintype.card S)) : + (literal (index i)).1.val = ((Fintype.equivFin S).symm i).val ∧ + (literal (index i)).2 = site := + ⟨primeSubsetIndex_value U S hS i, rfl⟩ + have hVcard : (Fintype.card V : ℝ) ≤ Real.exp L := by + have hbound : V.card ≤ B := (card_le_card hV).trans + (primePool_card_bound U (fun p hp => data.prime ⟨p, hp⟩) B hB) + have hbound' : (V.card : ℝ) ≤ B := by exact_mod_cast hbound + simpa only [Fintype.card_coe] using hbound'.trans hBL + have hqcard : (Fintype.card q.primeFactors : ℝ) ≤ 100 * Real.log L := by + simpa only [Fintype.card_coe] using hqdegree + have hfloor : ((⌊T⌋₊ + 1 : ℕ) : ℝ) ≤ 400 * Real.log L + 1 := by + push_cast + linarith [Nat.floor_le hT] + have hsize : (c.size : ℝ) ≤ Real.exp (L ^ 3) := + degreeDivisorCircuit_size_exp pindex qindex (⌊T⌋₊ + 1) L hL hVcard hqcard hfloor + have hc : c.depth ≤ 19 := (degreeDivisorCircuit_depth pindex qindex _).trans (by norm_num) + have hbad (n : ℤ) : c.eval + (fun i => decide (((literal i).1.val : ℤ) ∣ n + (literal i).2)) = true ↔ bad n := + degreeDivisorCircuit_integer U V data.Q hV hQU data.primeQ q hq T hT (n + site) + have hh := hb h J M B data hB hpool hBL S hS hSL q.primeFactors.card + (Fintype.card U) hqdegree literal index site hindex c hc hsize bad hbad a N hN + simpa [actualPaddingCoefficient, bad] using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DegreeCostResidue.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DegreeCostResidue.lean new file mode 100644 index 0000000000000000000000000000000000000000..3439e62f848133cb69dd2b7a95e7853255ca4a57 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DegreeCostResidue.lean @@ -0,0 +1,132 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DegreeCostComparison +import OAI.NumberTheory.TwoPoint.Bounds.PaddingResidueEvent +import OAI.NumberTheory.TwoPoint.Bounds.PrimePaddingDeletion + +namespace OAI + +/-! The model degree cost preserves one reciprocal for the fixed +padding divisor. This is the estimate transferred to integer intervals. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +namespace ProhibitedPrimeFamily + +variable {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + +lemma padding_divisor_probability_le (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (q : ℕ) (hq : q ∈ retainedPrimeDivisors data.Q) (site : ℤ) : + (data.paddingResidueLaw B hB).average (fun z => + if (q : ℤ) ∣ data.paddingResidueOrigin z + site then (1 : ℝ) else 0) ≤ + 1 / (q : ℝ) := by + have hsupport := retainedPrimeDivisor_factors data.Q data.primeQ hq + have hsq := retainedPrimeDivisor_squarefree data.Q data.primeQ hq + have he (z : data.Q → Fin B) : + (q : ℤ) ∣ data.paddingResidueOrigin z + site ↔ + PaddingResidueEvent data.Q (fun _ : Fin 1 => q) (fun _ => site) z := by + rw [← padding_literal_support_iff_dvd data.Q data.primeQ + (data.paddingResidueOrigin z + site) q hq, paddingAvailablePrimes_integer] + constructor + · intro hz i p hp + have hdiv := (mem_filter.mp (hz hp)).2 + exact (residue_offset_divisibility + ((z p).val : ZMod p.val) (data.paddingResidueOrigin z) site + (data.paddingResidueOrigin_spec z p)).mp hdiv + · intro hz p hp + refine mem_filter.mpr ⟨hsupport hp, ?_⟩ + let p' : data.Q := ⟨p, hsupport hp⟩ + exact (residue_offset_divisibility ((z p').val : ZMod p) + (data.paddingResidueOrigin z) site (data.paddingResidueOrigin_spec z p')).mpr + (hz 0 p' hp) + have hs : paddingPrimeSupport (fun _ : Fin 1 => q) = q.primeFactors := by + ext p + simp only [paddingPrimeSupport, mem_biUnion, mem_univ, true_and] + exact ⟨fun ⟨_, hp⟩ => hp, fun hp => ⟨0, hp⟩⟩ + have hsup : paddingPrimeSupport (fun _ : Fin 1 => q) ⊆ data.Q := by + simpa only [hs] using hsupport + have hh := paddingResidueEvent_probability_le data.Q (fun _ : Fin 1 => q) + (fun _ => site) B (fun p hp => (data.primeQ p hp).pos) + (fun p hp => hB p (mem_union_right _ hp)) hsup + have hprod : (∏ p ∈ paddingPrimeSupport (fun _ : Fin 1 => q), (p : ℝ)⁻¹) = + 1 / (q : ℝ) := by + rw [hs] + rw [prod_inv_distrib, ← Nat.cast_prod, Nat.prod_primeFactors_of_squarefree hsq, one_div] + rw [hprod] at hh + simpa [FiniteLaw.probability, he, ProhibitedPrimeFamily.paddingResidueLaw] using hh + +theorem positive_divisor_degree_cost (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (S : Finset ℕ) (hSP : S ⊆ data.P) (q : ℕ) (hq : q ∈ retainedPrimeDivisors data.Q) + (W : ℝ) (hW : 10 ≤ W) + (hmass : (∑ p ∈ data.P, 1 / (p : ℝ)) ≤ 2 * W * S.card) (site : ℤ) : + (data.residueLaw B hB).average (fun x => + actualPaddingCoefficient q * positivePrimeWeight S (data.residueOrigin x + site) * + if (q : ℤ) ∣ data.residueOrigin x + site ∧ + 6 * W * S.card < (actualPaddingDegree data.P (data.residueOrigin x + site) : ℝ) + then 1 else 0) ≤ + actualPaddingCoefficient q / q * positivePrimeNormalizer S * + Real.exp (-2 * W * S.card) := by + let g := fun n : ℤ => if (q : ℤ) ∣ n then (1 : ℝ) else 0 + have hg0 (n) : 0 ≤ g n := by dsimp [g]; split_ifs <;> norm_num + have hg (n m : ℤ) (he : ∀ p ∈ data.Q, (n : ZMod p) = (m : ZMod p)) : g n = g m := by + have hd := squarefree_divisor_congr data.Q q + (retainedPrimeDivisor_squarefree data.Q data.primeQ hq) + (retainedPrimeDivisor_factors data.Q data.primeQ hq) n m he + simp only [g, hd] + have hh := data.positive_prime_padding_degree_tail hB S hSP W hW hmass site g hg0 hg + have hprob := data.padding_divisor_probability_le hB q hq site + have hconstant : 0 ≤ positivePrimeNormalizer S * Real.exp (-2 * W * S.card) := by + unfold positivePrimeNormalizer + positivity + have hbound := hh.trans (mul_le_mul_of_nonneg_left hprob hconstant) + have hm := mul_le_mul_of_nonneg_left hbound (actualPaddingCoefficient_nonneg q) + calc + _ = actualPaddingCoefficient q * (data.residueLaw B hB).average (fun x => + (positivePrimeWeight S (data.residueOrigin x + site) * + if 6 * W * S.card < (actualPaddingDegree data.P (data.residueOrigin x + site) : ℝ) + then 1 else 0) * g (data.residueOrigin x + site)) := by + rw [mul_comm (actualPaddingCoefficient q) _, ← FiniteLaw.average_mul_const] + apply congrArg (data.residueLaw B hB).average + funext x + dsimp [g] + split_ifs <;> simp_all + all_goals ring + _ ≤ _ := by convert hm using 1; ring + +end ProhibitedPrimeFamily + +theorem BravermanDepth22Input.eventually_integer_degree_cost + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M) + (_hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (S : Finset ℕ), S ⊆ data.P → (S.card : ℝ) ≤ L ^ 2 → + ∀ (W : ℝ), 10 ≤ W → 6 * W * S.card ≤ 400 * Real.log L → + (∑ p ∈ data.P, 1 / (p : ℝ)) ≤ 2 * W * S.card → + ∀ (q : ℕ), q ∈ retainedPrimeDivisors data.Q → + (q.primeFactors.card : ℝ) ≤ 100 * Real.log L → + ∀ (site : ℤ) (a N : ℕ), Real.exp (L ^ A / 2) ≤ (N : ℝ) → + uniformAverage (fun x : Fin N => + actualPaddingCoefficient q * positivePrimeWeight S ((a + x.val : ℤ) + site) * + if (q : ℤ) ∣ (a + x.val : ℤ) + site ∧ + 6 * W * S.card < (actualPaddingDegree data.P ((a + x.val : ℤ) + site) : ℝ) + then 1 else 0) ≤ + actualPaddingCoefficient q / q * positivePrimeNormalizer S * + Real.exp (-2 * W * S.card) + Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_degree_cost_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hb] with L hb + intro h J M B data hB hpool hBL S hSP hSL W hW hTL hmass q hq hqdegree site a N hN + have hc := hb h J M B data hB hpool hBL S data.P + (hSP.trans subset_union_left) subset_union_left hSL q hq hqdegree + (6 * W * S.card) (by positivity) hTL site a N hN + have hm := data.positive_divisor_degree_cost hB S hSP q hq W hW hmass site + dsimp only at hc + have hu := le_trans (le_abs_self _) hc + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DegreeDeletionSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DegreeDeletionSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4d575276767ea5487d5e170729720f758fb7535 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DegreeDeletionSum.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DegreeCostResidue + +namespace OAI + +/-! Summing the actual integer degree-deletion cost preserves the +padding reciprocal mass and the tuple normalizer. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def positiveDegreeCost (P S : Finset ℕ) (W : ℝ) (q : ℕ) (n : ℤ) : ℝ := + actualPaddingCoefficient q * positivePrimeWeight S n * + if (q : ℤ) ∣ n ∧ 6 * W * S.card < (actualPaddingDegree P n : ℝ) then 1 else 0 + +theorem BravermanDepth22Input.eventually_integer_degree_sum + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M) + (_hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (S : Finset ℕ), S ⊆ data.P → (S.card : ℝ) ≤ L ^ 2 → + ∀ (W : ℝ), 10 ≤ W → 6 * W * S.card ≤ 400 * Real.log L → + (∑ p ∈ data.P, 1 / (p : ℝ)) ≤ 2 * W * S.card → + ∀ (Q : Finset ℕ), Q ⊆ retainedPrimeDivisors data.Q → + (∀ q ∈ Q, (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) → + ∀ (site : ℤ) (a N : ℕ), Real.exp (L ^ A / 2) ≤ (N : ℝ) → + (∑ q ∈ Q, uniformAverage (fun x : Fin N => + positiveDegreeCost data.P S W q ((a + x.val : ℤ) + site))) ≤ + positivePrimeNormalizer S * Real.exp (-2 * W * S.card) * + (∑ q ∈ Q, actualPaddingCoefficient q / q) + Q.card * Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_integer_degree_cost + refine ⟨A, hA, ?_⟩ + filter_upwards [hb] with L hb + intro h J M B data hB hpool hBL S hSP hSL W hW hTL hmass Q hQ hqdegree site a N hN + calc + _ ≤ ∑ q ∈ Q, (actualPaddingCoefficient q / q * positivePrimeNormalizer S * + Real.exp (-2 * W * S.card) + Real.exp (-(L ^ 9))) := by + apply sum_le_sum + intro q hq + simpa only [positiveDegreeCost] using + hb h J M B data hB hpool hBL S hSP hSL W hW hTL hmass + q (hQ hq) (hqdegree q hq) site a N hN + _ = _ := by + simp only [sum_add_distrib, ← sum_mul, sum_const, nsmul_eq_mul] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DegreeThresholdCircuit.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DegreeThresholdCircuit.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f3b93681439206b6b50d1cd0805f7e6a7214934 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DegreeThresholdCircuit.lean @@ -0,0 +1,158 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActiveStateExpansion +import OAI.NumberTheory.TwoPoint.Circuits.CircuitBooleanOps + +namespace OAI + +/-! The literal degree cutoffs are depth-two monotone circuits: a large +active set contains a subset of the prescribed size. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace AC0Circuit + +noncomputable def disjunction {ι : Type*} [Fintype ι] {n : ℕ} + (c : ι → AC0Circuit n) : AC0Circuit n := + .orGate (fun i : Fin (Fintype.card ι) => c ((Fintype.equivFin ι).symm i)) + +lemma disjunction_eval {ι : Type*} [Fintype ι] {n : ℕ} + (c : ι → AC0Circuit n) (x : BooleanCube n) : + (disjunction c).eval x = true ↔ ∃ i, (c i).eval x = true := by + simp only [disjunction, eval, decide_eq_true_eq] + constructor + · rintro ⟨i, hi⟩ + exact ⟨_, hi⟩ + · rintro ⟨i, hi⟩ + exact ⟨(Fintype.equivFin ι) i, by simpa only [Equiv.symm_apply_apply] using hi⟩ + +lemma disjunction_depth {ι : Type*} [Fintype ι] {n d : ℕ} + (c : ι → AC0Circuit n) (hc : ∀ i, (c i).depth ≤ d) : + (disjunction c).depth ≤ d + 1 := by + simp only [disjunction, depth] + have hh : (univ.sup fun i : Fin (Fintype.card ι) => + (c ((Fintype.equivFin ι).symm i)).depth) ≤ d := + Finset.sup_le (fun i _ => hc _) + omega + +lemma disjunction_size {ι : Type*} [Fintype ι] {n : ℕ} + (c : ι → AC0Circuit n) : (disjunction c).size = 1 + ∑ i, (c i).size := by + simp only [disjunction, size] + congr 1 + exact (Fintype.equivFin ι).symm.sum_comp (fun i => (c i).size) + +end AC0Circuit + +noncomputable def degreeSubsetCircuit {n : ℕ} (S : Finset (Fin n)) : AC0Circuit n := + AC0Circuit.conjunction (fun i : S => .literal i.val true) + +lemma degreeSubsetCircuit_eval {n : ℕ} (S : Finset (Fin n)) (x : BooleanCube n) : + (degreeSubsetCircuit S).eval x = true ↔ S ⊆ activeState x := by + rw [degreeSubsetCircuit, AC0Circuit.conjunction_eval] + simp only [AC0Circuit.eval, ite_true] + constructor + · intro h i hi + exact mem_filter.mpr ⟨mem_univ i, h ⟨i, hi⟩⟩ + · intro h i + exact (mem_filter.mp (h i.property)).2 + +lemma degreeSubsetCircuit_depth {n : ℕ} (S : Finset (Fin n)) : + (degreeSubsetCircuit S).depth ≤ 1 := + AC0Circuit.conjunction_depth _ (fun _ => Nat.le_refl 0) + +lemma degreeSubsetCircuit_size {n : ℕ} (S : Finset (Fin n)) : + (degreeSubsetCircuit S).size = 1 + S.card := by + simp [degreeSubsetCircuit, AC0Circuit.conjunction_size, AC0Circuit.size] + +noncomputable def degreeThresholdCircuit (n r : ℕ) : AC0Circuit n := + AC0Circuit.disjunction (fun S : (univ : Finset (Fin n)).powersetCard r => + degreeSubsetCircuit S.val) + +lemma degreeThresholdCircuit_eval (n r : ℕ) (x : BooleanCube n) : + (degreeThresholdCircuit n r).eval x = true ↔ r ≤ (activeState x).card := by + rw [degreeThresholdCircuit, AC0Circuit.disjunction_eval] + constructor + · rintro ⟨S, hS⟩ + have hsub := (degreeSubsetCircuit_eval S.val x).mp hS + have hcard := (mem_powersetCard.mp S.property).2 + exact hcard ▸ card_le_card hsub + · intro hr + obtain ⟨S, hsub, hcard⟩ := exists_subset_card_eq hr + refine ⟨⟨S, mem_powersetCard.mpr ⟨subset_univ S, hcard⟩⟩, ?_⟩ + exact (degreeSubsetCircuit_eval S x).mpr hsub + +lemma degreeThresholdCircuit_depth (n r : ℕ) : + (degreeThresholdCircuit n r).depth ≤ 2 := + AC0Circuit.disjunction_depth _ (fun S => degreeSubsetCircuit_depth S.val) + +lemma degreeThresholdCircuit_size (n r : ℕ) : + (degreeThresholdCircuit n r).size = 1 + n.choose r * (r + 1) := by + rw [degreeThresholdCircuit, AC0Circuit.disjunction_size] + have hs (S : (univ : Finset (Fin n)).powersetCard r) : + (degreeSubsetCircuit S.val).size = r + 1 := by + rw [degreeSubsetCircuit_size, (mem_powersetCard.mp S.property).2] + omega + simp only [hs, sum_const, card_univ, Fintype.card_coe, card_powersetCard, + Fintype.card_fin, nsmul_eq_mul, Nat.cast_id] + +lemma degreeThresholdCircuit_size_le (n r : ℕ) : + (degreeThresholdCircuit n r).size ≤ 1 + (r + 1) * (n + 1) ^ r := by + rw [degreeThresholdCircuit_size] + have hb : n.choose r ≤ (n + 1) ^ r := + (Nat.choose_le_pow n r).trans (Nat.pow_le_pow_left (Nat.le_succ n) r) + simpa only [Nat.mul_comm] using Nat.add_le_add_left + (Nat.mul_le_mul_right (r + 1) hb) 1 + +lemma degreeThresholdCircuit_real_eval (n : ℕ) (t : ℝ) (ht : 0 ≤ t) + (x : BooleanCube n) : + (degreeThresholdCircuit n (⌊t⌋₊ + 1)).eval x = true ↔ + t < ((activeState x).card : ℝ) := by + rw [degreeThresholdCircuit_eval, ← Nat.lt_iff_add_one_le, Nat.floor_lt ht] + +lemma degreeThresholdCircuit_size_exp (L : ℝ) (n r : ℕ) + (hL : 2407 ≤ L) (hn : (n : ℝ) ≤ Real.exp L) + (hr : (r : ℝ) ≤ 400 * Real.log L + 1) : + ((degreeThresholdCircuit n r).size : ℝ) ≤ Real.exp (L ^ 3) := by + have hL0 : 0 ≤ L := by linarith + have hlog : Real.log L ≤ L := + (Real.log_le_sub_one_of_pos (by linarith)).trans (by linarith) + have hrL : (r : ℝ) ≤ 401 * L := by nlinarith + have hexp : (2 : ℝ) ≤ Real.exp L := by linarith [Real.add_one_le_exp L] + have hn' : (n : ℝ) + 1 ≤ Real.exp (2 * L) := by + rw [show 2 * L = L + L by ring, Real.exp_add] + nlinarith + have hmass : ((r : ℝ) + 1) * ((n : ℝ) + 1) ^ r ≤ + Real.exp (1203 * L ^ 2) := by + calc + _ ≤ Real.exp (r : ℝ) * (Real.exp (2 * L)) ^ r := + mul_le_mul (Real.add_one_le_exp (r : ℝ)) + (pow_le_pow_left₀ (by positivity) hn' r) (by positivity) (by positivity) + _ = Real.exp ((r : ℝ) * (1 + 2 * L)) := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + congr 1 + ring + _ ≤ _ := Real.exp_le_exp.mpr (by + have hmul := mul_le_mul_of_nonneg_right hrL + (show 0 ≤ 1 + 2 * L by positivity) + have hsq := mul_nonneg hL0 (show 0 ≤ L - 1 by linarith) + nlinarith) + have hsize : ((degreeThresholdCircuit n r).size : ℝ) ≤ + 1 + ((r : ℝ) + 1) * ((n : ℝ) + 1) ^ r := by + exact_mod_cast degreeThresholdCircuit_size_le n r + have hb : 1 ≤ Real.exp (1203 * L ^ 2) := + Real.one_le_exp (by positivity) + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + calc + _ ≤ 1 + Real.exp (1203 * L ^ 2) := by linarith [hsize, hmass] + _ ≤ Real.exp (1 + 1203 * L ^ 2) := by + rw [Real.exp_add] + nlinarith + _ ≤ _ := Real.exp_le_exp.mpr (by + have hsq : (1 : ℝ) ≤ L ^ 2 := by nlinarith + have hc := mul_nonneg (sq_nonneg L) (show 0 ≤ L - 1204 by linarith) + nlinarith) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DeletionErrorScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DeletionErrorScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..e740d6b7a469ae71ae663e1feb6e6621345653ff --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DeletionErrorScale.lean @@ -0,0 +1,95 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Analysis.SpecialFunctions.Log.Basic +import Mathlib.Order.Filter.AtTopBot.Basic +import Mathlib.Tactic + +namespace OAI + +/-! The finite-catalog error in the three deletion estimates is +negligible even when every bin uses a different interval. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma deletion_comparison_error_bound (L C b d q S V : ℝ) + (hL : 4800 ≤ L) (hC : 0 ≤ C) (hCL : C + 104 ≤ L) + (hb0 : 0 ≤ b) (hd0 : 0 ≤ d) (hq0 : 0 ≤ q) + (hb : b ≤ Real.exp (C * Real.log L)) (hd : d ≤ Real.exp (2 * L)) + (hq : q ≤ Real.exp (100 * L ^ 2)) (hS : 1 ≤ S) (hV : 1 ≤ V) : + ((3 * b * d * q + b * Real.exp (101 * L)) * Real.exp (-(L ^ 9))) / + (S * V) ≤ Real.exp (-L ^ (9 / 10 : ℝ)) := by + have hL0 : 0 ≤ L := by linarith + have hL1 : 1 ≤ L := by linarith + have hlog : Real.log L ≤ L := + (Real.log_le_sub_one_of_pos (by linarith)).trans (by linarith) + have hcLog := mul_le_mul_of_nonneg_left hlog hC + have hcL := mul_le_mul_of_nonneg_right hCL hL0 + have h101 := mul_le_mul_of_nonneg_right (show (101 : ℝ) ≤ L by linarith) (sq_nonneg L) + have hp1 : C * Real.log L + 2 * L + 100 * L ^ 2 ≤ L ^ 3 := by nlinarith + have hp2 : C * Real.log L + 101 * L ≤ L ^ 3 := by nlinarith + have hprod : b * d * q ≤ Real.exp (L ^ 3) := by + calc + _ ≤ Real.exp (C * Real.log L) * Real.exp (2 * L) * Real.exp (100 * L ^ 2) := + mul_le_mul (mul_le_mul hb hd hd0 (Real.exp_pos _).le) hq hq0 + (mul_nonneg (Real.exp_pos _).le (Real.exp_pos _).le) + _ = Real.exp (C * Real.log L + 2 * L + 100 * L ^ 2) := by + rw [← Real.exp_add, ← Real.exp_add] + _ ≤ _ := Real.exp_le_exp.mpr hp1 + have hother : b * Real.exp (101 * L) ≤ Real.exp (L ^ 3) := by + calc + _ ≤ Real.exp (C * Real.log L) * Real.exp (101 * L) := + mul_le_mul_of_nonneg_right hb (Real.exp_pos _).le + _ = Real.exp (C * Real.log L + 101 * L) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr hp2 + have h34 : L ^ 3 + 3 ≤ L ^ 4 := by + have hh := mul_le_mul_of_nonneg_right (show (2 : ℝ) ≤ L by linarith) (pow_nonneg hL0 3) + have hp : 3 ≤ L ^ 3 := (show (3 : ℝ) ≤ L by linarith).trans (by + simpa only [pow_one] using pow_le_pow_right₀ hL1 (show 1 ≤ 3 by norm_num)) + nlinarith + have hcoefficient : 3 * b * d * q + b * Real.exp (101 * L) ≤ Real.exp (L ^ 4) := by + calc + _ ≤ 4 * Real.exp (L ^ 3) := by nlinarith + _ ≤ Real.exp 3 * Real.exp (L ^ 3) := + mul_le_mul_of_nonneg_right (by linarith [Real.add_one_le_exp (3 : ℝ)]) (Real.exp_pos _).le + _ = Real.exp (L ^ 3 + 3) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr h34 + have hpower : L ^ 4 + L ≤ L ^ 9 := by + have h45 : 2 * L ^ 4 ≤ L ^ 5 := by + have hh := mul_le_mul_of_nonneg_right (show (2 : ℝ) ≤ L by linarith) (pow_nonneg hL0 4) + nlinarith + have h59 : L ^ 5 ≤ L ^ 9 := pow_le_pow_right₀ hL1 (by norm_num) + have h14 : L ≤ L ^ 4 := by + have hh : L ^ 1 ≤ L ^ 4 := pow_le_pow_right₀ hL1 (by norm_num) + simpa only [pow_one] using hh + linarith + have hsmall : L ^ (9 / 10 : ℝ) ≤ L := by + simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le hL1 + (show (9 / 10 : ℝ) ≤ 1 by norm_num) + have hSV : 1 ≤ S * V := by nlinarith + have hnonneg : 0 ≤ (3 * b * d * q + b * Real.exp (101 * L)) * Real.exp (-(L ^ 9)) := by + positivity + calc + _ ≤ (3 * b * d * q + b * Real.exp (101 * L)) * Real.exp (-(L ^ 9)) := + div_le_self hnonneg hSV + _ ≤ Real.exp (L ^ 4) * Real.exp (-(L ^ 9)) := + mul_le_mul_of_nonneg_right hcoefficient (Real.exp_pos _).le + _ = Real.exp (L ^ 4 - L ^ 9) := by rw [← Real.exp_add]; congr 1 + _ ≤ _ := Real.exp_le_exp.mpr (by linarith) + +theorem eventually_deletion_comparison_error (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ b d q S V : ℝ, + 0 ≤ b → 0 ≤ d → 0 ≤ q → + b ≤ Real.exp (C * Real.log L) → d ≤ Real.exp (2 * L) → + q ≤ Real.exp (100 * L ^ 2) → 1 ≤ S → 1 ≤ V → + ((3 * b * d * q + b * Real.exp (101 * L)) * Real.exp (-(L ^ 9))) / + (S * V) ≤ Real.exp (-L ^ (9 / 10 : ℝ)) := by + filter_upwards [eventually_ge_atTop (max 4800 (C + 104))] with L hL + intro b d q S V hb0 hd0 hq0 hb hd hq hS hV + exact deletion_comparison_error_bound L C b d q S V + ((le_max_left _ _).trans hL) hC ((le_max_right _ _).trans hL) + hb0 hd0 hq0 hb hd hq hS hV + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DeletionNormalization.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DeletionNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab573c1c4851b86c4566c532ce9256f6cfe9495d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DeletionNormalization.lean @@ -0,0 +1,46 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Tactic + +namespace OAI + +/-! Normalize the three deletion costs by the exact padding and tuple +masses. The rare-site term uses only S*V ≥ 1. -/ + +namespace TwoPointCorrelations + +lemma normalize_three_deletion_costs + (F pad deg rare S V T α β δ ep ed er : ℝ) + (hS : 1 ≤ S) (hV : 1 ≤ V) (hδ : 0 ≤ δ) + (hF : F ≤ pad + deg + rare) + (hpad : pad ≤ S * V * T * α + ep) + (hdeg : deg ≤ S * V * T * β + ed) + (hrare : rare ≤ δ + er) : + F / (S * V) ≤ T * (α + β) + δ + (ep + ed + er) / (S * V) := by + have hSV : 1 ≤ S * V := by nlinarith + have hSVpos : 0 < S * V := by linarith + have hrare' : δ ≤ S * V * δ := by nlinarith + have hb : F ≤ S * V * (T * (α + β) + δ) + (ep + ed + er) := by nlinarith + calc + _ ≤ (S * V * (T * (α + β) + δ) + (ep + ed + er)) / (S * V) := + div_le_div_of_nonneg_right hb hSVpos.le + _ = _ := by rw [add_div, mul_div_cancel_left₀ _ hSVpos.ne'] + +lemma normalize_endpoint_deletion_costs + (F pad deg rare S V T α β δ ep ed er : ℝ) + (hS : 1 ≤ S) (hV : 1 ≤ V) (hδ : 0 ≤ δ) + (hF : F ≤ 2 * (pad + deg + rare)) + (hpad : pad ≤ S * V * T * α + ep) + (hdeg : deg ≤ S * V * T * β + ed) + (hrare : rare ≤ δ + er) : + F / (S * V) ≤ 2 * (T * (α + β) + δ + (ep + ed + er) / (S * V)) := by + have hSVpos : 0 < S * V := mul_pos (by linarith) (by linarith) + have hb := normalize_three_deletion_costs (pad + deg + rare) pad deg rare S V T α β δ ep ed er + hS hV hδ le_rfl hpad hdeg hrare + calc + _ ≤ (2 * (pad + deg + rare)) / (S * V) := div_le_div_of_nonneg_right hF hSVpos.le + _ = 2 * ((pad + deg + rare) / (S * V)) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left hb (by norm_num) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DeletionRowSplit.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DeletionRowSplit.lean new file mode 100644 index 0000000000000000000000000000000000000000..a80b0dc1972767b7412fb8f3ac30fda750963eb3 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DeletionRowSplit.lean @@ -0,0 +1,119 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingDeletionIdentity +import OAI.NumberTheory.TwoPoint.Bounds.DegreeDeletionSum + +namespace OAI + +/-! Deterministic union bound for the three actual source deletions. +The disjoint logarithmic bins prevent an extra bin-count loss in the +tuple-degree term. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma actualPaddingBin_sum_le (bins : Finset ℤ) (η c : ℝ) (hη : 0 < η) + (q : ℕ) (w : ℝ) (hw : 0 ≤ w) : + (∑ j ∈ bins, if actualPaddingBin η c j q then w else 0) ≤ w := by + have he (j : ℤ) : actualPaddingBin η c j q ↔ paddingBin η c (Real.log q) = j := + (paddingBin_eq_iff η c (Real.log q) j hη).symm + simp only [he] + by_cases hm : paddingBin η c (Real.log q) ∈ bins + · simp [hm] + · simpa [hm] using hw + +lemma weighted_three_deletions (w : ℝ) (hw : 0 ≤ w) (divisor A B C : Prop) : + w * (if divisor ∧ (A ∨ B ∨ C) then 1 else 0) ≤ + w * (if divisor ∧ A then 1 else 0) + + w * (if divisor ∧ B then 1 else 0) + + w * (if divisor ∧ C then 1 else 0) := by + by_cases hd : divisor <;> by_cases ha : A <;> by_cases hb : B <;> by_cases hc : C <;> + simp [hd, ha, hb, hc] <;> linarith + +noncomputable def positiveSourceDeletion (P Q D R : Finset ℕ) (bins : Finset ℤ) + (η : ℝ) (c : ℕ → ℝ) (L K W : ℝ) (bad : ℤ → ℤ → Prop) (n : ℤ) : ℝ := + ∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R, + if actualPaddingBin η (c d) j q then + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors n * + (if (q : ℤ) ∣ n ∧ + (¬integerEdgeKeep R actualPaddingCoefficient (actualPaddingBin η (c d) j) + (actualPaddingVertex Q) L K (actualPaddingDegreeCut Q L) n ∨ + 6 * W * d.primeFactors.card < (actualPaddingDegree P n : ℝ) ∨ bad j n) + then 1 else 0) + else 0 + +lemma positiveSourceDeletion_split (P Q D R : Finset ℕ) (bins : Finset ℤ) + (η : ℝ) (c : ℕ → ℝ) (L K W : ℝ) (hη : 0 < η) + (bad : ℤ → ℤ → Prop) (n : ℤ) : + positiveSourceDeletion P Q D R bins η c L K W bad n ≤ + (∑ d ∈ D, positivePrimeWeight d.primeFactors n * + paddingRejectedMass Q R bins η (c d) L K n) + + (∑ d ∈ D, ∑ q ∈ R, positiveDegreeCost P d.primeFactors W q n) + + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R.filter (actualPaddingBin η (c d) j), + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors n * + if (q : ℤ) ∣ n ∧ bad j n then 1 else 0) := by + let pad := fun j d q => paddingRejectionAtom Q d.primeFactors R + (actualPaddingBin η (c d) j) L K q n + let deg := fun j d q => if actualPaddingBin η (c d) j q then + positiveDegreeCost P d.primeFactors W q n else 0 + let rare := fun j d q => if actualPaddingBin η (c d) j q then + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors n * + (if (q : ℤ) ∣ n ∧ bad j n then 1 else 0) else 0 + have hterm (j : ℤ) (d q : ℕ) : + (if actualPaddingBin η (c d) j q then + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors n * + (if (q : ℤ) ∣ n ∧ + (¬integerEdgeKeep R actualPaddingCoefficient (actualPaddingBin η (c d) j) + (actualPaddingVertex Q) L K (actualPaddingDegreeCut Q L) n ∨ + 6 * W * d.primeFactors.card < (actualPaddingDegree P n : ℝ) ∨ bad j n) + then 1 else 0) else 0) ≤ pad j d q + deg j d q + rare j d q := by + by_cases hb : actualPaddingBin η (c d) j q + · simp only [pad, deg, rare, paddingRejectionAtom, hb, ite_true, positiveDegreeCost] + simpa using weighted_three_deletions + (actualPaddingCoefficient q * positivePrimeWeight d.primeFactors n) + (mul_nonneg (actualPaddingCoefficient_nonneg q) (positivePrimeWeight_nonneg _ _)) + ((q : ℤ) ∣ n) + (¬integerEdgeKeep R actualPaddingCoefficient (actualPaddingBin η (c d) j) + (actualPaddingVertex Q) L K (actualPaddingDegreeCut Q L) n) + (6 * W * d.primeFactors.card < (actualPaddingDegree P n : ℝ)) (bad j n) + · simp only [pad, deg, rare, paddingRejectionAtom, hb, ite_false, add_zero, le_refl] + have hpad : (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R, pad j d q) = + ∑ d ∈ D, positivePrimeWeight d.primeFactors n * paddingRejectedMass Q R bins η (c d) L K n := by + rw [sum_comm] + apply sum_congr rfl + intro d _ + exact (padding_rejection_bin_identity Q d.primeFactors R bins η (c d) L K n).symm + have hdeg : (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R, deg j d q) ≤ + ∑ d ∈ D, ∑ q ∈ R, positiveDegreeCost P d.primeFactors W q n := by + rw [sum_comm] + apply sum_le_sum + intro d _ + rw [sum_comm] + apply sum_le_sum + intro q _ + apply actualPaddingBin_sum_le bins η (c d) hη q + unfold positiveDegreeCost + exact mul_nonneg (mul_nonneg (actualPaddingCoefficient_nonneg q) + (positivePrimeWeight_nonneg _ _)) (by split_ifs <;> norm_num) + have hrare : (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R, rare j d q) = + ∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R.filter (actualPaddingBin η (c d) j), + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors n * + if (q : ℤ) ∣ n ∧ bad j n then 1 else 0 := by + simp only [sum_filter, rare] + calc + _ ≤ ∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R, (pad j d q + deg j d q + rare j d q) := by + apply sum_le_sum + intro j _ + apply sum_le_sum + intro d _ + apply sum_le_sum + intro q _ + exact hterm j d q + _ = (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R, pad j d q) + + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R, deg j d q) + + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R, rare j d q) := by simp only [sum_add_distrib] + _ ≤ _ := by rw [hpad, hrare]; linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DepartureWeightBounds.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DepartureWeightBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..531c6a652d25e54935a379ef8da7f5df63797d3a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DepartureWeightBounds.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CrudeTraceWeights + +namespace OAI + +/-! Bounds for the actual normalized departure factors after the cutoffs are discarded. -/ + +namespace TwoPointCorrelations + +open Finset + +noncomputable def departureWeight {r : ℕ} (L : ℝ) (u : ℕ → ℝ) (q : Fin r → ℕ) + (denom cutoff : Fin r → ℝ) : ℝ := + ∏ i, (L * u (q i) / denom i) * cutoff i + +lemma departureWeight_nonneg {r : ℕ} (L : ℝ) (u : ℕ → ℝ) (q : Fin r → ℕ) + (denom cutoff : Fin r → ℝ) (hL : 0 ≤ L) (hu : ∀ i, 0 ≤ u (q i)) + (hd : ∀ i, 0 ≤ denom i) (hc : ∀ i, 0 ≤ cutoff i) : + 0 ≤ departureWeight L u q denom cutoff := by + apply prod_nonneg + intro i _ + exact mul_nonneg (div_nonneg (mul_nonneg hL (hu i)) (hd i)) (hc i) + +lemma departureWeight_le_crude {r : ℕ} (L : ℝ) (u : ℕ → ℝ) (q : Fin r → ℕ) + (denom cutoff : Fin r → ℝ) (hL : 0 ≤ L) + (hu : ∀ i, 0 ≤ u (q i)) (hub : ∀ i, u (q i) ≤ crudePaddingWeight (q i)) + (hd : ∀ i, 1 ≤ denom i) (hc : ∀ i, 0 ≤ cutoff i) (hcb : ∀ i, cutoff i ≤ 1) : + departureWeight L u q denom cutoff ≤ ∏ i, L * crudePaddingWeight (q i) := by + apply prod_le_prod₀ + · intro i _ + exact mul_nonneg (div_nonneg (mul_nonneg hL (hu i)) (by linarith [hd i])) (hc i) + · intro i _ + calc + _ ≤ (L * u (q i) / denom i) * 1 := + mul_le_mul_of_nonneg_left (hcb i) + (div_nonneg (mul_nonneg hL (hu i)) (by linarith [hd i])) + _ = L * u (q i) / denom i := mul_one _ + _ ≤ L * u (q i) := div_le_self (mul_nonneg hL (hu i)) (hd i) + _ ≤ _ := mul_le_mul_of_nonneg_left (hub i) hL + +/-- All designation and singleton multiplicities are included in this cost. -/ +theorem departureWeight_designation_cost {r m S : ℕ} + (L external Cexternal Csingle : ℝ) (u : ℕ → ℝ) (q : Fin r → ℕ) + (denom cutoff : Fin r → ℝ) + (hL : 1 ≤ L) (hlog : 1 ≤ Real.log L) (hr : (r : ℝ) ≤ 2 * L) + (hS : ((m + S : ℕ) : ℝ) ≤ Csingle * L * Real.log L) + (hCe : 0 ≤ Cexternal) (he : 0 ≤ external) + (hext : external ≤ Real.exp (Cexternal * L)) + (hpad : ∀ i, ((q i).primeFactors.card : ℝ) ≤ 100 * Real.log L) + (hu : ∀ i, 0 ≤ u (q i)) (hub : ∀ i, u (q i) ≤ crudePaddingWeight (q i)) + (hd : ∀ i, 1 ≤ denom i) (hc : ∀ i, 0 ≤ cutoff i) (hcb : ∀ i, cutoff i ≤ 1) : + (external * departureWeight L u q denom cutoff) * 2 ^ (m + S) ≤ + Real.exp ((Cexternal + Csingle + 402) * L * (Real.log L) ^ 2) := by + apply le_trans _ (crudeTraceWeight_exp_bound r (m + S) q L external Cexternal Csingle + hL hlog hr hS hCe hext hpad) + calc + _ ≤ (external * (∏ i, L * crudePaddingWeight (q i))) * 2 ^ (m + S) := by + apply mul_le_mul_of_nonneg_right _ (by positivity) + exact mul_le_mul_of_nonneg_left + (departureWeight_le_crude L u q denom cutoff (by linarith) hu hub hd hc hcb) he + _ = crudeTraceWeight r (m + S) q L external := by + unfold crudeTraceWeight + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DesignationWeights.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DesignationWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f71436b10d0ef8e29fd066c975b7cfef891eebb --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DesignationWeights.lean @@ -0,0 +1,133 @@ +import OAI.NumberTheory.TwoPoint.Bounds.TraceDesignations + +namespace OAI + +/-! Group literal unlit factors and forced lit atoms into exact prime exponents. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι τ : Type*} [Fintype ι] [DecidableEq ι] + +lemma product_grouped_by_label (S : Finset τ) (label : τ → ι) (θ : ι → ℝ) : + (∏ t ∈ S, θ (label t)) = ∏ i, θ i ^ (S.filter (fun t => label t = i)).card := by + rw [← prod_fiberwise' S label θ] + simp only [prod_const] + +omit [Fintype ι] in +lemma mem_label_image_iff_count_pos (S : Finset τ) (label : τ → ι) (i : ι) : + i ∈ S.image label ↔ 0 < (S.filter (fun t => label t = i)).card := by + rw [card_pos, filter_nonempty_iff] + exact mem_image + +lemma label_image_product (S : Finset τ) (label : τ → ι) (θ : ι → ℝ) : + (∏ i ∈ S.image label, θ i) = + ∏ i, θ i ^ (if (S.filter (fun t => label t = i)).card = 0 then 0 else 1) := by + have he : (∏ i ∈ S.image label, θ i) = + ∏ i, if i ∈ S.image label then θ i else 1 := by + rw [← prod_filter] + congr 1 + ext i + simp only [mem_filter, mem_univ, true_and] + rw [he] + apply prod_congr rfl + intro i _ + have hi := mem_label_image_iff_count_pos S label i + by_cases hc : (S.filter (fun t => label t = i)).card = 0 + · have hn : i ∉ S.image label := by simpa [hc] using hi + simp [hc, hn] + · have hm : i ∈ S.image label := hi.mpr (Nat.pos_of_ne_zero hc) + simp [hc, hm] + +/-- The modulus atom appears once if there is any lit occurrence; unlit +occurrences retain their individual scalar reciprocals. -/ +lemma designated_weight_exponents (L U : Finset τ) (label : τ → ι) (θ : ι → ℝ) : + (∏ t ∈ U, θ (label t)) * (∏ i ∈ L.image label, θ i) = + ∏ i, θ i ^ litReciprocalExponent + (L.filter (fun t => label t = i)).card (U.filter (fun t => label t = i)).card := by + rw [product_grouped_by_label, label_image_product, ← prod_mul_distrib] + apply prod_congr rfl + intro i _ + rw [← pow_add] + rfl + +omit [Fintype ι] [DecidableEq ι] in +lemma absolute_unlit_coefficient (U : Finset τ) (label : τ → ι) (θ : ι → ℝ) + (hθ : ∀ i, 0 ≤ θ i) : + |(-1 : ℝ) ^ U.card * ∏ t ∈ U, θ (label t)| = ∏ t ∈ U, θ (label t) := by + rw [abs_mul, abs_pow, abs_neg, abs_one, one_pow, one_mul] + exact abs_of_nonneg (prod_nonneg (fun t _ => hθ (label t))) + +/-- Exact baseline extraction for the designated reciprocal coefficient. -/ +theorem designated_reciprocal_extra_bound (L U : Finset τ) (label : τ → ι) + (p : ι → ℝ) (H : ℝ) + (hcount : ∀ i, 2 ≤ (L.filter (fun t => label t = i)).card + + (U.filter (fun t => label t = i)).card) + (hH : 0 < H) (hp : ∀ i, H ≤ p i) : + (∏ t ∈ U, (p (label t))⁻¹) * (∏ i ∈ L.image label, (p i)⁻¹) ≤ + (∏ i, (p i)⁻¹) * H⁻¹ ^ + (∑ i, extraReciprocalExponent (L.filter (fun t => label t = i)).card + (U.filter (fun t => label t = i)).card) := by + rw [designated_weight_exponents L U label (fun i => (p i)⁻¹)] + exact lit_reciprocal_product_bound _ _ p H hcount hH hp + +/-- Including singleton atoms gives exactly one basic reciprocal for every +observed label. Extra powers are still measured only by the nonsingleton +lit and unlit counts; singleton labels have both counts zero. -/ +theorem designated_all_reciprocal_bound (S : Finset ι) (L U : Finset τ) + (label : τ → ι) (p : ι → ℝ) (H : ℝ) + (hzero : ∀ i ∈ S, (L.filter (fun t => label t = i)).card = 0 ∧ + (U.filter (fun t => label t = i)).card = 0) + (hcount : ∀ i ∉ S, 2 ≤ (L.filter (fun t => label t = i)).card + + (U.filter (fun t => label t = i)).card) + (hH : 0 < H) (hp : ∀ i, H ≤ p i) : + (∏ t ∈ U, (p (label t))⁻¹) * (∏ i ∈ L.image label, (p i)⁻¹) * + (∏ i ∈ S, (p i)⁻¹) ≤ + (∏ i, (p i)⁻¹) * H⁻¹ ^ + (∑ i, extraReciprocalExponent (L.filter (fun t => label t = i)).card + (U.filter (fun t => label t = i)).card) := by + let E : ι → ℕ := fun i => extraReciprocalExponent + (L.filter (fun t => label t = i)).card (U.filter (fun t => label t = i)).card + have hs : (∏ i ∈ S, (p i)⁻¹) = + ∏ i, (p i)⁻¹ ^ (if i ∈ S then 1 else 0) := by + calc + _ = ∏ i, if i ∈ S then (p i)⁻¹ else 1 := by + rw [← prod_filter] + simp + _ = _ := by + apply prod_congr rfl + intro i _ + split_ifs <;> simp + have he (i : ι) : litReciprocalExponent + (L.filter (fun t => label t = i)).card (U.filter (fun t => label t = i)).card + + (if i ∈ S then 1 else 0) = E i + 1 := by + by_cases hi : i ∈ S + · rcases hzero i hi with ⟨hl, hu⟩ + simp only [E, hl, hu, ite_eq_left hi, extraReciprocalExponent, litReciprocalExponent] + norm_num + · have hpos := litReciprocalExponent_pos _ _ (hcount i hi) + simp only [hi, ite_false, add_zero] + dsimp [E, extraReciprocalExponent] + omega + have hf : (∏ t ∈ U, (p (label t))⁻¹) * (∏ i ∈ L.image label, (p i)⁻¹) * + (∏ i ∈ S, (p i)⁻¹) = (∏ i, (p i)⁻¹) * ∏ i, (p i)⁻¹ ^ E i := by + rw [designated_weight_exponents L U label (fun i => (p i)⁻¹), hs, + ← prod_mul_distrib, ← prod_mul_distrib] + apply prod_congr rfl + intro i _ + rw [← pow_add, he, pow_succ] + ring + rw [hf, ← prod_pow_eq_pow_sum] + apply mul_le_mul_of_nonneg_left + · apply prod_le_prod₀ + · intro i _ + exact pow_nonneg (inv_nonneg.mpr (hH.trans_le (hp i)).le) _ + · intro i _ + exact pow_le_pow_left₀ (inv_nonneg.mpr (hH.trans_le (hp i)).le) + (inv_anti₀ hH (hp i)) _ + · exact prod_nonneg (fun i _ => inv_nonneg.mpr (hH.trans_le (hp i)).le) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedForwardWindows.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedForwardWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..1670e22d86dc44cc5c4836c5e22f51fd426ce542 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedForwardWindows.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DilatedMRTScale + +namespace OAI + +/-! Positive-origin Fourier windows for the exact dilated sequence. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma OneBounded.mul_argument {f : ℕ → ℂ} (hf : OneBounded f) + (q : ℕ) (hq : 0 < q) : OneBounded (fun n => f (q * n)) := by + intro n hn + exact hf _ (Nat.mul_pos hq hn) + +theorem MRTShortExponentialInput.dilated_forward_windows + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ) (D : ℕ), + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → + (D : ℝ) ≤ Real.exp (C₀ * B ^ (2 : ℕ)) → + ∀ q : ℕ, 0 < q → ∀ᶠ Y : ℕ in atTop, + ∀ b : ℕ → ℂ, Multiplicative b → OneBounded b → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → + ∀ θ : AddCircle (1 : ℝ), + (∑ v ∈ range Y, ‖forwardWindowPolynomial (fun n => b (q * n)) D (v + 1) θ‖) ≤ + C * D * Y * (Real.log B / B ^ (9999 / 10000 : ℝ)) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + obtain ⟨C, hC, hwindow⟩ := hMRT.dilated_window_scale hfnp hf C₀ hC₀ + refine ⟨2 * C, by positivity, ?_⟩ + filter_upwards [hwindow, eventually_ge_atTop 1] with B hB hB1 + intro P D hDlo hDhi q hq + have ht : Tendsto (fun Y : ℕ => Y + 1) atTop atTop := tendsto_add_atTop_nat 1 + filter_upwards [ht.eventually (hB P D hDlo hDhi q hq), + eventually_ge_atTop 1] with Y hY hY1 + intro b hb hbb heq θ + obtain ⟨α, rfl⟩ := QuotientAddGroup.mk_surjective θ + simp only [forwardWindowPolynomial_at_real] + have hs : (∑ v ∈ range Y, ‖shortWindowSum (fun n => b (q * n)) D α (v + 1)‖) ≤ + ∑ v ∈ range (Y + 1), ‖shortWindowSum (fun n => b (q * n)) D α v‖ := by + rw [sum_range_succ'] + exact le_add_of_nonneg_right (norm_nonneg _) + have hYr : ((Y + 1 : ℕ) : ℝ) ≤ 2 * Y := by exact_mod_cast (show Y + 1 ≤ 2 * Y by omega) + have hM := smoothReciprocalProduct_nonneg q.primeFactors + (fun _ hp => Nat.prime_of_mem_primeFactors hp) (1 / 2) (by norm_num) + have hE : 0 ≤ Real.log B / B ^ (9999 / 10000 : ℝ) := + div_nonneg (Real.log_nonneg hB1) (Real.rpow_nonneg (by linarith) _) + calc + _ ≤ _ := hs + _ ≤ C * D * (Y + 1 : ℕ) * (Real.log B / B ^ (9999 / 10000 : ℝ)) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := hY b hb hbb heq α + _ ≤ C * D * (2 * Y) * (Real.log B / B ^ (9999 / 10000 : ℝ)) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by gcongr + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedMRTScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedMRTScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..e823a4caec568c4bec3937246a63fdaa6f80cdc6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedMRTScale.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DilatedShortSums +import OAI.NumberTheory.TwoPoint.Bounds.DilatedWindowParameters +import OAI.NumberTheory.TwoPoint.Bounds.SmoothProductBounds + +namespace OAI + +/-! The fixed-scale short-sum input for actual dilated factors. Its constant +is independent of the dilation and of the finite set of changed primes. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem MRTShortExponentialInput.dilated_window_scale + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ) (D : ℕ), + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → + (D : ℝ) ≤ Real.exp (C₀ * B ^ (2 : ℕ)) → + ∀ q : ℕ, 0 < q → ∀ᶠ Y : ℕ in atTop, + ∀ b : ℕ → ℂ, Multiplicative b → OneBounded b → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → ∀ α : ℝ, + (∑ v ∈ range Y, ‖shortWindowSum (fun n => b (q * n)) D α v‖) ≤ + C * D * Y * (Real.log B / B ^ (9999 / 10000 : ℝ)) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + obtain ⟨C, hC, hwindow⟩ := hMRT.dilated_short_sums hfnp hf + let cE := 2 * (Real.log (C₀ + 1) + 2) + have hcE : 0 < cE := by + have hh : 0 ≤ Real.log (C₀ + 1) := Real.log_nonneg (by linarith) + dsimp [cE] + linarith + let C' := 4 * C * (cE + 1) + 6 + refine ⟨C', by dsimp [C']; positivity, ?_⟩ + filter_upwards [eventually_dilationWindowParameters C₀ hC₀, + eventually_ge_atTop (Real.exp 1)] with B hparams hB + intro P D hDlo hDhi q hq + have hp := hparams D hDlo hDhi + have hBp : 0 < B := (Real.exp_pos 1).trans_le hB + have hlog : 0 < Real.log B := by + have hh : 1 ≤ Real.log B := by + rw [← Real.log_exp 1] + exact Real.log_le_log (Real.exp_pos 1) hB + linarith + let e := Real.log B / B ^ (9999 / 10000 : ℝ) + have he : 0 < e := by dsimp [e]; positivity + have hDpos : 0 < D := hp.cutoff_pos.trans_le hp.cutoff_le + have hDr : (0 : ℝ) < D := by exact_mod_cast hDpos + have hM : 1 ≤ smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := + one_le_smoothReciprocalProduct _ (fun _ hx => Nat.prime_of_mem_primeFactors hx) _ (by norm_num) + filter_upwards [hwindow P q D (dilationCutoff B) hq hp.cutoff_pos hp.cutoff_le + hp.quotient_ten (cE * e) (by positivity) hp.quotient_error e he] with Y hY + intro b hb hbb heq α + have hraw := hY b hb hbb heq α + have hcoefficient : 4 * C * (cE * e + e) + + 2 * (dilationCutoff B : ℝ) ^ (-(1 / 2) : ℝ) ≤ + (4 * C * (cE + 1) + 4) * e := by + have ht : (dilationCutoff B : ℝ) ^ (-(1 / 2) : ℝ) ≤ 2 * e := hp.cutoff_tail + nlinarith + have hK : (dilationCutoff B : ℝ) ≤ 2 * e * D := + (div_le_iff₀ hDr).mp hp.cutoff_relative + have hboundary : (dilationCutoff B : ℝ) * Y ≤ + 2 * D * Y * e * smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + calc + _ ≤ (2 * e * D) * Y := mul_le_mul_of_nonneg_right hK (Nat.cast_nonneg Y) + _ = 2 * D * Y * e := by ring + _ ≤ _ := le_mul_of_one_le_right (by positivity) hM + apply hraw.trans + calc + _ ≤ (D : ℝ) * Y * ((4 * C * (cE + 1) + 4) * e * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ)) + + 2 * D * Y * e * smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + apply add_le_add _ hboundary + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact mul_le_mul_of_nonneg_right hcoefficient (by linarith) + _ = _ := by dsimp [C', e]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedRoughBins.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedRoughBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..36a0034b6a0a57afd5b33f9a3e3bf284c739c18f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedRoughBins.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DilatedRoughRight +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeRoughBins + +namespace OAI + +/-! Actual real bins for the direct dilation estimates, retaining their +single Euler cost for subsequent averaging over padding divisors. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem qualitative_dilated_rough_shifts_real_bins (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ) (M τ : ℝ), 1 < τ → τ < 2 → + Real.exp (B ^ (9999 / 10000 : ℝ)) / τ ≤ M → + M ≤ Real.exp (C₀ * B ^ (2 : ℕ)) → + ∀ q : ℕ, 0 < q → ∀ᶠ Y : ℕ in atTop, + ∀ b g : ℕ → ℂ, Multiplicative b → OneBounded b → OneBounded g → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → + ∀ (Z : Finset ℕ) (c : ℕ → ℂ), + (∀ z ∈ Z, M < (z : ℝ) ∧ (z : ℝ) ≤ τ * M ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + (∀ z ∈ Z, ‖c z‖ ≤ 1) → + ‖weightedRoughShiftAverage (fun n => b (q * n)) (fun n => g (q * n)) Z c h Y‖ ≤ + C * B ^ (-11 / 10 : ℝ) * smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + obtain ⟨C, hC, hrough⟩ := qualitative_dilated_rough_shifts hM hMRT hfnp hf h hh + (C₀ + 1) (by linarith) + refine ⟨C, hC, ?_⟩ + filter_upwards [hrough, eventually_ge_atTop 1] with B hb hB + intro P M τ hτ₁ hτ₂ hMlower hMupper q hq + have hτpos : 0 < τ := zero_lt_one.trans hτ₁ + have hMpos : 0 < M := (div_pos (Real.exp_pos _) hτpos).trans_le hMlower + have hMc : M ≤ (Nat.ceil M : ℝ) := Nat.le_ceil M + have hDlower : (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ Nat.ceil M := by + have ht := (div_le_iff₀ hτpos).mp hMlower + nlinarith only [ht, hτ₂, hMpos, hMc] + have hDupper := ceil_exp_scale_bound (B ^ (2 : ℕ)) C₀ M (by nlinarith) hC₀ hMpos.le hMupper + filter_upwards [hb P (Nat.ceil M) hDlower hDupper q hq] with Y hy + intro b g hbm hbb hgb heq Z c hZ hc + apply hy b g hbm hbb hgb heq Z c _ hc + intro z hz + have hzw := rough_bin_ceil_window M τ hMpos hτ₂ z ⟨(hZ z hz).1, (hZ z hz).2.1⟩ + exact ⟨hzw.1, hzw.2, (hZ z hz).2.2⟩ + +theorem qualitative_dilated_rough_shifts_real_bins_right (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ) (M τ : ℝ), 1 < τ → τ < 2 → + Real.exp (B ^ (9999 / 10000 : ℝ)) / τ ≤ M → + M ≤ Real.exp (C₀ * B ^ (2 : ℕ)) → + ∀ q : ℕ, 0 < q → ∀ᶠ Y : ℕ in atTop, + ∀ b g : ℕ → ℂ, OneBounded b → Multiplicative g → OneBounded g → + (∀ p, Nat.Prime p → p ∉ P → g p = f p) → + ∀ (Z : Finset ℕ) (c : ℕ → ℂ), + (∀ z ∈ Z, M < (z : ℝ) ∧ (z : ℝ) ≤ τ * M ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + (∀ z ∈ Z, ‖c z‖ ≤ 1) → + ‖weightedRoughShiftAverage (fun n => b (q * n)) (fun n => g (q * n)) Z c h Y‖ ≤ + C * B ^ (-11 / 10 : ℝ) * smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + obtain ⟨C, hC, hrough⟩ := qualitative_dilated_rough_shifts_right hM hMRT hfnp hf h hh + (C₀ + 1) (by linarith) + refine ⟨C, hC, ?_⟩ + filter_upwards [hrough, eventually_ge_atTop 1] with B hb hB + intro P M τ hτ₁ hτ₂ hMlower hMupper q hq + have hτpos : 0 < τ := zero_lt_one.trans hτ₁ + have hMpos : 0 < M := (div_pos (Real.exp_pos _) hτpos).trans_le hMlower + have hMc : M ≤ (Nat.ceil M : ℝ) := Nat.le_ceil M + have hDlower : (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ Nat.ceil M := by + have ht := (div_le_iff₀ hτpos).mp hMlower + nlinarith only [ht, hτ₂, hMpos, hMc] + have hDupper := ceil_exp_scale_bound (B ^ (2 : ℕ)) C₀ M (by nlinarith) hC₀ hMpos.le hMupper + filter_upwards [hb P (Nat.ceil M) hDlower hDupper q hq] with Y hy + intro b g hbb hgm hgb heq Z c hZ hc + apply hy b g hbb hgm hgb heq Z c _ hc + intro z hz + have hzw := rough_bin_ceil_window M τ hMpos hτ₂ z ⟨(hZ z hz).1, (hZ z hz).2.1⟩ + exact ⟨hzw.1, hzw.2, (hZ z hz).2.2⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedRoughRight.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedRoughRight.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a1295043ce4bb535a6b5874fac02967befd8734 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedRoughRight.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DilatedRoughShifts +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeStrongRight + +namespace OAI + +/-! The same dilated rough-shift estimate when the original second factor +is uniformly nonpretentious. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem qualitative_dilated_rough_shifts_right (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ) (D : ℕ), + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → + (D : ℝ) ≤ Real.exp (C₀ * B ^ (2 : ℕ)) → + ∀ q : ℕ, 0 < q → ∀ᶠ Y : ℕ in atTop, + ∀ b g : ℕ → ℂ, OneBounded b → Multiplicative g → OneBounded g → + (∀ p, Nat.Prime p → p ∉ P → g p = f p) → + ∀ (Z : Finset ℕ) (c : ℕ → ℂ), + (∀ z ∈ Z, D ≤ z ∧ z < D + D ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + (∀ z ∈ Z, ‖c z‖ ≤ 1) → + ‖weightedRoughShiftAverage (fun n => b (q * n)) (fun n => g (q * n)) Z c h Y‖ ≤ + C * B ^ (-11 / 10 : ℝ) * smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + obtain ⟨U, V, hU, hV, hfourier⟩ := hM.qualitative_rough_fourier + obtain ⟨K, hK, hwindows⟩ := hMRT.dilated_forward_windows hfnp hf + (C₀ + (2 * (h : ℝ) + 1)) (by + have ht : (0 : ℝ) ≤ h := Nat.cast_nonneg h + linarith only [hC₀, ht]) + let A := 2 + (2 * (h : ℝ) + 1) + let T := (2 * (h : ℝ) + 1) * U * V * K + refine ⟨A + T, by dsimp [A, T]; positivity, ?_⟩ + filter_upwards [hfourier, hwindows, eventually_strong_qualitative_frequency_gap, + eventually_qualitative_interval_lower, eventually_ge_atTop (Real.exp 1)] with + B hfour hwin hgap hlower hB + intro P D hDlower hDupper q hq + have hDten : 10 ≤ D := hlower D hDlower + have hDpos : 0 < D := by omega + have hB1 : 1 ≤ B := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hB + have hBpos : 0 < B := zero_lt_one.trans_le hB1 + have hlog : 0 ≤ Real.log B := Real.log_nonneg hB1 + have hη : 0 < B ^ (-11 / 10 : ℝ) := Real.rpow_pos_of_pos hBpos _ + let Q := (2 * h + 1) * D + have hDQ : D ≤ Q := Nat.le_mul_of_pos_left D (by omega) + have hQlower : (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ Q := + hDlower.trans (by exact_mod_cast hDQ) + have hQupper : (Q : ℝ) ≤ Real.exp ((C₀ + (2 * (h : ℝ) + 1)) * B ^ (2 : ℕ)) := + long_window_exp_bound (B ^ (2 : ℕ)) C₀ D h (by nlinarith) hDupper + let M := smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) + have hM1 : 1 ≤ M := one_le_smoothReciprocalProduct _ + (fun _ hp => Nat.prime_of_mem_primeFactors hp) (1 / 2) (by norm_num) + have hM0 : 0 ≤ M := by linarith + filter_upwards [hwin P Q hQlower hQupper q hq, + eventually_fixed_interval_endpoint D _ hη] with Y hY hend + intro b g hbb hg hgb heq Z c hZ hc + have hfourZ := hfour D h hDlower hh Z c hZ hc + have hZinterval : ∀ z ∈ Z, D ≤ z ∧ z < D + D := + fun z hz => ⟨(hZ z hz).1, (hZ z hz).2.1⟩ + have hZend : ∀ z ∈ Z, z ≤ 2 * D := by + intro z hz + have ht := (hZ z hz).2.1 + omega + have hr := weighted_rough_shift_parameter_bound_right + (fun n => b (q * n)) (fun n => g (q * n)) + (hbb.mul_argument q hq) (hgb.mul_argument q hq) Z c D h Y hDpos hend.1 hZend + (Real.log B / B ^ (9999 / 10000 : ℝ)) (B ^ (-11 / 10 : ℝ)) U V (K * M) + (by positivity) hη hU.le hV.le (mul_nonneg hK.le hM0) + (rough_coefficient_mass_le_one Z c D hDpos hZinterval hc) + hend.2 hgap hfourZ.1 hfourZ.2 (fun θ => by + simp_rw [backwardWindowPolynomial_eq_forward_neg] + convert hY g hg hgb heq (-θ) using 1 + dsimp [M, Q] + push_cast + ring) + calc + _ ≤ (A + T * M) * B ^ (-11 / 10 : ℝ) := hr.trans_eq (by dsimp [A, T]; ring) + _ ≤ (A + T) * B ^ (-11 / 10 : ℝ) * M := by + have hA : 0 ≤ A := by dsimp [A]; positivity + have hhA := mul_le_mul_of_nonneg_left hM1 hA + nlinarith [mul_nonneg (sub_nonneg.mpr hhA) hη.le] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedRoughShifts.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedRoughShifts.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ad4af7622e48aad58aae045f5df457e32cb3ea8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedRoughShifts.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DilatedForwardWindows +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeStrongRoughShifts + +namespace OAI + +/-! Rough-shift cancellation for the actual factors b(qn), g(qn). +The dilation is unrestricted and its sole cost is the averaged Euler factor. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem qualitative_dilated_rough_shifts (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ) (D : ℕ), + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → + (D : ℝ) ≤ Real.exp (C₀ * B ^ (2 : ℕ)) → + ∀ q : ℕ, 0 < q → ∀ᶠ Y : ℕ in atTop, + ∀ b g : ℕ → ℂ, Multiplicative b → OneBounded b → OneBounded g → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → + ∀ (Z : Finset ℕ) (c : ℕ → ℂ), + (∀ z ∈ Z, D ≤ z ∧ z < D + D ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + (∀ z ∈ Z, ‖c z‖ ≤ 1) → + ‖weightedRoughShiftAverage (fun n => b (q * n)) (fun n => g (q * n)) Z c h Y‖ ≤ + C * B ^ (-11 / 10 : ℝ) * smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + obtain ⟨U, V, hU, hV, hfourier⟩ := hM.qualitative_rough_fourier + obtain ⟨K, hK, hwindows⟩ := hMRT.dilated_forward_windows hfnp hf C₀ hC₀ + let A := 2 + (2 * (h : ℝ) + 1) + let T := (2 * (h : ℝ) + 1) * U * V * K + refine ⟨A + T, by dsimp [A, T]; positivity, ?_⟩ + filter_upwards [hfourier, hwindows, eventually_strong_qualitative_frequency_gap, + eventually_qualitative_interval_lower, eventually_ge_atTop (Real.exp 1)] with + B hfour hwin hgap hlower hB + intro P D hDlower hDupper q hq + have hDten : 10 ≤ D := hlower D hDlower + have hDpos : 0 < D := by omega + have hBpos : 0 < B := (Real.exp_pos 1).trans_le hB + have hB1 : 1 ≤ B := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hB + have hlog : 0 ≤ Real.log B := Real.log_nonneg hB1 + have hη : 0 < B ^ (-11 / 10 : ℝ) := Real.rpow_pos_of_pos hBpos _ + let M := smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) + have hM1 : 1 ≤ M := one_le_smoothReciprocalProduct _ + (fun _ hp => Nat.prime_of_mem_primeFactors hp) (1 / 2) (by norm_num) + have hM0 : 0 ≤ M := by linarith + filter_upwards [hwin P D hDlower hDupper q hq, + eventually_fixed_interval_endpoint D _ hη] with Y hY hend + intro b g hb hbb hg heq Z c hZ hc + have hfourZ := hfour D h hDlower hh Z c hZ hc + have hZinterval : ∀ z ∈ Z, D ≤ z ∧ z < D + D := + fun z hz => ⟨(hZ z hz).1, (hZ z hz).2.1⟩ + have hZend : ∀ z ∈ Z, z ≤ 2 * D := by + intro z hz + have ht := (hZ z hz).2.1 + omega + have hr := weighted_rough_shift_parameter_bound (fun n => b (q * n)) (fun n => g (q * n)) + (hbb.mul_argument q hq) (hg.mul_argument q hq) Z c D h Y hDpos hend.1 hZend + (Real.log B / B ^ (9999 / 10000 : ℝ)) (B ^ (-11 / 10 : ℝ)) U V (K * M) + (by positivity) hη hU.le hV.le (mul_nonneg hK.le hM0) + (rough_coefficient_mass_le_one Z c D hDpos hZinterval hc) + hend.2 hgap hfourZ.1 hfourZ.2 (fun θ => by + convert hY b hb hbb heq θ using 1 + dsimp [M] + ring) + calc + _ ≤ (A + T * M) * B ^ (-11 / 10 : ℝ) := hr.trans_eq (by dsimp [A, T]; ring) + _ ≤ (A + T) * B ^ (-11 / 10 : ℝ) * M := by + have hA : 0 ≤ A := by dsimp [A]; positivity + have hhA := mul_le_mul_of_nonneg_left hM1 hA + nlinarith [mul_nonneg (sub_nonneg.mpr hhA) hη.le] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedShortSums.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedShortSums.lean new file mode 100644 index 0000000000000000000000000000000000000000..1068be6d28c7d044a17aa242383020bfd29867c5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedShortSums.lean @@ -0,0 +1,49 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DilationMRT +import OAI.NumberTheory.TwoPoint.Bounds.SmoothWindowBound + +namespace OAI + +/-! The published MRT input applied to the actual sequence f(qn), using +only the exact smooth-divisor expansion. All dilation dependence is exposed +through one Euler product and an elementary finite truncation error. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem MRTShortExponentialInput.dilated_short_sums + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) : + ∃ C : ℝ, 0 < C ∧ ∀ (P : Finset ℕ) (q D K : ℕ), + 0 < q → 0 < K → K ≤ D → + (∀ a ∈ Icc 1 K, 10 ≤ D / a + 1) → + ∀ E : ℝ, 0 ≤ E → + (∀ a ∈ Icc 1 K, + Real.log (Real.log (D / a + 1 : ℕ)) / Real.log (D / a + 1 : ℕ) ≤ E) → + ∀ ε : ℝ, 0 < ε → ∀ᶠ Y : ℕ in atTop, + ∀ b : ℕ → ℂ, Multiplicative b → OneBounded b → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → ∀ α : ℝ, + (∑ v ∈ range Y, ‖shortWindowSum (fun n => b (q * n)) D α v‖) ≤ + (D : ℝ) * Y * + ((4 * C * (E + ε) + 2 * (K : ℝ) ^ (-(1 / 2) : ℝ)) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ)) + K * Y := by + obtain ⟨C, hC, hquotient⟩ := hMRT.modified_quotient_windows hfnp hf + refine ⟨C, hC, ?_⟩ + intro P q D K hq hK hKD hlength E hE hlog ε hε + filter_upwards [hquotient P q D K hq hlength ε hε, + eventually_ge_atTop D] with Y hY hDY + intro b hb hbb heq α + have hbase : ∀ a ∈ Icc 1 K, ∀ β : ℝ, + (∑ m ∈ range (Y / a + 1), + ‖shortWindowSum (coprimeRestriction q b) (D / a + 1) β m‖) ≤ + C * (D / a + 1 : ℕ) * (Y / a + 1 : ℕ) * (E + ε) := by + intro a ha β + exact (hY b hb hbb heq a ha β).trans + (mul_le_mul_of_nonneg_left (add_le_add (hlog a ha) le_rfl) (by positivity)) + exact (smooth_dilation_window_bound hb hbb q K D Y hq hK hKD hDY C (E + ε) + hC.le (by positivity) hbase α).trans_eq (by ring) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedWindowParameters.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedWindowParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e9ede4167e931762398c8a766d33585c225af99 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedWindowParameters.lean @@ -0,0 +1,136 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DilatedWindowScale + +namespace OAI + +/-! Uniform parameter bounds for the exact smooth-divisor MRT reduction. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma dilation_quotient_log_upper (B C₀ : ℝ) (D a : ℕ) + (hB : 1 ≤ B) (hDpos : 0 < D) + (hD : (D : ℝ) ≤ Real.exp (C₀ * B ^ (2 : ℕ))) : + Real.log (D / a + 1 : ℕ) ≤ (C₀ + 1) * B ^ (2 : ℕ) := by + have hM : (0 : ℝ) < (D / a + 1 : ℕ) := by positivity + have hMbound : (D / a + 1 : ℕ) ≤ 2 * (D : ℝ) := by + have hd : D / a + 1 ≤ 2 * D := by have hh := Nat.div_le_self D a; omega + exact_mod_cast hd + have hBsq : 1 ≤ B ^ (2 : ℕ) := one_le_pow₀ hB + have hexp : 2 ≤ Real.exp (B ^ (2 : ℕ)) := by + have hh := Real.add_one_le_exp (B ^ (2 : ℕ)); linarith + have hlast : (2 : ℝ) * Real.exp (C₀ * B ^ (2 : ℕ)) ≤ + Real.exp ((C₀ + 1) * B ^ (2 : ℕ)) := by + calc + _ ≤ Real.exp (B ^ (2 : ℕ)) * Real.exp (C₀ * B ^ (2 : ℕ)) := + mul_le_mul_of_nonneg_right hexp (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + exact (Real.log_le_log hM + (hMbound.trans ((mul_le_mul_of_nonneg_left hD (by norm_num)).trans hlast))).trans_eq + (Real.log_exp _) + +lemma dilation_cutoff_error_bounds (B : ℝ) (D : ℕ) + (hB : 0 < B) (hlarge : 4 * Real.log 2 ≤ B ^ (9999 / 10000 : ℝ)) + (hD : (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D) : + (dilationCutoff B : ℝ) / D ≤ 2 * Real.exp (-B ^ (9999 / 10000 : ℝ) / 8) ∧ + (dilationCutoff B : ℝ) ^ (-(1 / 2) : ℝ) ≤ + 2 * Real.exp (-B ^ (9999 / 10000 : ℝ) / 8) := by + let t := B ^ (9999 / 10000 : ℝ) + have ht : 0 < t := Real.rpow_pos_of_pos hB _ + have hk := dilationCutoff_bounds B hB hlarge + have hkp : (0 : ℝ) < dilationCutoff B := by exact_mod_cast hk.1 + have hratio : (dilationCutoff B : ℝ) / D ≤ 2 * Real.exp (-3 * t / 4) := by + calc + _ ≤ Real.exp (t / 4) / ((1 / 2 : ℝ) * Real.exp t) := + div_le_div₀ (Real.exp_pos _).le hk.2.2 (by positivity) hD + _ = _ := by + rw [show -3 * t / 4 = t / 4 - t by ring, Real.exp_sub] + field_simp + have hexp : Real.exp (-3 * t / 4) ≤ Real.exp (-t / 8) := + Real.exp_le_exp.mpr (by linarith) + refine ⟨hratio.trans (mul_le_mul_of_nonneg_left hexp (by norm_num)), ?_⟩ + have hlog : t / 4 - Real.log 2 ≤ Real.log (dilationCutoff B : ℝ) := by + have hh := Real.log_le_log (by positivity : (0 : ℝ) < Real.exp (t / 4) / 2) hk.2.1 + rw [Real.log_div (Real.exp_ne_zero _) (by norm_num), Real.log_exp] at hh + exact hh + have hlog2 : 0 ≤ Real.log (2 : ℝ) := Real.log_nonneg (by norm_num) + rw [Real.rpow_def_of_pos hkp] + calc + _ ≤ Real.exp (-t / 8 + Real.log 2) := Real.exp_le_exp.mpr (by nlinarith) + _ = _ := by rw [Real.exp_add, Real.exp_log (by norm_num : (0 : ℝ) < 2)]; ring + +structure DilationWindowParameters (B C₀ : ℝ) (D : ℕ) : Prop where + cutoff_pos : 0 < dilationCutoff B + cutoff_le : dilationCutoff B ≤ D + quotient_ten : ∀ a ∈ Icc 1 (dilationCutoff B), 10 ≤ D / a + 1 + quotient_error : ∀ a ∈ Icc 1 (dilationCutoff B), + Real.log (Real.log (D / a + 1 : ℕ)) / Real.log (D / a + 1 : ℕ) ≤ + (2 * (Real.log (C₀ + 1) + 2)) * + (Real.log B / B ^ (9999 / 10000 : ℝ)) + cutoff_relative : (dilationCutoff B : ℝ) / D ≤ + 2 * (Real.log B / B ^ (9999 / 10000 : ℝ)) + cutoff_tail : (dilationCutoff B : ℝ) ^ (-(1 / 2) : ℝ) ≤ + 2 * (Real.log B / B ^ (9999 / 10000 : ℝ)) + +theorem eventually_dilationWindowParameters (C₀ : ℝ) (hC : 1 ≤ C₀) : + ∀ᶠ B : ℝ in atTop, ∀ D : ℕ, + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → + (D : ℝ) ≤ Real.exp (C₀ * B ^ (2 : ℕ)) → + DilationWindowParameters B C₀ D := by + have htend := tendsto_rpow_atTop (show 0 < (9999 / 10000 : ℝ) by norm_num) + have hsmall := htend.eventually + ((isLittleO_exp_neg_mul_rpow_atTop (show 0 < (1 / 8 : ℝ) by norm_num) (-1)).bound + (show 0 < (1 : ℝ) by norm_num)) + filter_upwards [eventually_ge_atTop (Real.exp 1), + htend.eventually (eventually_ge_atTop (4 * Real.log 2)), + htend.eventually (eventually_ge_atTop (2 * Real.log 10)), hsmall] with + B hB hlarge hten hsmallB + intro D hD hDupper + have hB1 : 1 ≤ B := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hB + have hBp : 0 < B := zero_lt_one.trans_le hB1 + have ht : 0 < B ^ (9999 / 10000 : ℝ) := Real.rpow_pos_of_pos hBp _ + have hlogB : 1 ≤ Real.log B := by + rw [← Real.log_exp 1] + exact Real.log_le_log (Real.exp_pos 1) hB + have hlog2 : 0 ≤ Real.log (2 : ℝ) := Real.log_nonneg (by norm_num) + have hK := dilationCutoff_bounds B hBp hlarge + have hDpos : 0 < D := by + have hh : (0 : ℝ) < D := lt_of_lt_of_le (by positivity) hD + exact_mod_cast hh + have hKD : dilationCutoff B ≤ D := by + have he : Real.exp (B ^ (9999 / 10000 : ℝ) / 4) ≤ + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) := by + apply (Real.log_le_log_iff (Real.exp_pos _) (by positivity)).mp + rw [Real.log_exp, Real.log_mul (by norm_num : (1 / 2 : ℝ) ≠ 0) + (Real.exp_ne_zero _), one_div, Real.log_inv, Real.log_exp] + linarith + exact_mod_cast hK.2.2.trans (he.trans hD) + have hsmall' : Real.exp (-B ^ (9999 / 10000 : ℝ) / 8) ≤ + Real.log B / B ^ (9999 / 10000 : ℝ) := by + rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), Real.norm_eq_abs, + abs_of_pos (Real.rpow_pos_of_pos ht _), one_mul, Real.rpow_neg_one] at hsmallB + calc + _ = Real.exp (-(1 / 8 : ℝ) * B ^ (9999 / 10000 : ℝ)) := by congr 1; ring + _ ≤ (B ^ (9999 / 10000 : ℝ))⁻¹ := hsmallB + _ ≤ _ := by rw [div_eq_mul_inv]; exact le_mul_of_one_le_left (by positivity) hlogB + have herr := dilation_cutoff_error_bounds B D hBp hlarge hD + refine ⟨hK.1, hKD, ?_, ?_, + herr.1.trans (mul_le_mul_of_nonneg_left hsmall' (by norm_num)), + herr.2.trans (mul_le_mul_of_nonneg_left hsmall' (by norm_num))⟩ + · intro a ha + have hm := dilation_quotient_log_lower B D a hBp hlarge hD + (mem_Icc.mp ha).1 (mem_Icc.mp ha).2 + have hex : (10 : ℝ) ≤ (D / a + 1 : ℕ) := by + rw [← Real.exp_log (by norm_num : (0 : ℝ) < 10)] + apply (Real.exp_le_exp.mpr (show Real.log 10 ≤ Real.log (D / a + 1 : ℕ) by linarith)).trans_eq + exact Real.exp_log (by positivity) + exact_mod_cast hex + · intro a ha + exact quotient_log_error_bound B C₀ (D / a + 1) hB hC + (dilation_quotient_log_lower B D a hBp hlarge hD (mem_Icc.mp ha).1 (mem_Icc.mp ha).2) + (dilation_quotient_log_upper B C₀ D a hB1 hDpos hDupper) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedWindowScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedWindowScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..0884ad60873b8a113b4ac8b6aaeeffd91a8ced17 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedWindowScale.lean @@ -0,0 +1,97 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeSquareWindows +import OAI.NumberTheory.TwoPoint.Bounds.SmoothWindowBound +import Mathlib.Algebra.Order.Floor.Semifield + +namespace OAI + +/-! The smooth-divisor truncation is far below the original window length. +All surviving quotient windows retain a fixed positive fraction of its +logarithmic length. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def dilationCutoff (B : ℝ) : ℕ := + ⌊Real.exp (B ^ (9999 / 10000 : ℝ) / 4)⌋₊ + +lemma quotient_log_error_bound (B C₀ : ℝ) (M : ℕ) + (hB : Real.exp 1 ≤ B) (hC : 1 ≤ C₀) + (hlo : B ^ (9999 / 10000 : ℝ) / 2 ≤ Real.log (M : ℝ)) + (hhi : Real.log (M : ℝ) ≤ (C₀ + 1) * B ^ (2 : ℕ)) : + Real.log (Real.log (M : ℝ)) / Real.log M ≤ + (2 * (Real.log (C₀ + 1) + 2)) * + (Real.log B / B ^ (9999 / 10000 : ℝ)) := by + have hB1 : 1 ≤ B := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hB + have hBp : 0 < B := zero_lt_one.trans_le hB1 + have hlogB : 1 ≤ Real.log B := by + rw [← Real.log_exp 1] + exact Real.log_le_log (Real.exp_pos 1) hB + have hCpos : 0 < C₀ + 1 := by linarith + have hClog : 0 ≤ Real.log (C₀ + 1) := Real.log_nonneg (by linarith) + have hA : 0 < B ^ (9999 / 10000 : ℝ) := Real.rpow_pos_of_pos hBp _ + have hM : 0 < Real.log (M : ℝ) := lt_of_lt_of_le (by positivity) hlo + have hnum : Real.log (Real.log (M : ℝ)) ≤ + (Real.log (C₀ + 1) + 2) * Real.log B := by + have hh := Real.log_le_log hM hhi + rw [Real.log_mul hCpos.ne' (pow_ne_zero 2 hBp.ne'), Real.log_pow] at hh + norm_num only [Nat.cast_ofNat] at hh + nlinarith [mul_nonneg hClog (sub_nonneg.mpr hlogB)] + calc + _ ≤ ((Real.log (C₀ + 1) + 2) * Real.log B) / Real.log M := + div_le_div_of_nonneg_right hnum hM.le + _ ≤ ((Real.log (C₀ + 1) + 2) * Real.log B) / + (B ^ (9999 / 10000 : ℝ) / 2) := + div_le_div_of_nonneg_left (by positivity) (by positivity) hlo + _ = _ := by ring + +lemma dilationCutoff_bounds (B : ℝ) + (_hB : 0 < B) (hlarge : 4 * Real.log 2 ≤ B ^ (9999 / 10000 : ℝ)) : + 0 < dilationCutoff B ∧ + Real.exp (B ^ (9999 / 10000 : ℝ) / 4) / 2 ≤ dilationCutoff B ∧ + (dilationCutoff B : ℝ) ≤ Real.exp (B ^ (9999 / 10000 : ℝ) / 4) := by + have he : 2 ≤ Real.exp (B ^ (9999 / 10000 : ℝ) / 4) := by + rw [← Real.exp_log (by norm_num : (0 : ℝ) < 2)] + exact Real.exp_le_exp.mpr (by linarith) + have hlo := Nat.lt_floor_add_one (Real.exp (B ^ (9999 / 10000 : ℝ) / 4)) + have hhi := Nat.floor_le (le_of_lt (Real.exp_pos (B ^ (9999 / 10000 : ℝ) / 4))) + change Real.exp (B ^ (9999 / 10000 : ℝ) / 4) < (dilationCutoff B : ℝ) + 1 at hlo + change (dilationCutoff B : ℝ) ≤ _ at hhi + refine ⟨?_, by linarith, hhi⟩ + have hh : (0 : ℝ) < dilationCutoff B := by linarith + exact_mod_cast hh + +lemma dilation_quotient_log_lower (B : ℝ) (D a : ℕ) + (hB : 0 < B) (hlarge : 4 * Real.log 2 ≤ B ^ (9999 / 10000 : ℝ)) + (hD : (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D) + (ha : 0 < a) (haK : a ≤ dilationCutoff B) : + B ^ (9999 / 10000 : ℝ) / 2 ≤ Real.log (D / a + 1 : ℕ) := by + let t := B ^ (9999 / 10000 : ℝ) + have hap : (0 : ℝ) < a := by exact_mod_cast ha + have haKr : (a : ℝ) ≤ dilationCutoff B := by exact_mod_cast haK + have haexp : (a : ℝ) ≤ Real.exp (t / 4) := + haKr.trans (dilationCutoff_bounds B hB hlarge).2.2 + have hr : (1 / 2 : ℝ) * Real.exp (3 * t / 4) ≤ (D : ℝ) / a := by + calc + _ = ((1 / 2 : ℝ) * Real.exp t) / Real.exp (t / 4) := by + calc + _ = (1 / 2 : ℝ) * Real.exp (t - t / 4) := by congr 2; ring + _ = (1 / 2 : ℝ) * (Real.exp t / Real.exp (t / 4)) := by rw [Real.exp_sub] + _ = _ := by ring + _ ≤ (D : ℝ) / a := div_le_div₀ (by positivity) hD hap haexp + have hfloor : (D : ℝ) / a < (D / a + 1 : ℕ) := by + have hh := Nat.lt_floor_add_one ((D : ℝ) / a) + simpa only [Nat.floor_div_natCast, Nat.floor_natCast, Nat.cast_add, Nat.cast_one] using hh + have hM : (0 : ℝ) < (D / a + 1 : ℕ) := by positivity + have hh := Real.log_le_log (by positivity : (0 : ℝ) < + (1 / 2 : ℝ) * Real.exp (3 * t / 4)) (hr.trans hfloor.le) + rw [Real.log_mul (by norm_num : (1 / 2 : ℝ) ≠ 0) (Real.exp_ne_zero _), + Real.log_exp, one_div, Real.log_inv] at hh + change t / 2 ≤ _ + change 4 * Real.log 2 ≤ t at hlarge + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedWindows.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..0cf5c467ccba99cf8049b4f544b6a8fe53be72fd --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilatedWindows.lean @@ -0,0 +1,132 @@ +import OAI.NumberTheory.TwoPoint.Bounds.TruncatedDilation +import OAI.NumberTheory.TwoPoint.Bounds.WindowPolynomialBounds + +namespace OAI + +/-! Exact short-window reindexing for a sequence supported on multiples +of a fixed integer. Only one endpoint term is lost to a fixed window length. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def dilationSequence (a : ℕ) (f : ℕ → ℂ) (n : ℕ) : ℂ := + if a ∣ n then f (n / a) else 0 + +lemma additiveCharacter_nat_mul (α : ℝ) (a m : ℕ) : + additiveCharacter α (a * m) = additiveCharacter (a * α) m := by + unfold additiveCharacter + congr 1 + push_cast + ring + +lemma shortExponentialSum_dilation (f : ℕ → ℂ) (a D v : ℕ) + (ha : 0 < a) (α : ℝ) : + shortExponentialSum (dilationSequence a f) D α v = + shortExponentialSum f ((v + D) / a - v / a) (a * α) ((v / a : ℕ) : ℝ) := by + have hle : v / a ≤ (v + D) / a := Nat.div_le_div_right (Nat.le_add_right _ _) + rw [shortExponentialSum_at_nat, shortExponentialSum_at_nat, + Nat.add_sub_of_le hle] + have hleft : (∑ n ∈ Icc (v + 1) (v + D), + dilationSequence a f n * additiveCharacter α n) = + ∑ n ∈ (Icc (v + 1) (v + D)).filter (fun n => a ∣ n), + f (n / a) * additiveCharacter α n := by + rw [sum_filter] + apply sum_congr rfl + intro n _ + unfold dilationSequence + split_ifs <;> simp + rw [hleft] + symm + apply sum_bij (fun m _ => a * m) + · intro m hm + obtain ⟨hm0, hm1⟩ := mem_Icc.mp hm + apply mem_filter.mpr + refine ⟨mem_Icc.mpr ⟨?_, ?_⟩, dvd_mul_right a m⟩ + · have ht : v < a * m := by + have hh := (Nat.div_lt_iff_lt_mul ha).mp (show v / a < m by omega) + simpa only [Nat.mul_comm] using hh + omega + · have hh := (Nat.le_div_iff_mul_le ha).mp hm1 + simpa only [Nat.mul_comm] using hh + · intro m _ n _ he + exact Nat.eq_of_mul_eq_mul_left ha he + · intro n hn + obtain ⟨hnI, hd⟩ := mem_filter.mp hn + obtain ⟨hn0, hn1⟩ := mem_Icc.mp hnI + refine ⟨n / a, mem_Icc.mpr ⟨?_, Nat.div_le_div_right hn1⟩, + Nat.mul_div_cancel' hd⟩ + have he : v < a * (n / a) := by rw [Nat.mul_div_cancel' hd]; omega + have hh : v / a < n / a := (Nat.div_lt_iff_lt_mul ha).mpr (by + simpa only [Nat.mul_comm] using he) + omega + · intro m _ + rw [Nat.mul_div_cancel_left _ ha, additiveCharacter_nat_mul] + +lemma quotient_window_length (a D v : ℕ) (_ha : 0 < a) : + (v + D) / a - v / a = D / a ∨ (v + D) / a - v / a = D / a + 1 := by + have hlo : v / a + D / a ≤ (v + D) / a := Nat.div_add_div_le_add_div + have hhi := Nat.add_div_le_div_add_div_add_one v D a + generalize (v + D) / a = t at * + generalize v / a = u at * + generalize D / a = w at * + omega + +lemma norm_shortWindowSum_le_succ (f : ℕ → ℂ) (hf : OneBounded f) + (D v : ℕ) (α : ℝ) : + ‖shortWindowSum f D α v‖ ≤ ‖shortWindowSum f (D + 1) α v‖ + 1 := by + have he : shortWindowSum f (D + 1) α v = shortWindowSum f D α v + + f (v + D + 1) * additiveCharacter α (D + 1) := by + simp only [shortWindowSum, sum_range_succ] + have hn : ‖f (v + D + 1) * additiveCharacter α (D + 1)‖ ≤ 1 := by + rw [norm_mul, norm_additiveCharacter, mul_one] + exact hf _ (by omega) + have ht := norm_sub_le (shortWindowSum f (D + 1) α v) + (f (v + D + 1) * additiveCharacter α (D + 1)) + have ht' : ‖shortWindowSum f D α v‖ ≤ + ‖shortWindowSum f (D + 1) α v‖ + + ‖f (v + D + 1) * additiveCharacter α (D + 1)‖ := by + simpa only [he, add_sub_cancel_right] using ht + linarith + +lemma norm_shortExponentialSum_dilation_le (f : ℕ → ℂ) (hf : OneBounded f) + (a D v : ℕ) (ha : 0 < a) (α : ℝ) : + ‖shortExponentialSum (dilationSequence a f) D α v‖ ≤ + ‖shortWindowSum f (D / a + 1) (a * α) (v / a)‖ + 1 := by + rw [shortExponentialSum_dilation f a D v ha α, + norm_shortExponentialSum_eq_window] + rcases quotient_window_length a D v ha with he | he + · rw [he] + exact norm_shortWindowSum_le_succ f hf _ _ _ + · rw [he] + exact le_add_of_nonneg_right zero_le_one + +lemma quotient_sample_sum_le (F : ℕ → ℝ) (hF : ∀ n, 0 ≤ F n) + (a Y : ℕ) (ha : 0 < a) : + (∑ v ∈ range Y, F (v / a)) ≤ + (a : ℝ) * ∑ m ∈ range (Y / a + 1), F m := by + have hb : (∑ v ∈ range Y, F (v / a)) ≤ + ∑ x ∈ range (Y / a + 1) ×ˢ range a, F x.1 := by + apply sum_le_sum_of_injOn (fun v => (v / a, v % a)) + · intro v _ w _ he + have h1 := congrArg Prod.fst he + have h2 := congrArg Prod.snd he + nlinarith [Nat.div_add_mod v a, Nat.div_add_mod w a] + · intro x hx + obtain ⟨v, hv, rfl⟩ := mem_image.mp hx + exact mem_product.mpr ⟨mem_range.mpr (by + have hh : v / a ≤ Y / a := Nat.div_le_div_right (Nat.le_of_lt (mem_range.mp hv)) + exact Nat.lt_succ_of_le hh), + mem_range.mpr (Nat.mod_lt _ ha)⟩ + · intro v _ + exact le_rfl + · intro x _ _ + exact hF x.1 + apply hb.trans_eq + rw [sum_product] + simp only [sum_const, card_range, nsmul_eq_mul, ← mul_sum] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/Dilation.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/Dilation.lean new file mode 100644 index 0000000000000000000000000000000000000000..1eb55cc048014a0065cf406aa799155d2bb0e177 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/Dilation.lean @@ -0,0 +1,153 @@ +import OAI.NumberTheory.TwoPoint.Bounds.LocalExpansion + +namespace OAI + +/-! +# Finite multiplicative expansion of a dilation + +This is the arithmetic content of manuscript Lemma `lem:affine-dilation`. +The equality is asserted for positive arguments, the domain relevant to +ordinary multiplicative functions. No complete multiplicativity is used. +-/ + +open scoped BigOperators + +namespace TwoPointCorrelations + +/-- Extend `f(m/a)` by zero away from multiples of `a`. -/ +noncomputable def dilate (a : ℕ) (f : ℕ → ℂ) (m : ℕ) : ℂ := + if a ∣ m then f (m / a) else 0 + +noncomputable def dilationLocal (a : ℕ) (f : ℕ → ℂ) (p k : ℕ) : ℂ := + if k < a.factorization p then 0 else f (p ^ (k - a.factorization p)) + +noncomputable def dilationB (a : ℕ) (f : ℕ → ℂ) (p k : ℕ) : ℂ := + if k = 0 then 1 else dilationLocal a f p k + +noncomputable def dilationC (_a : ℕ) (_f : ℕ → ℂ) (_p k : ℕ) : ℂ := + if k = 0 then 1 else 0 + +noncomputable def dilationComponent (a : ℕ) (f : ℕ → ℂ) (E : Finset ℕ) : ℕ → ℂ := + localComponent f (dilationB a f) (dilationC a f) a.primeFactors E + +theorem dilationLocal_eq_sub (a : ℕ) (f : ℕ → ℂ) {p : ℕ} + (hp : p ∈ a.primeFactors) (k : ℕ) : + dilationLocal a f p k = dilationB a f p k - dilationC a f p k := by + have hpos : 0 < a.factorization p := by + exact Nat.pos_of_ne_zero (Finsupp.mem_support_iff.mp hp) + by_cases hk : k = 0 + · subst k + simp [dilationLocal, dilationB, dilationC, hpos] + · simp [dilationB, dilationC, hk] + +theorem dilate_eq_local_product (a : ℕ) (f : ℕ → ℂ) + (ha : 0 < a) (hf : Multiplicative f) (h1 : f 1 = 1) + {n : ℕ} (hn : 0 < n) : + dilate a f n = + (∏ p ∈ a.primeFactors, dilationLocal a f p (n.factorization p)) * + ∏ p ∈ n.primeFactors \ a.primeFactors, f (p ^ n.factorization p) := by + classical + by_cases hd : a ∣ n + · have hle : a.factorization ≤ n.factorization := + (Nat.factorization_le_iff_dvd ha.ne' hn.ne').mpr hd + have hsupport : (n / a).factorization.support ⊆ a.primeFactors ∪ n.primeFactors := by + intro p hp + apply Finset.mem_union.mpr + right + change p ∈ n.factorization.support + apply Finsupp.mem_support_iff.mpr + have hp' := Finsupp.mem_support_iff.mp hp + simp only [Nat.factorization_div hd, Finsupp.tsub_apply] at hp' + omega + have hprod := fromPrimePowers_reconstruct f hf h1 + (Nat.div_pos (Nat.le_of_dvd hn hd) ha) + rw [dilate, ite_eq_left_iff.mpr (fun h => (h hd).elim), ← hprod] + unfold fromPrimePowers + rw [Finsupp.prod_of_support_subset _ hsupport _ (by intro p _; simp [h1])] + rw [← Finset.union_sdiff_self_eq_union (s := a.primeFactors) (t := n.primeFactors), + Finset.prod_union disjoint_sdiff_self_left.symm] + congr 1 + · apply Finset.prod_congr rfl + intro p hp + simp [dilationLocal, Nat.not_lt.mpr (hle p), Nat.factorization_div hd, + Finsupp.tsub_apply] + · apply Finset.prod_congr rfl + intro p hp + have hp0 : a.factorization p = 0 := + Finsupp.notMem_support_iff.mp (Finset.mem_sdiff.mp hp).2 + simp [Nat.factorization_div hd, Finsupp.tsub_apply, hp0] + · have hex : ∃ p, n.factorization p < a.factorization p := by + by_contra! h + apply hd + exact (Nat.factorization_le_iff_dvd ha.ne' hn.ne').mp (Finsupp.le_def.mpr h) + obtain ⟨p, hp⟩ := hex + have hpP : p ∈ a.primeFactors := by + change p ∈ a.factorization.support + apply Finsupp.mem_support_iff.mpr + omega + simp only [dilate, hd, ite_false] + rw [Finset.prod_eq_zero hpP (by simp [dilationLocal, hp])] + simp + +/-- A fixed dilation is a finite signed sum of normalized ordinary +multiplicative functions, even at arguments with nonunit residue classes. -/ +theorem dilate_eq_sum_components (a : ℕ) (f : ℕ → ℂ) + (ha : 0 < a) (hf : Multiplicative f) (h1 : f 1 = 1) + {n : ℕ} (hn : 0 < n) : + dilate a f n = ∑ E ∈ a.primeFactors.powerset, + (-1 : ℂ) ^ E.card * dilationComponent a f E n := by + rw [dilate_eq_local_product a f ha hf h1 hn] + rw [show (∏ p ∈ a.primeFactors, dilationLocal a f p (n.factorization p)) = + ∏ p ∈ a.primeFactors, (dilationB a f p (n.factorization p) - + dilationC a f p (n.factorization p)) from + Finset.prod_congr rfl (fun p hp => dilationLocal_eq_sub a f hp _)] + exact local_difference_expansion f (dilationB a f) (dilationC a f) a.primeFactors h1 + (by intro p; simp [dilationB]) (by intro p; simp [dilationC]) n + +theorem dilationComponent_multiplicative (a : ℕ) (f : ℕ → ℂ) (E : Finset ℕ) : + Multiplicative (dilationComponent a f E) := + localComponent_multiplicative _ _ _ _ _ + +@[simp] theorem dilationComponent_one (a : ℕ) (f : ℕ → ℂ) (E : Finset ℕ) : + dilationComponent a f E 1 = 1 := by + simp [dilationComponent, localComponent] + +theorem dilationB_bound (a : ℕ) (f : ℕ → ℂ) (hf : OneBounded f) + {p k : ℕ} (hp : p ∈ a.primeFactors) : ‖dilationB a f p k‖ ≤ 1 := by + have hpos := (Nat.prime_of_mem_primeFactors hp).pos + unfold dilationB dilationLocal + split_ifs + · simp + · simp + · exact hf _ (pow_pos hpos _) + +theorem dilationComponent_oneBounded (a : ℕ) (f : ℕ → ℂ) (E : Finset ℕ) + (hf : OneBounded f) : OneBounded (dilationComponent a f E) := by + apply localComponent_oneBounded _ _ _ _ _ hf + · intro p k hp _ + exact dilationB_bound a f hf hp + · intro p k _ hk + simp [dilationC, Nat.ne_of_gt hk] + +theorem dilationComponent_nonpretentious (a : ℕ) (f : ℕ → ℂ) (E : Finset ℕ) + (hf : OneBounded f) (hfnp : UniformlyNonpretentious f) : + UniformlyNonpretentious (dilationComponent a f E) := by + apply localComponent_nonpretentious _ _ _ _ _ hfnp hf + · intro p k hp _ + exact dilationB_bound a f hf hp + · intro p k _ hk + simp [dilationC, Nat.ne_of_gt hk] + +/-- Outside the dilation primes, the components keep the full prime-power +sequence of the original function. -/ +theorem dilationComponent_prime_pow (a : ℕ) (f : ℕ → ℂ) (E : Finset ℕ) + (h1 : f 1 = 1) {p : ℕ} (hp : p.Prime) (hpA : p ∉ a.primeFactors) (k : ℕ) : + dilationComponent a f E (p ^ k) = f (p ^ k) := by + unfold dilationComponent localComponent fromPrimePowers + rw [hp.factorization_pow, Finsupp.prod_single_index] + · simp [hpA] + · simp [hpA, h1] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DilationMRT.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilationMRT.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e450c3332c4faf05cbb5161ba32674a786ddb54 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DilationMRT.lean @@ -0,0 +1,110 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SmoothWindowSum +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeShortSums +import OAI.NumberTheory.TwoPoint.Bounds.RescaledPrefixSums + +namespace OAI + +/-! MRT at the exact quotient-window lengths needed by a fixed dilation. +The published input is unchanged; only finite reindexing is performed. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma zero_origin_sum_le (F : ℕ → ℝ) (hF : ∀ n, 0 ≤ F n) (Y : ℕ) : + (∑ v ∈ range Y, F v) ≤ F 0 + ∑ v ∈ range Y, F (v + 1) := by + have h1 := sum_range_succ F Y + have h2 := sum_range_succ' F Y + linarith [hF Y] + +lemma shortWindowSum_norm_bound (f : ℕ → ℂ) (hf : OneBounded f) + (D v : ℕ) (α : ℝ) : ‖shortWindowSum f D α v‖ ≤ D := by + apply (norm_shortWindowSum_le f D v α).trans + calc + _ ≤ ∑ _m ∈ range D, (1 : ℝ) := sum_le_sum (fun m _ => hf _ (by omega)) + _ = _ := by simp + +theorem MRTShortExponentialInput.modified_zero_windows + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) : + ∃ C : ℝ, 0 < C ∧ ∀ (P : Finset ℕ) (D : ℕ), 10 ≤ D → + ∀ ε : ℝ, 0 < ε → ∀ᶠ Y : ℕ in atTop, + ∀ b : ℕ → ℂ, Multiplicative b → OneBounded b → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → ∀ α : ℝ, + (∑ v ∈ range Y, ‖shortWindowSum b D α v‖) ≤ + C * D * Y * (Real.log (Real.log (D : ℝ)) / Real.log D + ε) := by + obtain ⟨C, hC, hbase⟩ := hMRT.modified_fixed_windows hfnp hf + refine ⟨C + 1, by positivity, ?_⟩ + intro P D hD ε hε + filter_upwards [hbase P D hD ε hε, + eventually_ge_atTop (Nat.ceil (1 / ε))] with Y hY hYlarge + intro b hb hbb heq α + have hprog : progressionSequence b 1 (0 : ZMod 1) = b := by + funext n + simp only [progressionSequence, Subsingleton.elim (n : ZMod 1) 0, ite_true] + have hw := hY b hb hbb heq 1 (0 : ZMod 1) (α : AddCircle (1 : ℝ)) + simp only [hprog, forwardWindowPolynomial_at_real] at hw + have hYs : 1 / ε ≤ (Y : ℝ) := (Nat.le_ceil _).trans (by exact_mod_cast hYlarge) + have hYe : 1 ≤ (Y : ℝ) * ε := (div_le_iff₀ hε).mp hYs + have hE : 0 ≤ Real.log (Real.log (D : ℝ)) / Real.log D := + loglog_div_log_nonneg D hD + have hD0 : (0 : ℝ) ≤ D := Nat.cast_nonneg D + have hpiece : (D : ℝ) ≤ (D : ℝ) * Y * + (Real.log (Real.log (D : ℝ)) / Real.log D + ε) := by + have hy : 1 ≤ (Y : ℝ) * (Real.log (Real.log (D : ℝ)) / Real.log D + ε) := by + nlinarith [mul_nonneg (Nat.cast_nonneg Y) hE] + nlinarith + calc + _ ≤ ‖shortWindowSum b D α 0‖ + ∑ v ∈ range Y, ‖shortWindowSum b D α (v + 1)‖ := + zero_origin_sum_le _ (fun _ => norm_nonneg _) Y + _ ≤ D + C * D * Y * (Real.log (Real.log (D : ℝ)) / Real.log D + ε) := + add_le_add (shortWindowSum_norm_bound b hbb D 0 α) hw + _ ≤ _ := by nlinarith only [hpiece] + +/-- Each quotient length is fixed before taking the long average. Thus +all shorter MRT estimates hold on a common tail, uniformly in the modified +function and in frequency. -/ +theorem MRTShortExponentialInput.modified_quotient_windows + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) : + ∃ C : ℝ, 0 < C ∧ ∀ (P : Finset ℕ) (q D K : ℕ), 0 < q → + (∀ a ∈ Icc 1 K, 10 ≤ D / a + 1) → + ∀ ε : ℝ, 0 < ε → ∀ᶠ Y : ℕ in atTop, + ∀ b : ℕ → ℂ, Multiplicative b → OneBounded b → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → + ∀ a ∈ Icc 1 K, ∀ α : ℝ, + (∑ m ∈ range (Y / a + 1), + ‖shortWindowSum (coprimeRestriction q b) (D / a + 1) α m‖) ≤ + C * (D / a + 1 : ℕ) * (Y / a + 1 : ℕ) * + (Real.log (Real.log (D / a + 1 : ℕ)) / Real.log (D / a + 1 : ℕ) + ε) := by + obtain ⟨C, hC, hw⟩ := hMRT.modified_zero_windows hfnp hf + refine ⟨C, hC, ?_⟩ + intro P q D K hq hlength ε hε + have hall : ∀ᶠ Y : ℕ in atTop, ∀ a ∈ Icc 1 K, + ∀ b : ℕ → ℂ, Multiplicative b → OneBounded b → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → ∀ α : ℝ, + (∑ m ∈ range (Y / a + 1), + ‖shortWindowSum (coprimeRestriction q b) (D / a + 1) α m‖) ≤ + C * (D / a + 1 : ℕ) * (Y / a + 1 : ℕ) * + (Real.log (Real.log (D / a + 1 : ℕ)) / Real.log (D / a + 1 : ℕ) + ε) := by + apply (eventually_all_finset (Icc 1 K)).mpr + intro a ha + have hap : 0 < a := (mem_Icc.mp ha).1 + have ht : Tendsto (fun Y : ℕ => Y / a + 1) atTop atTop := + (tendsto_add_atTop_nat 1).comp (tendsto_nat_div_atTop a hap) + filter_upwards [ht.eventually (hw (P ∪ q.primeFactors) (D / a + 1) + (hlength a ha) ε hε)] with Y hY + intro b hb hbb heq α + refine hY (coprimeRestriction q b) (coprimeRestriction_multiplicative q hb) + (coprimeRestriction_oneBounded q hbb) ?_ α + intro p hp hnot + rw [coprimeRestriction_prime q hq b hp (fun h => hnot (mem_union_right _ h))] + exact heq p hp (fun h => hnot (mem_union_left _ h)) + filter_upwards [hall] with Y hY + intro b hb hbb heq a ha α + exact hY a ha b hb hbb heq α + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DivisibilityPrefix.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DivisibilityPrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..362896d5da139f5adc1995449aad115bb2fb737b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DivisibilityPrefix.lean @@ -0,0 +1,50 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CenterBandExpansion +import OAI.NumberTheory.TwoPoint.Bounds.ShortSumSampling +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftBoundary + +namespace OAI + +/-! Exact change of variables `x=u*z` for a divisibility indicator, +including the floor endpoint `floor(X/u)`. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma positivePrefix_eq_Icc (F : ℕ → ℂ) (X : ℕ) : + positivePrefix F X = ∑ n ∈ Icc 1 X, F n := by + simpa only [Nat.zero_add, positivePrefix] using (sum_Icc_shift F 0 X).symm + +theorem divisibility_positivePrefix (F : ℕ → ℂ) (u X : ℕ) (hu : 0 < u) : + positivePrefix (fun n => natDivisibilityIndicator u n * F n) X = + positivePrefix (fun z => F (u * z)) (X / u) := by + calc + _ = ∑ n ∈ (Icc 1 X).filter (fun n => u ∣ n), F n := by + rw [positivePrefix_eq_Icc, sum_filter] + apply sum_congr rfl + intro n _ + by_cases hn : u ∣ n <;> simp only [natDivisibilityIndicator, hn, ite_true, ite_false, + one_mul, zero_mul] + _ = ∑ z ∈ Icc 1 (X / u), F (u * z) := by + symm + apply sum_bij (fun z _ => u * z) + · intro z hz + obtain ⟨hz₁, hzX⟩ := mem_Icc.mp hz + apply mem_filter.mpr + refine ⟨mem_Icc.mpr ⟨Nat.mul_pos hu hz₁, ?_⟩, dvd_mul_right u z⟩ + simpa only [Nat.mul_comm] using (Nat.le_div_iff_mul_le hu).mp hzX + · intro z _ w _ heq + exact Nat.eq_of_mul_eq_mul_left hu heq + · intro n hn + obtain ⟨hnI, hdiv⟩ := mem_filter.mp hn + obtain ⟨hn₁, hnX⟩ := mem_Icc.mp hnI + refine ⟨n / u, mem_Icc.mpr ⟨?_, Nat.div_le_div_right hnX⟩, Nat.mul_div_cancel' hdiv⟩ + exact Nat.div_pos (Nat.le_of_dvd hn₁ hdiv) hu + · intro z _ + rfl + _ = _ := (positivePrefix_eq_Icc (fun z => F (u * z)) (X / u)).symm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DivisorEndpointSymmetry.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DivisorEndpointSymmetry.lean new file mode 100644 index 0000000000000000000000000000000000000000..f6e4946ef26fd9cad7a0812a74f40b3512cac363 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DivisorEndpointSymmetry.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeDegreeTail + +namespace OAI + +/-! Positive tuple/padding edge weights are unchanged when the origin +is moved to the other endpoint. Both signs of the shift are included. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma dvd_add_multiple_iff (d : ℕ) (n c : ℤ) : + (d : ℤ) ∣ n + (d : ℤ) * c ↔ (d : ℤ) ∣ n := by + have hc : (d : ℤ) ∣ (d : ℤ) * c := dvd_mul_right _ _ + constructor + · intro hn + simpa only [add_sub_cancel_right] using dvd_sub hn hc + · intro hn + exact dvd_add hn hc + +lemma positivePrimeWeight_add_multiple (d : ℕ) (n c : ℤ) : + positivePrimeWeight d.primeFactors (n + (d : ℤ) * c) = + positivePrimeWeight d.primeFactors n := by + unfold positivePrimeWeight + apply prod_congr rfl + intro p hp + have hpd : (p : ℤ) ∣ (d : ℤ) := by exact_mod_cast Nat.dvd_of_mem_primeFactors hp + have hc : (p : ℤ) ∣ (d : ℤ) * c := dvd_mul_of_dvd_left hpd c + have he : (p : ℤ) ∣ n + (d : ℤ) * c ↔ (p : ℤ) ∣ n := by + constructor + · intro hn + simpa only [add_sub_cancel_right] using dvd_sub hn hc + · intro hn + exact dvd_add hn hc + simp only [he] + +lemma positive_divisor_endpoint (d q : ℕ) (n c : ℤ) (bad : ℤ → Prop) : + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors n * + (if (q : ℤ) ∣ n ∧ bad (n + (d * q : ℕ) * c) then 1 else 0) = + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors (n + (d * q : ℕ) * c) * + (if (q : ℤ) ∣ n + (d * q : ℕ) * c ∧ bad (n + (d * q : ℕ) * c) then 1 else 0) := by + have hd : (d * q : ℕ) * c = (d : ℤ) * ((q : ℤ) * c) := by push_cast; ring + have hq : (d * q : ℕ) * c = (q : ℤ) * ((d : ℤ) * c) := by push_cast; ring + rw [hd, positivePrimeWeight_add_multiple] + have he : (q : ℤ) ∣ n + (d : ℤ) * ((q : ℤ) * c) ↔ (q : ℤ) ∣ n := by + rw [← hd, hq] + exact dvd_add_multiple_iff q n ((d : ℤ) * c) + simp only [he] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/DivisorWordMajorant.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/DivisorWordMajorant.lean new file mode 100644 index 0000000000000000000000000000000000000000..93729082ea5d8295038c5a9d4e3540ad1739f66d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/DivisorWordMajorant.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResidueCentering + +namespace OAI + +/-! The full divisibility word bound, including exact unlit extra powers. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +/-- Keep the extra power of every designated nonsingleton. The ambient +prime pool may contain coordinates unused by the word. -/ +theorem uniform_divisor_word_reciprocal_bound {ι τ : Type*} [Fintype ι] [Fintype τ] + [DecidableEq ι] (B : ℕ) (p : ι → ℕ) (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (label : τ → ι) (offset : τ → ℤ) (base : ι → Fin B) + (R H : ℝ) (hR : 0 ≤ R) (hH : 0 < H) (hpH : ∀ i, H ≤ p i) + (G : (ι → Fin B) → ℝ) (hG : ∀ z, |G z| ≤ 1) : + |(FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun z => R * (∏ t, + ((if (p (label t) : ℤ) ∣ (z (label t)).val + offset t then (1 : ℝ) else 0) - + (p (label t) : ℝ)⁻¹)) * G z)| ≤ + ∑ U ∈ (nonsingletonSlots label).powerset, + R * (∏ i ∈ univ.image label, (p i : ℝ)⁻¹) * H⁻¹ ^ + (∑ i ∈ nonsingletonLabels label, + extraReciprocalExponent (litOccurrences label (designationLit U) i).card + (unlitOccurrences label (designationLit U) i).card) * + 2 ^ (singletonLabels label).card := by + rw [uniform_divisor_word_average B p hp hpB label offset R G] + apply (uniform_centered_word_crude_bound B p hp hpB label + (fun t => forcedResidue B (p (label t)) (hp _) (hpB _) (offset t)) base + (fun t => forcedResidue_lt B (p (label t)) (hp _) (hpB _) (offset t)) R hR G hG).trans + apply sum_le_sum + intro U hU + have hc := full_word_designated_reciprocal_bound label U (mem_powerset.mp hU) p H hH hpH + simpa only [mul_assoc] using + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hc hR) + (show 0 ≤ (2 : ℝ) ^ (singletonLabels label).card by positivity) + +/-- The exact literal number of unlit slots is bounded by twice the +retained extra exponent, with no hypothesis about unused coordinates. -/ +lemma designation_card_le_twice_extra {ι τ : Type*} [Fintype ι] [Fintype τ] + [DecidableEq ι] (label : τ → ι) (U : Finset τ) (hU : U ⊆ nonsingletonSlots label) : + U.card ≤ 2 * ∑ i ∈ nonsingletonLabels label, + extraReciprocalExponent (litOccurrences label (designationLit U) i).card + (unlitOccurrences label (designationLit U) i).card := by + have h := actual_unlit_le_twice_extra label (designationLit U) + rw [← nonsingleton_unlit_card, designationLit_unlit label U hU] at h + rw [← sum_coe_sort] + exact h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedBadSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedBadSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..41b93b8e4a71e7461d5fa8bf7eb159831e47441f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedBadSum.lean @@ -0,0 +1,97 @@ +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedPrimeEncoding +import OAI.NumberTheory.TwoPoint.Bounds.BadCatalogCost + +namespace OAI + +/-! The prohibited-word reciprocal estimate summed over all finite codes. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem encoded_prohibited_sum_le (R T h s J : ℕ) (P Q : Finset ℕ) + (supply : ℕ → ℕ → Prop) + (hP : ∀ p ∈ P, p.Prime) (hVP : 1 ≤ primeHarmonicMass P) + (H B : ℕ) (hH : 0 < H) (hB : 1 ≤ B) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ B) : + (∑ e : PrimeWordEncoding R T P Q, + if e.Prohibited h s J supply then e.weight else 0) ≤ + (∑ n : Fin (T + 1), ∑ c : CrudeWordCode R n.val R, + c.badReciprocalCost (primeHarmonicMass P) (primeHarmonicMass Q)) * + ((H : ℝ)⁻¹ + (1 + Real.log B) / H) := by + rw [Fintype.sum_sigma] + rw [sum_mul] + apply sum_le_sum + intro n _ + rw [Fintype.sum_sigma] + rw [sum_mul] + apply sum_le_sum + intro c _ + rw [Fintype.sum_prod_type] + by_cases hc : c.KindConsistent + · by_cases hi : c.RowInjective + · rw [sum_comm] + let E (a : c.tupleClasses → P) + (b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q) : Prop := + PrimeWordEncoding.Prohibited ⟨n, c, a, b⟩ h s J supply + have hE : ∀ a b, E a b → + let w := c.numericalWord (joinCoordinates c.tupleClasses + (fun z => (a z).val) (fun z => (b z).val)) + Function.Injective (fun z => (a z).val) ∧ + ForwardProhibited h s supply w ∧ + (∀ t ∈ w, Squarefree t.tuple) ∧ + (∀ t ∈ w, t.tuple.primeFactors.card = J) ∧ + (∀ p j, TuplePrimeAt w p j → ¬p ∣ h ∧ ∀ t ∈ w, ¬p ∣ t.padding) := by + intro a b he + exact he.2.2 + have hb := c.prohibited_fiber_reciprocal_bound hc hi P Q E hE + hP hVP H B hH hB hlo hhi + have heq : (∑ b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q, + ∑ a : c.tupleClasses → P, + if PrimeWordEncoding.Prohibited ⟨n, c, a, b⟩ h s J supply + then PrimeWordEncoding.weight ⟨n, c, a, b⟩ else 0) = + ∑ b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q, + ∑ a : c.tupleClasses → P, if E a b then + (∏ i, ((a i).val : ℝ)⁻¹) * ∏ j, ((b j).val : ℝ)⁻¹ else 0 := by + apply sum_congr rfl + intro b _ + apply sum_congr rfl + intro a _ + dsimp only [E, PrimeWordEncoding.weight] + rw [reciprocal_product_join] + rw [heq] + exact hb + · have he (a : c.tupleClasses → P) + (b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q) : + ¬PrimeWordEncoding.Prohibited ⟨n, c, a, b⟩ h s J supply := fun he => hi he.2.1 + simp only [he, ite_false, sum_const_zero] + exact mul_nonneg (c.badReciprocalCost_nonneg + (by unfold primeHarmonicMass; positivity) (by unfold primeHarmonicMass; positivity)) + (by positivity) + · have he (a : c.tupleClasses → P) + (b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q) : + ¬PrimeWordEncoding.Prohibited ⟨n, c, a, b⟩ h s J supply := fun he => hc he.1 + simp only [he, ite_false, sum_const_zero] + exact mul_nonneg (c.badReciprocalCost_nonneg + (by unfold primeHarmonicMass; positivity) (by unfold primeHarmonicMass; positivity)) + (by positivity) + +/-- Length and slot-count summation retain the one-prime saving. -/ +theorem bounded_encoded_prohibited_sum_le (T h s J : ℕ) (P Q : Finset ℕ) + (supply : ℕ → ℕ → Prop) + (hP : ∀ p ∈ P, p.Prime) (hVP : 1 ≤ primeHarmonicMass P) + (H B : ℕ) (hH : 0 < H) (hB : 1 ≤ B) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ B) : + (∑ R : Fin (s + 1), ∑ e : PrimeWordEncoding R.val T P Q, + if e.Prohibited h s J supply then e.weight else 0) ≤ + badCatalogCost s T (primeHarmonicMass P) (primeHarmonicMass Q) * + ((H : ℝ)⁻¹ + (1 + Real.log B) / H) := by + unfold badCatalogCost + rw [sum_mul] + exact sum_le_sum (fun R _ => encoded_prohibited_sum_le R.val T h s J P Q supply + hP hVP H B hH hB hlo hhi) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedCoefficients.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedCoefficients.lean new file mode 100644 index 0000000000000000000000000000000000000000..fce73bf30491520f2e5ddce5de34647aa6d99c14 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedCoefficients.lean @@ -0,0 +1,244 @@ +import OAI.NumberTheory.TwoPoint.Circuits.BitMarginals +import OAI.NumberTheory.TwoPoint.Bounds.SampleDensity +import OAI.NumberTheory.TwoPoint.Bounds.FourierMass +import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset + +namespace OAI + +/-! +# Low-order coefficients of the actual encoded interval law + +A Walsh coefficient only uses the residue coordinates touched by its bits. +All other independent jitters integrate out. The remaining observable is +bounded by one, so CRT gives the product of its selected moduli divided by +the interval length as an explicit coefficient bound. +-/ + +namespace TwoPointCorrelations + +open Finset + +lemma finiteRandomKernel_expectation {α β J : Type*} [Fintype β] [DecidableEq β] + [Fintype J] (F : α → J → β) (u : β → ℝ) (x : α) : + (∑ y, finiteRandomKernel F x y * u y) = uniformAverage (fun j => u (F x j)) := by + unfold finiteRandomKernel uniformAverage + simp_rw [div_mul_eq_mul_div, Finset.sum_mul] + rw [← Finset.sum_div, Finset.sum_comm] + simp + +lemma kernelTransport_expectation {α β : Type*} [Fintype α] [Fintype β] + (K : α → β → ℝ) (p : α → ℝ) (u : β → ℝ) : + (∑ y, kernelTransport K p y * u y) = ∑ x, p x * ∑ y, K x y * u y := by + unfold kernelTransport + simp_rw [Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro y _ + ring + +lemma crtJitterBits_uniformAverage {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] (B : ℕ) + (u : (ι → BooleanCube B) → ℝ) : + uniformAverage (fun r : ∀ i, ZMod (s i) => + uniformAverage (fun j : ι → Fin (2 ^ B) => u (crtJitterBits s B r j))) = + uniformAverage u := by + rw [← crtUniform_expectation s] + simp_rw [← finiteRandomKernel_expectation (crtJitterBits s B) u] + rw [← kernelTransport_expectation] + simp_rw [crtJitterBits_uniform] + unfold uniformAverage + rw [← Finset.mul_sum] + ring + +/-- Flatten bit blocks in the same order as the standard product equivalence +`Fin m × Fin B ≃ Fin (m*B)`. -/ +def flattenBitBlocks (m B : ℕ) : (Fin m → BooleanCube B) ≃ BooleanCube (m * B) := + (Equiv.curry (Fin m) (Fin B) Bool).symm.trans + (Equiv.arrowCongr finProdFinEquiv (Equiv.refl Bool)) + +@[simp] lemma flattenBitBlocks_apply {m B : ℕ} (z : Fin m → BooleanCube B) + (k : Fin (m * B)) : flattenBitBlocks m B z k = z k.divNat k.modNat := rfl + +/-- Residue coordinates on which a given Walsh character depends. -/ +def bitSources {m B : ℕ} (S : Finset (Fin (m * B))) : Finset (Fin m) := + S.image (fun k => k.divNat) + +lemma card_bitSources_le {m B : ℕ} (S : Finset (Fin (m * B))) : + (bitSources S).card ≤ S.card := Finset.card_image_le + +lemma bitSource_mem {m B : ℕ} (S : Finset (Fin (m * B))) {k : Fin (m * B)} (hk : k ∈ S) : + k.divNat ∈ bitSources S := Finset.mem_image_of_mem _ hk + +/-- Extend selected blocks by zero bits outside the selection. -/ +def extendBitBlocks {m B : ℕ} (C : Finset (Fin m)) (z : C → BooleanCube B) : Fin m → BooleanCube B := + fun i => if h : i ∈ C then z ⟨i, h⟩ else fun _ => false + +noncomputable def selectedWalsh {m B : ℕ} (S : Finset (Fin (m * B))) + (z : bitSources S → BooleanCube B) : ℝ := + walsh S (flattenBitBlocks m B (extendBitBlocks (bitSources S) z)) + +lemma selectedWalsh_restrict {m B : ℕ} (S : Finset (Fin (m * B))) + (z : Fin m → BooleanCube B) : + selectedWalsh S (fun i : bitSources S => z i) = walsh S (flattenBitBlocks m B z) := by + unfold selectedWalsh walsh + apply Finset.prod_congr rfl + intro k hk + simp only [flattenBitBlocks_apply, extendBitBlocks, dite_eq_left (bitSource_mem S hk)] + +lemma abs_selectedWalsh {m B : ℕ} (S : Finset (Fin (m * B))) + (z : bitSources S → BooleanCube B) : |selectedWalsh S z| = 1 := abs_walsh _ _ + +/-- The actual bits sampled from one uniformly chosen integer origin and +independent finite jitters in every residue coordinate. -/ +noncomputable def integerBitSample {m : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (B a : ℕ) {N : ℕ} (x : Fin N × (Fin m → Fin (2 ^ B))) : BooleanCube (m * B) := + flattenBitBlocks m B (crtJitterBits s B (fun i => (a + x.1.val : ZMod (s i))) x.2) + +noncomputable def integerBitDensity {m : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (B a N : ℕ) : BooleanCube (m * B) → ℝ := + sampleDensity (@integerBitSample m s _ B a N) + +lemma integerBitDensity_nonneg {m : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (B a N : ℕ) (x : BooleanCube (m * B)) : 0 ≤ integerBitDensity s B a N x := + sampleDensity_nonneg _ x + +lemma integerBitDensity_mean {m : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (B a N : ℕ) (hN : 0 < N) : cubeAverage (integerBitDensity s B a N) = 1 := by + let : Nonempty (Fin N) := ⟨⟨0, hN⟩⟩ + let : Nonempty (Fin (2 ^ B)) := ⟨⟨0, by positivity⟩⟩ + exact sampleDensity_mean _ + +/-- The bounded observable on precisely the touched residue coordinates. -/ +noncomputable def selectedWalshMean {m B : ℕ} (s : Fin m → ℕ) + [∀ i, NeZero (s i)] (S : Finset (Fin (m * B))) + (r : ∀ i : bitSources S, ZMod (s i)) : ℝ := + uniformAverage (fun j : bitSources S → Fin (2 ^ B) => + selectedWalsh S (crtJitterBits (fun i : bitSources S => s i) B r j)) + +lemma abs_selectedWalshMean_le_one {m B : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (S : Finset (Fin (m * B))) (r : ∀ i : bitSources S, ZMod (s i)) : + |selectedWalshMean s S r| ≤ 1 := by + apply abs_uniformAverage_le_one + intro j + exact (abs_selectedWalsh _ _).le + +lemma crtJitterBits_restrict {m B : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (C : Finset (Fin m)) (r : ∀ i, ZMod (s i)) (j : Fin m → Fin (2 ^ B)) : + (fun i : C => crtJitterBits s B r j i) = + crtJitterBits (fun i : C => s i) B (fun i : C => r i) (fun i : C => j i) := rfl + +lemma selectedWalshMean_eq_full {m B : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (S : Finset (Fin (m * B))) (r : ∀ i, ZMod (s i)) : + selectedWalshMean s S (fun i : bitSources S => r i) = + uniformAverage (fun j : Fin m → Fin (2 ^ B) => + walsh S (flattenBitBlocks m B (crtJitterBits s B r j))) := by + let : Nonempty (Fin (2 ^ B)) := ⟨⟨0, by positivity⟩⟩ + rw [selectedWalshMean, ← uniformAverage_restrict (fun _ : Fin m => Fin (2 ^ B)) (bitSources S)] + apply congrArg uniformAverage + funext j + rw [← crtJitterBits_restrict, selectedWalsh_restrict] + +lemma selectedWalshMean_average_zero {m B : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (S : Finset (Fin (m * B))) (hS : S.Nonempty) : uniformAverage (selectedWalshMean s S) = 0 := by + rw [← uniformAverage_restrict (fun i : Fin m => ZMod (s i)) (bitSources S)] + simp_rw [selectedWalshMean_eq_full] + rw [crtJitterBits_uniformAverage s B (fun z => walsh S (flattenBitBlocks m B z))] + have heq := uniformAverage_equiv (flattenBitBlocks m B) (walsh S) + rw [heq] + exact cubeAverage_walsh hS + +/-- Each low-order coefficient is the actual selected-coordinate observable +along the integer interval. -/ +lemma integerBitDensity_coefficient {m B : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (a N : ℕ) (hN : 0 < N) (S : Finset (Fin (m * B))) : + walshCoefficient (integerBitDensity s B a N) S = + uniformAverage (fun j : Fin N => + selectedWalshMean s S (fun i : bitSources S => (a + j.val : ZMod (s i)))) := by + let : Nonempty (Fin N) := ⟨⟨0, hN⟩⟩ + let : Nonempty (Fin (2 ^ B)) := ⟨⟨0, by positivity⟩⟩ + rw [integerBitDensity, sampleDensity_walshCoefficient, + uniformAverage_prod (fun (j : Fin N) (noise : Fin m → Fin (2 ^ B)) => + walsh S (integerBitSample s B a (j, noise)))] + apply congrArg uniformAverage + funext j + change uniformAverage (fun noise : Fin m → Fin (2 ^ B) => + walsh S (flattenBitBlocks m B + (crtJitterBits s B (fun i => (a + j.val : ZMod (s i))) noise))) = _ + exact (selectedWalshMean_eq_full s S (fun i => (a + j.val : ZMod (s i)))).symm + +/-- The Fourier error for a set of bits is bounded by the product of the +moduli of the residue coordinates touched by those bits, divided by length. -/ +theorem integerBitDensity_coefficient_bound {m B : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (a N : ℕ) (hN : 0 < N) (S : Finset (Fin (m * B))) (hS : S.Nonempty) : + |walshCoefficient (integerBitDensity s B a N) S| ≤ + (∏ i : bitSources S, s i : ℕ) / (N : ℝ) := by + have hcopS : Pairwise (fun i j : bitSources S => (s i).Coprime (s j)) := by + intro i j hij + exact hcop (fun h => hij (Subtype.ext h)) + have h := crt_observable_difference (fun i : bitSources S => s i) hcopS + (a : ZMod (∏ i : bitSources S, s i)) N hN (selectedWalshMean s S) + (abs_selectedWalshMean_le_one s S) + have hvec (j : Fin N) : + ZMod.prodEquivPi (fun i : bitSources S => s i) hcopS + ((a : ZMod (∏ i : bitSources S, s i)) + (j.val : ZMod (∏ i : bitSources S, s i))) = + (fun i : bitSources S => (a + j.val : ZMod (s i))) := by + funext i + simp only [ZMod.prodEquivPi_apply, map_add, map_natCast] + simp_rw [hvec, selectedWalshMean_average_zero s S hS, sub_zero] at h + rw [integerBitDensity_coefficient s a N hN S] + exact h + +lemma selected_modulus_product_le {m B : ℕ} (s : Fin m → ℕ) + (S : Finset (Fin (m * B))) (M : ℝ) (hM : 1 ≤ M) + (hs : ∀ i, (s i : ℝ) ≤ M) (t : ℕ) (ht : S.card ≤ t) : + ((∏ i : bitSources S, s i : ℕ) : ℝ) ≤ M ^ t := by + calc + ((∏ i : bitSources S, s i : ℕ) : ℝ) = ∏ i : bitSources S, (s i : ℝ) := by push_cast; rfl + _ ≤ ∏ _i : bitSources S, M := + Finset.prod_le_prod₀ (fun _ _ => Nat.cast_nonneg _) (fun i _ => hs i) + _ = M ^ (bitSources S).card := by simp + _ ≤ M ^ t := pow_le_pow_right₀ hM ((card_bitSources_le S).trans ht) + +lemma integerBitDensity_low_coefficients {m B : ℕ} (s : Fin m → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (a N : ℕ) (hN : 0 < N) (M : ℝ) (hM : 1 ≤ M) (hs : ∀ i, (s i : ℝ) ≤ M) (t : ℕ) : + ∀ S ∈ lowWalshSets (m * B) t, + |walshCoefficient (integerBitDensity s B a N) S| ≤ M ^ t / (N : ℝ) := by + intro S hS + have hdata := (Finset.mem_filter.mp hS).2 + exact (integerBitDensity_coefficient_bound s hcop a N hN S hdata.1).trans + (div_le_div_of_nonneg_right (selected_modulus_product_le s S M hM hs t hdata.2) + (Nat.cast_nonneg N)) + +/-- Finite-parameter encoded residue comparison derived from the published +Braverman input, with all Fourier errors discharged by the actual interval +sampling law. Only the final numerical error budget is left to choose. -/ +theorem BravermanDepth22Input.encoded_interval_comparison (hBraverman : BravermanDepth22Input) : + ∃ K C : ℕ, 0 < K ∧ 0 < C ∧ ∀ (m B : ℕ), 0 < m * B → + ∀ (s : Fin m → ℕ) [∀ i, NeZero (s i)], + Pairwise (fun i j => (s i).Coprime (s j)) → + ∀ (c : AC0Circuit (m * B)), c.depth ≤ 22 → + ∀ ε : ℝ, 0 < ε → ε ≤ 1 / 2 → ∀ t : ℕ, + (K : ℝ) * (Real.log ((c.size : ℝ) / ε)) ^ C ≤ (t : ℝ) → + ∀ (a N : ℕ), 0 < N → ∀ M A : ℝ, 1 ≤ M → (∀ i, (s i : ℝ) ≤ M) → + (M ^ t / (N : ℝ)) * ((t + 1 : ℕ) : ℝ) * ((m * B : ℕ) : ℝ) ^ t ≤ A → + |uniformAverage (fun x : Fin N × (Fin m → Fin (2 ^ B)) => + c.indicator (integerBitSample s B a x)) - cubeAverage c.indicator| ≤ + 3 * A / 2 + ε := by + obtain ⟨K, C, hK, hC, hbound⟩ := hBraverman.coefficient_comparison + refine ⟨K, C, hK, hC, ?_⟩ + intro m B hn s _hpos hcop c hc ε hε hεmax t ht a N hN M A hM hs hA + let : Nonempty (Fin N) := ⟨⟨0, hN⟩⟩ + let : Nonempty (Fin (2 ^ B)) := ⟨⟨0, by positivity⟩⟩ + have h := hbound (m * B) hn c hc ε hε hεmax t ht (integerBitDensity s B a N) + (M ^ t / (N : ℝ)) A (integerBitDensity_nonneg s B a N) + (integerBitDensity_mean s B a N hN) (by positivity) + (integerBitDensity_low_coefficients s hcop a N hN M hM hs t) hA + simpa only [integerBitDensity, sampleDensity_expectation] using h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedPaddingUnion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedPaddingUnion.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b1b6c3abbce5fab2d0c6b1fa5ba6285dd64bce5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedPaddingUnion.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.TwoPoint.Bounds.EncodedPaddingWitness +import OAI.NumberTheory.TwoPoint.Bounds.EncodedPrimeSupport + +namespace OAI + +/-! Sum the retained padding-event probabilities over all main words exactly once. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem sum_main_encoded_padding_probability_le {R T n : ℕ} {P Q : Finset ℕ} + {ι : Type*} [Fintype ι] [DecidableEq ι] + (d : WitnessRecord n R) (e : PrimeWordEncoding R T P Q) + (F : Finset (List SignedStep)) (S : List SignedStep → Finset ι) (p : ι → ℕ) (hinj : Function.Injective p) + (B h s J : ℕ) (supply : ℕ → ℕ → Prop) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (hcover : ∀ q ∈ wordDivisorPrimeSupport e.decode, ∃ i, p i = q) + (hS : ∀ main ∈ F, ∀ i ∈ S main, p i ∈ wordDivisorPrimeSupport main) : + (∑ main ∈ F, (∏ i ∈ S main, (p i : ℝ)⁻¹) * + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).probability + (EncodedPaddingWitnessEvent (S main) d e main p B h s J supply)) ≤ + if e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) (fun i => (d.1.2.2 i).val) + h s J supply then e.weight else 0 := by + let μ := FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i)) + let g (main : List SignedStep) := + (∏ i ∈ S main, (p i : ℝ)⁻¹) * + μ.probability (EncodedPaddingWitnessEvent (S main) d e main p B h s J supply) + have hzero (main : List SignedStep) (hne : main ≠ e.decode.take d.1.1.val) : g main = 0 := by + have hfalse : ∀ x, ¬EncodedPaddingWitnessEvent (S main) d e main p B h s J supply x := by + intro x hx + exact hne hx.2.1.1.symm + simp only [g, FiniteLaw.probability, FiniteLaw.average, hfalse, ite_false, + mul_zero, sum_const_zero] + change ∑ main ∈ F, g main ≤ _ + by_cases hm : e.decode.take d.1.1.val ∈ F + · rw [sum_eq_single_of_mem (e.decode.take d.1.1.val) hm (fun main _ hne => hzero main hne)] + exact encoded_padding_witness_probability_le (S _) d e _ p hinj B h s J supply hp hpB (hS _ hm) hcover + · rw [sum_eq_zero (fun main hmain => hzero main (fun he => hm (he ▸ hmain)))] + split_ifs + · exact e.weight_nonneg + · exact le_refl 0 + +theorem main_sum_padding_witness_union_probability_le {R T n : ℕ} {P Q : Finset ℕ} + {ι : Type*} [Fintype ι] [DecidableEq ι] + (F : Finset (List SignedStep)) (S : List SignedStep → Finset ι) (p : ι → ℕ) (hinj : Function.Injective p) + (B h s J : ℕ) (supply : ℕ → ℕ → Prop) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (hP : ∀ q ∈ P, q.Prime) (hQ : ∀ q ∈ Q, q.Prime) + (hcover : ∀ q ∈ P ∪ Q, ∃ i, p i = q) + (hS : ∀ main ∈ F, ∀ i ∈ S main, p i ∈ wordDivisorPrimeSupport main) : + (∑ main ∈ F, (∏ i ∈ S main, (p i : ℝ)⁻¹) * + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).probability + (fun x => ∃ d : WitnessRecord n R, ∃ e : PrimeWordEncoding R T P Q, + EncodedPaddingWitnessEvent (S main) d e main p B h s J supply x)) ≤ + ∑ d : WitnessRecord n R, ∑ e : PrimeWordEncoding R T P Q, + if e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) (fun i => (d.1.2.2 i).val) + h s J supply then e.weight else 0 := by + let μ := FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i)) + calc + _ ≤ ∑ main ∈ F, ∑ d : WitnessRecord n R, ∑ e : PrimeWordEncoding R T P Q, + (∏ i ∈ S main, (p i : ℝ)⁻¹) * + μ.probability (EncodedPaddingWitnessEvent (S main) d e main p B h s J supply) := by + apply sum_le_sum + intro main _ + simp only [← mul_sum] + apply mul_le_mul_of_nonneg_left _ (prod_nonneg (fun _ _ => by positivity)) + apply (μ.probability_exists_le _).trans + exact sum_le_sum (fun d _ => μ.probability_exists_le _) + _ ≤ _ := by + rw [sum_comm] + apply sum_le_sum + intro d _ + rw [sum_comm] + apply sum_le_sum + intro e _ + exact sum_main_encoded_padding_probability_le d e F S p hinj B h s J supply hp hpB + (fun q hq => hcover q (e.divisor_support_subset hP hQ hq)) hS + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedPaddingWitness.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedPaddingWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..2fd46ac89804fe3adc44ec88cd8721946b8298e0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedPaddingWitness.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.TwoPoint.Bounds.EncodedWitnessProbability +import OAI.NumberTheory.TwoPoint.Bounds.PaddingWitnessProbability + +namespace OAI + +/-! The singleton trace term keeps the main padding event inside the residue average. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def EncodedPaddingWitnessEvent {R T n : ℕ} {P Q : Finset ℕ} {ι : Type*} [DecidableEq ι] + (S : Finset ι) (d : WitnessRecord n R) (e : PrimeWordEncoding R T P Q) + (main : List SignedStep) (p : ι → ℕ) (B h s J : ℕ) + (supply : ℕ → ℕ → Prop) (x : ι → Fin B) : Prop := + e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) (fun i => (d.1.2.2 i).val) + h s J supply ∧ d.Realizes e main ∧ RetainedMainTests p S h B main x ∧ + ∃ y : ι → Fin B, (∀ i, i ∉ S → y i = x i) ∧ + ∀ j, AttachedResiduePositiveWord p h + ((e.decode.drop (d.1.2.1 j).val).take (d.1.2.2 j).val) + (wordDisplacement h (main.take (d.2 j).val)) B y + +lemma EncodedPaddingWitnessEvent.congr {R T n : ℕ} {P Q : Finset ℕ} + {ι : Type*} [DecidableEq ι] (S : Finset ι) (d : WitnessRecord n R) + (e : PrimeWordEncoding R T P Q) (main : List SignedStep) (p : ι → ℕ) + (B h s J : ℕ) (supply : ℕ → ℕ → Prop) (x z : ι → Fin B) + (hxz : ∀ i, i ∉ S → x i = z i) : + EncodedPaddingWitnessEvent S d e main p B h s J supply x ↔ + EncodedPaddingWitnessEvent S d e main p B h s J supply z := by + constructor + · rintro ⟨hw, hr, hm, y, hy, ht⟩ + refine ⟨hw, hr, (retainedMainTests_congr p S h B main x z hxz).mp hm, y, ?_, ht⟩ + intro i hi + exact (hy i hi).trans (hxz i hi) + · rintro ⟨hw, hr, hm, y, hy, ht⟩ + refine ⟨hw, hr, (retainedMainTests_congr p S h B main x z hxz).mpr hm, y, ?_, ht⟩ + intro i hi + exact (hy i hi).trans (hxz i hi).symm + +theorem encoded_padding_witness_probability_le {R T n : ℕ} {P Q : Finset ℕ} + {ι : Type*} [Fintype ι] [DecidableEq ι] + (S : Finset ι) (d : WitnessRecord n R) (e : PrimeWordEncoding R T P Q) + (main : List SignedStep) (p : ι → ℕ) (hinj : Function.Injective p) + (B h s J : ℕ) (supply : ℕ → ℕ → Prop) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (hS : ∀ i ∈ S, p i ∈ wordDivisorPrimeSupport main) + (hcover : ∀ q ∈ wordDivisorPrimeSupport e.decode, ∃ i, p i = q) : + (∏ i ∈ S, (p i : ℝ)⁻¹) * + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).probability + (EncodedPaddingWitnessEvent S d e main p B h s J supply) ≤ + if e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) (fun i => (d.1.2.2 i).val) + h s J supply then e.weight else 0 := by + let μ := FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i)) + have hnonneg : 0 ≤ ∏ i ∈ S, (p i : ℝ)⁻¹ := by positivity + by_cases hw : e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) + (fun i => (d.1.2.2 i).val) h s J supply + · rw [ite_eq_left hw] + by_cases hr : d.Realizes e main + · have hc : ∀ q ∈ wordDivisorPrimeSupport (recordedWitnessWord main + (fun i => (e.decode.drop (d.1.2.1 i).val).take (d.1.2.2 i).val)), + ∃ i, p i = q := by + simpa only [← hr.2.1] using hcover + have hb := tuple_weight_mul_padding_hybrid_probability_le n B h p hinj hp hpB S main + (fun i => (e.decode.drop (d.1.2.1 i).val).take (d.1.2.2 i).val) + (fun i => wordDisplacement h (main.take (d.2 i).val)) hS hc + have hmono := μ.probability_mono_of_imp + (fun x (he : EncodedPaddingWitnessEvent S d e main p B h s J supply x) => he.2.2) + apply (mul_le_mul_of_nonneg_left hmono hnonneg).trans + simpa only [← hr.2.1, ← hr.2.2] using hb + · have he : ∀ x, ¬EncodedPaddingWitnessEvent S d e main p B h s J supply x := + fun _ hx => hr hx.2.1 + simp only [FiniteLaw.probability, FiniteLaw.average, he, ite_false, mul_zero, + sum_const_zero] + exact e.weight_nonneg + · rw [ite_eq_right hw] + have he : ∀ x, ¬EncodedPaddingWitnessEvent S d e main p B h s J supply x := + fun _ hx => hw hx.1 + simp only [FiniteLaw.probability, FiniteLaw.average, he, ite_false, mul_zero, + sum_const_zero, le_refl] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedPrimeSupport.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedPrimeSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..5e588acaebe2138b54658d48798cdd2bc1c25a18 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedPrimeSupport.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeWordEncoding + +namespace OAI + +/-! Every prime used by a numerical encoding lies in its declared finite pools. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem PrimeWordEncoding.divisor_support_subset {R T : ℕ} {P Q : Finset ℕ} + (e : PrimeWordEncoding R T P Q) + (hP : ∀ p ∈ P, p.Prime) (hQ : ∀ q ∈ Q, q.Prime) : + wordDivisorPrimeSupport e.decode ⊆ P ∪ Q := by + let c := e.2.1 + let value := joinCoordinates c.tupleClasses + (fun z => (e.2.2.1 z).val) (fun z => (e.2.2.2 z).val) + have hv (z : c.usedClasses) : value z ∈ P ∪ Q := by + by_cases hz : z ∈ c.tupleClasses + · exact mem_union_left _ (by simpa only [value, joinCoordinates, hz, dite_true] + using (e.2.2.1 ⟨z, hz⟩).property) + · exact mem_union_right _ (by simpa only [value, joinCoordinates, hz, dite_false] + using (e.2.2.2 ⟨z, hz⟩).property) + have hpv (z : c.usedClasses) : (value z).Prime := by + rcases mem_union.mp (hv z) with hz | hz + · exact hP _ hz + · exact hQ _ hz + intro q hq + have hm : ∃ i : Fin R, q ∈ + ((c.primeData value).factor i true * (c.primeData value).factor i false).primeFactors := by + change q ∈ wordDivisorPrimeSupport (c.primeData value).word at hq + simpa only [wordDivisorPrimeSupport, PrimeSlotData.word, mem_biUnion, + List.mem_toFinset, List.mem_ofFn, exists_exists_eq_and] using hq + obtain ⟨i, hi⟩ := hm + have hprime := (Nat.mem_primeFactors.mp hi).1 + have hdvd := (Nat.mem_primeFactors.mp hi).2.1 + have hf (b : Bool) (hd : q ∣ (c.primeData value).factor i b) : q ∈ P ∪ Q := by + obtain ⟨j, _, hj⟩ := (hprime.prime.dvd_finsetProd_iff + (c.primeData value).prime).mp hd + have he : q = value (c.classAt j) := + (Nat.prime_dvd_prime_iff_eq hprime (hpv (c.classAt j))).mp hj + rw [he] + exact hv _ + rcases hprime.dvd_mul.mp hdvd with hd | hd + · exact hf true hd + · exact hf false hd + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedWitnessDecay.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedWitnessDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..e1f6c772ffac1bc82911583d7601925612d907aa --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedWitnessDecay.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.TwoPoint.Walks.WitnessCatalogCost +import OAI.NumberTheory.TwoPoint.Bounds.SingletonDecay + +namespace OAI + +/-! Exponential singleton saving for the entire encoded numerical witness catalog. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem eventually_encoded_witness_decay (C Cw : ℝ) (hC : 0 ≤ C) (hCw : 0 ≤ Cw) : + ∀ᶠ L : ℝ in atTop, ∀ (R T n K M mainLength h s J H B : ℕ) + (start len : Fin n → ℕ) (P Q : Finset ℕ) (supply : ℕ → ℕ → Prop) (W : ℝ), + 1 ≤ R → (R : ℝ) ≤ 4 * L → R ≤ M → + (T : ℝ) ≤ C * R * Real.log L → + (T : ℝ) + 1 ≤ L ^ (2 : ℕ) → (R : ℝ) + 1 ≤ L ^ (2 : ℕ) → + T ≤ M + 1 → n ≤ M + 1 → (n : ℝ) ≤ 4 * L → (M : ℝ) + 1 ≤ L ^ (2 : ℕ) → + 8 * K ≤ n → L ^ (1 / 12 : ℝ) / 32 ≤ (K : ℝ) → (K : ℝ) ≤ L → + (∀ p ∈ P, p.Prime) → 1 ≤ primeHarmonicMass P → + primeHarmonicMass P ≤ L ^ (2 : ℕ) → primeHarmonicMass Q ≤ L ^ (2 : ℕ) → + 1 ≤ B → (B : ℝ) ≤ Real.exp L → + (∀ p ∈ P, H ≤ p) → (∀ p ∈ P, p ≤ B) → + Real.exp (L ^ (199 / 200 : ℝ)) ≤ H → + 0 ≤ W → W ≤ Real.exp (Cw * L * (Real.log L) ^ 2) → + W * (∑ e : PrimeWordEncoding R T P Q, + if e.Witnesses n mainLength start len h s J supply then e.weight else 0) ≤ + Real.exp (-L ^ (21 / 20 : ℝ)) := by + let A := 63 + Cw + 4 * (3 + 7 * C) + have hA : 0 ≤ A := by dsimp [A]; positivity + have hA2 : 2 ≤ A := by dsimp [A]; linarith + filter_upwards [eventually_ge_atTop (2 : ℝ), + Real.tendsto_log_atTop.eventually (eventually_ge_atTop 1), + eventually_singleton_progression_factor, eventually_singleton_total A hA] + with L hL hlog hfactor hdecay + intro R T n K M mainLength h s J H B start len P Q supply W + hR hRL hRM hslots hT hRp hTM hnM hn hM hsize hKlo hKhi hP hV hPup hQup + hB hBexp hlo hhi hH hW hWup + have hLp : 0 < L := by linarith + have hHp : (0 : ℝ) < H := (Real.exp_pos _).trans_le hH + have hHN : 0 < H := by exact_mod_cast hHp + have hraw := encoded_witness_sum_le R T n K M mainLength h s J start len P Q supply + hRM hsize hP hV H B hHN hB hlo hhi (hfactor B H hB hBexp hH).2 + have hcost : W * witnessCatalogCost R T n M (primeHarmonicMass P) (primeHarmonicMass Q) ≤ + Real.exp (A * L * (Real.log L) ^ 2) := by + have hb := witnessCatalogCost_exp_bound R T n M L C hR (by linarith) hlog + hslots hT hRp hTM hnM hn hM (primeHarmonicMass P) (primeHarmonicMass Q) + (by unfold primeHarmonicMass; positivity) (by unfold primeHarmonicMass; positivity) hPup hQup + have hr := mul_le_mul_of_nonneg_right hRL + (show 0 ≤ (3 + 7 * C) * (Real.log L) ^ 2 by positivity) + calc + _ ≤ Real.exp (Cw * L * (Real.log L) ^ 2) * + Real.exp (63 * L * (Real.log L) ^ 2 + (3 + 7 * C) * R * (Real.log L) ^ 2) := + mul_le_mul hWup hb (witnessCatalogCost_nonneg _ _ _ _ _ _ + (by unfold primeHarmonicMass; positivity) (by unfold primeHarmonicMass; positivity)) + (Real.exp_pos _).le + _ = Real.exp (Cw * L * (Real.log L) ^ 2 + + (63 * L * (Real.log L) ^ 2 + (3 + 7 * C) * R * (Real.log L) ^ 2)) := + (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by dsimp [A]; nlinarith) + have hlogB : Real.log (B : ℝ) ≤ L := by + have hb := Real.log_le_log (show (0 : ℝ) < B by exact_mod_cast (by omega : 0 < B)) hBexp + simpa only [Real.log_exp] using hb + have hnum : 2 + Real.log B ≤ Real.exp (A * Real.log L) := by + have he : Real.exp (2 * Real.log L) = L ^ (2 : ℕ) := by + rw [show 2 * Real.log L = Real.log L + Real.log L by ring, + Real.exp_add, Real.exp_log hLp] + ring + calc + _ ≤ L ^ (2 : ℕ) := by nlinarith + _ = Real.exp (2 * Real.log L) := he.symm + _ ≤ _ := Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hA2 (by linarith)) + apply hdecay K B H (W * witnessCatalogCost R T n M (primeHarmonicMass P) (primeHarmonicMass Q)) + _ hKlo hKhi hH hnum (mul_nonneg hW (witnessCatalogCost_nonneg _ _ _ _ _ _ + (by unfold primeHarmonicMass; positivity) (by unfold primeHarmonicMass; positivity))) hcost + have hb := mul_le_mul_of_nonneg_left hraw hW + simpa only [witnessCatalogCost, mul_assoc] using hb + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedWitnessProbability.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedWitnessProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..8fc64ecddb80e571ae115823c910dcbef024831e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedWitnessProbability.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualWitnessRecord +import OAI.NumberTheory.TwoPoint.Walks.WitnessProbabilityWeight + +namespace OAI + +/-! The encoded witness union has its actual reciprocal-probability majorant. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def WitnessRecord.Realizes {R T n : ℕ} {P Q : Finset ℕ} + (d : WitnessRecord n R) (e : PrimeWordEncoding R T P Q) (main : List SignedStep) : Prop := + e.decode.take d.1.1.val = main ∧ + e.decode = recordedWitnessWord main + (fun i => (e.decode.drop (d.1.2.1 i).val).take (d.1.2.2 i).val) ∧ + e.weight = ∏ q ∈ wordDivisorPrimeSupport e.decode, (q : ℝ)⁻¹ + +def EncodedWitnessHybridEvent {R T n : ℕ} {P Q : Finset ℕ} {ι : Type*} + (d : WitnessRecord n R) (e : PrimeWordEncoding R T P Q) + (main : List SignedStep) (p : ι → ℕ) (B h s J : ℕ) + (supply : ℕ → ℕ → Prop) (x : ι → Fin B) : Prop := + e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) (fun i => (d.1.2.2 i).val) + h s J supply ∧ d.Realizes e main ∧ + ∃ y : ι → Fin B, (∀ i, p i ∉ wordDivisorPrimeSupport main → y i = x i) ∧ + ∀ j, AttachedResiduePositiveWord p h + ((e.decode.drop (d.1.2.1 j).val).take (d.1.2.2 j).val) + (wordDisplacement h (main.take (d.2 j).val)) B y + +theorem encoded_witness_hybrid_probability_le {R T n : ℕ} {P Q : Finset ℕ} + {ι : Type*} [Fintype ι] [DecidableEq ι] + (d : WitnessRecord n R) (e : PrimeWordEncoding R T P Q) + (main : List SignedStep) (p : ι → ℕ) (hinj : Function.Injective p) + (B h s J : ℕ) (supply : ℕ → ℕ → Prop) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (hcover : ∀ q ∈ wordDivisorPrimeSupport e.decode, ∃ i, p i = q) : + (∏ q ∈ wordDivisorPrimeSupport main, (q : ℝ)⁻¹) * + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).probability + (EncodedWitnessHybridEvent d e main p B h s J supply) ≤ + if e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) (fun i => (d.1.2.2 i).val) + h s J supply then e.weight else 0 := by + let μ := FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i)) + have hmain : 0 ≤ ∏ q ∈ wordDivisorPrimeSupport main, (q : ℝ)⁻¹ := by positivity + by_cases hw : e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) + (fun i => (d.1.2.2 i).val) h s J supply + · rw [ite_eq_left hw] + by_cases hr : d.Realizes e main + · have hc : ∀ q ∈ wordDivisorPrimeSupport (recordedWitnessWord main + (fun i => (e.decode.drop (d.1.2.1 i).val).take (d.1.2.2 i).val)), + ∃ i, p i = q := by + simpa only [← hr.2.1] using hcover + have hb := main_weight_mul_hybrid_probability_le n B h p hinj hp hpB main + (fun i => (e.decode.drop (d.1.2.1 i).val).take (d.1.2.2 i).val) + (fun i => wordDisplacement h (main.take (d.2 i).val)) hc + have hmono := μ.probability_mono_of_imp + (fun x (he : EncodedWitnessHybridEvent d e main p B h s J supply x) => he.2.2) + apply (mul_le_mul_of_nonneg_left hmono hmain).trans + simpa only [← hr.2.1, ← hr.2.2] using hb + · have he : ∀ x, ¬EncodedWitnessHybridEvent d e main p B h s J supply x := + fun _ hx => hr hx.2.1 + simp only [FiniteLaw.probability, FiniteLaw.average, he, ite_false, mul_zero, + sum_const_zero] + exact e.weight_nonneg + · rw [ite_eq_right hw] + have he : ∀ x, ¬EncodedWitnessHybridEvent d e main p B h s J supply x := + fun _ hx => hw hx.1 + simp only [FiniteLaw.probability, FiniteLaw.average, he, ite_false, mul_zero, + sum_const_zero, le_refl] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedWitnessSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedWitnessSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee5cf561db7801ecee4bb94445c8fa5e4ea12122 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedWitnessSum.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CodedWitnessFiber +import OAI.NumberTheory.TwoPoint.Bounds.PrimeWordEncoding + +namespace OAI + +/-! Sum the numerical singleton-witness event over the complete prime-slot catalog. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +/-- The main path and all attached witnesses are segments of one recorded word. -/ +def PrimeWordEncoding.Witnesses {R T : ℕ} {P Q : Finset ℕ} + (e : PrimeWordEncoding R T P Q) (n mainLength : ℕ) (start len : Fin n → ℕ) + (h s J : ℕ) (supply : ℕ → ℕ → Prop) : Prop := + e.2.1.KindConsistent ∧ e.2.1.RowInjective ∧ + NumericalWitnessEvent (e.decode.take mainLength) + (fun i => (e.decode.drop (start i)).take (len i)) + (fun z => (e.2.2.1 z).val) h s J supply + +theorem encoded_witness_sum_le (R T n K M mainLength h s J : ℕ) + (start len : Fin n → ℕ) (P Q : Finset ℕ) (supply : ℕ → ℕ → Prop) + (hRM : R ≤ M) (hsize : 8 * K ≤ n) + (hP : ∀ p ∈ P, p.Prime) (hV : 1 ≤ primeHarmonicMass P) + (H B : ℕ) (hH : 0 < H) (hB : 1 ≤ B) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ B) + (hdelta : (H : ℝ)⁻¹ + (1 + Real.log B) / H ≤ 1) : + (∑ e : PrimeWordEncoding R T P Q, + if e.Witnesses n mainLength start len h s J supply then e.weight else 0) ≤ + (∑ t : Fin (T + 1), ∑ c : CrudeWordCode R t.val R, + (Fintype.card (WitnessSystemData n M c.tupleClasses) : ℝ) * + primeHarmonicMass P ^ Fintype.card c.tupleClasses * + primeHarmonicMass Q ^ Fintype.card {z : c.usedClasses // z ∉ c.tupleClasses}) * + ((H : ℝ)⁻¹ + (1 + Real.log B) / H) ^ K := by + have hP0 : 0 ≤ primeHarmonicMass P := by unfold primeHarmonicMass; positivity + have hQ0 : 0 ≤ primeHarmonicMass Q := by unfold primeHarmonicMass; positivity + have hlogB : 0 ≤ Real.log (B : ℝ) := Real.log_nonneg (by exact_mod_cast hB) + rw [Fintype.sum_sigma, sum_mul] + apply sum_le_sum + intro t _ + rw [Fintype.sum_sigma, sum_mul] + apply sum_le_sum + intro c _ + rw [Fintype.sum_prod_type] + by_cases hc : c.KindConsistent + · by_cases hi : c.RowInjective + · rw [sum_comm] + let E (a : c.tupleClasses → P) + (b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q) : Prop := + (show PrimeWordEncoding R T P Q from ⟨t, c, a, b⟩).Witnesses + n mainLength start len h s J supply + have hb := c.witness_fiber_reciprocal_bound hc hi hRM mainLength start len P Q E + (fun a b he => he.2.2) hsize hP hV H B hH hB hlo hhi hdelta + have heq : (∑ b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q, + ∑ a : c.tupleClasses → P, + if (show PrimeWordEncoding R T P Q from ⟨t, c, a, b⟩).Witnesses + n mainLength start len h s J supply + then PrimeWordEncoding.weight ⟨t, c, a, b⟩ else 0) = + ∑ b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q, + ∑ a : c.tupleClasses → P, if E a b then + (∏ i, ((a i).val : ℝ)⁻¹) * ∏ j, ((b j).val : ℝ)⁻¹ else 0 := by + apply sum_congr rfl + intro b _ + apply sum_congr rfl + intro a _ + dsimp only [E, PrimeWordEncoding.weight] + rw [reciprocal_product_join] + rw [heq] + exact hb + · have he (a : c.tupleClasses → P) + (b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q) : + ¬(show PrimeWordEncoding R T P Q from ⟨t, c, a, b⟩).Witnesses + n mainLength start len h s J supply := fun he => hi he.2.1 + simp only [he, ite_false, sum_const_zero] + positivity + · have he (a : c.tupleClasses → P) + (b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q) : + ¬(show PrimeWordEncoding R T P Q from ⟨t, c, a, b⟩).Witnesses + n mainLength start len h s J supply := fun he => hc he.1 + simp only [he, ite_false, sum_const_zero] + positivity + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedWitnessUnion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedWitnessUnion.lean new file mode 100644 index 0000000000000000000000000000000000000000..e891924b377223053e59d8c08ffd5b9c2498f6c3 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/EncodedWitnessUnion.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.TwoPoint.Bounds.EncodedWitnessProbability +import OAI.NumberTheory.TwoPoint.Bounds.EncodedPrimeSupport + +namespace OAI + +/-! Sum over all main words without paying a second main-word catalog factor. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem sum_main_encoded_witness_probability_le {R T n : ℕ} {P Q : Finset ℕ} + {ι : Type*} [Fintype ι] [DecidableEq ι] + (d : WitnessRecord n R) (e : PrimeWordEncoding R T P Q) + (F : Finset (List SignedStep)) (p : ι → ℕ) (hinj : Function.Injective p) + (B h s J : ℕ) (supply : ℕ → ℕ → Prop) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (hcover : ∀ q ∈ wordDivisorPrimeSupport e.decode, ∃ i, p i = q) : + (∑ main ∈ F, (∏ q ∈ wordDivisorPrimeSupport main, (q : ℝ)⁻¹) * + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).probability + (EncodedWitnessHybridEvent d e main p B h s J supply)) ≤ + if e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) (fun i => (d.1.2.2 i).val) + h s J supply then e.weight else 0 := by + let μ := FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i)) + let g (main : List SignedStep) := + (∏ q ∈ wordDivisorPrimeSupport main, (q : ℝ)⁻¹) * + μ.probability (EncodedWitnessHybridEvent d e main p B h s J supply) + have hzero (main : List SignedStep) (hne : main ≠ e.decode.take d.1.1.val) : g main = 0 := by + have hfalse : ∀ x, ¬EncodedWitnessHybridEvent d e main p B h s J supply x := by + intro x hx + exact hne hx.2.1.1.symm + simp only [g, FiniteLaw.probability, FiniteLaw.average, hfalse, ite_false, + mul_zero, sum_const_zero] + change ∑ main ∈ F, g main ≤ _ + by_cases hm : e.decode.take d.1.1.val ∈ F + · rw [sum_eq_single_of_mem (e.decode.take d.1.1.val) hm (fun main _ hne => hzero main hne)] + exact encoded_witness_hybrid_probability_le d e _ p hinj B h s J supply hp hpB hcover + · rw [sum_eq_zero (fun main hmain => hzero main (fun he => hm (he ▸ hmain)))] + split_ifs + · exact e.weight_nonneg + · exact le_refl 0 + +theorem main_sum_witness_union_probability_le {R T n : ℕ} {P Q : Finset ℕ} + {ι : Type*} [Fintype ι] [DecidableEq ι] + (F : Finset (List SignedStep)) (p : ι → ℕ) (hinj : Function.Injective p) + (B h s J : ℕ) (supply : ℕ → ℕ → Prop) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (hP : ∀ q ∈ P, q.Prime) (hQ : ∀ q ∈ Q, q.Prime) + (hcover : ∀ q ∈ P ∪ Q, ∃ i, p i = q) : + (∑ main ∈ F, (∏ q ∈ wordDivisorPrimeSupport main, (q : ℝ)⁻¹) * + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).probability + (fun x => ∃ d : WitnessRecord n R, ∃ e : PrimeWordEncoding R T P Q, + EncodedWitnessHybridEvent d e main p B h s J supply x)) ≤ + ∑ d : WitnessRecord n R, ∑ e : PrimeWordEncoding R T P Q, + if e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) (fun i => (d.1.2.2 i).val) + h s J supply then e.weight else 0 := by + let μ := FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i)) + calc + _ ≤ ∑ main ∈ F, ∑ d : WitnessRecord n R, ∑ e : PrimeWordEncoding R T P Q, + (∏ q ∈ wordDivisorPrimeSupport main, (q : ℝ)⁻¹) * + μ.probability (EncodedWitnessHybridEvent d e main p B h s J supply) := by + apply sum_le_sum + intro main _ + simp only [← mul_sum] + apply mul_le_mul_of_nonneg_left _ (prod_nonneg (fun _ _ => by positivity)) + apply (μ.probability_exists_le _).trans + exact sum_le_sum (fun d _ => μ.probability_exists_le _) + _ ≤ _ := by + rw [sum_comm] + apply sum_le_sum + intro d _ + rw [sum_comm] + apply sum_le_sum + intro e _ + exact sum_main_encoded_witness_probability_le d e F p hinj B h s J supply hp hpB + (fun q hq => hcover q (e.divisor_support_subset hP hQ hq)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/EndpointResidueAverage.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/EndpointResidueAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef2628d95b229395de21a117f58d80bc3b6d0a3a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/EndpointResidueAverage.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DivisorEndpointSymmetry +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedRowComparison + +namespace OAI + +/-! Exact equality of the two endpoint deletion costs in the actual +product law. The whole padding weight need not be periodic across an +edge: only the fixed q and tuple divisor tests are transported. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma positivePrimeWeight_residue_congr (S : Finset ℕ) (n m : ℤ) + (hnm : ∀ p ∈ S, (n : ZMod p) = (m : ZMod p)) : + positivePrimeWeight S n = positivePrimeWeight S m := by + unfold positivePrimeWeight + apply prod_congr rfl + intro p hp + have he : (p : ℤ) ∣ n ↔ (p : ℤ) ∣ m := by + rw [← ZMod.intCast_zmod_eq_zero_iff_dvd, ← ZMod.intCast_zmod_eq_zero_iff_dvd, hnm p hp] + simp only [he] + +lemma ProhibitedPrimeFamily.positive_divisor_event_average_endpoint {h J M B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (d q : ℕ) (hd : d.primeFactors ⊆ data.P ∪ data.Q) + (hq : q ∈ retainedPrimeDivisors data.Q) (c : ℤ) (bad : ℤ → Prop) + (hbad : ∀ n m, (∀ p : ↥(data.P ∪ data.Q), (n : ZMod p.val) = (m : ZMod p.val)) → + (bad n ↔ bad m)) : + (data.residueLaw B hB).average (fun x => + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors (data.residueOrigin x) * + if (q : ℤ) ∣ data.residueOrigin x ∧ bad (data.residueOrigin x + (d * q : ℕ) * c) + then 1 else 0) = + (data.residueLaw B hB).average (fun x => + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors (data.residueOrigin x) * + if (q : ℤ) ∣ data.residueOrigin x ∧ bad (data.residueOrigin x) then 1 else 0) := by + let F := fun n : ℤ => actualPaddingCoefficient q * positivePrimeWeight d.primeFactors n * + if (q : ℤ) ∣ n ∧ bad n then 1 else 0 + have hF (n m : ℤ) + (hnm : ∀ p : ↥(data.P ∪ data.Q), (n : ZMod p.val) = (m : ZMod p.val)) : F n = F m := by + have hw := positivePrimeWeight_residue_congr d.primeFactors n m + (fun p hp => hnm ⟨p, hd hp⟩) + have hdiv := squarefree_divisor_congr data.Q q + (retainedPrimeDivisor_squarefree data.Q data.primeQ hq) + (retainedPrimeDivisor_factors data.Q data.primeQ hq) n m + (fun p hp => hnm ⟨p, mem_union_right _ hp⟩) + simp only [F, hw, hdiv, hbad n m hnm] + calc + _ = (data.residueLaw B hB).average (fun x => F (data.residueOrigin x + (d * q : ℕ) * c)) := by + apply congrArg (data.residueLaw B hB).average + funext x + exact positive_divisor_endpoint d q (data.residueOrigin x) c bad + _ = _ := data.residue_average_translate hB F hF ((d * q : ℕ) * c) + +lemma ProhibitedPrimeFamily.prohibited_average_endpoint {h J M B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (s d q : ℕ) (hd : d.primeFactors ⊆ data.P ∪ data.Q) + (hq : q ∈ retainedPrimeDivisors data.Q) (c : ℤ) : + (data.residueLaw B hB).average (fun x => + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors (data.residueOrigin x) * + if (q : ℤ) ∣ data.residueOrigin x ∧ + ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) + (data.residueOrigin x + (d * q : ℕ) * c) then 1 else 0) = + (data.residueLaw B hB).average (fun x => + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors (data.residueOrigin x) * + if (q : ℤ) ∣ data.residueOrigin x ∧ + ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) (data.residueOrigin x) + then 1 else 0) := + data.positive_divisor_event_average_endpoint hB d q hd hq c _ + (fun n m hnm => data.prohibitedSite_congr hB s n m hnm) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/EventualResidueComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/EventualResidueComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..5683a1901e6b44be8ad3cd8cb44e9c36e1b23ad1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/EventualResidueComparison.lean @@ -0,0 +1,119 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteLawParameters +import OAI.NumberTheory.TwoPoint.Bounds.ScalarComparison + +namespace OAI + +/-! The explicit polynomial bit and independence budgets give the +finite-interval circuit comparison required in the graph application. -/ + +namespace TwoPointCorrelations + +open Finset Filter + +theorem BravermanDepth22Input.eventually_residue_comparison (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (m : ℕ) (s : Fin m → ℕ) [∀ i, NeZero (s i)], + 0 < m → (m : ℝ) ≤ Real.exp L + 1 → + Pairwise (fun i j => (s i).Coprime (s j)) → + (∀ i, (s i : ℝ) ≤ Real.exp L) → + ∀ (n : ℕ) (coord : Fin n → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) (c : AC0Circuit n), + c.depth ≤ 20 → (c.size : ℝ) ≤ Real.exp (L ^ 6) → + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + |uniformAverage (fun x : Fin N => + eventIndicator (residueCircuitEvent s coord test c) + (fun i => (a + x.val : ZMod (s i)))) - + uniformAverage (eventIndicator (residueCircuitEvent s coord test c))| ≤ + Real.exp (-(L ^ 10)) := by + obtain ⟨K, C, hK, hC, hcompare⟩ := hBr.finite_residue_comparison + let T := 17 * C + 1 + let A := T + 1002 + refine ⟨A, by omega, ?_⟩ + filter_upwards [eventually_ge_atTop (2 : ℝ), eventually_encoded_size_bound, + eventually_bit_count_bound, eventually_braverman_budget K C, + eventually_fourier_budget T A (by omega) (by omega), + eventually_total_comparison_error] with L hL hsize hbits hbr hfourier herr + intro m s _ hm hmexp hcop hs n coord test c hc hcsize a N hN + let B := ⌈L ^ 15⌉₊ + let t := ⌈L ^ T⌉₊ + have hLone : 1 ≤ L := by linarith + have hLp : 0 ≤ L := by linarith + have hBone : 0 < B := by + have hBbound := (ceil_pow_bounds hLone 15).1 + have hone : (1 : ℝ) ≤ L ^ 15 := one_le_pow₀ hLone + have hBp : (0 : ℝ) < B := by dsimp only [B]; linarith + exact_mod_cast hBp + have hBsize0 : ((encodeResidueCircuit s B coord test c).size : ℝ) ≤ + (1 + (2 : ℝ) ^ B * (1 + B)) * c.size := by + exact_mod_cast encodeResidueCircuit_size (B := B) s coord test c + have hBsize : ((encodeResidueCircuit s B coord test c).size : ℝ) ≤ Real.exp (L ^ 17) := + hBsize0.trans (hsize B rfl c.size hcsize) + have hBsizeone : (1 : ℝ) ≤ (encodeResidueCircuit s B coord test c).size := by + exact_mod_cast (encodeResidueCircuit s B coord test c).size_pos + have ht := hbr (encodeResidueCircuit s B coord test c).size hBsizeone hBsize + have hnbits := hbits m B hmexp rfl + have hfour := hfourier t (m * B) N rfl hnbits hN + have hNpos : 0 < N := by + have hNp : (0 : ℝ) < N := (Real.exp_pos _).trans_le hN + exact_mod_cast hNp + have heps : Real.exp (-(L ^ 11)) ≤ 1 / 2 := by + have hone : (1 : ℝ) ≤ L ^ 11 := one_le_pow₀ hLone + have he : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + rw [Real.exp_neg] + exact (inv_anti₀ (by norm_num : (0 : ℝ) < 2) + (he.trans (Real.exp_le_exp.mpr hone))).trans_eq (by norm_num) + have hb := hcompare m B (Nat.mul_pos hm hBone) s hcop n coord test c hc + (Real.exp (-(L ^ 11))) (Real.exp_pos _) heps t ht a N hNpos (Real.exp L) + (Real.exp (-(L ^ 11))) (Real.one_le_exp hLp) hs hfour + have hsum : (∑ i : Fin m, (s i : ℝ)) ≤ Real.exp (3 * L) := by + have hbound : (∑ i : Fin m, (s i : ℝ)) ≤ m * Real.exp L := by + calc + _ ≤ ∑ _i : Fin m, Real.exp L := sum_le_sum (fun i _ => hs i) + _ = _ := by simp + have hE : (1 : ℝ) ≤ Real.exp L := Real.one_le_exp hLp + have hE2 : (2 : ℝ) ≤ Real.exp L := by + linarith [Real.add_one_le_exp L] + calc + _ ≤ (Real.exp L + 1) * Real.exp L := + hbound.trans (mul_le_mul_of_nonneg_right hmexp (Real.exp_pos _).le) + _ ≤ Real.exp L * Real.exp L * Real.exp L := by nlinarith + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + apply hb.trans + simpa only [← sum_div, Nat.cast_pow, Nat.cast_ofNat, mul_div_assoc] using herr B rfl _ hsum + +/-- Scalar expansions preserve their signed coefficients through the +finite-law comparison; only their total absolute mass enters the error. -/ +theorem BravermanDepth22Input.eventually_scalar_residue_comparison + (hBr : BravermanDepth22Input) (C : ℝ) (hC : 0 ≤ C) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (m : ℕ) (s : Fin m → ℕ) [∀ i, NeZero (s i)], + 0 < m → (m : ℝ) ≤ Real.exp L + 1 → + Pairwise (fun i j => (s i).Coprime (s j)) → + (∀ i, (s i : ℝ) ≤ Real.exp L) → + ∀ (ι : Type) [Fintype ι] (n : ℕ) (coord : Fin n → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) + (c : ι → AC0Circuit n) (coeff : ι → ℝ), + (∀ i, (c i).depth ≤ 20) → (∀ i, ((c i).size : ℝ) ≤ Real.exp (L ^ 6)) → + (∑ i, |coeff i|) ≤ Real.exp (C * L ^ 5) → + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + |uniformAverage (fun x : Fin N => ∑ i, coeff i * + eventIndicator (residueCircuitEvent s coord test (c i)) + (fun j => (a + x.val : ZMod (s j)))) - + uniformAverage (fun r => ∑ i, coeff i * + eventIndicator (residueCircuitEvent s coord test (c i)) r)| ≤ + Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hevent⟩ := hBr.eventually_residue_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hevent, eventually_scalar_error C hC] with L hevent herror + intro m s _ hm hmexp hcop hs ι _ n coord test c coeff hc hsize hcoeff a N hN + have hb := scalar_average_comparison_uniform + (fun i (x : Fin N) => eventIndicator (residueCircuitEvent s coord test (c i)) + (fun j => (a + x.val : ZMod (s j)))) + (fun i r => eventIndicator (residueCircuitEvent s coord test (c i)) r) + coeff (Real.exp (-(L ^ 10))) + (fun i => hevent m s hm hmexp hcop hs n coord test (c i) (hc i) (hsize i) a N hN) + exact hb.trans ((mul_le_mul_of_nonneg_right hcoeff (Real.exp_pos _).le).trans herror) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ExistentialWitnesses.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ExistentialWitnesses.lean new file mode 100644 index 0000000000000000000000000000000000000000..5147e52413d932e626db27cfaf966c2cf21f7938 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ExistentialWitnesses.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResampledWitnesses + +namespace OAI + +/-! Witness choices are eliminated by the existing relation metadata union. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +/-- The marked labels and attachment positions may depend on the numerical sample. -/ +def HasResampledWitnesses {n : ℕ} {ι : Type*} [DecidableEq ι] + (main : LabeledPrimeWord ι) (word : Fin n → LabeledPrimeWord ι) + (h s J : ℕ) (supply : ℕ → ℕ → Prop) (value : ι → ℕ) : Prop := + ∃ (mark : Fin n → ι) (attachment position : Fin n → ℕ), + Monotone attachment ∧ (∀ i, attachment i ≤ main.word.length) ∧ + ResampledWitnessEvent main word h s J supply mark attachment position value + +theorem has_resampled_witnesses_reciprocal_bound {n K h s J N : ℕ} + {supply : ℕ → ℕ → Prop} {ι : Type*} [Fintype ι] [DecidableEq ι] + (main : LabeledPrimeWord ι) (word : Fin n → LabeledPrimeWord ι) + (hsize : 8 * K ≤ n) (hmainLength : main.word.length ≤ N) + (hwordLength : ∀ i, (word i).word.length ≤ N) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hV : 1 ≤ primeHarmonicMass P) + (H B : ℕ) (hH : 0 < H) (hB : 1 ≤ B) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ B) + (hdelta : (H : ℝ)⁻¹ + (1 + Real.log B) / H ≤ 1) : + (∑ a : ι → P, if HasResampledWitnesses main word h s J supply + (fun z => (a z).val) then ∏ z, ((a z).val : ℝ)⁻¹ else 0) ≤ + (Fintype.card (WitnessSystemData n N ι) : ℝ) * primeHarmonicMass P ^ Fintype.card ι * + ((H : ℝ)⁻¹ + (1 + Real.log B) / H) ^ K := by + apply le_trans _ (witness_metadata_reciprocal_bound n N K h main word P hP hV + H B hH hB hlo hhi hdelta) + apply sum_le_sum + intro a _ + by_cases he : HasResampledWitnesses main word h s J supply (fun z => (a z).val) + · obtain ⟨mark, attachment, position, horder, hbound, hevent⟩ := he + have hd := resampled_witness_metadata main word mark attachment position hsize horder + hbound hmainLength hwordLength (fun z => (a z).val) hevent + have hd' : ∃ d : WitnessSystemData n N ι, K ≤ d.chosen.card ∧ + d.Triangular main word h ∧ d.Holds main word h (integerPrimeAssignment Subtype.val a) := hd + simp only [ite_eq_left (show HasResampledWitnesses main word h s J supply + (fun z => (a z).val) from ⟨mark, attachment, position, horder, hbound, hevent⟩), + ite_eq_left hd'] + exact le_rfl + · simp only [he, ite_false] + split_ifs <;> positivity + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ExtractedWindowScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ExtractedWindowScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c3b97358f0b0fd079513edf68971ce7c8911e03 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ExtractedWindowScale.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeAlphabetSize +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftEndpoints + +namespace OAI + +/-! An absolute long-interval scale survives extraction of every bounded +padding divisor and every partial tuple product, including both floor operations. -/ + +namespace TwoPointCorrelations + +lemma extracted_window_lower (L T : ℝ) (u : ℕ) (hL : 1000 ≤ L) + (hu : 0 < u) (hT : Real.exp (L ^ (1000 : ℝ)) ≤ T) + (hupper : (u : ℝ) ≤ Real.exp (100 * L ^ 2 + 2 * L)) : + Real.exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ)) ≤ ((⌊T⌋₊ / u : ℕ) : ℝ) := by + have hLp : 0 < L := by linarith + have hLone : 1 ≤ L := by linarith + have hp : L ^ (4 : ℕ) ≤ L ^ (1000 : ℝ) := by + simpa only [Real.rpow_ofNat] using + Real.rpow_le_rpow_of_exponent_le hLone (show (4 : ℝ) ≤ 1000 by norm_num) + have hsq : (1000 : ℝ) ≤ L ^ 2 := by nlinarith + have hfour : 1000 * L ^ 2 ≤ L ^ (4 : ℕ) := by + calc + _ ≤ (L ^ 2) * (L ^ 2) := mul_le_mul_of_nonneg_right hsq (sq_nonneg L) + _ = _ := by ring + have hgap : 3 ≤ (1 / 2 : ℝ) * L ^ (1000 : ℝ) - (100 * L ^ 2 + 2 * L) := by + nlinarith + have he : 4 ≤ Real.exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ) - (100 * L ^ 2 + 2 * L)) := by + linarith [Real.add_one_le_exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ) - (100 * L ^ 2 + 2 * L))] + let E := Real.exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ)) + have hE : 1 ≤ E := Real.one_le_exp (by positivity) + have hup : (0 : ℝ) < u := by exact_mod_cast hu + have huone : (1 : ℝ) ≤ u := by exact_mod_cast hu + have hEu : 1 ≤ E * u := one_le_mul_of_one_le_of_one_le hE huone + have hsmall : 4 * (E * u) ≤ T := by + apply le_trans _ hT + calc + _ ≤ 4 * (E * Real.exp (100 * L ^ 2 + 2 * L)) := by gcongr + _ = 4 * Real.exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ) + (100 * L ^ 2 + 2 * L)) := by + congr 1 + exact (Real.exp_add _ _).symm + _ ≤ Real.exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ) - (100 * L ^ 2 + 2 * L)) * + Real.exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ) + (100 * L ^ 2 + 2 * L)) := by + exact mul_le_mul_of_nonneg_right he (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + have hfloor : 2 * (E * u) ≤ (⌊T⌋₊ : ℝ) := by + have ht := Nat.lt_floor_add_one T + nlinarith + have hdiv : (⌊T⌋₊ : ℝ) < (u : ℝ) * (((⌊T⌋₊ / u : ℕ) : ℝ) + 1) := by + exact_mod_cast Nat.lt_mul_div_succ ⌊T⌋₊ hu + have hratio : 2 * E < ((⌊T⌋₊ / u : ℕ) : ℝ) + 1 := by + apply (mul_lt_mul_iff_right₀ hup).mp + nlinarith + change E ≤ _ + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FamilyPatternSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FamilyPatternSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..efe502ec95daa9eb5afd49f5457cb9ba04c09980 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FamilyPatternSum.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PatternHarmonicSum +import OAI.NumberTheory.TwoPoint.Bounds.SplitBadWordSum + +namespace OAI + +/-! Reciprocal pattern sums for an arbitrary finite family of prime pools. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem same_family_patterns_reciprocal_sum {I : Type*} [Fintype I] [DecidableEq I] + {R : ℕ} (P : I → Finset ℕ) + (F : Finset (((j : I) → Fin R → P j))) (template : ((j : I) → Fin R → P j)) + (hpattern : ∀ w ∈ F, ∀ j i k, w j i = w j k ↔ template j i = template j k) : + (∑ w ∈ F, (∏ j, ∏ p ∈ univ.image (w j), (p.val : ℝ)⁻¹)) ≤ + ∏ j, primeHarmonicMass (P j) ^ (univ.image (template j)).card := by + let C (j : I) := univ.image (template j) + let rep (j : I) (c : C j) : Fin R := Classical.choose (mem_image.mp c.property) + have hrep (j : I) (c : C j) : template j (rep j c) = c.val := + (Classical.choose_spec (mem_image.mp c.property)).2 + let classify (j : I) (i : Fin R) : C j := + ⟨template j i, mem_image.mpr ⟨i, mem_univ _, rfl⟩⟩ + have hconstant (w : ((j : I) → Fin R → P j)) (hw : w ∈ F) (j : I) (i : Fin R) : + w j i = w j (rep j (classify j i)) := + (hpattern w hw j i _).mpr (hrep j (classify j i)).symm + let encode (w : ((j : I) → Fin R → P j)) : (j : I) → C j → P j := + fun j c => w j (rep j c) + have hinj : Set.InjOn encode F := by + intro w hw v hv he + funext j i + exact (hconstant w hw j i).trans + ((congrFun (congrFun he j) (classify j i)).trans (hconstant v hv j i).symm) + have hweight (w : ((j : I) → Fin R → P j)) (hw : w ∈ F) : + (∏ j, ∏ p ∈ univ.image (w j), (p.val : ℝ)⁻¹) = ∏ j, ∏ c : C j, ((encode w j c).val : ℝ)⁻¹ := by + apply prod_congr rfl + intro j _ + have himage : univ.image (fun c : C j => w j (rep j c)) = univ.image (w j) := by + ext p + constructor + · rintro hp + obtain ⟨c, _, rfl⟩ := mem_image.mp hp + exact mem_image.mpr ⟨rep j c, mem_univ _, rfl⟩ + · rintro hp + obtain ⟨i, _, rfl⟩ := mem_image.mp hp + exact mem_image.mpr ⟨classify j i, mem_univ _, (hconstant w hw j i).symm⟩ + rw [← himage, prod_image] + intro c _ d _ hcd + apply Subtype.ext + exact (hrep j c).symm.trans (((hpattern w hw j _ _).mp hcd).trans (hrep j d)) + calc + _ = ∑ z ∈ F.image encode, ∏ j, ∏ c : C j, ((z j c).val : ℝ)⁻¹ := by + rw [sum_image hinj] + exact sum_congr rfl hweight + _ ≤ ∑ z : (j : I) → C j → P j, ∏ j, ∏ c : C j, ((z j c).val : ℝ)⁻¹ := by + apply sum_le_sum_of_subset_of_nonneg (subset_univ _) + intro z _ _ + positivity + _ = ∏ j, ∑ z : C j → P j, ∏ c, ((z c).val : ℝ)⁻¹ := by rw [Fintype.prod_sum] + _ = _ := by + apply prod_congr rfl + intro j _ + simpa only [Fintype.card_coe, C] using sum_reciprocal_assignments (ι := C j) (P j) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FinalCorrelationBound.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FinalCorrelationBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad14b1f8732bc2c2d6267856624296ccb15fb6c7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FinalCorrelationBound.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FinalErrorScale +import OAI.NumberTheory.TwoPoint.Bounds.QuantitativeCenteringAssembly + +namespace OAI + +/-! Arithmetic assembly of the centering, endpoint deletion, and retained +spectral estimates at the manuscript's final parameter choice. -/ + +namespace TwoPointCorrelations + +lemma quantitative_deletion_small (L W C : ℝ) (J : ℕ) + (hL : 1 ≤ L) (hW : 1 ≤ W) (hC : 0 ≤ C) + (hJ : 60 * (J : ℝ) ≤ Real.log L) + (hr : Real.exp (-L ^ (9 / 10 : ℝ)) ≤ Real.exp (-(J : ℝ))) : + (2 : ℝ) ^ J * (C / Real.exp (4 * J) + L ^ (-100 : ℝ) + + Real.exp (-2 * W * J)) + 2 * Real.exp (-L ^ (9 / 10 : ℝ)) ≤ + (C + 4) * Real.exp (-(J : ℝ)) := by + obtain ⟨_, hk, hl, hw⟩ := quantitative_small_terms L W J hL hW hJ + have hc := mul_le_mul_of_nonneg_left hk hC + have he : (2 : ℝ) ^ J * (C / Real.exp (4 * J)) = + C * ((2 : ℝ) ^ J * Real.exp (-4 * (J : ℝ))) := by + rw [show (4 : ℝ) * J = -(-4 * (J : ℝ)) by ring, Real.exp_neg] + simp only [div_eq_mul_inv, inv_inv] + ring + rw [← he] at hc + nlinarith + +lemma reciprocal_cutoff_saving (L W X : ℝ) (A : ℕ) + (hL : 1 ≤ L) (hW : 1 ≤ W) (hA : A ≠ 0) + (hX : Real.exp (L ^ A) ≤ X) : + 1 / X ≤ Real.exp (-(primeSupplyCount W L : ℝ)) := by + have hXp : 0 < X := (Real.exp_pos _).trans_le hX + have hJ := primeSupplyCount_le_log W L hW hL + have hlog : Real.log L ≤ L := + (Real.log_le_sub_one_of_pos (by linarith)).trans (by linarith) + have hpow : L ≤ L ^ A := le_self_pow₀ hL hA + calc + 1 / X ≤ 1 / Real.exp (L ^ A) := one_div_le_one_div_of_le (Real.exp_pos _) hX + _ = Real.exp (-(L ^ A)) := by rw [Real.exp_neg, one_div] + _ ≤ _ := Real.exp_le_exp.mpr (by linarith) + +lemma correlation_normalized_bound (raw retained F : ℂ) + (S₀ M η Cret Cdel Ccenter Xinv : ℝ) + (hS : 0 < S₀) (_hM : 0 ≤ M) (hη : 0 ≤ η) + (_hretC : 0 ≤ Cret) (hdelC : 0 ≤ Cdel) (hcenterC : 0 ≤ Ccenter) + (hmass : M / 2 ≤ S₀) (hX : Xinv ≤ η) + (hret : ‖retained‖ / S₀ ≤ Cret * η) + (hdel : ‖raw - retained‖ ≤ 2 * M * ((Cdel + 4) * η)) + (hcenter : ‖raw - (S₀ : ℂ) * F‖ ≤ + Ccenter * η * M + S₀ * (2 * η + Xinv)) : + ‖F‖ ≤ (Cret + 4 * Cdel + 2 * Ccenter + 19) * η := by + have hr := (div_le_iff₀ hS).mp hret + have hmc : Ccenter * η * M ≤ 2 * Ccenter * η * S₀ := by + have hx := mul_le_mul_of_nonneg_left (show M ≤ 2 * S₀ by linarith) + (mul_nonneg hcenterC hη) + nlinarith + have hmd : 2 * M * ((Cdel + 4) * η) ≤ + 4 * (Cdel + 4) * η * S₀ := by + have hx := mul_le_mul_of_nonneg_left (show M ≤ 2 * S₀ by linarith) + (show 0 ≤ 2 * ((Cdel + 4) * η) by positivity) + nlinarith + have ht : ‖(S₀ : ℂ) * F‖ ≤ + ‖raw - (S₀ : ℂ) * F‖ + ‖raw - retained‖ + ‖retained‖ := by + calc + _ = ‖raw - (raw - (S₀ : ℂ) * F)‖ := by congr 1; ring + _ ≤ ‖raw‖ + ‖raw - (S₀ : ℂ) * F‖ := norm_sub_le _ _ + _ ≤ (‖raw - retained‖ + ‖retained‖) + ‖raw - (S₀ : ℂ) * F‖ := by + gcongr + calc + ‖raw‖ = ‖(raw - retained) + retained‖ := by rw [sub_add_cancel] + _ ≤ _ := norm_add_le _ _ + _ = _ := by ring + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hS] at ht + have hxe := mul_le_mul_of_nonneg_left hX hS.le + have hf : S₀ * ‖F‖ ≤ S₀ * ((Cret + 4 * Cdel + 2 * Ccenter + 19) * η) := by + nlinarith + exact (mul_le_mul_iff_right₀ hS).mp hf + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FinalErrorScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FinalErrorScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..405875010cbf14f72c958a732682bd3e7c27831a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FinalErrorScale.lean @@ -0,0 +1,42 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QuantitativeParameterChoice + +namespace OAI + +/-! The residual rare-site and summed block-boundary errors are below +the same exp(-J) saving as the principal terms. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma eventually_rare_error_saving (W : ℝ) (hW : 1 ≤ W) : + ∀ᶠ L : ℝ in atTop, Real.exp (-L ^ (9 / 10 : ℝ)) ≤ + Real.exp (-(primeSupplyCount W L : ℝ)) := by + have hs := (isLittleO_log_rpow_atTop (show (0 : ℝ) < 9 / 10 by norm_num)).bound + (show (0 : ℝ) < 1 by norm_num) + filter_upwards [eventually_ge_atTop (1 : ℝ), hs] with L hL hs + rw [Real.norm_eq_abs, abs_of_nonneg (Real.log_nonneg hL), Real.norm_eq_abs, + abs_of_pos (Real.rpow_pos_of_pos (by linarith : 0 < L) _), one_mul] at hs + apply Real.exp_le_exp.mpr + have hj := primeSupplyCount_le_log W L hW hL + linarith + +lemma eventually_bin_error_saving (W : ℝ) (hW : 1 ≤ W) : + ∀ᶠ L : ℝ in atTop, + (L / Real.exp (-(primeSupplyCount W L : ℝ))) * Real.exp (-L) ≤ + Real.exp (-(primeSupplyCount W L : ℝ)) := by + filter_upwards [eventually_ge_atTop (1 : ℝ), + eventually_sublinear_log_cost 0 3 (by norm_num) (by norm_num)] with L hL hs + simp only [Real.rpow_zero, mul_one] at hs + have hLp : 0 < L := by linarith + have hj := primeSupplyCount_le_log W L hW hL + have he : L / Real.exp (-(primeSupplyCount W L : ℝ)) = + Real.exp (Real.log L + (primeSupplyCount W L : ℝ)) := by + rw [Real.exp_add, Real.exp_log hLp, Real.exp_neg, div_inv_eq_mul] + rw [he, ← Real.exp_add] + apply Real.exp_le_exp.mpr + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteAverages.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteAverages.lean new file mode 100644 index 0000000000000000000000000000000000000000..af7cd6b4e3ced8fb417078cc22d26c67e8d87901 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteAverages.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CRTComparison +import Mathlib.Logic.Equiv.Prod + +namespace OAI + +/-! Elementary finite averaging identities used to assemble encoded marginals. -/ + +namespace TwoPointCorrelations + +open Finset + +noncomputable def uniformAverage {α : Type*} [Fintype α] (f : α → ℝ) : ℝ := + (∑ x, f x) / Fintype.card α + +@[simp] lemma uniformAverage_const {α : Type*} [Fintype α] [Nonempty α] (c : ℝ) : + uniformAverage (fun _ : α => c) = c := by simp [uniformAverage] + +lemma uniformAverage_equiv {α β : Type*} [Fintype α] [Fintype β] + (e : α ≃ β) (f : β → ℝ) : uniformAverage (fun x => f (e x)) = uniformAverage f := by + unfold uniformAverage + rw [e.sum_comp, Fintype.card_congr e] + +lemma uniformAverage_prod {α β : Type*} [Fintype α] [Fintype β] + (f : α → β → ℝ) : + uniformAverage (fun x : α × β => f x.1 x.2) = + uniformAverage (fun x => uniformAverage (f x)) := by + unfold uniformAverage + rw [Fintype.sum_prod_type', Fintype.card_prod, Nat.cast_mul, ← Finset.sum_div] + rw [div_div] + congr 1 + ring + +/-- A uniform independent family restricted to selected coordinates remains +uniform; coordinates outside the selection integrate out exactly. -/ +lemma uniformAverage_restrict {ι : Type*} [Fintype ι] [DecidableEq ι] + (β : ι → Type*) [∀ i, Fintype (β i)] [∀ i, Nonempty (β i)] (S : Finset ι) + (f : (∀ i : S, β i) → ℝ) : + uniformAverage (fun x : ∀ i, β i => f (fun i : S => x i)) = uniformAverage f := by + let e := Equiv.piEquivPiSubtypeProd (fun i => i ∈ S) β + calc + _ = uniformAverage (fun x : (∀ i : S, β i) × (∀ i : {i // i ∉ S}, β i) => f x.1) := + uniformAverage_equiv e (fun x => f x.1) + _ = uniformAverage f := by + rw [uniformAverage_prod (fun (x : ∀ i : S, β i) + (_y : ∀ i : {i // i ∉ S}, β i) => f x)] + simp only [uniformAverage_const] + +lemma abs_uniformAverage_le_one {α : Type*} [Fintype α] (f : α → ℝ) + (hf : ∀ x, |f x| ≤ 1) : |uniformAverage f| ≤ 1 := by + unfold uniformAverage + rw [abs_div, show |(Fintype.card α : ℝ)| = (Fintype.card α : ℝ) from + abs_of_nonneg (Nat.cast_nonneg _)] + calc + |∑ x, f x| / (Fintype.card α : ℝ) ≤ + (∑ x, |f x|) / (Fintype.card α : ℝ) := + div_le_div_of_nonneg_right (Finset.abs_sum_le_sum_abs _ _) (Nat.cast_nonneg _) + _ ≤ (∑ _x : α, (1 : ℝ)) / (Fintype.card α : ℝ) := + div_le_div_of_nonneg_right (Finset.sum_le_sum (fun x _ => hf x)) (Nat.cast_nonneg _) + _ ≤ 1 := by simp [div_self_le_one] + +/-- Grouping an interval average by its actual CRT residue vector. -/ +lemma crtJointProbability_expectation {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ZMod (∏ i, s i)) (N : ℕ) (F : (∀ i, ZMod (s i)) → ℝ) : + (∑ r, crtJointProbability s hcop A N r * F r) = + uniformAverage (fun j : Fin N => + F (ZMod.prodEquivPi s hcop (A + (j.val : ZMod (∏ i, s i))))) := by + simp_rw [crtJointProbability_eq_count, div_mul_eq_mul_div, Finset.sum_mul] + rw [← Finset.sum_div, Finset.sum_comm] + simp only [ite_mul, one_mul, zero_mul, Finset.sum_ite_eq, Finset.mem_univ, ite_true] + unfold uniformAverage + rw [Fintype.card_fin] + congr 1 + exact (Fin.sum_univ_eq_sum_range + (fun j : ℕ => F (ZMod.prodEquivPi s hcop (A + (j : ZMod (∏ i, s i))))) N).symm + +lemma crtUniform_expectation {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] (F : (∀ i, ZMod (s i)) → ℝ) : + (∑ r, crtUniform s r * F r) = uniformAverage F := by + unfold crtUniform uniformAverage + rw [← Finset.mul_sum] + simp only [Fintype.card_pi, ZMod.card, Nat.cast_prod] + ring + +/-- Uniform translated interval averages of any bounded observable of the +selected residue coordinates differ from the product law by at most `D/N`. -/ +theorem crt_observable_difference {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ZMod (∏ i, s i)) (N : ℕ) (hN : 0 < N) + (F : (∀ i, ZMod (s i)) → ℝ) (hF : ∀ r, |F r| ≤ 1) : + |uniformAverage (fun j : Fin N => + F (ZMod.prodEquivPi s hcop (A + (j.val : ZMod (∏ i, s i))))) - + uniformAverage F| ≤ (∏ i, s i : ℕ) / (N : ℝ) := by + have h := finite_observable_difference (crtJointProbability s hcop A N) (crtUniform s) F hF + rw [crtJointProbability_expectation, crtUniform_expectation] at h + calc + _ ≤ 2 * finiteTotalVariation (crtJointProbability s hcop A N) (crtUniform s) := h + _ = 2 * residueTotalVariation A N := by rw [crtJointProbability_totalVariation] + _ ≤ 2 * ((∏ i, s i : ℕ) / (2 * (N : ℝ))) := + mul_le_mul_of_nonneg_left (residueTotalVariation_le A N hN) (by norm_num) + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteDesignationSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteDesignationSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..fb6600b79e117907d29638692419c8da94126b4b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteDesignationSum.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.TwoPoint.Walks.ManyUnlitCatalog +import OAI.NumberTheory.TwoPoint.Walks.GoodWordWeightedSum + +namespace OAI + +/-! Finite designation catalogs may be indexed by numerical words of varying length. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +/-- Each admissible designation set is a subset of all slots. The complete +catalog therefore costs at most one binary choice per slot. -/ +lemma designation_catalog_weight {I τ : Type*} [DecidableEq I] [Fintype τ] + (F : Finset I) (allowed : I → Finset (Finset τ)) (weight : I → ℝ) + (hw : ∀ i, 0 ≤ weight i) : + (∑ a ∈ F.sigma allowed, weight a.1) ≤ + (2 : ℝ) ^ Fintype.card τ * ∑ i ∈ F, weight i := by + rw [sum_sigma] + rw [mul_sum] + apply sum_le_sum + intro i _ + have hc : (allowed i).card ≤ 2 ^ Fintype.card τ := by + exact (card_le_card (subset_univ _)).trans_eq (by simp) + simp only [sum_const, nsmul_eq_mul] + exact mul_le_mul_of_nonneg_right (by exact_mod_cast hc) (hw i) + +/-- The threshold is uniform in the finite catalog and in its index type. +It can therefore be used for word lengths and prime pools varying with L. -/ +theorem eventually_many_unlit_finsets (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ (I : Type) [DecidableEq I] (F : Finset I) + (E : I → ℕ) (H : ℝ) (weight : I → ℝ), + (∀ i ∈ F, 0 ≤ weight i) → + (∑ i ∈ F, weight i) ≤ Real.exp (C * L * (Real.log L) ^ 2) → + (∀ i ∈ F, L ^ (1 / 50 : ℝ) ≤ 2 * E i) → + Real.exp (L ^ (199 / 200 : ℝ)) ≤ H → + (∑ i ∈ F, weight i * (H⁻¹) ^ E i) ≤ Real.exp (-L ^ (101 / 100 : ℝ)) := by + filter_upwards [eventually_many_unlit_decay C hC] with L hdecay + intro I _ F E H weight hw hmass hE hH + let scale := Real.exp (C * L * (Real.log L) ^ 2) + let target := Real.exp (-L ^ (101 / 100 : ℝ)) + have hs : 0 < scale := Real.exp_pos _ + have hi (i) (hmem : i ∈ F) : (H⁻¹) ^ E i ≤ target / scale := by + apply (le_div_iff₀ hs).mpr + simpa only [mul_comm] using hdecay (E i) H (hE i hmem) hH + calc + _ ≤ ∑ i ∈ F, weight i * (target / scale) := + sum_le_sum (fun i hmem => mul_le_mul_of_nonneg_left (hi i hmem) (hw i hmem)) + _ = (∑ i ∈ F, weight i) * (target / scale) := (sum_mul _ _ _).symm + _ ≤ scale * (target / scale) := mul_le_mul_of_nonneg_right hmass (by positivity) + _ = _ := mul_div_cancel₀ _ hs.ne' + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteLawMapping.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteLawMapping.lean new file mode 100644 index 0000000000000000000000000000000000000000..82546e009538d13947dfbfccbf4b45646c13b2da --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteLawMapping.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.TwoPoint.Bounds.IndependentSampling + +namespace OAI + +/-! Finite pushforward identities, used to identify the actual two-selection +padding experiment with its three-point difference law. -/ + +namespace TwoPointCorrelations.FiniteLaw + +open Finset +open scoped Classical + +variable {α β ι : Type*} [Fintype α] [Fintype β] [Fintype ι] + +lemma average_fibers (μ : FiniteLaw α) (g : α → β) (F : β → ℝ) : + μ.average (fun x => F (g x)) = ∑ y, μ.probability (fun x => g x = y) * F y := by + calc + _ = μ.average (fun x => ∑ y, if g x = y then F y else 0) := by + congr 1 + funext x + simp + _ = _ := by + rw [average_sum] + apply sum_congr rfl + intro y _ + simp [average, probability, sum_mul, mul_ite, ite_mul] + +lemma independent_average_map [DecidableEq ι] (μ : ι → FiniteLaw α) + (ν : ι → FiniteLaw β) (g : ι → α → β) + (hg : ∀ i y, (μ i).probability (fun x => g i x = y) = (ν i).weight y) + (F : (ι → β) → ℝ) : + (independent μ).average (fun x => F (fun i => g i (x i))) = + (independent ν).average F := by + rw [average_fibers] + unfold average + apply sum_congr rfl + intro y _ + congr 1 + have he : (fun x : ι → α => (fun i => g i (x i)) = y) = + (fun x => ∀ i, g i (x i) = y i) := by + funext x + exact propext funext_iff + rw [he, independent_probability_all μ (fun i x => g i x = y i)] + simp only [hg, independent] + +noncomputable def dependentProduct (μ : FiniteLaw α) (ν : α → FiniteLaw β) : + FiniteLaw (α × β) where + weight x := μ.weight x.1 * (ν x.1).weight x.2 + nonneg x := mul_nonneg (μ.nonneg _) ((ν _).nonneg _) + total := by + simp only [Fintype.sum_prod_type, ← mul_sum, total, mul_one] + +lemma average_dependentProduct (μ : FiniteLaw α) (ν : α → FiniteLaw β) + (F : α × β → ℝ) : + (μ.dependentProduct ν).average F = + μ.average (fun x => (ν x).average (fun y => F (x, y))) := by + simp only [average, dependentProduct, Fintype.sum_prod_type, mul_sum, mul_assoc] + +end TwoPointCorrelations.FiniteLaw + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteLawParameters.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteLawParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e3df581171cd4c0689c62f947ac12bfe2a680e4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteLawParameters.lean @@ -0,0 +1,220 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteResidueComparison +import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics + +namespace OAI + +/-! Explicit large-scale choices for the finite residue comparison. -/ + +namespace TwoPointCorrelations + +open Filter Finset + +/-- Fixed coefficients are absorbed by increasing a positive integer power. -/ +lemma eventually_const_mul_pow_le (p q : ℕ) (hpq : p < q) (c : ℝ) : + ∀ᶠ L : ℝ in atTop, c * L ^ p ≤ L ^ q := by + filter_upwards [eventually_ge_atTop 1, eventually_ge_atTop c] with L hL hc + calc + c * L ^ p ≤ L * L ^ p := mul_le_mul_of_nonneg_right hc (pow_nonneg (by linarith) _) + _ = L ^ (p + 1) := by rw [pow_succ]; ring + _ ≤ L ^ q := pow_le_pow_right₀ hL hpq + +lemma ceil_pow_bounds {L : ℝ} (hL : 1 ≤ L) (k : ℕ) : + L ^ k ≤ (⌈L ^ k⌉₊ : ℝ) ∧ (⌈L ^ k⌉₊ : ℝ) ≤ 2 * L ^ k := by + have hp : 1 ≤ L ^ k := one_le_pow₀ hL + exact ⟨Nat.le_ceil _, (Nat.ceil_lt_add_one (by positivity : 0 ≤ L ^ k)).le.trans (by linarith)⟩ + +/-- Truth-table substitution fits the manuscript's encoded size bound. -/ +lemma eventually_encoded_size_bound : + ∀ᶠ L : ℝ in atTop, ∀ B : ℕ, B = ⌈L ^ 15⌉₊ → + ∀ S : ℝ, S ≤ Real.exp (L ^ 6) → + (1 + (2 : ℝ) ^ B * (1 + B)) * S ≤ Real.exp (L ^ 17) := by + filter_upwards [eventually_ge_atTop 1, + eventually_const_mul_pow_le 15 17 (by norm_num) 7] with L hL hpow B hB S hS + have hLp : 0 ≤ L := le_trans zero_le_one hL + have hBbound : (B : ℝ) ≤ 2 * L ^ 15 := by simpa only [hB] using (ceil_pow_bounds hL 15).2 + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hpowB : (2 : ℝ) ^ B ≤ Real.exp (B : ℝ) := by + calc + _ ≤ (Real.exp 1) ^ B := pow_le_pow_left₀ (by norm_num) htwo B + _ = Real.exp (B : ℝ) := by rw [← Real.exp_nat_mul]; simp + have honeB : 1 + (B : ℝ) ≤ Real.exp (B : ℝ) := by + simpa [add_comm] using Real.add_one_le_exp (B : ℝ) + have hfac : 1 + (2 : ℝ) ^ B * (1 + B) ≤ Real.exp (1 + 2 * (B : ℝ)) := by + calc + _ ≤ 1 + Real.exp (B : ℝ) * Real.exp (B : ℝ) := + add_le_add (le_refl 1) (mul_le_mul hpowB honeB (by positivity) (by positivity)) + _ = 1 + Real.exp (2 * (B : ℝ)) := by rw [← Real.exp_add]; congr 2; ring + _ ≤ 2 * Real.exp (2 * (B : ℝ)) := by + have := Real.one_le_exp_iff.mpr (show 0 ≤ 2 * (B : ℝ) by positivity) + linarith + _ ≤ Real.exp 1 * Real.exp (2 * (B : ℝ)) := + mul_le_mul_of_nonneg_right htwo (Real.exp_pos _).le + _ = _ := (Real.exp_add _ _).symm + have hsmall : L ^ 6 ≤ L ^ 15 := pow_le_pow_right₀ hL (by norm_num) + calc + _ ≤ (1 + (2 : ℝ) ^ B * (1 + B)) * Real.exp (L ^ 6) := + mul_le_mul_of_nonneg_left hS (by positivity) + _ ≤ Real.exp (1 + 2 * (B : ℝ)) * Real.exp (L ^ 6) := + mul_le_mul_of_nonneg_right hfac (Real.exp_pos _).le + _ = Real.exp (1 + 2 * (B : ℝ) + L ^ 6) := (Real.exp_add _ _).symm + _ ≤ Real.exp (7 * L ^ 15) := by + apply Real.exp_le_exp.mpr + have hp : 1 ≤ L ^ 15 := one_le_pow₀ hL + nlinarith + _ ≤ _ := Real.exp_le_exp.mpr hpow + +/-- The number of bits is small even after adding the fixed-modulus block. -/ +lemma eventually_bit_count_bound : + ∀ᶠ L : ℝ in atTop, ∀ m B : ℕ, (m : ℝ) ≤ Real.exp L + 1 → B = ⌈L ^ 15⌉₊ → + ((m * B : ℕ) : ℝ) ≤ Real.exp (2 * L) := by + have h := (Real.isLittleO_pow_exp_atTop (n := 15)).bound (show 0 < (1 / 4 : ℝ) by norm_num) + filter_upwards [eventually_ge_atTop 1, h] with L hL hpow m B hm hB + have hLp : 0 ≤ L := le_trans zero_le_one hL + have hp : 0 ≤ L ^ 15 := pow_nonneg hLp _ + have h4 : 4 * L ^ 15 ≤ Real.exp L := by + rw [Real.norm_eq_abs, abs_of_nonneg hp, Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] at hpow + linarith + have hm' : (m : ℝ) ≤ 2 * Real.exp L := by + have := Real.one_le_exp_iff.mpr hLp + linarith + have hB' : (B : ℝ) ≤ 2 * L ^ 15 := by simpa only [hB] using (ceil_pow_bounds hL 15).2 + calc + ((m * B : ℕ) : ℝ) = (m : ℝ) * (B : ℝ) := by push_cast; rfl + _ ≤ (2 * Real.exp L) * (2 * L ^ 15) := mul_le_mul hm' hB' (by positivity) (by positivity) + _ = Real.exp L * (4 * L ^ 15) := by ring + _ ≤ Real.exp L * Real.exp L := mul_le_mul_of_nonneg_left h4 (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +/-- Polynomially many independence coordinates suffice for Braverman's +logarithmic requirement at encoded size `exp (L^17)`. -/ +lemma eventually_braverman_budget (K C : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ S : ℝ, 1 ≤ S → S ≤ Real.exp (L ^ 17) → + (K : ℝ) * (Real.log (S / Real.exp (-(L ^ 11)))) ^ C ≤ + (⌈L ^ (17 * C + 1)⌉₊ : ℝ) := by + filter_upwards [eventually_ge_atTop 1, + eventually_const_mul_pow_le (17 * C) (17 * C + 1) (by omega) ((K : ℝ) * 2 ^ C)] + with L hL hpow S hS hlo + have hSpos : 0 < S := lt_of_lt_of_le zero_lt_one hS + have hlog : Real.log (S / Real.exp (-(L ^ 11))) ≤ 2 * L ^ 17 := by + rw [Real.log_div hSpos.ne' (Real.exp_pos _).ne', Real.log_exp] + have hl := Real.log_le_log hSpos hlo + rw [Real.log_exp] at hl + have hsmall : L ^ 11 ≤ L ^ 17 := pow_le_pow_right₀ hL (by norm_num) + linarith + have hlogpos : 0 ≤ Real.log (S / Real.exp (-(L ^ 11))) := by + apply Real.log_nonneg + apply (le_div_iff₀ (Real.exp_pos _)).mpr + have he : Real.exp (-(L ^ 11)) ≤ 1 := Real.exp_le_one_iff.mpr (neg_nonpos.mpr (pow_nonneg (le_trans zero_le_one hL) _)) + simpa using he.trans hS + calc + _ ≤ (K : ℝ) * (2 * L ^ 17) ^ C := + mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hlogpos hlog C) (Nat.cast_nonneg _) + _ = ((K : ℝ) * 2 ^ C) * L ^ (17 * C) := by rw [mul_pow, ← pow_mul]; ring + _ ≤ L ^ (17 * C + 1) := hpow + _ ≤ _ := Nat.le_ceil _ + +/-- The actual low-order Fourier mass is exponentially small once the +interval exponent exceeds the independence exponent. -/ +lemma eventually_fourier_budget (T A : ℕ) (hT : 10 ≤ T) (hA : T + 1 < A) : + ∀ᶠ L : ℝ in atTop, ∀ t n N : ℕ, t = ⌈L ^ T⌉₊ → + (n : ℝ) ≤ Real.exp (2 * L) → Real.exp (L ^ A / 2) ≤ (N : ℝ) → + ((Real.exp L) ^ t / (N : ℝ)) * ((t + 1 : ℕ) : ℝ) * (n : ℝ) ^ t ≤ + Real.exp (-(L ^ 11)) := by + filter_upwards [eventually_ge_atTop 1, + eventually_const_mul_pow_le (T + 1) A hA 20] with L hL hpower t n N ht hn hN + have hLp : 0 ≤ L := le_trans zero_le_one hL + have htbound : (t : ℝ) ≤ 2 * L ^ T := by simpa only [ht] using (ceil_pow_bounds hL T).2 + have htp : 1 ≤ L ^ T := one_le_pow₀ hL + have htadd : (t : ℝ) + 1 ≤ 3 * L ^ T := by linarith + have hNt : 0 < (N : ℝ) := lt_of_lt_of_le (Real.exp_pos _) hN + have htExp : ((t + 1 : ℕ) : ℝ) ≤ Real.exp ((t : ℝ) + 1) := by + push_cast + have h := Real.add_one_le_exp ((t : ℝ) + 1) + linarith + have hcalc : (((Real.exp L) ^ t / Real.exp (L ^ A / 2)) * + Real.exp ((t : ℝ) + 1)) * (Real.exp (2 * L)) ^ t = + Real.exp (3 * L * (t : ℝ) + ((t : ℝ) + 1) - L ^ A / 2) := by + rw [← Real.exp_nat_mul, ← Real.exp_nat_mul, ← Real.exp_sub, + ← Real.exp_add, ← Real.exp_add] + congr 1 + ring + have hsmall : L ^ T ≤ L ^ (T + 1) := pow_le_pow_right₀ hL (by omega) + have h11 : L ^ 11 ≤ L ^ (T + 1) := pow_le_pow_right₀ hL (by omega) + have hterm : L * (t : ℝ) ≤ 2 * L ^ (T + 1) := by + have h := mul_le_mul_of_nonneg_left htbound hLp + rw [pow_succ] + nlinarith + calc + _ ≤ (((Real.exp L) ^ t / Real.exp (L ^ A / 2)) * + Real.exp ((t : ℝ) + 1)) * (Real.exp (2 * L)) ^ t := by + gcongr + _ = _ := hcalc + _ ≤ _ := by + apply Real.exp_le_exp.mpr + linarith + +/-- Both decoder errors and the corrected-law errors fit inside the final +`exp (-L^10)` budget. -/ +lemma eventually_total_comparison_error : + ∀ᶠ L : ℝ in atTop, ∀ B : ℕ, B = ⌈L ^ 15⌉₊ → ∀ D : ℝ, + D ≤ Real.exp (3 * L) → + 2 * D / (2 : ℝ) ^ B + 3 * Real.exp (-(L ^ 11)) / 2 + + Real.exp (-(L ^ 11)) ≤ Real.exp (-(L ^ 10)) := by + have hlog : 0 < Real.log (2 : ℝ) := Real.log_pos (by norm_num) + filter_upwards [eventually_ge_atTop 4, + eventually_const_mul_pow_le 11 15 (by norm_num) (6 / Real.log (2 : ℝ))] + with L hL4 hpower B hB D hD + have hL : 1 ≤ L := by linarith + have hLp : 0 ≤ L := le_trans zero_le_one hL + have hBbound : L ^ 15 ≤ (B : ℝ) := by simpa only [hB] using (ceil_pow_bounds hL 15).1 + have hdom : 6 * L ^ 11 ≤ L ^ 15 * Real.log (2 : ℝ) := by + apply (div_le_iff₀ hlog).mp + convert hpower using 1; ring + have hlogmax : Real.log (2 : ℝ) ≤ 1 := by + have h := Real.log_le_sub_one_of_pos (show 0 < (2 : ℝ) by norm_num) + linarith + have h11one : 1 ≤ L ^ 11 := one_le_pow₀ hL + have hL11 : L ≤ L ^ 11 := by simpa using pow_le_pow_right₀ hL (show 1 ≤ (11 : ℕ) by norm_num) + have hmul : L ^ 15 * Real.log (2 : ℝ) ≤ (B : ℝ) * Real.log (2 : ℝ) := + mul_le_mul_of_nonneg_right hBbound hlog.le + have hdecodeExp : Real.log (2 : ℝ) + 3 * L - (B : ℝ) * Real.log (2 : ℝ) ≤ -(L ^ 11) := by + linarith + have hpowB : (2 : ℝ) ^ B = Real.exp ((B : ℝ) * Real.log (2 : ℝ)) := by + rw [Real.exp_nat_mul, Real.exp_log (show 0 < (2 : ℝ) by norm_num)] + have hdecode : 2 * D / (2 : ℝ) ^ B ≤ Real.exp (-(L ^ 11)) := by + calc + _ ≤ 2 * Real.exp (3 * L) / (2 : ℝ) ^ B := by gcongr + _ = Real.exp (Real.log (2 : ℝ) + 3 * L - (B : ℝ) * Real.log (2 : ℝ)) := by + rw [hpowB, Real.exp_sub, Real.exp_add, + Real.exp_log (show 0 < (2 : ℝ) by norm_num)] + _ ≤ _ := Real.exp_le_exp.mpr hdecodeExp + have h10one : 1 ≤ L ^ 10 := one_le_pow₀ hL + have h11grow : 4 * L ^ 10 ≤ L ^ 11 := by + calc + 4 * L ^ 10 ≤ L * L ^ 10 := mul_le_mul_of_nonneg_right hL4 (pow_nonneg hLp 10) + _ = L ^ 11 := by ring + have hfour : (4 : ℝ) ≤ Real.exp 3 := by + linarith [Real.add_one_le_exp (3 : ℝ)] + calc + _ ≤ 4 * Real.exp (-(L ^ 11)) := by linarith [Real.exp_pos (-(L ^ 11))] + _ ≤ Real.exp 3 * Real.exp (-(L ^ 11)) := + mul_le_mul_of_nonneg_right hfour (Real.exp_pos _).le + _ = Real.exp (3 - L ^ 11) := by rw [← Real.exp_add]; rfl + _ ≤ _ := Real.exp_le_exp.mpr (by linarith) + +/-- The coefficient mass allowed in scalar expansions consumes only one +power in the exponent of the finite-law error. -/ +lemma eventually_scalar_error (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, + Real.exp (C * L ^ 5) * Real.exp (-(L ^ 10)) ≤ Real.exp (-(L ^ 9)) := by + filter_upwards [eventually_ge_atTop 1, + eventually_const_mul_pow_le 9 10 (by norm_num) (C + 1)] with L hL hpower + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + have hsmall : L ^ 5 ≤ L ^ 9 := pow_le_pow_right₀ hL (by norm_num) + have hmul := mul_le_mul_of_nonneg_left hsmall hC + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FinitePrimePhases.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FinitePrimePhases.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ede8e3d927e52425cd4da43e62cca1f71b50d97 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FinitePrimePhases.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShortSumSampling + +namespace OAI + +/-! The Fourier twists used in qualitative analytic centering count distinct +prime divisors, rather than their multiplicities. Their multiplicativity is +therefore asserted only for coprime arguments. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def finitePrimeDivisorCount (P : Finset ℕ) (n : ℕ) : ℕ := + ∑ p ∈ P, if p ∣ n then 1 else 0 + +lemma finitePrimeDivisorCount_mul (P : Finset ℕ) + (hP : ∀ p ∈ P, Nat.Prime p) (m n : ℕ) (hcop : m.Coprime n) : + finitePrimeDivisorCount P (m * n) = + finitePrimeDivisorCount P m + finitePrimeDivisorCount P n := by + unfold finitePrimeDivisorCount + rw [← sum_add_distrib] + apply sum_congr rfl + intro p hp + have hprime := hP p hp + have hboth : ¬(p ∣ m ∧ p ∣ n) := by + rintro ⟨hm, hn⟩ + exact hprime.ne_one (Nat.eq_one_of_dvd_coprimes hcop hm hn) + simp only [hprime.dvd_mul] + by_cases hm : p ∣ m <;> by_cases hn : p ∣ n <;> simp_all + +lemma finitePrimeDivisorCount_prime_outside (P : Finset ℕ) + (hP : ∀ p ∈ P, Nat.Prime p) {p : ℕ} (hp : Nat.Prime p) (hout : p ∉ P) : + finitePrimeDivisorCount P p = 0 := by + apply sum_eq_zero + intro q hq + have hnot : ¬q ∣ p := by + intro hdiv + have heq : p = q := (hp.dvd_iff_eq (hP q hq).ne_one).mp hdiv + exact hout (heq.symm ▸ hq) + exact ite_eq_right hnot + +noncomputable def finitePrimePhase (P : Finset ℕ) (t : ℝ) (n : ℕ) : ℂ := + additiveCharacter t (finitePrimeDivisorCount P n) + +lemma norm_finitePrimePhase (P : Finset ℕ) (t : ℝ) (n : ℕ) : + ‖finitePrimePhase P t n‖ = 1 := norm_additiveCharacter _ _ + +lemma finitePrimePhase_mul (P : Finset ℕ) (hP : ∀ p ∈ P, Nat.Prime p) + (t : ℝ) (m n : ℕ) (hcop : m.Coprime n) : + finitePrimePhase P t (m * n) = finitePrimePhase P t m * finitePrimePhase P t n := by + unfold finitePrimePhase + rw [finitePrimeDivisorCount_mul P hP m n hcop, additiveCharacter_nat_add] + +noncomputable def twistByPrimePhase (f : ℕ → ℂ) (P : Finset ℕ) (t : ℝ) + (n : ℕ) : ℂ := f n * finitePrimePhase P t n + +lemma Multiplicative.twistByPrimePhase {f : ℕ → ℂ} (hf : Multiplicative f) + (P : Finset ℕ) (hP : ∀ p ∈ P, Nat.Prime p) (t : ℝ) : + Multiplicative (TwoPointCorrelations.twistByPrimePhase f P t) := by + intro m n hm hn hcop + unfold TwoPointCorrelations.twistByPrimePhase + rw [hf m n hm hn hcop, finitePrimePhase_mul P hP t m n hcop] + ring + +lemma OneBounded.twistByPrimePhase {f : ℕ → ℂ} (hf : OneBounded f) + (P : Finset ℕ) (t : ℝ) : OneBounded (TwoPointCorrelations.twistByPrimePhase f P t) := by + intro n hn + simpa only [TwoPointCorrelations.twistByPrimePhase, norm_mul, + norm_finitePrimePhase, mul_one] using hf n hn + +lemma twistByPrimePhase_prime_outside (f : ℕ → ℂ) (P : Finset ℕ) + (hP : ∀ p ∈ P, Nat.Prime p) (t : ℝ) {p : ℕ} + (hp : Nat.Prime p) (hout : p ∉ P) : + twistByPrimePhase f P t p = f p := by + simp [twistByPrimePhase, finitePrimePhase, + finitePrimeDivisorCount_prime_outside P hP hp hout, additiveCharacter] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteProbability.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..99354b83cefa8e3156db416cd86745655ce488b6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteProbability.lean @@ -0,0 +1,155 @@ +import Mathlib.Algebra.Order.BigOperators.Ring.Finset +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Data.Fintype.Pi +import Mathlib.Tactic + +namespace OAI + +/-! +# Finite weighted sampling for the random-prime rank argument + +The prime labels in the rank argument have a nonuniform reciprocal law. +The corresponding finite-sum probability identities account for that law. +-/ + +namespace TwoPointCorrelations + +open Finset + +structure FiniteLaw (α : Type*) [Fintype α] where + weight : α → ℝ + nonneg : ∀ x, 0 ≤ weight x + total : ∑ x, weight x = 1 + +namespace FiniteLaw + +variable {α β ι : Type*} [Fintype α] [Fintype β] [Fintype ι] + +noncomputable def average (μ : FiniteLaw α) (f : α → ℝ) : ℝ := + ∑ x, μ.weight x * f x + +noncomputable def probability (μ : FiniteLaw α) (E : α → Prop) : ℝ := by + classical + exact μ.average (fun x => if E x then 1 else 0) + +lemma average_nonneg (μ : FiniteLaw α) {f : α → ℝ} (hf : ∀ x, 0 ≤ f x) : + 0 ≤ μ.average f := sum_nonneg (fun x _ => mul_nonneg (μ.nonneg x) (hf x)) + +lemma average_mono (μ : FiniteLaw α) {f g : α → ℝ} (h : ∀ x, f x ≤ g x) : + μ.average f ≤ μ.average g := sum_le_sum (fun x _ => mul_le_mul_of_nonneg_left (h x) (μ.nonneg x)) + +@[simp] lemma average_const (μ : FiniteLaw α) (c : ℝ) : μ.average (fun _ => c) = c := by + simp [average, ← sum_mul, μ.total] + +lemma average_sum (μ : FiniteLaw α) (f : ι → α → ℝ) : + μ.average (fun x => ∑ i, f i x) = ∑ i, μ.average (f i) := by + simp only [average, mul_sum] + rw [sum_comm] + +lemma average_mul_const (μ : FiniteLaw α) (f : α → ℝ) (c : ℝ) : + μ.average (fun x => f x * c) = μ.average f * c := by + simp only [average, mul_assoc, sum_mul] + +lemma average_comm (μ : FiniteLaw α) (ν : FiniteLaw β) (f : α → β → ℝ) : + μ.average (fun x => ν.average (f x)) = ν.average (fun y => μ.average (fun x => f x y)) := by + simp only [average, mul_sum] + rw [sum_comm] + congr 1 + funext y + apply sum_congr rfl + intro x _ + ring + +/-- Weighted Cauchy--Schwarz against the constant function one. -/ +lemma square_average_le (μ : FiniteLaw α) (f : α → ℝ) : + (μ.average f) ^ 2 ≤ μ.average (fun x => f x ^ 2) := by + have h := sum_sq_le_sum_mul_sum_of_sq_le_mul univ + (f := μ.weight) (g := fun x => μ.weight x * f x ^ 2) + (r := fun x => μ.weight x * f x) + (fun x _ => μ.nonneg x) + (fun x _ => mul_nonneg (μ.nonneg x) (sq_nonneg _)) + (fun x _ => le_of_eq (by ring)) + simpa only [average, μ.total, one_mul] using h + +lemma square_average_eq (μ : FiniteLaw α) (f : α → ℝ) : + (μ.average f) ^ 2 = μ.average (fun x => μ.average (fun y => f x * f y)) := by + simp only [average, pow_two, mul_sum, sum_mul] + apply sum_congr rfl + intro x _ + apply sum_congr rfl + intro y _ + ring + +/-- Repeating the second sample removes every term depending only on the +first sample. This is the Cauchy--Schwarz step of `q:rank-probability`. -/ +theorem two_sample_bound (μ : FiniteLaw α) (ν : FiniteLaw β) + (E : α → β → Prop) (D : α → β → β → Prop) + (hD : ∀ c y z, E c y → E c z → D c y z) : + (μ.average (fun c => ν.probability (E c))) ^ 2 ≤ + μ.average (fun c => ν.average (fun y => ν.probability (D c y))) := by + classical + apply (μ.square_average_le _).trans + apply μ.average_mono + intro c + rw [probability, ν.square_average_eq] + apply ν.average_mono + intro y + apply ν.average_mono + intro z + by_cases hy : E c y <;> by_cases hz : E c z + · simp [hy, hz, hD c y z hy hz] + · simp [hy, hz]; split_ifs <;> norm_num + · simp [hy, hz]; split_ifs <;> norm_num + · simp [hy, hz]; split_ifs <;> norm_num + +noncomputable def product (μ : FiniteLaw α) (ν : FiniteLaw β) : FiniteLaw (α × β) where + weight x := μ.weight x.1 * ν.weight x.2 + nonneg x := mul_nonneg (μ.nonneg _) (ν.nonneg _) + total := by simp [Fintype.sum_prod_type, ← mul_sum, μ.total, ν.total] + +lemma average_product (μ : FiniteLaw α) (ν : FiniteLaw β) (f : α × β → ℝ) : + (μ.product ν).average f = μ.average (fun x => ν.average (fun y => f (x, y))) := by + simp only [average, product, Fintype.sum_prod_type, mul_sum, mul_assoc] + +noncomputable def independent [DecidableEq ι] (μ : ι → FiniteLaw α) : FiniteLaw (ι → α) where + weight x := ∏ i, (μ i).weight (x i) + nonneg x := prod_nonneg (fun i _ => (μ i).nonneg _) + total := by + rw [← Fintype.prod_sum (fun i x => (μ i).weight x)] + simp only [FiniteLaw.total, prod_const_one] + +lemma independent_average_product [DecidableEq ι] (μ : ι → FiniteLaw α) (f : ι → α → ℝ) : + (independent μ).average (fun x => ∏ i, f i (x i)) = ∏ i, (μ i).average (f i) := by + simp only [average, independent, ← prod_mul_distrib] + exact (Fintype.prod_sum (fun i x => (μ i).weight x * f i x)).symm + +lemma probability_nonneg (μ : FiniteLaw α) (E : α → Prop) : 0 ≤ μ.probability E := by + classical + apply μ.average_nonneg + intro x + split_ifs <;> norm_num + +lemma probability_le_one (μ : FiniteLaw α) (E : α → Prop) : μ.probability E ≤ 1 := by + classical + apply (μ.average_mono (g := fun _ => 1) ?_).trans_eq (μ.average_const 1) + intro x + split_ifs <;> norm_num + +/-- If an event contains at most one atom, its mass is bounded by the +largest allowed atom. This is used after fixing the nonpivot labels. -/ +lemma probability_le_atom_bound (μ : FiniteLaw α) (E : α → Prop) (a : ℝ) + (ha : 0 ≤ a) (hatom : ∀ x, μ.weight x ≤ a) + (hunique : ∀ x y, E x → E y → x = y) : μ.probability E ≤ a := by + classical + by_cases he : ∃ x, E x + · obtain ⟨x, hx⟩ := he + have hE (y : α) : E y ↔ y = x := ⟨fun hy => hunique y x hy hx, fun hy => hy ▸ hx⟩ + simpa [probability, average, hE] using hatom x + · have hE (x : α) : ¬ E x := fun hx => he ⟨x, hx⟩ + simpa [probability, average, hE] using ha + +end FiniteLaw + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteResidueComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteResidueComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..c050e2c2454da4c78be9ecbb5da7b5332b9971bb --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteResidueComparison.lean @@ -0,0 +1,169 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DecoderComparison + +namespace OAI + +/-! +# Finite residue-circuit comparison + +An original residue circuit has depth at most twenty. Each input tests one +residue coordinate, and is replaced by its explicit truth table on the +corresponding bit block. The encoded circuit therefore has depth at most +twenty-two. The empirical Fourier bound, the published Braverman input, +and the two decoding errors give a completely finite error estimate. +-/ + +namespace TwoPointCorrelations + +open Finset + +lemma abs_add_three (a b c : ℝ) : |a + b + c| ≤ |a| + |b| + |c| := + (abs_add_le (a + b) c).trans (add_le_add (abs_add_le a b) (le_refl |c|)) + +/-- Inputs to an actual Boolean circuit, with each input depending on one +specified residue coordinate. Equality with a fixed residue is a special case. -/ +def residueCircuitInputs {n m : ℕ} (s : Fin m → ℕ) (coord : Fin n → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) (r : ∀ j, ZMod (s j)) : BooleanCube n := + fun i => test i (r (coord i)) + +def residueCircuitEvent {n m : ℕ} (s : Fin m → ℕ) (coord : Fin n → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) (c : AC0Circuit n) + (r : ∀ j, ZMod (s j)) : Bool := c.eval (residueCircuitInputs s coord test r) + +/-- The actual truth-table circuit used for encoded residue testing. -/ +noncomputable def encodeResidueCircuit {n m : ℕ} (s : Fin m → ℕ) + [∀ i, NeZero (s i)] (B : ℕ) (coord : Fin n → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) (c : AC0Circuit n) : AC0Circuit (m * B) := + AC0Circuit.encodeInputs (fun i j => finProdFinEquiv (coord i, j)) + (fun i z => test i (ZMod.finEquiv (s (coord i)) + (decodeBits (NeZero.pos (s (coord i))) z))) c + +lemma flattenBitBlocks_block {m B : ℕ} (z : Fin m → BooleanCube B) (i : Fin m) : + (fun j => flattenBitBlocks m B z (finProdFinEquiv (i, j))) = z i := by + funext j + exact congrArg (fun p : Fin m × Fin B => z p.1 p.2) + (finProdFinEquiv.symm_apply_apply (i, j)) + +lemma encodeResidueCircuit_eval {n m B : ℕ} (s : Fin m → ℕ) + [∀ i, NeZero (s i)] (coord : Fin n → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) (c : AC0Circuit n) + (z : Fin m → BooleanCube B) : + (encodeResidueCircuit s B coord test c).eval (flattenBitBlocks m B z) = + residueCircuitEvent s coord test c (decodedResidues s B z) := by + unfold encodeResidueCircuit + rw [AC0Circuit.encodeInputs_eval] + simp only [flattenBitBlocks_block] + rfl + +lemma encodeResidueCircuit_indicator {n m B : ℕ} (s : Fin m → ℕ) + [∀ i, NeZero (s i)] (coord : Fin n → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) (c : AC0Circuit n) + (z : Fin m → BooleanCube B) : + (encodeResidueCircuit s B coord test c).indicator (flattenBitBlocks m B z) = + eventIndicator (residueCircuitEvent s coord test c) (decodedResidues s B z) := by + simp only [AC0Circuit.indicator, eventIndicator, encodeResidueCircuit_eval] + +lemma encodeResidueCircuit_depth {n m B : ℕ} (s : Fin m → ℕ) + [∀ i, NeZero (s i)] (coord : Fin n → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) (c : AC0Circuit n) : + (encodeResidueCircuit s B coord test c).depth ≤ c.depth + 2 := + AC0Circuit.encodeInputs_depth _ _ c + +lemma encodeResidueCircuit_size {n m B : ℕ} (s : Fin m → ℕ) + [∀ i, NeZero (s i)] (coord : Fin n → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) (c : AC0Circuit n) : + (encodeResidueCircuit s B coord test c).size ≤ (1 + 2 ^ B * (1 + B)) * c.size := + AC0Circuit.encodeInputs_size _ _ c + +lemma encodeResidueCircuit_interval_average {n m B : ℕ} (s : Fin m → ℕ) + [∀ i, NeZero (s i)] (coord : Fin n → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) (c : AC0Circuit n) (a N : ℕ) : + uniformAverage (fun x : Fin N × (Fin m → Fin (2 ^ B)) => + (encodeResidueCircuit s B coord test c).indicator (integerBitSample s B a x)) = + uniformAverage (fun x : Fin N => uniformAverage (fun j : Fin m → Fin (2 ^ B) => + eventIndicator (residueCircuitEvent s coord test c) + (decodedResidues s B (crtJitterBits s B (fun i => (a + x.val : ZMod (s i))) j)))) := by + change uniformAverage (fun x : Fin N × (Fin m → Fin (2 ^ B)) => + (encodeResidueCircuit s B coord test c).indicator + (flattenBitBlocks m B (crtJitterBits s B (fun i => (a + x.1.val : ZMod (s i))) x.2))) = _ + simp_rw [encodeResidueCircuit_indicator] + exact uniformAverage_prod (fun (x : Fin N) (j : Fin m → Fin (2 ^ B)) => + eventIndicator (residueCircuitEvent s coord test c) + (decodedResidues s B (crtJitterBits s B (fun i => (a + x.val : ZMod (s i))) j))) + +lemma encodeResidueCircuit_uniform_average {n m B : ℕ} (s : Fin m → ℕ) + [∀ i, NeZero (s i)] (coord : Fin n → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) (c : AC0Circuit n) : + cubeAverage (encodeResidueCircuit s B coord test c).indicator = + uniformAverage (fun r : ∀ i, ZMod (s i) => + uniformAverage (fun j : Fin m → Fin (2 ^ B) => + eventIndicator (residueCircuitEvent s coord test c) + (decodedResidues s B (crtJitterBits s B r j)))) := by + calc + _ = uniformAverage (fun z : Fin m → BooleanCube B => + (encodeResidueCircuit s B coord test c).indicator (flattenBitBlocks m B z)) := + (uniformAverage_equiv (flattenBitBlocks m B) + (encodeResidueCircuit s B coord test c).indicator).symm + _ = uniformAverage (fun r : ∀ i, ZMod (s i) => + uniformAverage (fun j : Fin m → Fin (2 ^ B) => + (encodeResidueCircuit s B coord test c).indicator + (flattenBitBlocks m B (crtJitterBits s B r j)))) := + (crtJitterBits_uniformAverage s B _).symm + _ = _ := by simp_rw [encodeResidueCircuit_indicator] + +/-- Comparison for the original depth-twenty residue circuit. The arithmetic +hypotheses are precisely positivity and pairwise coprimality of the moduli; +no squarefreeness or bound on their total product is used. The low-order +Fourier error and the decoding error are explicit finite quantities. -/ +theorem BravermanDepth22Input.finite_residue_comparison (hBraverman : BravermanDepth22Input) : + ∃ K C : ℕ, 0 < K ∧ 0 < C ∧ ∀ (m B : ℕ), 0 < m * B → + ∀ (s : Fin m → ℕ) [∀ i, NeZero (s i)], + Pairwise (fun i j => (s i).Coprime (s j)) → + ∀ (n : ℕ) (coord : Fin n → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) (c : AC0Circuit n), c.depth ≤ 20 → + ∀ ε : ℝ, 0 < ε → ε ≤ 1 / 2 → ∀ t : ℕ, + (K : ℝ) * (Real.log + (((encodeResidueCircuit s B coord test c).size : ℝ) / ε)) ^ C ≤ (t : ℝ) → + ∀ (a N : ℕ), 0 < N → ∀ M A : ℝ, 1 ≤ M → (∀ i, (s i : ℝ) ≤ M) → + (M ^ t / (N : ℝ)) * ((t + 1 : ℕ) : ℝ) * ((m * B : ℕ) : ℝ) ^ t ≤ A → + |uniformAverage (fun x : Fin N => + eventIndicator (residueCircuitEvent s coord test c) + (fun i => (a + x.val : ZMod (s i)))) - + uniformAverage (eventIndicator (residueCircuitEvent s coord test c))| ≤ + 2 * (∑ i : Fin m, (s i : ℝ) / (2 ^ B : ℕ)) + 3 * A / 2 + ε := by + obtain ⟨K, C, hK, hC, hcompare⟩ := hBraverman.encoded_interval_comparison + refine ⟨K, C, hK, hC, ?_⟩ + intro m B hn s _hpos hcop n coord test c hc ε hε hεmax t ht a N hN M A hM hs hA + let : Nonempty (Fin N) := ⟨⟨0, hN⟩⟩ + have hdepth : (encodeResidueCircuit s B coord test c).depth ≤ 22 := + (encodeResidueCircuit_depth (B := B) s coord test c).trans (by omega) + have hmiddle := hcompare m B hn s hcop (encodeResidueCircuit s B coord test c) + hdepth ε hε hεmax t ht a N hN M A hM hs hA + rw [encodeResidueCircuit_interval_average, encodeResidueCircuit_uniform_average] at hmiddle + have hleft := decoder_event_error_averaged (B := B) s (residueCircuitEvent s coord test c) + (fun x : Fin N => fun i => (a + x.val : ZMod (s i))) + have hright := decoder_event_error_averaged (B := B) s (residueCircuitEvent s coord test c) + (fun r : ∀ i, ZMod (s i) => r) + let I := uniformAverage (fun x : Fin N => + eventIndicator (residueCircuitEvent s coord test c) (fun i => (a + x.val : ZMod (s i)))) + let J := uniformAverage (fun x : Fin N => uniformAverage (fun j : Fin m → Fin (2 ^ B) => + eventIndicator (residueCircuitEvent s coord test c) + (decodedResidues s B (crtJitterBits s B (fun i => (a + x.val : ZMod (s i))) j)))) + let U := uniformAverage (fun r : ∀ i, ZMod (s i) => + uniformAverage (fun j : Fin m → Fin (2 ^ B) => + eventIndicator (residueCircuitEvent s coord test c) + (decodedResidues s B (crtJitterBits s B r j)))) + let V := uniformAverage (eventIndicator (residueCircuitEvent s coord test c)) + change |I - J| ≤ _ at hleft + change |J - U| ≤ _ at hmiddle + change |V - U| ≤ _ at hright + change |I - V| ≤ _ + have htriangle : |I - V| ≤ |I - J| + |J - U| + |U - V| := by + calc + _ = |(I - J) + (J - U) + (U - V)| := by congr 1; ring + _ ≤ _ := abs_add_three (I - J) (J - U) (U - V) + rw [abs_sub_comm] at hright + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteRoughSieve.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteRoughSieve.lean new file mode 100644 index 0000000000000000000000000000000000000000..829edc45aee5fece01cdfddc980ec403fc64b871 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteRoughSieve.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveIntersections +import OAI.NumberTheory.TwoPoint.Bounds.SieveBoundary +import OAI.NumberTheory.TwoPoint.Bounds.SieveProducts + +namespace OAI + +/-! Finite rough-sieve bounds with every intersection error discharged by +CRT on the actual interval sample space. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem finite_interval_sieve {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A N : ℕ) [NeZero N] (E : ∀ i, ZMod (s i) → Prop) (r : ℕ) (Y : ℝ) + (hY : 0 ≤ Y) (hs : ∀ i, (s i : ℝ) ≤ Y) : + (uniformFiniteLaw (Fin N)).probability + (avoidsEvents univ (fun i (j : Fin N) => E i ((A + j.val : ℕ) : ZMod (s i)))) ≤ + (∏ i, (1 - (uniformZModLaw (s i)).probability (E i))) + + elementarySymmetric univ (fun i => (uniformZModLaw (s i)).probability (E i)) + (2 * r + 1) + + 1 / (N : ℝ) * (2 * r + 1 : ℕ) * ((Fintype.card ι : ℝ) * Y + 1) ^ (2 * r) := by + have hh := finite_independent_sieve_bound (uniformFiniteLaw (Fin N)) + (fun i (j : Fin N) => E i ((A + j.val : ℕ) : ZMod (s i))) + (fun i => uniformZModLaw (s i)) E r + (fun S => 1 / (N : ℝ) * ∏ i ∈ S, (s i : ℝ)) (fun S _ _ => by + exact (sieve_one_intersection s hcop A N E S).trans_eq (by ring)) + apply hh.trans + gcongr + simpa only [card_univ] using sieveIntersectionError_crude univ (fun i => (s i : ℝ)) + Y 1 hY zero_le_one (fun i _ => ⟨Nat.cast_nonneg _, hs i⟩) N (2 * r) + +theorem finite_cube_sieve {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ℕ × ℕ × ℕ) (N : ℕ) [NeZero N] + (E : ∀ i, (ZMod (s i) × ZMod (s i) × ZMod (s i)) → Prop) (r : ℕ) (Y : ℝ) + (hY : 0 ≤ Y) (hs : ∀ i, (s i : ℝ) ≤ Y) : + (uniformFiniteLaw (Fin N × Fin N × Fin N)).probability + (avoidsEvents univ (fun i (j : Fin N × Fin N × Fin N) => E i + (((A.1 + j.1.val : ℕ) : ZMod (s i)), ((A.2.1 + j.2.1.val : ℕ) : ZMod (s i)), + ((A.2.2 + j.2.2.val : ℕ) : ZMod (s i))))) ≤ + (∏ i, (1 - (uniformResidueCubeLaw (s i)).probability (E i))) + + elementarySymmetric univ + (fun i => (uniformResidueCubeLaw (s i)).probability (E i)) (2 * r + 1) + + 3 / (N : ℝ) * (2 * r + 1 : ℕ) * ((Fintype.card ι : ℝ) * Y + 1) ^ (2 * r) := by + have hh := finite_independent_sieve_bound (uniformFiniteLaw (Fin N × Fin N × Fin N)) + (fun i (j : Fin N × Fin N × Fin N) => E i + (((A.1 + j.1.val : ℕ) : ZMod (s i)), ((A.2.1 + j.2.1.val : ℕ) : ZMod (s i)), + ((A.2.2 + j.2.2.val : ℕ) : ZMod (s i)))) + (fun i => uniformResidueCubeLaw (s i)) E r + (fun S => 3 / (N : ℝ) * ∏ i ∈ S, (s i : ℝ)) + (fun S _ _ => sieve_cube_intersection s hcop A N E S) + apply hh.trans + gcongr + simpa only [card_univ] using sieveIntersectionError_crude univ (fun i => (s i : ℝ)) + Y 3 hY (by norm_num) (fun i _ => ⟨Nat.cast_nonneg _, hs i⟩) N (2 * r) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteSupportAverage.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteSupportAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..d172816f995c1c631df1b17193589213b61e53a5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteSupportAverage.lean @@ -0,0 +1,28 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PositiveWordProbability + +namespace OAI + +/-! A bounded function pays the probability of its actual nonzero support. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem FiniteLaw.average_abs_le_support {A : Type*} [Fintype A] + (μ : FiniteLaw A) (f : A → ℝ) (E : A → Prop) (C : ℝ) + (hf : ∀ x, |f x| ≤ C) (hsupport : ∀ x, f x ≠ 0 → E x) : + μ.average (fun x => |f x|) ≤ C * μ.probability E := by + calc + _ ≤ μ.average (fun x => (if E x then 1 else 0) * C) := by + apply μ.average_mono + intro x + by_cases hx : E x + · simpa only [ite_eq_left hx, one_mul] using hf x + · have hz : f x = 0 := by by_contra hn; exact hx (hsupport x hn) + simp only [hz, abs_zero, ite_eq_right hx, zero_mul, le_refl] + _ = C * μ.probability E := by rw [μ.average_mul_const]; exact mul_comm _ _ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteWalkFamily.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteWalkFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..78a709f5a5ee0e08f64da936e6fc3502b19af8c5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteWalkFamily.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.TwoPoint.Walks.ForestPathRealization + +namespace OAI + +/-! Restricting a finite walk family to its observed vertices preserves its code. -/ + +namespace TwoPointCorrelations + +open Finset SimpleGraph + +variable {V : Type*} [DecidableEq V] {G : SimpleGraph V} {segments N : ℕ} + (start finish : Fin segments → V) (p : ∀ i, G.Walk (start i) (finish i)) + +def walkFamilySupport : Finset V := + univ.biUnion (fun i => (p i).support.toFinset) + +lemma mem_walkFamilySupport (i : Fin segments) (v : V) (hv : v ∈ (p i).support) : + v ∈ walkFamilySupport start finish p := + mem_biUnion.mpr ⟨i, mem_univ _, List.mem_toFinset.mpr hv⟩ + +theorem walkFamilySupport_card_le : + (walkFamilySupport start finish p).card ≤ ∑ i, (p i).support.length := by + apply (card_biUnion_le).trans + exact sum_le_sum (fun i _ => List.toFinset_card_le (p i).support) + +abbrev walkFamilyGraph := G.induce (walkFamilySupport start finish p : Set V) + +def walkFamilyStart (i : Fin segments) : (walkFamilySupport start finish p) := + ⟨start i, mem_walkFamilySupport start finish p i _ (p i).start_mem_support⟩ + +def walkFamilyFinish (i : Fin segments) : (walkFamilySupport start finish p) := + ⟨finish i, mem_walkFamilySupport start finish p i _ (p i).end_mem_support⟩ + +def restrictedFamilyWalk (i : Fin segments) : + (walkFamilyGraph start finish p).Walk + (walkFamilyStart start finish p i) (walkFamilyFinish start finish p i) := + (p i).induce _ (mem_walkFamilySupport start finish p i) + +theorem restrictedFamilyWalk_reduced (hG : G.IsAcyclic) + (hp : ∀ i, List.IsChain (· ≠ ·) (p i).edges) (i : Fin segments) : + List.IsChain (· ≠ ·) (restrictedFamilyWalk start finish p i).edges := by + have hH := hG.induce (walkFamilySupport start finish p : Set V) + apply (hH.isPath_iff_isChain _).mp + apply (Walk.isPath_map_iff_of_injective (f := (Embedding.induce _).toHom) + (show Function.Injective (Subtype.val : (walkFamilySupport start finish p) → V) + from Subtype.val_injective)).mp + have hm : (restrictedFamilyWalk start finish p i).map (Embedding.induce _).toHom = p i := + Walk.map_induce (p i) (mem_walkFamilySupport start finish p i) + rw [hm] + exact (hG.isPath_iff_isChain _).mpr (hp i) + +/-- No finiteness hypothesis on the ambient graph is needed: the observed +support alone suffices for the universal forest code. -/ +theorem finite_walk_family_realizable (hG : G.IsAcyclic) + (hp : ∀ i, List.IsChain (· ≠ ·) (p i).edges) + (hsize : (∑ i, (p i).support.length) ≤ N) (color : V → Bool) : + ∃ t : BinaryTree (walkFamilySupport start finish p), + (forestNodes t).Nodup ∧ (∀ v, v ∈ forestNodes t) ∧ + (fun i => (restrictedFamilyWalk start finish p i).support.map + (fun v => @List.idxOf _ instBEqOfDecidableEq v (forestNodes t))) ∈ + Set.range (@ForestPathData.pattern N segments) := by + have hcard : Fintype.card (walkFamilySupport start finish p) ≤ N := by + rw [Fintype.card_coe] + exact (walkFamilySupport_card_le start finish p).trans hsize + exact forest_paths_realizable (walkFamilyGraph start finish p) (hG.induce _) hcard + (fun v => color v) (walkFamilyStart start finish p) (walkFamilyFinish start finish p) + (restrictedFamilyWalk start finish p) (restrictedFamilyWalk_reduced start finish p hG hp) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteWalkNumbering.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteWalkNumbering.lean new file mode 100644 index 0000000000000000000000000000000000000000..d40177c49fa5dac607844b04747a5cc01d3d2003 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FiniteWalkNumbering.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteWalkFamily +import OAI.NumberTheory.TwoPoint.Walks.ColumnDecoder + +namespace OAI + +/-! A single bounded numbering of all vertices observed in a finite walk family. -/ + +namespace TwoPointCorrelations + +open Finset SimpleGraph + +variable {V : Type*} [DecidableEq V] {G : SimpleGraph V} {segments N : ℕ} + +/-- The forest code comes with a numbering of the actual observed vertices. +It is injective across the whole family, so line numbers encode equality +between runs in different segments as well as within each segment. -/ +theorem finite_walk_family_numbering + (start finish : Fin segments → V) (p : ∀ i, G.Walk (start i) (finish i)) + (hG : G.IsAcyclic) (hp : ∀ i, List.IsChain (· ≠ ·) (p i).edges) + (hsize : (∑ i, (p i).support.length) ≤ N) (color : V → Bool) : + ∃ (number : V → ℕ) (code : ForestPathData.Code N segments), + Set.InjOn number (walkFamilySupport start finish p : Set V) ∧ + (∀ v ∈ walkFamilySupport start finish p, number v < N) ∧ + ∀ i, decodeForestPaths code i = (p i).support.map number := by + classical + obtain ⟨t, ht, hcover, d, hd⟩ := finite_walk_family_realizable start finish p hG hp hsize color + let index : (walkFamilySupport start finish p) → ℕ := + fun v => @List.idxOf _ instBEqOfDecidableEq v (forestNodes t) + let number : V → ℕ := fun v => + if hv : v ∈ walkFamilySupport start finish p then index ⟨v, hv⟩ else 0 + have hnumber (v : walkFamilySupport start finish p) : number v.val = index v := by + simp only [number, dite_eq_left v.property] + have hindex : Function.Injective index := preorder_index_injective t hcover + have hnodes : (forestNodes t).length ≤ N := by + rw [forestNodes_length, forest_representation_numNodes t ht hcover, Fintype.card_coe] + exact (walkFamilySupport_card_le start finish p).trans hsize + refine ⟨number, d.code, ?_, ?_, ?_⟩ + · intro a ha b hb hab + have heq : index ⟨a, ha⟩ = index ⟨b, hb⟩ := by + simpa only [← hnumber] using hab + exact congrArg Subtype.val (hindex heq) + · intro v hv + let : BEq (walkFamilySupport start finish p) := instBEqOfDecidableEq + rw [show number v = index ⟨v, hv⟩ from hnumber ⟨v, hv⟩] + exact (List.idxOf_lt_length_iff.mpr (hcover ⟨v, hv⟩)).trans_le hnodes + · intro i + rw [decodeForestPaths_code] + have hi := congrFun hd i + change d.pattern i = (restrictedFamilyWalk start finish p i).support.map index at hi + rw [hi] + have hm : (restrictedFamilyWalk start finish p i).map (Embedding.induce _).toHom = p i := + Walk.map_induce (p i) (mem_walkFamilySupport start finish p i) + have hs : (p i).support = (restrictedFamilyWalk start finish p i).support.map + (fun v => v.val) := by + exact (congrArg (fun q : G.Walk (start i) (finish i) => q.support) hm).symm.trans + (Walk.support_map _ _) + rw [hs, List.map_map] + apply List.map_congr_left + intro v _ + exact (hnumber v).symm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FixedColumnWords.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FixedColumnWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..63827191c036f306f5820fcd6a9b27e4b1fa6e1c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FixedColumnWords.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.TwoPoint.Walks.HighRankWordEvents +import Mathlib.Data.List.OfFn + +namespace OAI + +/-! The actual resampling model after every other column and padding are fixed. -/ + +namespace TwoPointCorrelations + +structure ColumnWordPattern (α : Type*) where + length : ℕ + label : ℕ → α + forward : ℕ → Bool + padding : ℕ → ℕ + otherColumns : ℕ → ℕ + +namespace ColumnWordPattern + +variable {α : Type*} + +def step (w : ColumnWordPattern α) (value : α → ℕ) (j : ℕ) : SignedStep where + forward := w.forward j + tuple := value (w.label j) * w.otherColumns j + padding := w.padding j + +def word (w : ColumnWordPattern α) (value : α → ℕ) : List SignedStep := + List.ofFn (fun j : Fin w.length => w.step value j) + +def coefficient (w : ColumnWordPattern α) (h j : ℕ) : ℤ := + (if w.forward j then 1 else -1) * (h : ℤ) * w.padding j * w.otherColumns j + +@[simp] lemma word_length (w : ColumnWordPattern α) (value : α → ℕ) : + (w.word value).length = w.length := by simp [word] + +lemma displacement (w : ColumnWordPattern α) (h : ℕ) (value : α → ℕ) + (j : ℕ) (hj : j < w.length) : + wordStepDisplacement h (w.word value) j = w.coefficient h j * value (w.label j) := by + rw [wordStepDisplacement_getElem h (w.word value) j (by simpa using hj)] + simp only [word, List.getElem_ofFn, step, SignedStep.displacement, coefficient, Nat.cast_mul] + ring + +lemma coefficient_abs (w : ColumnWordPattern α) (h j : ℕ) : + |w.coefficient h j| = (h : ℤ) * w.padding j * w.otherColumns j := by + cases hb : w.forward j <;> simp [coefficient, hb, abs_mul] + +lemma coefficient_bound (w : ColumnWordPattern α) (h Q D : ℕ) + (hq : ∀ j < w.length, w.padding j ≤ Q) + (hd : ∀ j < w.length, w.otherColumns j ≤ D) : + ∀ j < w.length, |w.coefficient h j| ≤ (h * Q * D : ℕ) := by + intro j hj + rw [coefficient_abs] + exact_mod_cast Nat.mul_le_mul (Nat.mul_le_mul_left h (hq j hj)) (hd j hj) + +/-- The resampled step list has fixed coefficients independent of every +numerical prime in the chosen column. Only selected departures need be lit. -/ +theorem high_rank_event_bound [Fintype α] [DecidableEq α] + {ρ : Type*} [Fintype ρ] [DecidableEq ρ] + (w : ColumnWordPattern α) (h Q D B : ℕ) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (μ : FiniteLaw P) + (hbound : ∀ p ∈ P, p ≤ B) + (hq : ∀ j < w.length, w.padding j ≤ Q) + (hd : ∀ j < w.length, w.otherColumns j ≤ D) + (left right : ρ → ℕ) (control : ρ → α) + (hl : ∀ i, left i ≤ w.length) (hr : ∀ i, right i ≤ w.length) + (hind : LinearIndependent ℝ (Sum.elim + (fun i => formalDeparture w.label (fun j => (w.coefficient h j : ℝ)) (left i) - + formalDeparture w.label (fun j => (w.coefficient h j : ℝ)) (right i)) + (fun i => Pi.basisFun ℝ α (control i)))) + (a : ℝ) (ha : 0 ≤ a) (hatom : ∀ p, μ.weight p ≤ a) + (base : (α → P) → ℤ) (E : (α → P) → Prop) + (hlit : ∀ x, E x → ∀ i, ((x (control i)).val : ℤ) ∣ base x + + wordDisplacement h ((w.word (fun z => (x z).val)).take (left i))) + (hrit : ∀ x, E x → ∀ i, ((x (control i)).val : ℤ) ∣ base x + + wordDisplacement h ((w.word (fun z => (x z).val)).take (right i))) : + (FiniteLaw.independent (fun _ : α => μ)).probability E ≤ + Real.sqrt ((a * (1 + (Nat.log 2 (2 * w.length * (h * Q * D) * B) : ℝ))) ^ Fintype.card ρ) := by + apply high_rank_column_event_bound P hP μ w.label (w.coefficient h) left right control + hind w.length (h * Q * D) B hl hr (w.coefficient_bound h Q D hq hd) hbound a ha hatom + h (fun x => w.word (fun z => (x z).val)) base E + · intro x _ j hj + exact w.displacement h _ j (by simpa using hj) + · intro x _ i + simpa using hl i + · intro x _ i + simpa using hr i + · exact hlit + · exact hrit + +end ColumnWordPattern + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ForcedSingletonDifference.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ForcedSingletonDifference.lean new file mode 100644 index 0000000000000000000000000000000000000000..93d4b6917a154b1477ec4c6600c9ae491a47f260 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ForcedSingletonDifference.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResidueWitnessHybrid +import OAI.NumberTheory.TwoPoint.Bounds.PaddingWitnessProbability + +namespace OAI + +/-! Forcing lit nonsingletons commutes with singleton differences; padding stays outside them. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem selectedMixedDifference_invariant_factor {ι A : Type*} + [Fintype ι] [DecidableEq ι] [Fintype A] [DecidableEq A] + (S M : Finset ι) (hSM : S ⊆ M) (a x : ι → A) + (R F : (ι → A) → ℝ) + (hR : ∀ y z, (∀ i, i ∉ M → y i = z i) → R y = R z) : + selectedMixedDifference S a (fun y => R y * F y) x = + R x * selectedMixedDifference S a F x := by + have hsame (z : S → A) : + R (joinCoordinates S z (fun i : {i // i ∉ S} => x i)) = R x := by + apply hR + intro i hi + have hiS : i ∉ S := fun his => hi (hSM his) + simp only [joinCoordinates, hiS, dite_false] + unfold selectedMixedDifference + simp_rw [hsame] + exact mixedDifference_const_mul _ _ _ _ + +theorem selectedMixedDifference_force_disjoint {ι A : Type*} [Fintype ι] [DecidableEq ι] + [Fintype A] [DecidableEq A] (S T : Finset ι) (hST : Disjoint S T) + (a b x : ι → A) (F : (ι → A) → ℝ) : + selectedMixedDifference S a (fun y => F (forceCoordinates T b y)) x = + selectedMixedDifference S a F (forceCoordinates T b x) := by + have hcomm (z : S → A) : + forceCoordinates T b (joinCoordinates S z (fun i : {i // i ∉ S} => x i)) = + joinCoordinates S z (fun i : {i // i ∉ S} => forceCoordinates T b x i) := by + funext i + by_cases hiS : i ∈ S + · have hiT : i ∉ T := fun hiT => disjoint_left.mp hST hiS hiT + simp only [forceCoordinates_apply, hiT, ite_false, joinCoordinates, hiS, dite_true] + · simp only [joinCoordinates, hiS, dite_false, forceCoordinates_apply] + have hx : (fun i : S => forceCoordinates T b x i) = (fun i : S => x i) := by + funext i + have hiT : i.val ∉ T := fun hiT => disjoint_left.mp hST i.property hiT + simp only [forceCoordinates_apply, hiT, ite_false] + unfold selectedMixedDifference + simp_rw [hcomm] + rw [hx] + +theorem selectedMixedDifference_retainedMainTests {ι : Type*} + [Fintype ι] [DecidableEq ι] (p : ι → ℕ) (S M : Finset ι) (hSM : S ⊆ M) + (h B : ℕ) (main : List SignedStep) (a x : ι → Fin B) (F : (ι → Fin B) → ℝ) : + selectedMixedDifference S a + (fun y => (if RetainedMainTests p M h B main y then 1 else 0) * F y) x = + (if RetainedMainTests p M h B main x then 1 else 0) * + selectedMixedDifference S a F x := by + have hsame (z : S → Fin B) : + RetainedMainTests p M h B main (joinCoordinates S z (fun i : {i // i ∉ S} => x i)) ↔ + RetainedMainTests p M h B main x := by + apply retainedMainTests_congr + intro i hi + have hiS : i ∉ S := fun his => hi (hSM his) + simp only [joinCoordinates, hiS, dite_false] + unfold selectedMixedDifference + simp_rw [hsame] + exact mixedDifference_const_mul _ _ _ _ + +lemma witnessAvoidance_abs_le_one {ι A W : Type*} [Fintype W] + (I : W → (ι → A) → Bool) (x : ι → A) : |witnessAvoidance I x| ≤ 1 := by + unfold witnessAvoidance + rw [abs_prod] + calc + _ ≤ ∏ _w : W, (1 : ℝ) := by + apply prod_le_prod₀ (fun _ _ => abs_nonneg _) + intro w _ + cases hi : I w x <;> norm_num [hi] + _ = _ := prod_const_one + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FormalDepartures.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FormalDepartures.lean new file mode 100644 index 0000000000000000000000000000000000000000..96fc89e3386508b751b064ea158b7ec7c875e20c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FormalDepartures.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RegularQuotient +import Mathlib.Algebra.BigOperators.Intervals + +namespace OAI + +/-! Formal departures and exact quotient increments of constant runs. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {K α V : Type*} [Field K] [Fintype α] + [AddCommGroup V] [Module K V] + +noncomputable def formalDeparture (label : ℕ → α) (coefficient : ℕ → K) (n : ℕ) : α → K := + ∑ i ∈ range n, coefficient i • Pi.basisFun K α (label i) + +theorem formalDeparture_const_run (label : ℕ → α) (coefficient : ℕ → K) + (a b : ℕ) (hab : a ≤ b) (z : α) (hz : ∀ i ∈ Ico a b, label i = z) : + formalDeparture label coefficient b = formalDeparture label coefficient a + + (∑ i ∈ Ico a b, coefficient i) • Pi.basisFun K α z := by + unfold formalDeparture + rw [← sum_range_add_sum_Ico _ hab] + congr 1 + rw [Finset.sum_smul] + apply sum_congr rfl + intro i hi + rw [hz i hi] + +/-- Every regular run moves parallel to its independent quotient direction. -/ +theorem quotient_departure_const_run (D : Submodule K (α → K)) + (label : ℕ → α) (coefficient : ℕ → K) + (a b : ℕ) (hab : a ≤ b) (z : α) (hz : ∀ i ∈ Ico a b, label i = z) : + D.mkQ (formalDeparture label coefficient b) = + D.mkQ (formalDeparture label coefficient a) + + (∑ i ∈ Ico a b, coefficient i) • D.mkQ (Pi.basisFun K α z) := by + rw [formalDeparture_const_run label coefficient a b hab z hz, map_add, map_smul] + +theorem affine_line_successor (anchor direction x y : V) + (hx : ∃ t : K, x = anchor + t • direction) + (c : K) (hy : y = x + c • direction) : + ∃ t : K, y = anchor + t • direction := by + obtain ⟨t, rfl⟩ := hx + refine ⟨t + c, ?_⟩ + rw [hy, add_smul, add_assoc] + +theorem nonzero_direction_increment {direction x y : V} {c : K} + (hd : direction ≠ 0) (hc : c ≠ 0) (hy : y = x + c • direction) : x ≠ y := by + intro heq + have hz : c • direction = 0 := by + have h := hy + rw [← heq] at h + exact (add_eq_left.mp h.symm) + exact (smul_ne_zero hc hd) hz + +/-- Scalar evaluation turns the formal displacement into the numerical +one in a column. A nonzero numerical run forces a nonzero scalar sum. -/ +theorem run_coefficient_ne_zero (coefficient : ℕ → K) (a b : ℕ) (prime : K) + (hnonzero : (∑ i ∈ Ico a b, coefficient i * prime) ≠ 0) : + (∑ i ∈ Ico a b, coefficient i) ≠ 0 := by + intro hz + apply hnonzero + rw [← Finset.sum_mul, hz, zero_mul] + +/-- A regular run has distinct quotient endpoints as required by the +point--line--point non-reversal check. -/ +theorem quotient_run_endpoints_ne (D : Submodule K (α → K)) + (label : ℕ → α) (coefficient : ℕ → K) + (a b : ℕ) (hab : a ≤ b) (z : α) (hz : ∀ i ∈ Ico a b, label i = z) + (hdir : D.mkQ (Pi.basisFun K α z) ≠ 0) + (hc : (∑ i ∈ Ico a b, coefficient i) ≠ 0) : + D.mkQ (formalDeparture label coefficient a) ≠ D.mkQ (formalDeparture label coefficient b) := + nonzero_direction_increment hdir hc + (quotient_departure_const_run D label coefficient a b hab z hz) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FourFormLocal.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FourFormLocal.lean new file mode 100644 index 0000000000000000000000000000000000000000..009372b4594331c21fb7a8d53fc058d101a889ee --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FourFormLocal.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResidueBox + +namespace OAI + +/-! Exact local density of the four rough-sieve forms. All coefficients +needed to solve pairs are units already over every nonzero modulus; +there is no exceptional argument at the prime two. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def zeroResidueIndicator {D : ℕ} [NeZero D] (x : ZMod D) : ℝ := + if x = 0 then 1 else 0 + +def fourFormBad {D : ℕ} [NeZero D] (x : ZMod D × ZMod D × ZMod D) : Prop := + x.1 = 0 ∨ x.2.1 = 0 ∨ x.2.2 = 0 ∨ x.1 + x.2.1 - x.2.2 = 0 + +lemma fourFormBad_indicator {D : ℕ} [NeZero D] (x y z : ZMod D) : + (if fourFormBad (x, y, z) then (1 : ℝ) else 0) = + zeroResidueIndicator x + zeroResidueIndicator y + zeroResidueIndicator z + + zeroResidueIndicator (x + y - z) - + (zeroResidueIndicator x * zeroResidueIndicator y + + zeroResidueIndicator x * zeroResidueIndicator z + + zeroResidueIndicator x * zeroResidueIndicator (x + y - z) + + zeroResidueIndicator y * zeroResidueIndicator z + + zeroResidueIndicator y * zeroResidueIndicator (x + y - z) + + zeroResidueIndicator z * zeroResidueIndicator (x + y - z)) + + (zeroResidueIndicator x * zeroResidueIndicator y * zeroResidueIndicator z + + zeroResidueIndicator x * zeroResidueIndicator y * + zeroResidueIndicator (x + y - z) + + zeroResidueIndicator x * zeroResidueIndicator z * + zeroResidueIndicator (x + y - z) + + zeroResidueIndicator y * zeroResidueIndicator z * + zeroResidueIndicator (x + y - z)) - + zeroResidueIndicator x * zeroResidueIndicator y * zeroResidueIndicator z * + zeroResidueIndicator (x + y - z) := by + by_cases hx : x = 0 <;> by_cases hy : y = 0 <;> by_cases hz : z = 0 <;> + by_cases hw : x + y - z = 0 <;> + simp only [fourFormBad, zeroResidueIndicator, hx, hy, hz, hw, + ite_true, ite_false, true_or, false_or, or_true, or_false] <;> norm_num <;> ring + +private lemma add_zero_iff_right {D : ℕ} [NeZero D] (x y : ZMod D) : + x + y = 0 ↔ y = -x := by + constructor + · intro h + calc + y = (x + y) - x := by ring + _ = -x := by rw [h]; ring + · intro h + rw [h] + ring + +/-- The count is exact for every nonzero modulus, not only prime moduli. -/ +lemma fourFormBad_count (D : ℕ) [NeZero D] : + (∑ x : ZMod D, ∑ y : ZMod D, ∑ z : ZMod D, + if fourFormBad (x, y, z) then (1 : ℝ) else 0) = + 4 * (D : ℝ) ^ 2 - 6 * D + 3 := by + simp only [fourFormBad_indicator, sum_add_distrib, sum_sub_distrib] + simp [zeroResidueIndicator, mul_ite, sub_eq_zero, + add_zero_iff_right, nsmul_eq_mul, ZMod.card] + ring + +lemma uniformResidueCube_probability {D : ℕ} [NeZero D] + (E : (ZMod D × ZMod D × ZMod D) → Prop) : + (uniformResidueCubeLaw D).probability E = + (∑ x : ZMod D, ∑ y : ZMod D, ∑ z : ZMod D, + if E (x, y, z) then (1 : ℝ) else 0) / (D : ℝ) ^ 3 := by + unfold FiniteLaw.probability FiniteLaw.average uniformResidueCubeLaw + FiniteLaw.product uniformZModLaw + simp only [Fintype.sum_prod_type] + simp_rw [← mul_assoc, ← mul_sum] + ring + +noncomputable def fourFormBadDensity (D : ℕ) [NeZero D] : ℝ := + (uniformResidueCubeLaw D).probability fourFormBad + +theorem fourFormBadDensity_exact (D : ℕ) [NeZero D] : + fourFormBadDensity D = (4 * (D : ℝ) ^ 2 - 6 * D + 3) / (D : ℝ) ^ 3 := by + rw [fourFormBadDensity, uniformResidueCube_probability, fourFormBad_count] + +lemma fourFormBadDensity_nonneg (D : ℕ) [NeZero D] : 0 ≤ fourFormBadDensity D := + (uniformResidueCubeLaw D).probability_nonneg fourFormBad + +theorem fourFormBadDensity_bounds (D : ℕ) [NeZero D] : + 4 / (D : ℝ) - 6 / (D : ℝ) ^ 2 ≤ fourFormBadDensity D ∧ + fourFormBadDensity D ≤ 4 / (D : ℝ) := by + have hD : (0 : ℝ) < D := by exact_mod_cast NeZero.pos D + have hD1 : (1 : ℝ) ≤ D := by exact_mod_cast NeZero.pos D + rw [fourFormBadDensity_exact] + constructor + · apply (le_div_iff₀ (pow_pos hD 3)).mpr + field_simp + nlinarith + · apply (div_le_iff₀ (pow_pos hD 3)).mpr + field_simp + nlinarith + +theorem fourFormBadDensity_lt_one (D : ℕ) [NeZero D] (hD : 2 ≤ D) : + fourFormBadDensity D < 1 := by + have hDr : (0 : ℝ) < D := by exact_mod_cast NeZero.pos D + have hD2 : (2 : ℝ) ≤ D := by exact_mod_cast hD + rw [fourFormBadDensity_exact, div_lt_one (pow_pos hDr 3)] + have hprod : 0 < ((D : ℝ) - 1) * (((D : ℝ) - 1) * ((D : ℝ) - 2) + 1) := by + apply mul_pos (by linarith) + have : 0 ≤ ((D : ℝ) - 1) * ((D : ℝ) - 2) := mul_nonneg (by linarith) (by linarith) + linarith + nlinarith + +lemma oneFormBadDensity (D : ℕ) [NeZero D] : + (uniformZModLaw D).probability (fun x => x = 0) = 1 / (D : ℝ) := by + simp [FiniteLaw.probability, FiniteLaw.average, uniformZModLaw] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FourierMass.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FourierMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..d3221d645ec3168ceb248e709f3cc8c5582d418f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FourierMass.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitComparison +import OAI.NumberTheory.TwoPoint.Bounds.CRTComparison +import Mathlib.Data.Nat.Choose.Bounds + +namespace OAI + +/-! +# Counting low-order Fourier coefficients + +The number of nonempty coordinate sets of order at most `t` is at most +`(t+1)n^t`. Combining individual coefficient bounds with this count gives +the explicit error budget used by finite residue comparison. +-/ + +namespace TwoPointCorrelations + +open Finset + +lemma card_lowWalshSets_le {n : ℕ} (hn : 0 < n) (t : ℕ) : + (lowWalshSets n t).card ≤ (t + 1) * n ^ t := by + have hsub : lowWalshSets n t ⊆ (Finset.range (t + 1)).biUnion + (fun k => (Finset.univ : Finset (Fin n)).powersetCard k) := by + intro S hS + have ht := (Finset.mem_filter.mp hS).2.2 + apply Finset.mem_biUnion.mpr + refine ⟨S.card, Finset.mem_range.mpr (by omega), ?_⟩ + simp + calc + (lowWalshSets n t).card ≤ ((Finset.range (t + 1)).biUnion + (fun k => (Finset.univ : Finset (Fin n)).powersetCard k)).card := + Finset.card_le_card hsub + _ ≤ ∑ k ∈ Finset.range (t + 1), ((Finset.univ : Finset (Fin n)).powersetCard k).card := + Finset.card_biUnion_le + _ = ∑ k ∈ Finset.range (t + 1), n.choose k := by simp + _ ≤ ∑ _k ∈ Finset.range (t + 1), n ^ t := by + apply Finset.sum_le_sum + intro k hk + exact (Nat.choose_le_pow n k).trans (Nat.pow_le_pow_right hn (by + have := Finset.mem_range.mp hk + omega)) + _ = (t + 1) * n ^ t := by simp + +lemma lowWalshMass_le_of_coefficients {n : ℕ} (hn : 0 < n) + (f : BooleanCube n → ℝ) (t : ℕ) (δ : ℝ) (hδ : 0 ≤ δ) + (hf : ∀ S ∈ lowWalshSets n t, |walshCoefficient f S| ≤ δ) : + lowWalshMass f t ≤ δ * ((t + 1 : ℕ) : ℝ) * (n : ℝ) ^ t := by + unfold lowWalshMass + calc + (∑ S ∈ lowWalshSets n t, |walshCoefficient f S|) ≤ ∑ _S ∈ lowWalshSets n t, δ := + Finset.sum_le_sum hf + _ = δ * ((lowWalshSets n t).card : ℝ) := by simp [mul_comm] + _ ≤ δ * (((t + 1) * n ^ t : ℕ) : ℝ) := + mul_le_mul_of_nonneg_left (by exact_mod_cast card_lowWalshSets_le hn t) hδ + _ = _ := by push_cast; ring + +/-- The fixed-parameter finite-law consequence of Braverman's theorem: +only the individual low-order Fourier errors and the actual circuit size +and depth occur as hypotheses. -/ +theorem BravermanDepth22Input.coefficient_comparison (hBraverman : BravermanDepth22Input) : + ∃ K C : ℕ, 0 < K ∧ 0 < C ∧ ∀ (n : ℕ), 0 < n → + ∀ (c : AC0Circuit n), c.depth ≤ 22 → + ∀ ε : ℝ, 0 < ε → ε ≤ 1 / 2 → ∀ t : ℕ, + (K : ℝ) * (Real.log ((c.size : ℝ) / ε)) ^ C ≤ (t : ℝ) → + ∀ (f : BooleanCube n → ℝ) (δ a : ℝ), + (∀ x, 0 ≤ f x) → cubeAverage f = 1 → 0 ≤ δ → + (∀ S ∈ lowWalshSets n t, |walshCoefficient f S| ≤ δ) → + δ * ((t + 1 : ℕ) : ℝ) * (n : ℝ) ^ t ≤ a → + |cubeAverage (fun x => f x * c.indicator x) - cubeAverage c.indicator| ≤ + 3 * a / 2 + ε := by + obtain ⟨K, C, hK, hC, hbound⟩ := hBraverman.fourier_comparison + refine ⟨K, C, hK, hC, ?_⟩ + intro n hn c hc ε hε hεmax t ht f δ a hf hmean hδ hcoeff ha + have hmass := lowWalshMass_le_of_coefficients hn f t δ hδ hcoeff + have ha0 : 0 ≤ a := le_trans (by positivity) ha + exact hbound n c hc ε hε hεmax t ht f a hf hmean ha0 (hmass.trans ha) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FourierPrimeCutoff.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FourierPrimeCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..5869f940f5eb8faff529bc0ad2616080afe31e53 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FourierPrimeCutoff.lean @@ -0,0 +1,129 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FinitePrimePhases +import OAI.NumberTheory.TwoPoint.Bounds.WeightedFourierIntegration +import Mathlib.Analysis.Fourier.Inversion + +namespace OAI + +/-! Fourier inversion of a cutoff evaluated at the centered count of +distinct prime divisors. The integral kernel splits into a constant phase +and the multiplicative finite-prime twist. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical FourierTransform + +noncomputable def primeCutoffKernel (P : Finset ℕ) (μ σ t : ℝ) (n : ℕ) : ℂ := + additiveCharacter (-t * μ / σ) 1 * finitePrimePhase P (t / σ) n + +lemma norm_primeCutoffKernel (P : Finset ℕ) (μ σ t : ℝ) (n : ℕ) : + ‖primeCutoffKernel P μ σ t n‖ = 1 := by + simp only [primeCutoffKernel, norm_mul, norm_additiveCharacter, + norm_finitePrimePhase, one_mul] + +lemma primeCutoffKernel_eq_exp (P : Finset ℕ) (μ σ t : ℝ) (n : ℕ) : + primeCutoffKernel P μ σ t n = + Complex.exp (((2 * Real.pi * t * + (((finitePrimeDivisorCount P n : ℝ) - μ) / σ) : ℝ) : ℂ) * Complex.I) := by + unfold primeCutoffKernel finitePrimePhase additiveCharacter + rw [← Complex.exp_add] + congr 1 + push_cast + ring + +lemma continuous_primeCutoffKernel (P : Finset ℕ) (μ σ : ℝ) (n : ℕ) : + Continuous (fun t => primeCutoffKernel P μ σ t n) := by + simp_rw [primeCutoffKernel_eq_exp] + fun_prop + +lemma integrable_weighted_primeCutoffKernel (P : Finset ℕ) (μ σ : ℝ) (n : ℕ) + {w : ℝ → ℂ} (hw : Integrable w) : + Integrable (fun t => w t * primeCutoffKernel P μ σ t n) := by + exact hw.mul_bdd (continuous_primeCutoffKernel P μ σ n).aestronglyMeasurable + (Filter.Eventually.of_forall (fun t => (norm_primeCutoffKernel P μ σ t n).le)) + +noncomputable def primeCountCutoff (P : Finset ℕ) (μ σ : ℝ) + (w : ℝ → ℂ) (n : ℕ) : ℂ := + ∫ t, w t * primeCutoffKernel P μ σ t n + +lemma primeCountCutoff_eq_fourierInv (P : Finset ℕ) (μ σ : ℝ) + (w : ℝ → ℂ) (n : ℕ) : + primeCountCutoff P μ σ w n = + 𝓕⁻ w (((finitePrimeDivisorCount P n : ℝ) - μ) / σ) := by + rw [Real.fourierInv_eq'] + unfold primeCountCutoff + apply integral_congr_ae + exact Filter.Eventually.of_forall (fun t => by + dsimp only + rw [primeCutoffKernel_eq_exp] + simp only [smul_eq_mul, Real.inner_apply, mul_assoc] + exact mul_comm _ _) + +/-- This is the actual cutoff `φ((ω_P(n)-μ)/σ)` when the frequency +coefficient is the Fourier transform of a continuous integrable cutoff. -/ +theorem primeCountCutoff_fourier (P : Finset ℕ) (μ σ : ℝ) + (φ : ℝ → ℂ) (hφ : Continuous φ) (hi : Integrable φ) + (hFourier : Integrable (𝓕 φ)) (n : ℕ) : + primeCountCutoff P μ σ (𝓕 φ) n = + φ (((finitePrimeDivisorCount P n : ℝ) - μ) / σ) := by + rw [primeCountCutoff_eq_fourierInv, hφ.fourierInv_fourier_eq hi hFourier] + +/-- Exact interchange for the two prime-count cutoffs in a finite +correlation sum. -/ +theorem primeCountCutoff_pair_sum {ι : Type*} (S : Finset ι) (c : ι → ℂ) + (n m : ι → ℕ) (P Q : Finset ℕ) (μ σ ν τ : ℝ) (w₁ w₂ : ℝ → ℂ) + (hw₁ : Integrable w₁) (hw₂ : Integrable w₂) : + (∑ i ∈ S, c i * primeCountCutoff P μ σ w₁ (n i) * + primeCountCutoff Q ν τ w₂ (m i)) = + ∫ t, ∫ s, ∑ i ∈ S, + c i * (w₁ t * primeCutoffKernel P μ σ t (n i)) * + (w₂ s * primeCutoffKernel Q ν τ s (m i)) := by + exact finite_two_integrals S c + (fun i t => w₁ t * primeCutoffKernel P μ σ t (n i)) + (fun i s => w₂ s * primeCutoffKernel Q ν τ s (m i)) + (fun i _ => integrable_weighted_primeCutoffKernel P μ σ (n i) hw₁) + (fun i _ => integrable_weighted_primeCutoffKernel Q ν τ (m i) hw₂) + +/-- The cutoff factors are exactly a Fourier average of multiplicative +finite-prime twists, with two unit-modulus constant phases. -/ +theorem primeCountCutoff_twisted_pair_sum {ι : Type*} (S : Finset ι) + (c : ι → ℂ) (n m : ι → ℕ) (f g : ℕ → ℂ) (P Q : Finset ℕ) + (μ σ ν τ : ℝ) (w₁ w₂ : ℝ → ℂ) + (hw₁ : Integrable w₁) (hw₂ : Integrable w₂) : + (∑ i ∈ S, (c i * f (n i) * g (m i)) * primeCountCutoff P μ σ w₁ (n i) * + primeCountCutoff Q ν τ w₂ (m i)) = + ∫ t, ∫ s, w₁ t * w₂ s * + (additiveCharacter (-t * μ / σ) 1 * additiveCharacter (-s * ν / τ) 1 * + ∑ i ∈ S, c i * twistByPrimePhase f P (t / σ) (n i) * + twistByPrimePhase g Q (s / τ) (m i)) := by + rw [primeCountCutoff_pair_sum S (fun i => c i * f (n i) * g (m i)) + n m P Q μ σ ν τ w₁ w₂ hw₁ hw₂] + apply integral_congr_ae + apply Filter.Eventually.of_forall + intro t + apply integral_congr_ae + apply Filter.Eventually.of_forall + intro s + dsimp only + simp only [primeCutoffKernel, twistByPrimePhase, mul_sum] + apply sum_congr rfl + intro i _ + ring + +theorem norm_primeCountCutoff_pair_sum_le {ι : Type*} (S : Finset ι) + (c : ι → ℂ) (n m : ι → ℕ) (f g : ℕ → ℂ) (P Q : Finset ℕ) + (μ σ ν τ : ℝ) (w₁ w₂ : ℝ → ℂ) + (hw₁ : Integrable w₁) (hw₂ : Integrable w₂) (E : ℝ) + (hbound : ∀ t s, ‖∑ i ∈ S, c i * twistByPrimePhase f P (t / σ) (n i) * + twistByPrimePhase g Q (s / τ) (m i)‖ ≤ E) : + ‖∑ i ∈ S, (c i * f (n i) * g (m i)) * primeCountCutoff P μ σ w₁ (n i) * + primeCountCutoff Q ν τ w₂ (m i)‖ ≤ + E * (∫ t, ‖w₁ t‖) * (∫ s, ‖w₂ s‖) := by + rw [primeCountCutoff_twisted_pair_sum S c n m f g P Q μ σ ν τ w₁ w₂ hw₁ hw₂] + apply norm_two_weighted_integrals w₁ w₂ hw₁ hw₂ + intro t s + simpa only [norm_mul, norm_additiveCharacter, one_mul] using hbound t s + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FourierRegionBound.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FourierRegionBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..0df562ec34b9496bee7e94589c28294caa5a2f30 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FourierRegionBound.lean @@ -0,0 +1,170 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughFourier +import Mathlib.MeasureTheory.Function.LpSpace.Indicator + +namespace OAI + +/-! +# The low/high Fourier split + +The short-sum bound is uniform at a fixed frequency. It is applied after +summing the origins, and no supremum is moved through an integral. +-/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +private lemma circle_integrable {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] (f : AddCircle (1 : ℝ) → E) (hf : Continuous f) : + Integrable f AddCircle.haarAddCircle := + hf.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) + +lemma circle_integral_mul_norm_le (F G : AddCircle (1 : ℝ) → ℂ) + (hF : Continuous F) (hG : Continuous G) : + (∫ θ, ‖F θ‖ * ‖G θ‖ ∂AddCircle.haarAddCircle) ≤ + Real.sqrt (∫ θ, ‖F θ‖ ^ 2 ∂AddCircle.haarAddCircle) * + Real.sqrt (∫ θ, ‖G θ‖ ^ 2 ∂AddCircle.haarAddCircle) := by + have hf : MemLp F (ENNReal.ofReal (2 : ℝ)) AddCircle.haarAddCircle := + hF.memLp_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) + have hg : MemLp G (ENNReal.ofReal (2 : ℝ)) AddCircle.haarAddCircle := + hG.memLp_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) + have hh := integral_mul_norm_le_Lp_mul_Lq + (show (2 : ℝ).HolderConjugate 2 by norm_num [Real.holderConjugate_iff]) hf hg + simpa only [Real.rpow_two, Real.sqrt_eq_rpow, one_div] using hh + +private lemma fourier_pointwise_split {ι : Type*} (S : Finset ι) + (B : AddCircle (1 : ℝ) → ℂ) (F G : ι → AddCircle (1 : ℝ) → ℂ) + (ε Bmax Gmax K : ℝ) (hε : 0 < ε) + (hBmax : 0 ≤ Bmax) (hGmax : 0 ≤ Gmax) (hK : 0 ≤ K) + (hBbound : ∀ θ, ‖B θ‖ ≤ Bmax) + (hGbound : ∀ v ∈ S, ∀ θ, ‖G v θ‖ ≤ Gmax) + (hFsum : ∀ θ, (∑ v ∈ S, ‖F v θ‖) ≤ K) (θ : AddCircle (1 : ℝ)) : + (∑ v ∈ S, ‖B θ‖ * ‖F v θ‖ * ‖G v θ‖) ≤ + ε * (∑ v ∈ S, ‖F v θ‖ * ‖G v θ‖) + + (Bmax * Gmax * K / ε ^ 4) * ‖B θ‖ ^ 4 := by + let A (θ : AddCircle (1 : ℝ)) := ∑ v ∈ S, ‖F v θ‖ * ‖G v θ‖ + let C : ℝ := Bmax * Gmax * K / ε ^ 4 + have hC : 0 ≤ C := by dsimp [C]; positivity + by_cases ht : ‖B θ‖ ≤ ε + · calc + _ ≤ ∑ v ∈ S, ε * (‖F v θ‖ * ‖G v θ‖) := by + apply sum_le_sum + intro v _ + calc + _ = ‖B θ‖ * (‖F v θ‖ * ‖G v θ‖) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_right ht + (mul_nonneg (norm_nonneg (F v θ)) (norm_nonneg (G v θ))) + _ = ε * A θ := by simp only [A, mul_sum] + _ ≤ _ := le_add_of_nonneg_right (mul_nonneg hC (by positivity)) + · have hs : (∑ v ∈ S, ‖B θ‖ * ‖F v θ‖ * ‖G v θ‖) ≤ Bmax * Gmax * K := by + calc + _ ≤ ∑ v ∈ S, Bmax * Gmax * ‖F v θ‖ := by + apply sum_le_sum + intro v hv + have hh := mul_le_mul (hBbound θ) (hGbound v hv θ) + (norm_nonneg _) hBmax + calc + _ = (‖B θ‖ * ‖G v θ‖) * ‖F v θ‖ := by ring + _ ≤ _ := mul_le_mul_of_nonneg_right hh (norm_nonneg (F v θ)) + _ = Bmax * Gmax * ∑ v ∈ S, ‖F v θ‖ := (mul_sum _ _ _).symm + _ ≤ _ := mul_le_mul_of_nonneg_left (hFsum θ) (mul_nonneg hBmax hGmax) + have hp : ε ^ 4 ≤ ‖B θ‖ ^ 4 := + pow_le_pow_left₀ hε.le (le_of_lt (lt_of_not_ge ht)) 4 + have hc : Bmax * Gmax * K ≤ C * ‖B θ‖ ^ 4 := by + dsimp [C] + rw [div_mul_eq_mul_div] + apply (le_div_iff₀ (pow_pos hε 4)).mpr + exact mul_le_mul_of_nonneg_left hp (mul_nonneg (mul_nonneg hBmax hGmax) hK) + exact hs.trans (hc.trans (le_add_of_nonneg_left (mul_nonneg hε.le + (sum_nonneg (fun v _ => mul_nonneg (norm_nonneg _) (norm_nonneg _)))))) + + +private lemma norm_sum_circle_integral_le {ι : Type*} (S : Finset ι) + (U : ι → AddCircle (1 : ℝ) → ℂ) (hU : ∀ v ∈ S, Continuous (U v)) : + ‖∑ v ∈ S, ∫ θ, U v θ ∂AddCircle.haarAddCircle‖ ≤ + ∫ θ, ∑ v ∈ S, ‖U v θ‖ ∂AddCircle.haarAddCircle := by + calc + _ ≤ ∑ v ∈ S, ‖∫ θ, U v θ ∂AddCircle.haarAddCircle‖ := norm_sum_le _ _ + _ ≤ ∑ v ∈ S, ∫ θ, ‖U v θ‖ ∂AddCircle.haarAddCircle := by + exact sum_le_sum (fun v _ => norm_integral_le_integral_norm (U v)) + _ = _ := by + rw [integral_finsetSum S (f := fun v θ => ‖U v θ‖) + (fun v hv => (circle_integrable (U v) (hU v hv)).norm)] + +private lemma circle_integral_sum_mul_norm_le {ι : Type*} (S : Finset ι) + (F G : ι → AddCircle (1 : ℝ) → ℂ) + (hF : ∀ v ∈ S, Continuous (F v)) (hG : ∀ v ∈ S, Continuous (G v)) : + (∫ θ, ∑ v ∈ S, ‖F v θ‖ * ‖G v θ‖ ∂AddCircle.haarAddCircle) ≤ + ∑ v ∈ S, Real.sqrt (∫ θ, ‖F v θ‖ ^ 2 ∂AddCircle.haarAddCircle) * + Real.sqrt (∫ θ, ‖G v θ‖ ^ 2 ∂AddCircle.haarAddCircle) := by + rw [integral_finsetSum S (f := fun v θ => ‖F v θ‖ * ‖G v θ‖) + (fun v hv => circle_integrable _ ((hF v hv).norm.mul (hG v hv).norm))] + exact sum_le_sum (fun v hv => circle_integral_mul_norm_le _ _ (hF v hv) (hG v hv)) + +private lemma circle_integral_linear_bound + (P A B : AddCircle (1 : ℝ) → ℝ) (hP : Continuous P) (hA : Continuous A) + (hB : Continuous B) (ε C : ℝ) (hpoint : ∀ θ, P θ ≤ ε * A θ + C * B θ) : + (∫ θ, P θ ∂AddCircle.haarAddCircle) ≤ + ε * (∫ θ, A θ ∂AddCircle.haarAddCircle) + + C * ∫ θ, B θ ∂AddCircle.haarAddCircle := by + have hl : Integrable (fun θ => ε * A θ) AddCircle.haarAddCircle := + (circle_integrable _ hA).const_mul _ + have hr : Integrable (fun θ => C * B θ) AddCircle.haarAddCircle := + (circle_integrable _ hB).const_mul _ + calc + _ ≤ ∫ θ, ε * A θ + C * B θ ∂AddCircle.haarAddCircle := + integral_mono (circle_integrable _ hP) (hl.add hr) hpoint + _ = _ := by rw [integral_add hl hr, integral_const_mul, integral_const_mul] + +private lemma circle_integrate_pointwise_split {ι : Type*} (S : Finset ι) + (B : AddCircle (1 : ℝ) → ℂ) (F G : ι → AddCircle (1 : ℝ) → ℂ) + (hB : Continuous B) (hF : ∀ v ∈ S, Continuous (F v)) + (hG : ∀ v ∈ S, Continuous (G v)) (ε C : ℝ) + (hpoint : ∀ θ, (∑ v ∈ S, ‖B θ‖ * ‖F v θ‖ * ‖G v θ‖) ≤ + ε * (∑ v ∈ S, ‖F v θ‖ * ‖G v θ‖) + C * ‖B θ‖ ^ 4) : + ‖∑ v ∈ S, ∫ θ, B θ * F v θ * G v θ ∂AddCircle.haarAddCircle‖ ≤ + ε * (∫ θ, ∑ v ∈ S, ‖F v θ‖ * ‖G v θ‖ ∂AddCircle.haarAddCircle) + + C * ∫ θ, ‖B θ‖ ^ 4 ∂AddCircle.haarAddCircle := by + have hnorm := norm_sum_circle_integral_le S + (fun v θ => B θ * F v θ * G v θ) + (fun v hv => (hB.mul (hF v hv)).mul (hG v hv)) + apply hnorm.trans + apply circle_integral_linear_bound + (fun θ => ∑ v ∈ S, ‖B θ * F v θ * G v θ‖) + (fun θ => ∑ v ∈ S, ‖F v θ‖ * ‖G v θ‖) + (fun θ => ‖B θ‖ ^ 4) + (continuous_finsetSum S (fun v hv => ((hB.mul (hF v hv)).mul (hG v hv)).norm)) + (continuous_finsetSum S (fun v hv => (hF v hv).norm.mul (hG v hv).norm)) + (hB.norm.pow 4) ε C + intro θ + simpa only [norm_mul] using hpoint θ + +/-- A finite-family version of the analytic split. The threshold term uses +only Cauchy--Schwarz; the complementary term uses the fourth moment and +our fixed-frequency sum over origins. -/ +theorem fourier_region_bound {ι : Type*} (S : Finset ι) + (B : AddCircle (1 : ℝ) → ℂ) (F G : ι → AddCircle (1 : ℝ) → ℂ) + (hB : Continuous B) (hF : ∀ v ∈ S, Continuous (F v)) + (hG : ∀ v ∈ S, Continuous (G v)) + (ε Bmax Gmax K : ℝ) (hε : 0 < ε) + (hBmax : 0 ≤ Bmax) (hGmax : 0 ≤ Gmax) (hK : 0 ≤ K) + (hBbound : ∀ θ, ‖B θ‖ ≤ Bmax) + (hGbound : ∀ v ∈ S, ∀ θ, ‖G v θ‖ ≤ Gmax) + (hFsum : ∀ θ, (∑ v ∈ S, ‖F v θ‖) ≤ K) : + ‖∑ v ∈ S, ∫ θ, B θ * F v θ * G v θ ∂AddCircle.haarAddCircle‖ ≤ + ε * ∑ v ∈ S, + Real.sqrt (∫ θ, ‖F v θ‖ ^ 2 ∂AddCircle.haarAddCircle) * + Real.sqrt (∫ θ, ‖G v θ‖ ^ 2 ∂AddCircle.haarAddCircle) + + (Bmax * Gmax * K / ε ^ 4) * + ∫ θ, ‖B θ‖ ^ 4 ∂AddCircle.haarAddCircle := by + apply (circle_integrate_pointwise_split S B F G hB hF hG ε + (Bmax * Gmax * K / ε ^ 4) + (fourier_pointwise_split S B F G ε Bmax Gmax K hε hBmax hGmax hK + hBbound hGbound hFsum)).trans + exact add_le_add (mul_le_mul_of_nonneg_left + (circle_integral_sum_mul_norm_le S F G hF hG) hε.le) le_rfl + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FullDivisibility.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FullDivisibility.lean new file mode 100644 index 0000000000000000000000000000000000000000..ffa73cc9ef813bfa190b0fd2315ab69892af68d7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FullDivisibility.lean @@ -0,0 +1,119 @@ +import OAI.NumberTheory.TwoPoint.Bounds.LiouvilleDivisorExtraction +import OAI.NumberTheory.TwoPoint.Bounds.NearbyCutoffs +import Mathlib.Algebra.Order.Floor.Semifield + +namespace OAI + +/-! The full-divisibility term extracts the original progression +correlation at a cutoff in the same logarithmic bin. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def fullLiouvilleProfile (l : ℕ) [NeZero l] (b : ZMod l) + (u h n : ℕ) : ℂ := + natDivisibilityIndicator u n * + (progressionSequence liouville l (b * (u : ZMod l)) n * liouville (n + h * u)) + +lemma fullLiouvilleProfile_prefix (l : ℕ) [NeZero l] (b : ZMod l) + (u h N : ℕ) (hu : 0 < u) (hunit : IsUnit (u : ZMod l)) : + positivePrefix (fullLiouvilleProfile l b u h) N = + positivePrefix (fun n => progressionSequence liouville l b n * liouville (n + h)) (N / u) := by + unfold fullLiouvilleProfile + rw [divisibility_positivePrefix _ u N hu] + congr 1 + funext v + simpa only [Nat.cast_one, mul_one] using liouville_progression_dilate l b u v 1 h hu hunit + +lemma progressionLiouvilleProfile_oneBounded (l : ℕ) [NeZero l] (b : ZMod l) (h : ℕ) : + OneBounded (fun n => progressionSequence liouville l b n * liouville (n + h)) := by + intro n hn + dsimp only [progressionSequence] + split_ifs + · rw [norm_mul] + calc + _ ≤ 1 * 1 := mul_le_mul (liouville_oneBounded n hn) + (liouville_oneBounded (n + h) (by omega)) (norm_nonneg _) (by norm_num) + _ = _ := by norm_num + · simp only [zero_mul, norm_zero, zero_le_one] + +lemma fullLiouvilleProfile_real_prefix (l : ℕ) [NeZero l] (b : ZMod l) + (u h : ℕ) (hu : 0 < u) (hunit : IsUnit (u : ZMod l)) (T : ℝ) (hT : 0 < T) : + positivePrefix (fullLiouvilleProfile l b u h) ⌊T⌋₊ / (T : ℂ) = + (1 / (u : ℂ)) * + (positivePrefix (fun n => progressionSequence liouville l b n * liouville (n + h)) + ⌊T / u⌋₊ / ((T / u : ℝ) : ℂ)) := by + rw [fullLiouvilleProfile_prefix l b u h _ hu hunit, Nat.floor_div_natCast] + push_cast + have huC : (u : ℂ) ≠ 0 := by exact_mod_cast hu.ne' + have hTC : (T : ℂ) ≠ 0 := by exact_mod_cast hT.ne' + field_simp + +lemma fullLiouvilleProfile_bin_error (l : ℕ) [NeZero l] (b : ZMod l) + (u h : ℕ) (hu : 0 < u) (hunit : IsUnit (u : ZMod l)) + (X T η : ℝ) (hX : 0 < X) (hη : 0 ≤ η) + (hlo : X * Real.exp (-η) ≤ T / u) (hhi : T / u ≤ X) : + ‖positivePrefix (fullLiouvilleProfile l b u h) ⌊T⌋₊ / (T : ℂ) - + (1 / (u : ℂ)) * + (positivePrefix (fun n => progressionSequence liouville l b n * liouville (n + h)) + ⌊X⌋₊ / (X : ℂ))‖ ≤ (1 / (u : ℝ)) * (2 * η + 1 / X) := by + have hY : 0 < T / u := (mul_pos hX (Real.exp_pos _)).trans_le hlo + have huR : (0 : ℝ) < u := by exact_mod_cast hu + have hT : 0 < T := by + rcases div_pos_iff.mp hY with hp | hn + · exact hp.1 + · linarith [hn.2] + rw [fullLiouvilleProfile_real_prefix l b u h hu hunit T hT, ← mul_sub, norm_mul] + have hc := real_prefix_log_bin _ (progressionLiouvilleProfile_oneBounded l b h) + X (T / u) η hX hη hlo hhi + simpa only [norm_div, norm_one, Complex.norm_natCast] using + mul_le_mul_of_nonneg_left hc (by positivity : (0 : ℝ) ≤ 1 / (u : ℝ)) + +lemma full_divisibility_bin_sum_error (l : ℕ) [NeZero l] (b : ZMod l) + (h : ℕ) (U : Finset ℕ) (weight : ℕ → ℝ) + (hweight : ∀ u ∈ U, 0 ≤ weight u) (hu : ∀ u ∈ U, 0 < u) + (hunit : ∀ u ∈ U, IsUnit (u : ZMod l)) (X T η : ℝ) + (hX : 0 < X) (hη : 0 ≤ η) + (hlo : ∀ u ∈ U, X * Real.exp (-η) ≤ T / u) + (hhi : ∀ u ∈ U, T / u ≤ X) : + ‖(∑ u ∈ U, (weight u : ℂ) * + (positivePrefix (fullLiouvilleProfile l b u h) ⌊T⌋₊ / (T : ℂ))) - + ((∑ u ∈ U, weight u / (u : ℝ) : ℝ) : ℂ) * + (positivePrefix (fun n => progressionSequence liouville l b n * liouville (n + h)) + ⌊X⌋₊ / (X : ℂ))‖ ≤ + (∑ u ∈ U, weight u / (u : ℝ)) * (2 * η + 1 / X) := by + let F := positivePrefix + (fun n => progressionSequence liouville l b n * liouville (n + h)) ⌊X⌋₊ / (X : ℂ) + have he : (∑ u ∈ U, (weight u : ℂ) * + (positivePrefix (fullLiouvilleProfile l b u h) ⌊T⌋₊ / (T : ℂ))) - + ((∑ u ∈ U, weight u / (u : ℝ) : ℝ) : ℂ) * F = + ∑ u ∈ U, (weight u : ℂ) * + ((positivePrefix (fullLiouvilleProfile l b u h) ⌊T⌋₊ / (T : ℂ)) - + (1 / (u : ℂ)) * F) := by + push_cast + rw [sum_mul, ← sum_sub_distrib] + apply sum_congr rfl + intro u _ + ring + change ‖_ - _ * F‖ ≤ _ + rw [he] + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ u ∈ U, weight u * ((1 / (u : ℝ)) * (2 * η + 1 / X)) := by + apply sum_le_sum + intro u huU + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hweight u huU)] + exact mul_le_mul_of_nonneg_left + (fullLiouvilleProfile_bin_error l b u h (hu u huU) (hunit u huU) X T η hX hη + (hlo u huU) (hhi u huU)) (hweight u huU) + _ = _ := by + rw [sum_mul] + apply sum_congr rfl + intro u _ + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FullDivisibilityFamily.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FullDivisibilityFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..a7281a07e557dcd2923a53faba8ae234e7712f1d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FullDivisibilityFamily.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FullDivisibility + +namespace OAI + +/-! Finite weighted summation of the full-divisibility cutoff errors. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma full_divisibility_family_error {ι : Type*} (l : ℕ) [NeZero l] (b : ZMod l) + (h : ℕ) (U : Finset ι) (u : ι → ℕ) (weight : ι → ℝ) + (hweight : ∀ i ∈ U, 0 ≤ weight i) (hu : ∀ i ∈ U, 0 < u i) + (hunit : ∀ i ∈ U, IsUnit (u i : ZMod l)) (X T η : ℝ) + (hX : 0 < X) (hη : 0 ≤ η) + (hlo : ∀ i ∈ U, X * Real.exp (-η) ≤ T / u i) + (hhi : ∀ i ∈ U, T / u i ≤ X) : + ‖(∑ i ∈ U, (weight i : ℂ) * + (positivePrefix (fullLiouvilleProfile l b (u i) h) ⌊T⌋₊ / (T : ℂ))) - + ((∑ i ∈ U, weight i / (u i : ℝ) : ℝ) : ℂ) * + (positivePrefix (fun n => progressionSequence liouville l b n * liouville (n + h)) + ⌊X⌋₊ / (X : ℂ))‖ ≤ + (∑ i ∈ U, weight i / (u i : ℝ)) * (2 * η + 1 / X) := by + let F := positivePrefix + (fun n => progressionSequence liouville l b n * liouville (n + h)) ⌊X⌋₊ / (X : ℂ) + have he : (∑ i ∈ U, (weight i : ℂ) * + (positivePrefix (fullLiouvilleProfile l b (u i) h) ⌊T⌋₊ / (T : ℂ))) - + ((∑ i ∈ U, weight i / (u i : ℝ) : ℝ) : ℂ) * F = + ∑ i ∈ U, (weight i : ℂ) * + ((positivePrefix (fullLiouvilleProfile l b (u i) h) ⌊T⌋₊ / (T : ℂ)) - + (1 / (u i : ℂ)) * F) := by + push_cast + rw [sum_mul, ← sum_sub_distrib] + apply sum_congr rfl + intro i _ + ring + change ‖_ - _ * F‖ ≤ _ + rw [he] + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ i ∈ U, weight i * ((1 / (u i : ℝ)) * (2 * η + 1 / X)) := by + apply sum_le_sum + intro i hiU + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hweight i hiU)] + exact mul_le_mul_of_nonneg_left + (fullLiouvilleProfile_bin_error l b (u i) h (hu i hiU) (hunit i hiU) X T η hX hη + (hlo i hiU) (hhi i hiU)) (hweight i hiU) + _ = _ := by + rw [sum_mul] + apply sum_congr rfl + intro i _ + ring + + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FullNumericalBins.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FullNumericalBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb72855993a0d6ac9b091e0e584084e3d19d7c27 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FullNumericalBins.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FullDivisibilityFamily +import OAI.NumberTheory.TwoPoint.Bounds.NumericalBins + +namespace OAI + +/-! The full-divisibility main term on the exact retained numerical pairs, +with its original harmonic mass and real bin endpoint. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def numericalBinPairs (D R : Finset ℕ) (L η : ℝ) (j : ℤ) : Finset (ℕ × ℕ) := + (D ×ˢ R).filter (fun e => numericalBinEligible L η j e.1 e.2) + +noncomputable def numericalBinHarmonicMass (D R : Finset ℕ) (L η : ℝ) (j : ℤ) : ℝ := + ∑ e ∈ numericalBinPairs D R L η j, actualPaddingCoefficient e.2 / (e.1 * e.2 : ℕ) + +noncomputable def fullNumericalBin (D R : Finset ℕ) (L η : ℝ) (j : ℤ) + (l : ℕ) [NeZero l] (b : ZMod l) (h : ℕ) (T : ℝ) : ℂ := + ∑ e ∈ numericalBinPairs D R L η j, (actualPaddingCoefficient e.2 : ℂ) * + (positivePrefix (fullLiouvilleProfile l b (e.2 * e.1) h) ⌊T⌋₊ / (T : ℂ)) + +lemma numericalBinHarmonicMass_nonneg (D R : Finset ℕ) (L η : ℝ) (j : ℤ) : + 0 ≤ numericalBinHarmonicMass D R L η j := by + apply sum_nonneg + intro e _ + exact div_nonneg (actualPaddingCoefficient_nonneg _) (Nat.cast_nonneg _) + +lemma fullNumericalBin_error (D R : Finset ℕ) (L η X : ℝ) + (hX : 0 < X) (hη : 0 ≤ η) (j : ℤ) + (l : ℕ) [NeZero l] (b : ZMod l) (h : ℕ) + (hunit : ∀ d ∈ D, ∀ q ∈ R, IsUnit ((q * d : ℕ) : ZMod l)) : + ‖fullNumericalBin D R L η j l b h (X * Real.exp ((j : ℝ) * η)) - + (numericalBinHarmonicMass D R L η j : ℂ) * + (positivePrefix (fun n => progressionSequence liouville l b n * liouville (n + h)) + ⌊X⌋₊ / (X : ℂ))‖ ≤ + numericalBinHarmonicMass D R L η j * (2 * η + 1 / X) := by + have he (e : ℕ × ℕ) (he : e ∈ numericalBinPairs D R L η j) : + e.1 ∈ D ∧ e.2 ∈ R ∧ numericalBinEligible L η j e.1 e.2 := by + simpa only [numericalBinPairs, mem_filter, mem_product, and_assoc] using he + have hb := full_divisibility_family_error l b h (numericalBinPairs D R L η j) + (fun e => e.2 * e.1) (fun e => actualPaddingCoefficient e.2) + (fun e _ => actualPaddingCoefficient_nonneg e.2) + (fun e he' => Nat.mul_pos (he e he').2.2.2.1 (he e he').2.2.1) + (fun e he' => hunit e.1 (he e he').1 e.2 (he e he').2.1) + X (X * Real.exp ((j : ℝ) * η)) η hX hη + (fun e he' => by + simpa only [Nat.mul_comm] using (actualPaddingBin_cutoff e.1 e.2 + (he e he').2.2.1 (he e he').2.2.2.1 η X hX j (he e he').2.2.2.2.2).1) + (fun e he' => by + simpa only [Nat.mul_comm] using (actualPaddingBin_cutoff e.1 e.2 + (he e he').2.2.1 (he e he').2.2.2.1 η X hX j (he e he').2.2.2.2.2).2) + simpa only [fullNumericalBin, numericalBinHarmonicMass, Nat.mul_comm] using hb + +lemma numericalBinHarmonicMass_total (D Q : Finset ℕ) + (hD : ∀ d ∈ D, 0 < d) (hQ : ∀ p ∈ Q, p.Prime) + (L η : ℝ) (hL : 1 ≤ L) : + (∑ j ∈ paddingBinIndices L η, + numericalBinHarmonicMass D (boundedPaddingDivisors Q ⌊100 * Real.log L⌋₊) L η j) = + totalPaddingBinMass D Q L η := by + simp only [numericalBinHarmonicMass, numericalBinPairs, sum_filter, sum_product] + exact numericalBin_mass D Q hD hQ L η hL + +theorem fullNumericalBins_error (D Q : Finset ℕ) + (hD : ∀ d ∈ D, 0 < d) (hQ : ∀ p ∈ Q, p.Prime) + (L η X : ℝ) (hL : 1 ≤ L) (hX : 0 < X) (hη : 0 ≤ η) + (l : ℕ) [NeZero l] (b : ZMod l) (h : ℕ) + (hunit : ∀ d ∈ D, ∀ q ∈ boundedPaddingDivisors Q ⌊100 * Real.log L⌋₊, + IsUnit ((q * d : ℕ) : ZMod l)) : + ‖(∑ j ∈ paddingBinIndices L η, + fullNumericalBin D (boundedPaddingDivisors Q ⌊100 * Real.log L⌋₊) L η j l b h + (X * Real.exp ((j : ℝ) * η))) - + (totalPaddingBinMass D Q L η : ℂ) * + (positivePrefix (fun n => progressionSequence liouville l b n * liouville (n + h)) + ⌊X⌋₊ / (X : ℂ))‖ ≤ + totalPaddingBinMass D Q L η * (2 * η + 1 / X) := by + let R := boundedPaddingDivisors Q ⌊100 * Real.log L⌋₊ + let F := positivePrefix + (fun n => progressionSequence liouville l b n * liouville (n + h)) ⌊X⌋₊ / (X : ℂ) + have hm := numericalBinHarmonicMass_total D Q hD hQ L η hL + have he : (∑ j ∈ paddingBinIndices L η, + fullNumericalBin D R L η j l b h (X * Real.exp ((j : ℝ) * η))) - + (totalPaddingBinMass D Q L η : ℂ) * F = + ∑ j ∈ paddingBinIndices L η, + (fullNumericalBin D R L η j l b h (X * Real.exp ((j : ℝ) * η)) - + (numericalBinHarmonicMass D R L η j : ℂ) * F) := by + rw [← hm] + push_cast + rw [sum_sub_distrib, sum_mul] + change ‖_ - _ * F‖ ≤ _ + rw [he] + calc + _ ≤ ∑ j ∈ paddingBinIndices L η, + ‖fullNumericalBin D R L η j l b h (X * Real.exp ((j : ℝ) * η)) - + (numericalBinHarmonicMass D R L η j : ℂ) * F‖ := norm_sum_le _ _ + _ ≤ ∑ j ∈ paddingBinIndices L η, + numericalBinHarmonicMass D R L η j * (2 * η + 1 / X) := + sum_le_sum (fun j _ => fullNumericalBin_error D R L η X hX hη j l b h hunit) + _ = _ := by rw [← sum_mul, hm] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/FullTupleBinIdentity.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/FullTupleBinIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..dfabbbb99ba7b8c7f2dcddad4ce147db4041c616 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/FullTupleBinIdentity.lean @@ -0,0 +1,49 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FullNumericalBins +import OAI.NumberTheory.TwoPoint.Bounds.UncutCenteredProfile +import OAI.NumberTheory.TwoPoint.Bounds.PartialCenteringSum + +namespace OAI + +/-! The empty supply subset is exactly the full numerical divisor sum. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma positivePrefix_ite_const (p : Prop) (f : ℕ → ℂ) (N : ℕ) : + positivePrefix (fun n => if p then f n else 0) N = + if p then positivePrefix f N else 0 := by + by_cases hp : p <;> simp only [hp, ite_true, ite_false, positivePrefix, sum_const_zero] + +lemma fullNumericalBin_tuple {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (R : Finset ℕ) (L η : ℝ) (j : ℤ) + (l : ℕ) [NeZero l] (b : ZMod l) (h : ℕ) (T : ℝ) : + fullNumericalBin (primeTupleDivisors P) R L η j l b h T = + ∑ q ∈ R, (actualPaddingCoefficient q : ℂ) * + (positivePrefix (tuplePartialProfile P ∅ q (numericalBinEligible L η j) l b h) ⌊T⌋₊ / + (T : ℂ)) := by + simp only [fullNumericalBin, numericalBinPairs, sum_filter, sum_product] + rw [sum_comm] + apply sum_congr rfl + intro q _ + rw [primeTupleDivisors, sum_image] + · have hf : tuplePartialProfile P ∅ q (numericalBinEligible L η j) l b h = + fun n => ∑ x : (i : Fin J) → P i, + if numericalBinEligible L η j (∏ i, (x i).val) q then + fullLiouvilleProfile l b (q * ∏ i, (x i).val) h n else 0 := by + funext n + exact tuplePartialProfile_empty P q (numericalBinEligible L η j) l b h n + rw [hf, positivePrefix_sum_finite, sum_div, mul_sum] + simp_rw [positivePrefix_ite_const] + apply sum_congr rfl + intro x _ + split_ifs <;> simp_all only [zero_div, mul_zero] + · intro x _ y _ hxy + exact primeTuple_injective hprime hdisjoint hxy + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodColumnSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodColumnSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..43ec847381c52021b660a24bdbcbb4865a8dfd92 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodColumnSum.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.TwoPoint.Walks.ColumnHarmonicSum +import OAI.NumberTheory.TwoPoint.Walks.ColumnCodeUniverse +import OAI.NumberTheory.TwoPoint.Bounds.OccurrenceCounts + +namespace OAI + +/-! Sum the good column patterns with one reciprocal per observed prime. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +/-- Unused elements of the ambient label type make no contribution. -/ +lemma twice_observed_labels_le_slots_add_singletons + {ι τ : Type*} [Fintype ι] [Fintype τ] [DecidableEq ι] (label : τ → ι) : + 2 * (univ.image label).card ≤ Fintype.card τ + (singletonLabels label).card := by + have hlocal (i : ι) : + 2 * (if 0 < (labelOccurrences label i).card then 1 else 0) ≤ + (labelOccurrences label i).card + + (if (labelOccurrences label i).card = 1 then 1 else 0) := by + split_ifs <;> omega + have hs := sum_le_sum (fun i (_ : i ∈ (univ : Finset ι)) => hlocal i) + rw [← mul_sum, sum_add_distrib, total_label_occurrences] at hs + have hused : (∑ i : ι, if 0 < (labelOccurrences label i).card then (1 : ℕ) else 0) = + (univ.image label).card := by + have hi (i : ι) : 0 < (labelOccurrences label i).card ↔ i ∈ univ.image label := by + rw [card_pos] + simp [labelOccurrences, filter_nonempty_iff, mem_image] + simp only [hi] + simp + have hsingle : (∑ i : ι, if (labelOccurrences label i).card = 1 then (1 : ℕ) else 0) = + (singletonLabels label).card := by simp [singletonLabels, sum_boole] + rwa [hused, hsingle] at hs + +def columnSingletonCount {J R : ℕ} {P : Fin J → Finset ℕ} + (w : ColumnPrimeAssignment J R P) : ℕ := + ∑ j, (singletonLabels (w j)).card + +lemma column_observed_count {J R : ℕ} {P : Fin J → Finset ℕ} + (w : ColumnPrimeAssignment J R P) : + 2 * (∑ j, (univ.image (w j)).card) ≤ J * R + columnSingletonCount w := by + have hs := sum_le_sum (fun j (_ : j ∈ (univ : Finset (Fin J))) => + twice_observed_labels_le_slots_add_singletons (w j)) + simpa only [← mul_sum, sum_add_distrib, Fintype.card_fin, sum_const, + card_univ, smul_eq_mul, columnSingletonCount] using hs + +/-- At most `2*S` singleton labels leave at most `J*k+S` distinct primes +in a word with `2*k` occurrences per column. -/ +lemma good_column_observed_count {J k S : ℕ} {P : Fin J → Finset ℕ} + (w : ColumnPrimeAssignment J (2 * k) P) (hs : columnSingletonCount w ≤ 2 * S) : + (∑ j, (univ.image (w j)).card) ≤ J * k + S := by + have h := column_observed_count w + nlinarith + +theorem covered_good_column_sum {J k S : ℕ} {Code : Type*} [Fintype Code] + (P : Fin J → Finset ℕ) (F : Finset (ColumnPrimeAssignment J (2 * k) P)) + (decode : Code → Fin J → Fin (2 * k) → Fin (2 * k) → Bool) + (A : ℝ) (hA : 1 ≤ A) (hmass : ∀ j, primeHarmonicMass (P j) ≤ A) + (hsingle : ∀ w ∈ F, columnSingletonCount w ≤ 2 * S) + (hcover : ∀ w ∈ F, ∃ c, ∀ j i l, decode c j i l = decide (w j i = w j l)) : + (∑ w ∈ F, columnReciprocalWeight w) ≤ (Fintype.card Code : ℝ) * A ^ (J * k + S) := + covered_column_patterns_reciprocal_sum P F decode A (J * k + S) hA hmass + (fun w hw => good_column_observed_count w (hsingle w hw)) hcover + +/-- The universal forest decoder and the separate column masses give the +required good-word prime sum. The exponential constant is absolute. -/ +theorem eventually_good_column_sum : + ∀ᶠ L : ℝ in atTop, ∀ J k S : ℕ, ∀ P : Fin J → Finset ℕ, + ∀ F : Finset (ColumnPrimeAssignment J (2 * k) P), ∀ W : ℝ, + L / 2 ≤ (k : ℝ) → (k : ℝ) ≤ L → 1 ≤ k → 1 ≤ W → + (∀ j, primeHarmonicMass (P j) ≤ 2 * W) → + (∀ w ∈ F, columnSingletonCount w ≤ 2 * S) → + (∀ w ∈ F, ∃ c : BudgetColumnArrayCode J (4 * k) L, + ∀ j i l, decodeBudgetColumnArray (show 2 * k ≤ 4 * k by omega) c j i l = + decide (w j i = w j l)) → + (∑ w ∈ F, columnReciprocalWeight w) ≤ + Real.exp (64 * k * J) * (2 * W) ^ (J * k + S) := by + filter_upwards [eventually_budget_column_array_card] with L h + intro J k S P F W hklo hkhi hk hW hmass hsingle hcover + apply (covered_good_column_sum P F + (decodeBudgetColumnArray (show 2 * k ≤ 4 * k by omega)) (2 * W) + (by linarith) hmass hsingle hcover).trans + apply mul_le_mul_of_nonneg_right + · exact h k J (4 * k) hklo hkhi (by omega) le_rfl + · positivity + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodDesignatedWordSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodDesignatedWordSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..e37a53876921a82eb5dea9f80b4249b134325ff1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodDesignatedWordSum.lean @@ -0,0 +1,136 @@ +import OAI.NumberTheory.TwoPoint.Walks.GoodWordForest +import OAI.NumberTheory.TwoPoint.Bounds.GoodWeightedDifferenceSum +import OAI.NumberTheory.TwoPoint.Bounds.AmbientTupleLabels + +namespace OAI + +/-! The actual good designated-word sum: forced residues, literal deletions and retained padding weights. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma budgetColumnArray_cover_congr {n J N M : ℕ} {L : ℝ} + (hn : n ≤ N) (hm : n ≤ M) (he : N = M) + (pattern : Fin J → Fin n → Fin n → Bool) + (hc : ∃ code : BudgetColumnArrayCode J N L, + ∀ j i l, decodeBudgetColumnArray hn code j i l = pattern j i l) : + ∃ code : BudgetColumnArrayCode J M L, + ∀ j i l, decodeBudgetColumnArray hm code j i l = pattern j i l := by + subst M + exact hc + +noncomputable def tupleForcedTarget {h J M R B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (word : List SignedStep) (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (t : Fin R × Fin J) : Fin B := + forcedResidue B (label t).val (data.prime _).pos (hB _ (label t).property) + (wordDisplacement h (word.take t.1.val)) + +noncomputable def prohibitedWordDifference {h J M R B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (s D : ℕ) (word : List SignedStep) (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (base : ↥(data.P ∪ data.Q) → Fin B) (U : Finset (Fin R × Fin J)) + (x : ↥(data.P ∪ data.Q) → Fin B) : ℝ := + selectedMixedDifference (singletonLabels label) + (singletonTarget label (tupleForcedTarget data hB word label) base) + (fun y => attachedCatalogAvoidance data s B D word + (forceCoordinates ((nonsingletonSlots label \ U).image label) + (litForcedTarget (nonsingletonSlots label \ U) label + (tupleForcedTarget data hB word label) base) y)) x + +lemma prohibitedWordDifference_abs_le {h J M R B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (s D : ℕ) (word : List SignedStep) (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (base : ↥(data.P ∪ data.Q) → Fin B) (U : Finset (Fin R × Fin J)) + (x : ↥(data.P ∪ data.Q) → Fin B) : + |prohibitedWordDifference data hB s D word label base U x| ≤ + 2 ^ (singletonLabels label).card := by + apply selectedMixedDifference_bound + intro y + exact witnessAvoidance_abs_le_one _ _ + +theorem good_designated_word_sum {h J M B s D k S r : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (P : Fin J → Finset ℕ) (Q : Finset ℕ) + (F : Finset (ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q))) + (hR : 0 < 2 * k) (forward : Fin (2 * k) → Bool) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (hpairs : ∀ a ∈ F, ∀ i, (columnTuple a.1 i, (a.2 i).val) ∈ data.pairs) + (hRD : 2 * k ≤ D) + (label : (ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q)) → + Fin (2 * k) × Fin J → ↥(data.P ∪ data.Q)) + (hlabel : ∀ a ∈ F, ∀ i j, (label a (i, j)).val = (a.1 j i).val) + (base : ↥(data.P ∪ data.Q) → Fin B) (U : Finset (Fin (2 * k) × Fin J)) + (hU : ∀ a ∈ F, U ⊆ nonsingletonSlots (label a)) + (hLit : ∀ a ∈ F, LitConsistent (nonsingletonSlots (label a) \ U) (label a) + (tupleForcedTarget data hB (columnTupleWord a.1 forward (fun i => (a.2 i).val)) (label a))) + (weight : (ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q)) → + (↥(data.P ∪ data.Q) → Fin B) → ℝ) + (hweight : ∀ a ∈ F, ∀ y z, (∀ i, i ∉ univ.image (label a) → y i = z i) → + weight a y = weight a z) + (hpadding : ∀ a ∈ F, ∀ x, weight a x ≠ 0 → MainPaddingTests + (fun p : ↥(data.P ∪ data.Q) => p.val) h B + (columnTupleWord a.1 forward (fun i => (a.2 i).val)) x) + (hh : 0 < h) (hs : 0 < s) (cut : Fin (2 * k)) + (hleft : ∀ a ∈ F, ((columnTupleWord a.1 forward (fun i => (a.2 i).val)).take cut.val).IsChain + (fun a b => a.tuple ≠ b.tuple)) + (hright : ∀ a ∈ F, ((columnTupleWord a.1 forward (fun i => (a.2 i).val)).drop cut.val).IsChain + (fun a b => a.tuple ≠ b.tuple)) + (L K A : ℝ) (hL : 1 ≤ L) (hRL : (2 * k : ℕ) ≤ 2 * L) + (hsL : L ^ (1 / 10 : ℝ) / 2 ≤ (s : ℝ)) + (hrL : (r : ℝ) ≤ L ^ (1 / 50 : ℝ)) + (hI : ∀ a ∈ F, (imperfectColumnCount ((perfectRows (label a) U).erase cut) : ℝ) ≤ + 2 * L ^ (1 / 4 : ℝ)) + (hno : ∀ a ∈ F, ∀ j, ColumnLowRank + (tupleColumnPattern a.1 hR forward (fun i => (a.2 i).val) j) + hR h (perfectRows (label a) U) cut r) + (u : ℕ → ℝ) (eligible : ColumnPrimeAssignment J (2 * k) P → ℕ → ℕ → Prop) + (g : ℤ → ℝ) (extra : ColumnPrimeAssignment J (2 * k) P → ℕ → ℤ → Prop) + (next : ColumnPrimeAssignment J (2 * k) P → ℕ → ℤ → ℕ → ℤ) + (origin : (↥(data.P ∪ data.Q) → Fin B) → ℤ) + (hK : 0 ≤ K) (hA : 1 ≤ A) (hu : ∀ q, 0 ≤ u q) + (hmass : ∀ j, primeHarmonicMass (P j) ≤ A) + (hsingle : ∀ a ∈ F, columnSingletonCount a.1 ≤ 2 * S) + (hw : ∀ a ∈ F, ∀ x, 0 ≤ weight a x) + (hpad : ∀ a ∈ F, ∀ x, weight a x ≤ + retainedColumnPaddingWeight Q u eligible g L K extra next (origin x) a.1 a.2) : + (∑ a ∈ F, designatedReciprocal (fun p : ↥(data.P ∪ data.Q) => p.val) + (singletonLabels (label a)) (nonsingletonSlots (label a) \ U) U (label a) * + (data.residueLaw B hB).average (fun x => weight a x * + |prohibitedWordDifference data hB s D + (columnTupleWord a.1 forward (fun i => (a.2 i).val)) (label a) base U x|)) ≤ + (2 : ℝ) ^ (2 * S) * ((Fintype.card (BudgetColumnArrayCode J (4 * k) L) : ℝ) * + K ^ (2 * k) * A ^ (J * k + S)) := by + let delta a := prohibitedWordDifference data hB s D + (columnTupleWord a.1 forward (fun i => (a.2 i).val)) (label a) base U + apply le_trans _ (good_weighted_difference_sum (data.residueLaw B hB) P Q F + (decodeBudgetColumnArray (show 2 * k ≤ 4 * k by omega)) u eligible g L K A + (2 ^ (2 * S)) extra next origin weight delta (by linarith) hK hA (by positivity) + hu hmass hsingle hw hpad ?_ ?_) + · apply sum_le_sum + intro a ha + exact mul_le_mul_of_nonneg_right + (designatedReciprocal_le_tuple a.1 hdisjoint _ Subtype.val_injective + (fun p => (data.prime p).pos) (label a) (hlabel a ha) U (hU a ha)) + ((data.residueLaw B hB).average_nonneg + (fun x => mul_nonneg (hw a ha x) (abs_nonneg _))) + · intro a ha x + apply (prohibitedWordDifference_abs_le data hB s D _ _ base U x).trans + apply pow_le_pow_right₀ (by norm_num) + rw [tuple_label_singleton_count a.1 hdisjoint _ Subtype.val_injective _ (hlabel a ha)] + exact hsingle a ha + · intro a ha x hx hd + apply budgetColumnArray_cover_congr (show 2 * k ≤ 2 * (2 * k) by omega) + (show 2 * k ≤ 4 * k by omega) (show 2 * (2 * k) = 4 * k by omega) + (fun j i l => decide (a.1 j i = a.1 j l)) + exact good_word_column_cover data P a.1 hR forward (fun i => (a.2 i).val) + hprime hdisjoint (hpairs a ha) hB hRD (label a) (hlabel a ha) U base x + (weight a) (hweight a ha) (hpadding a ha) hx (hLit a ha) hd hh hs cut + (hleft a ha) (hright a ha) L hL hRL hsL hrL (hI a ha) (hno a ha) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodMomentConstant.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodMomentConstant.lean new file mode 100644 index 0000000000000000000000000000000000000000..e84bffa465117317a88c4789cf8b47a4665a0f78 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodMomentConstant.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.TwoPoint.Bounds.GoodRetainedWordSum + +namespace OAI + +/-! Absorb the proved good-word costs into one absolute square-root mass constant. -/ + +namespace TwoPointCorrelations + +open Filter + +private lemma positive_nat_power_exp (x : ℝ) (hx : 0 < x) (n : ℕ) : + x ^ n = Real.exp ((n : ℝ) * Real.log x) := by + rw [Real.exp_nat_mul, Real.exp_log hx] + +/-- The threshold may depend on the fixed harmonic mass. The base +constant is absolute; the mass keeps its square-root exponent. -/ +theorem eventually_good_moment_constant (W : ℝ) (hW : 1 ≤ W) : + ∀ᶠ L : ℝ in atTop, ∀ J k S : ℕ, + 1 ≤ J → L / 2 ≤ (k : ℝ) → (S : ℝ) ≤ L ^ (1 / 4 : ℝ) → + Real.exp (108 * L) * (2 : ℝ) ^ (4 * k * J + 2 * S) * + Real.exp (64 * k * J) * (2 * W) ^ (J * k + S) ≤ + (Real.exp 150 * Real.sqrt W) ^ (2 * k * J) := by + let C := 2 * Real.log 2 + Real.log (2 * W) + have hWp : 0 < W := by linarith + have hC : 0 ≤ C := by + dsimp [C] + exact add_nonneg + (mul_nonneg (by norm_num) (Real.log_nonneg (by norm_num))) + (Real.log_nonneg (by linarith)) + have hgrow := (tendsto_rpow_atTop (show 0 < (3 / 4 : ℝ) by norm_num)).eventually + (eventually_ge_atTop (2 * C)) + filter_upwards [eventually_gt_atTop (0 : ℝ), hgrow] with L hL hgrow + intro J k S hJ hk hS + have hJreal : (1 : ℝ) ≤ J := by exact_mod_cast hJ + have hk0 : 0 ≤ (k : ℝ) := Nat.cast_nonneg _ + have hkj : (k : ℝ) ≤ k * J := by nlinarith + have hL2 : L ≤ 2 * (k : ℝ) := by linarith + have hprod : L ^ (1 / 4 : ℝ) * L ^ (3 / 4 : ℝ) = L := by + rw [← Real.rpow_add hL] + norm_num + have hCS : C * (S : ℝ) ≤ (k : ℝ) * J := by + have hh := mul_le_mul_of_nonneg_left hgrow + (Real.rpow_nonneg hL.le (1 / 4 : ℝ)) + rw [hprod] at hh + have hs := mul_le_mul_of_nonneg_left hS hC + nlinarith + have hlog2 : Real.log 2 ≤ 1 := by + have hh := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + linarith + have hlog : Real.log (2 * W) = Real.log 2 + Real.log W := + Real.log_mul (by norm_num) hWp.ne' + have hE : 108 * L + ((4 * k * J + 2 * S : ℕ) : ℝ) * Real.log 2 + + 64 * k * J + ((J * k + S : ℕ) : ℝ) * Real.log (2 * W) ≤ + ((J * k : ℕ) : ℝ) * (300 + Real.log W) := by + push_cast + dsimp [C] at hCS + rw [hlog] at hCS ⊢ + have h2 := mul_le_mul_of_nonneg_right hlog2 + (show 0 ≤ 5 * (k : ℝ) * J by positivity) + nlinarith + have hsq : (Real.exp 150 * Real.sqrt W) ^ 2 = Real.exp 300 * W := by + rw [mul_pow, Real.sq_sqrt hWp.le, ← Real.exp_nat_mul] + norm_num + calc + _ = Real.exp (108 * L + ((4 * k * J + 2 * S : ℕ) : ℝ) * Real.log 2 + + 64 * k * J + ((J * k + S : ℕ) : ℝ) * Real.log (2 * W)) := by + rw [positive_nat_power_exp 2 (by norm_num), + positive_nat_power_exp (2 * W) (by positivity), ← Real.exp_add, + ← Real.exp_add, ← Real.exp_add] + _ ≤ Real.exp (((J * k : ℕ) : ℝ) * (300 + Real.log W)) := Real.exp_le_exp.mpr hE + _ = (Real.exp 300 * W) ^ (J * k) := by + have he : Real.exp 300 * W = Real.exp (300 + Real.log W) := by + rw [Real.exp_add, Real.exp_log hWp] + rw [he, ← Real.exp_nat_mul] + _ = (Real.exp 150 * Real.sqrt W) ^ (2 * (J * k)) := by + exact ((pow_mul (Real.exp 150 * Real.sqrt W) 2 (J * k)).trans + (congrArg (fun a : ℝ => a ^ (J * k)) hsq)).symm + _ = _ := by congr 1; ring + +/-- Restore the normalization factor from the padding sum. -/ +theorem eventually_good_moment_with_padding (W : ℝ) (hW : 1 ≤ W) : + ∀ᶠ L : ℝ in atTop, ∀ J k S : ℕ, ∀ K : ℝ, + 1 ≤ J → L / 2 ≤ (k : ℝ) → (S : ℝ) ≤ L ^ (1 / 4 : ℝ) → 0 ≤ K → + Real.exp (108 * L) * (2 : ℝ) ^ (4 * k * J + 2 * S) * + Real.exp (64 * k * J) * K ^ (2 * k) * (2 * W) ^ (J * k + S) ≤ + (K * (Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * k) := by + filter_upwards [eventually_good_moment_constant W hW] with L hc + intro J k S K hJ hk hS hK + have hh := mul_le_mul_of_nonneg_right (hc J k S hJ hk hS) (pow_nonneg hK (2 * k)) + calc + _ = (Real.exp (108 * L) * (2 : ℝ) ^ (4 * k * J + 2 * S) * + Real.exp (64 * k * J) * (2 * W) ^ (J * k + S)) * K ^ (2 * k) := by ring + _ ≤ (Real.exp 150 * Real.sqrt W) ^ (2 * k * J) * K ^ (2 * k) := hh + _ = _ := by + symm + rw [mul_pow, ← pow_mul, show J * (2 * k) = 2 * k * J by ring, mul_comm] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodRetainedWordSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodRetainedWordSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..945e5454be099a82eaa3a0da94a5f11665eae89c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodRetainedWordSum.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.TwoPoint.Walks.GoodWordWeightedSum + +namespace OAI + +/-! The good-word bound with the actual, normalized, retained padding weights. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma paddingWordWeight_nonneg (Q : Finset ℕ) (weight : ℕ → ℤ → ℕ → ℝ) + (next : ℕ → ℤ → ℕ → ℤ) (hweight : ∀ i n q, 0 ≤ weight i n q) + {m : ℕ} (i : ℕ) (n : ℤ) (q : Fin m → Q) : + 0 ≤ paddingWordWeight Q weight next i n q := by + induction m generalizing i n with + | zero => exact zero_le_one + | succ m ih => + exact mul_nonneg (hweight _ _ _) (ih _ _ (Fin.tail q)) + +noncomputable def retainedColumnPaddingWeight {J k : ℕ} {P : Fin J → Finset ℕ} + (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ColumnPrimeAssignment J (2 * k) P → ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) + (extra : ColumnPrimeAssignment J (2 * k) P → ℕ → ℤ → Prop) + (next : ColumnPrimeAssignment J (2 * k) P → ℕ → ℤ → ℕ → ℤ) + (n : ℤ) (w : ColumnPrimeAssignment J (2 * k) P) (q : Fin (2 * k) → Q) : ℝ := + paddingWordWeight Q + (fun i n q => retainedPaddingAtom Q u (eligible w i) g L K (extra w i) n q) + (next w) 0 n q + +/-- The bound holds uniformly for prime-dependent eligibility, walk shifts, +and cutoffs, retaining the exact departure normalization at each step. -/ +theorem good_retained_word_sum {J k S : ℕ} {Code : Type*} [Fintype Code] + (P : Fin J → Finset ℕ) (Q : Finset ℕ) + (F : Finset (ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q))) + (decode : Code → Fin J → Fin (2 * k) → Fin (2 * k) → Bool) + (u : ℕ → ℝ) (eligible : ColumnPrimeAssignment J (2 * k) P → ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K A : ℝ) + (extra : ColumnPrimeAssignment J (2 * k) P → ℕ → ℤ → Prop) + (next : ColumnPrimeAssignment J (2 * k) P → ℕ → ℤ → ℕ → ℤ) (n : ℤ) + (hL : 0 < L) (hK : 0 ≤ K) (hA : 1 ≤ A) (hu : ∀ q, 0 ≤ u q) + (hmass : ∀ j, primeHarmonicMass (P j) ≤ A) + (hsingle : ∀ a ∈ F, columnSingletonCount a.1 ≤ 2 * S) + (hcover : ∀ a ∈ F, ∃ c, ∀ j i l, decode c j i l = decide (a.1 j i = a.1 j l)) : + (∑ a ∈ F, columnReciprocalWeight a.1 * + retainedColumnPaddingWeight Q u eligible g L K extra next n a.1 a.2) ≤ + (Fintype.card Code : ℝ) * K ^ (2 * k) * A ^ (J * k + S) := by + apply covered_good_column_padding_sum P F decode + (retainedColumnPaddingWeight Q u eligible g L K extra next n) A (K ^ (2 * k)) + hA (pow_nonneg hK _) hmass ?_ ?_ hsingle hcover + · intro w q + apply paddingWordWeight_nonneg + intro i n q + exact retainedPaddingAtom_nonneg Q u (eligible w i) g L K (extra w i) n q hL.le (hu q) + · intro w + exact retained_padding_word_sum_le Q u (eligible w) g L K (extra w) (next w) + hL hK (fun q _ => hu q) (2 * k) 0 n + +/-- The complete good-word prime/padding sum at the manuscript's forest +code scale, before signs, designations and external matrix dimensions. -/ +theorem eventually_good_retained_word_sum : + ∀ᶠ L : ℝ in atTop, ∀ J k S : ℕ, ∀ P : Fin J → Finset ℕ, ∀ Q : Finset ℕ, + ∀ F : Finset (ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q)), + ∀ (u : ℕ → ℝ) (eligible : ColumnPrimeAssignment J (2 * k) P → ℕ → ℕ → Prop) + (g : ℤ → ℝ) (K W : ℝ) + (extra : ColumnPrimeAssignment J (2 * k) P → ℕ → ℤ → Prop) + (next : ColumnPrimeAssignment J (2 * k) P → ℕ → ℤ → ℕ → ℤ) (n : ℤ), + L / 2 ≤ (k : ℝ) → (k : ℝ) ≤ L → 1 ≤ k → 0 ≤ K → 1 ≤ W → + (∀ q, 0 ≤ u q) → (∀ j, primeHarmonicMass (P j) ≤ 2 * W) → + (∀ a ∈ F, columnSingletonCount a.1 ≤ 2 * S) → + (∀ a ∈ F, ∃ c : BudgetColumnArrayCode J (4 * k) L, + ∀ j i l, decodeBudgetColumnArray (show 2 * k ≤ 4 * k by omega) c j i l = + decide (a.1 j i = a.1 j l)) → + (∑ a ∈ F, columnReciprocalWeight a.1 * + retainedColumnPaddingWeight Q u eligible g L K extra next n a.1 a.2) ≤ + Real.exp (64 * k * J) * K ^ (2 * k) * (2 * W) ^ (J * k + S) := by + filter_upwards [eventually_ge_atTop (1 : ℝ), eventually_budget_column_array_card] with L hL hc + intro J k S P Q F u eligible g K W extra next n hklo hkhi hk hK hW hu hmass hsingle hcover + apply (good_retained_word_sum P Q F + (decodeBudgetColumnArray (show 2 * k ≤ 4 * k by omega)) + u eligible g L K (2 * W) extra next n (by linarith) hK (by linarith) + hu hmass hsingle hcover).trans + apply mul_le_mul_of_nonneg_right + · exact mul_le_mul_of_nonneg_right + (hc k J (4 * k) hklo hkhi (by omega) le_rfl) (pow_nonneg hK _) + · positivity + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodTraceCost.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodTraceCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a78999020970d78d9a17455de63c45594b21db3 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodTraceCost.lean @@ -0,0 +1,49 @@ +import OAI.NumberTheory.TwoPoint.Bounds.GoodMomentConstant + +namespace OAI + +/-! Absorb the exact good designated-word cost, including all designations, into the moment base. -/ + +namespace TwoPointCorrelations + +open Filter + +theorem eventually_good_trace_cost (W : ℝ) (hW : 1 ≤ W) : + ∀ᶠ L : ℝ in atTop, ∀ (J k S : ℕ) (K M : ℝ), + 1 ≤ J → L / 2 ≤ (k : ℝ) → (k : ℝ) ≤ L → + (S : ℝ) ≤ L ^ (1 / 4 : ℝ) → 0 ≤ K → + M ≤ (2 : ℝ) ^ (2 * S) * + ((Fintype.card (BudgetColumnArrayCode J (4 * k) L) : ℝ) * + K ^ (2 * k) * (2 * W) ^ (J * k + S)) → + Real.exp (108 * L) * (2 : ℝ) ^ (4 * k * J) * M ≤ + (K * (Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * k) := by + filter_upwards [eventually_ge_atTop (1 : ℝ), eventually_budget_column_array_card, + eventually_good_moment_with_padding W hW] with L hL hcard hmoment + intro J k S K M hJ hklo hkhi hS hK hM + have hk : 1 ≤ k := by + by_contra hn + have hz : k = 0 := by omega + subst k + norm_num at hklo + linarith + have hc := hcard k J (4 * k) hklo hkhi (by omega) le_rfl + have hb : M ≤ (2 : ℝ) ^ (2 * S) * + (Real.exp (64 * k * J) * K ^ (2 * k) * (2 * W) ^ (J * k + S)) := by + apply hM.trans + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply mul_le_mul_of_nonneg_right _ (by positivity) + exact mul_le_mul_of_nonneg_right hc (pow_nonneg hK _) + calc + _ ≤ Real.exp (108 * L) * (2 : ℝ) ^ (4 * k * J) * + ((2 : ℝ) ^ (2 * S) * + (Real.exp (64 * k * J) * K ^ (2 * k) * (2 * W) ^ (J * k + S))) := + mul_le_mul_of_nonneg_left hb (by positivity) + _ = Real.exp (108 * L) * (2 : ℝ) ^ (4 * k * J + 2 * S) * + Real.exp (64 * k * J) * K ^ (2 * k) * (2 * W) ^ (J * k + S) := by + rw [pow_add] + ring + _ ≤ _ := hmoment J k S K hJ hklo hS hK + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodTraceTotal.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodTraceTotal.lean new file mode 100644 index 0000000000000000000000000000000000000000..57e07968af552699a55342dfc8b5403d885ce4b6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodTraceTotal.lean @@ -0,0 +1,125 @@ +import OAI.NumberTheory.TwoPoint.Bounds.TraceDesignationSlices +import OAI.NumberTheory.TwoPoint.Bounds.GoodTraceCost + +namespace OAI + +/-! All good designated terms, including the finite choice of designation, fit +inside the absolute square-root harmonic-mass moment bound. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem eventually_prohibited_good_trace_total (W : ℝ) (hW : 1 ≤ W) : + ∀ᶠ L : ℝ in atTop, ∀ (h J M B s D k S : ℕ) + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (P : Fin J → Finset ℕ) (Q : Finset ℕ) + (F : Finset (ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q))) + (hR : 0 < 2 * k) (forward : Fin (2 * k) → Bool) + (label : (ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q)) → + Fin (2 * k) × Fin J → ↥(data.P ∪ data.Q)) + (base : ↥(data.P ∪ data.Q) → Fin B) + (weight : (ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q)) → + (↥(data.P ∪ data.Q) → Fin B) → ℝ) + (cut : Fin (2 * k)) + (u : ℕ → ℝ) (eligible : ColumnPrimeAssignment J (2 * k) P → ℕ → ℕ → Prop) + (g : ℤ → ℝ) (K : ℝ) + (extra : ColumnPrimeAssignment J (2 * k) P → ℕ → ℤ → Prop) + (next : ColumnPrimeAssignment J (2 * k) P → ℕ → ℤ → ℕ → ℤ) + (origin : (↥(data.P ∪ data.Q) → Fin B) → ℤ), + 1 ≤ J → L / 2 ≤ (k : ℝ) → (k : ℝ) ≤ L → (S : ℝ) ≤ L ^ (1 / 4 : ℝ) → + (∀ j, ∀ p ∈ P j, p.Prime) → + (∀ j l, l ≠ j → Disjoint (P j) (P l)) → + (∀ a ∈ F, ∀ i, (columnTuple a.1 i, (a.2 i).val) ∈ data.pairs) → + 2 * k ≤ D → (∀ a ∈ F, ∀ i j, (label a (i, j)).val = (a.1 j i).val) → + (∀ a ∈ F, ∀ y z, (∀ i, i ∉ univ.image (label a) → y i = z i) → weight a y = weight a z) → + (∀ a ∈ F, ∀ x, weight a x ≠ 0 → MainPaddingTests Subtype.val h B + (columnTupleWord a.1 forward (fun i => (a.2 i).val)) x) → + 0 < h → 0 < s → L ^ (1 / 10 : ℝ) / 2 ≤ (s : ℝ) → + (∀ a ∈ F, ((columnTupleWord a.1 forward (fun i => (a.2 i).val)).take cut.val).IsChain + (fun a b => a.tuple ≠ b.tuple)) → + (∀ a ∈ F, ((columnTupleWord a.1 forward (fun i => (a.2 i).val)).drop cut.val).IsChain + (fun a b => a.tuple ≠ b.tuple)) → + 0 ≤ K → (∀ q, 0 ≤ u q) → (∀ j, primeHarmonicMass (P j) ≤ 2 * W) → + (∀ a ∈ F, columnSingletonCount a.1 ≤ S) → + (∀ a ∈ F, ∀ x, 0 ≤ weight a x) → + (∀ a ∈ F, ∀ x, weight a x ≤ + retainedColumnPaddingWeight Q u eligible g L K extra next (origin x) a.1 a.2) → + Real.exp (108 * L) * + (∑ a ∈ F, ∑ U ∈ (nonsingletonSlots (label a)).powerset.filter + (fun U => U.card ≤ ⌊L ^ (1 / 50 : ℝ)⌋₊ ∧ ∀ j, ColumnLowRank + (tupleColumnPattern a.1 hR forward (fun i => (a.2 i).val) j) + hR h (perfectRows (label a) U) cut ⌊L ^ (1 / 50 : ℝ)⌋₊), + prohibitedDesignatedTerm data hB s D + (columnTupleWord a.1 forward (fun i => (a.2 i).val)) (label a) base (weight a) U) ≤ + (K * (Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * k) := by + filter_upwards [eventually_ge_atTop (1 : ℝ), eventually_tuple_perfectRows_budget, + eventually_good_trace_cost W hW] with L hL hbudget hcost + intro h J M B s D k S data hB P Q F hR forward label base weight cut u eligible g K extra next origin + hJ hklo hkhi hS hprime hdisjoint hpairs hRD hlabel hweight hpadding hh hs hsL + hleft hright hK hu hmass hsingle hw hpad + let word (a : ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q)) := + columnTupleWord a.1 forward (fun i => (a.2 i).val) + let keep (a : ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q)) + (U : Finset (Fin (2 * k) × Fin J)) := U.card ≤ ⌊L ^ (1 / 50 : ℝ)⌋₊ ∧ ∀ j, ColumnLowRank + (tupleColumnPattern a.1 hR forward (fun i => (a.2 i).val) j) + hR h (perfectRows (label a) U) cut ⌊L ^ (1 / 50 : ℝ)⌋₊ + let A := (2 : ℝ) ^ (2 * S) * ((Fintype.card (BudgetColumnArrayCode J (4 * k) L) : ℝ) * + K ^ (2 * k) * (2 * W) ^ (J * k + S)) + have hA : 0 ≤ A := by dsimp [A]; positivity + have hslice (U : Finset (Fin (2 * k) × Fin J)) : + (∑ a ∈ F.filter (fun a => U ⊆ nonsingletonSlots (label a) ∧ keep a U), + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U) ≤ A := by + let E := (F.filter (fun a => U ⊆ nonsingletonSlots (label a) ∧ keep a U)).filter + (fun a => LitConsistent (nonsingletonSlots (label a) \ U) (label a) + (tupleForcedTarget data hB (word a) (label a))) + have hEF : E ⊆ F := (filter_subset _ _).trans (filter_subset _ _) + rw [prohibited_designated_sum_eq_lit_filter] + apply good_designated_word_sum data hB P Q E hR forward hprime hdisjoint + (fun a ha => hpairs a (hEF ha)) hRD label (fun a ha => hlabel a (hEF ha)) base U + (fun _ ha => (mem_filter.mp (mem_filter.mp ha).1).2.1) + (fun _ ha => (mem_filter.mp ha).2) weight + (fun a ha => hweight a (hEF ha)) (fun a ha => hpadding a (hEF ha)) hh hs cut + (fun a ha => hleft a (hEF ha)) (fun a ha => hright a (hEF ha)) + L K (2 * W) hL (by exact_mod_cast (mul_le_mul_of_nonneg_left hkhi (by norm_num : (0 : ℝ) ≤ 2))) + hsL (Nat.floor_le (Real.rpow_nonneg (by linarith) _)) ?_ ?_ + u eligible g extra next origin hK (by linarith) hu hmass + (fun a ha => (hsingle a (hEF ha)).trans (by omega)) + (fun a ha => hw a (hEF ha)) (fun a ha => hpad a (hEF ha)) + · intro a ha + rw [tuple_label_perfectRows a.1 hdisjoint _ Subtype.val_injective _ (hlabel a (hEF ha))] + apply hbudget J (2 * k) P a.1 U cut + · exact (show (columnSingletonCount a.1 : ℝ) ≤ S by exact_mod_cast hsingle a (hEF ha)).trans hS + · exact (show (U.card : ℝ) ≤ ⌊L ^ (1 / 50 : ℝ)⌋₊ by + exact_mod_cast (mem_filter.mp (mem_filter.mp ha).1).2.2.1).trans + (Nat.floor_le (Real.rpow_nonneg (by linarith) _)) + · intro a ha + exact (mem_filter.mp (mem_filter.mp ha).1).2.2.2 + have htotal := prohibited_designation_sum_le data hB s D F word label base weight keep A + (by + intro U + convert hslice U using 1 + apply sum_congr + · ext a + simp only [mem_filter] + · intro a _ + rfl) + have hexp : 2 * k * J ≤ 4 * k * J := + Nat.mul_le_mul_right J (Nat.mul_le_mul_right k (by decide : 2 ≤ 4)) + have htotal' := htotal.trans (mul_le_mul_of_nonneg_right + (pow_le_pow_right₀ (by norm_num : 1 ≤ (2 : ℝ)) hexp) hA) + convert (mul_le_mul_of_nonneg_left htotal' (Real.exp_pos (108 * L)).le).trans + (by simpa only [mul_assoc] using hcost J k S K A hJ hklo hkhi hS hK le_rfl) using 1 + congr 1 + apply sum_congr rfl + intro a _ + apply sum_congr + · ext U + simp only [mem_filter, keep] + · intro U _ + rfl + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodWeightedDifferenceSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodWeightedDifferenceSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f76b851f8d033c8ff97eb39d0dfa0f11184be46 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/GoodWeightedDifferenceSum.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.TwoPoint.Bounds.GoodRetainedWordSum +import OAI.NumberTheory.TwoPoint.Bounds.FiniteProbability + +namespace OAI + +/-! Average the good-word forest estimate while retaining the exact padding normalization. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem good_weighted_difference_sum {α : Type*} [Fintype α] + {J k S : ℕ} {Code : Type*} [Fintype Code] + (μ : FiniteLaw α) (P : Fin J → Finset ℕ) (Q : Finset ℕ) + (F : Finset (ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q))) + (decode : Code → Fin J → Fin (2 * k) → Fin (2 * k) → Bool) + (u : ℕ → ℝ) (eligible : ColumnPrimeAssignment J (2 * k) P → ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K A T : ℝ) + (extra : ColumnPrimeAssignment J (2 * k) P → ℕ → ℤ → Prop) + (next : ColumnPrimeAssignment J (2 * k) P → ℕ → ℤ → ℕ → ℤ) (origin : α → ℤ) + (weight delta : (ColumnPrimeAssignment J (2 * k) P × (Fin (2 * k) → Q)) → α → ℝ) + (hL : 0 < L) (hK : 0 ≤ K) (hA : 1 ≤ A) (hT : 0 ≤ T) (hu : ∀ q, 0 ≤ u q) + (hmass : ∀ j, primeHarmonicMass (P j) ≤ A) + (hsingle : ∀ a ∈ F, columnSingletonCount a.1 ≤ 2 * S) + (hw : ∀ a ∈ F, ∀ x, 0 ≤ weight a x) + (hpad : ∀ a ∈ F, ∀ x, weight a x ≤ + retainedColumnPaddingWeight Q u eligible g L K extra next (origin x) a.1 a.2) + (hdelta : ∀ a ∈ F, ∀ x, |delta a x| ≤ T) + (hcover : ∀ a ∈ F, ∀ x, weight a x ≠ 0 → delta a x ≠ 0 → + ∃ c, ∀ j i l, decode c j i l = decide (a.1 j i = a.1 j l)) : + (∑ a ∈ F, columnReciprocalWeight a.1 * + μ.average (fun x => weight a x * |delta a x|)) ≤ + T * ((Fintype.card Code : ℝ) * K ^ (2 * k) * A ^ (J * k + S)) := by + have hpoint (x : α) : + (∑ a ∈ F, columnReciprocalWeight a.1 * (weight a x * |delta a x|)) ≤ + T * ((Fintype.card Code : ℝ) * K ^ (2 * k) * A ^ (J * k + S)) := by + let Fx := F.filter (fun a => weight a x ≠ 0 ∧ delta a x ≠ 0) + have heq : (∑ a ∈ F, columnReciprocalWeight a.1 * (weight a x * |delta a x|)) = + ∑ a ∈ Fx, columnReciprocalWeight a.1 * (weight a x * |delta a x|) := by + rw [sum_filter] + apply sum_congr rfl + intro a _ + split_ifs with ha + · rfl + · rcases not_and_or.mp ha with hw | hd + · simp only [not_not] at hw + rw [hw, zero_mul, mul_zero] + · simp only [not_not] at hd + rw [hd, abs_zero, mul_zero, mul_zero] + rw [heq] + calc + _ ≤ ∑ a ∈ Fx, T * (columnReciprocalWeight a.1 * + retainedColumnPaddingWeight Q u eligible g L K extra next (origin x) a.1 a.2) := by + apply sum_le_sum + intro a ha + have haF := (mem_filter.mp ha).1 + have hb := mul_le_mul (hpad a haF x) (hdelta a haF x) + (abs_nonneg _) (le_trans (hw a haF x) (hpad a haF x)) + calc + _ ≤ columnReciprocalWeight a.1 * + (retainedColumnPaddingWeight Q u eligible g L K extra next (origin x) a.1 a.2 * T) := + mul_le_mul_of_nonneg_left hb (columnReciprocalWeight_nonneg _) + _ = _ := by ring + _ = T * ∑ a ∈ Fx, columnReciprocalWeight a.1 * + retainedColumnPaddingWeight Q u eligible g L K extra next (origin x) a.1 a.2 := + (mul_sum _ _ _).symm + _ ≤ _ := mul_le_mul_of_nonneg_left + (good_retained_word_sum P Q Fx decode u eligible g L K A extra next (origin x) + hL hK hA hu hmass (fun a ha => hsingle a (mem_filter.mp ha).1) + (fun a ha => hcover a (mem_filter.mp ha).1 x + (mem_filter.mp ha).2.1 (mem_filter.mp ha).2.2)) hT + calc + _ = μ.average (fun x => ∑ a ∈ F, + columnReciprocalWeight a.1 * (weight a x * |delta a x|)) := by + simp only [FiniteLaw.average, mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro x _ + apply sum_congr rfl + intro a _ + ring + _ ≤ _ := (μ.average_mono hpoint).trans_eq (μ.average_const _) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/GraphMatrixCompression.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/GraphMatrixCompression.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7ce54a690ac83bb3fead85b49f539f4a53f0cde --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/GraphMatrixCompression.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.TwoPoint.Bounds.GraphSpectralTransfer +import OAI.NumberTheory.TwoPoint.Walks.BlockOperatorSpectrum + +namespace OAI + +/-! The real integer-edge matrix, its complex graph operator, and the +nonbacktracking block have exactly the same spectral parameter. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical NNReal ENNReal + +noncomputable def primeRealEdgeMatrix {J : ℕ} {V : Type*} [Fintype V] + (P : Fin J → Finset ℕ) (site : V → ℤ) (Q : Finset ℕ) + (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) (g : ℤ → ℝ) + (L K : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → V → V → Prop) (d : (j : Fin J) → P j) : Matrix V V ℝ := + fun i j => if gate (∏ k, (d k).val) i j then + integerEdgeMatrix site Q u (eligible (∏ k, (d k).val)) g + (centeredTuple (∏ k, (d k).val).primeFactors) L K + (extra (∏ k, (d k).val)) h (∏ k, (d k).val) i j else 0 + +lemma primeFamilyGraphOperator_eq_realMatrix {J : ℕ} {V : Type*} + [Fintype V] [DecidableEq V] + (P : Fin J → Finset ℕ) (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (site : V → ℤ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → V → V → Prop) (d : (j : Fin J) → P j) : + primeFamilyGraphOperator (fun j (p : P j) => p.val) (fun _ _ => 0) + site Q u eligible g L K extra h gate d = + matrixOperator (fun i j => (primeRealEdgeMatrix P site Q u eligible g L K extra h gate d i j : ℂ)) := by + have hc : familyCenter (fun j (p : P j) => p.val) (fun _ _ => 0) d = + centeredTuple (∏ j, (d j).val).primeFactors := by + funext n + exact familyCenter_zero_eq_centeredTuple _ (fun j p => hprime j _ p.property) + d (selectedPrimeValues_injective d hdisjoint) n + unfold primeFamilyGraphOperator + rw [hc] + congr 1 + funext i j + simp only [maskedIntegerEdgeMatrix, maskMatrix, primeRealEdgeMatrix, familyTuple] + split_ifs <;> simp + +theorem prime_graph_compression_of_matrix_radius {J : ℕ} {V : Type*} + [Fintype V] [DecidableEq V] + (P : Fin J → Finset ℕ) (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (site : V → ℤ) (hinj : Function.Injective site) + (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → V → V → Prop) (hgate : ∀ d i j, gate d i j ↔ gate d j i) + (hL : 0 < L) (hK : 0 ≤ K) (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W) + (R : ℝ) (hR : 0 ≤ R) (hsingle : 2 * K ≤ R) + (hsquare : 4 * K ^ 2 * (8 * W) ^ J ≤ R ^ 2) + (hradius : realMatrixSpectralRadius (blockNonbacktrackingMatrix + (primeRealEdgeMatrix P site Q u eligible g L K extra h gate)) ≤ R) : + let B := primeFamilyGraphOperator (fun j (p : P j) => p.val) (fun _ _ => 0) + site Q u eligible g L K extra h gate + let proj := coordinateProjection (fun i : V => + (actualPaddingDegree (univ.biUnion P) (site i) : ℝ) ≤ 6 * W * J) + ‖proj * (∑ d, B d) * proj‖ ≤ 3 * R := by + apply prime_graph_compression_bound P hprime hdisjoint site hinj Q u eligible g + L K W extra h gate hgate hL hK hu hg hV R hR hsingle hsquare + have he : primeFamilyGraphOperator (fun j (p : P j) => p.val) + (fun _ _ => 0) site Q u eligible g L K extra h gate = + (fun d => matrixOperator (fun i j => + (primeRealEdgeMatrix P site Q u eligible g L K extra h gate d i j : ℂ))) := by + funext d + exact primeFamilyGraphOperator_eq_realMatrix P hprime hdisjoint site Q u eligible g + L K extra h gate d + rw [he, blockNonbacktracking_spectralRadius] + have ht : spectralRadius ℂ (matrixOperator (fun i j => + (blockNonbacktrackingMatrix + (primeRealEdgeMatrix P site Q u eligible g L K extra h gate) i j : ℂ))) ≠ ⊤ := + ne_top_of_le_ne_top ENNReal.coe_ne_top (spectralRadius_le_nnnorm (𝕜 := ℂ) _) + rw [← ENNReal.ofReal_toReal ht] + exact ENNReal.ofReal_le_ofReal hradius + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/GraphSpectralTransfer.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/GraphSpectralTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..02682ba90e8173ee70a45615461aa314a12d8510 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/GraphSpectralTransfer.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualCenterDegree +import OAI.NumberTheory.TwoPoint.Bounds.CoordinateProjection +import OAI.NumberTheory.TwoPoint.Bounds.PrimeFamilyGraph + +namespace OAI + +/-! Apply the noncommuting transfer to the literal prime graph and its +degree projection. The single-edge and square-function bounds are proved. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical NNReal ENNReal + +theorem prime_graph_compression_bound {J : ℕ} {V : Type*} [Fintype V] [DecidableEq V] + (P : Fin J → Finset ℕ) (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (site : V → ℤ) (hinj : Function.Injective site) + (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → V → V → Prop) (hgate : ∀ d i j, gate d i j ↔ gate d j i) + (hL : 0 < L) (hK : 0 ≤ K) (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W) : + let B := primeFamilyGraphOperator (fun j (p : P j) => p.val) (fun _ _ => 0) + site Q u eligible g L K extra h gate + let proj := coordinateProjection (fun i : V => + (actualPaddingDegree (univ.biUnion P) (site i) : ℝ) ≤ 6 * W * J) + ∀ R : ℝ, 0 ≤ R → 2 * K ≤ R → 4 * K ^ 2 * (8 * W) ^ J ≤ R ^ 2 → + spectralRadius ℂ (nonbacktrackingContinuous B) ≤ ENNReal.ofReal R → + ‖proj * (∑ d, B d) * proj‖ ≤ 3 * R := by + dsimp only + intro R hR hsingle hsquare hradius + let B := primeFamilyGraphOperator (fun j (p : P j) => p.val) (fun _ _ => 0) + site Q u eligible g L K extra h gate + let keep := fun i : V => (actualPaddingDegree (univ.biUnion P) (site i) : ℝ) ≤ 6 * W * J + let proj := coordinateProjection keep + apply noncommuting_spectral_transfer B + (fun d => primeFamilyGraphOperator_selfAdjoint _ _ _ _ _ _ _ _ _ _ _ _ hgate d) + proj (coordinateProjection_selfAdjoint keep) (coordinateProjection_idempotent keep) + ⟨R, hR⟩ + · intro d + exact (primeFamilyGraphOperator_norm_le _ (fun j p => hprime j _ p.property) + _ _ hinj _ _ _ _ _ _ _ _ _ hgate hL hK hu hg d).trans hsingle + · intro v hv + change (∑ d, ‖B d v‖ ^ 2) ≤ R ^ 2 * ‖v‖ ^ 2 + have hs := primeFamilyGraphOperator_square_sum (fun j (p : P j) => p.val) + (fun j p => hprime j _ p.property) (fun _ _ => 0) site hinj + Q u eligible g L K W extra h gate hgate hL hK hu hg hV v ?_ + · apply hs.trans + exact mul_le_mul_of_nonneg_right (by simpa only [Fintype.card_fin] using hsquare) + (sq_nonneg ‖v‖) + · intro i hi + have hk := coordinateProjection_support keep v hv i hi + simpa only [zero_add, prime_band_indicator_sum P hdisjoint, Fintype.card_fin] using hk + · convert hradius using 1 + exact (ENNReal.ofReal_eq_coe_nnreal hR).symm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/GraphTesting.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/GraphTesting.lean new file mode 100644 index 0000000000000000000000000000000000000000..dcda81b4ab3b35caa4e4839b5e72d7fe9e501a41 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/GraphTesting.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeFamilyGraph +import OAI.NumberTheory.TwoPoint.Bounds.PositiveRowMajorant +import OAI.NumberTheory.TwoPoint.Bounds.WeightedMatrixTest + +namespace OAI + +/-! The deterministic quadratic-form estimate on every block, including +exceptional blocks. The projected support pays only a power of the mass. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma matrixOperator_sum {D V : Type*} [Fintype D] [Fintype V] [DecidableEq V] + (A : D → V → V → ℂ) : + matrixOperator (fun i j => ∑ d, A d i j) = ∑ d, matrixOperator (A d) := by + ext v i + simp only [_root_.sum_apply, matrixOperator_apply, + WithLp.ofLp_sum, Finset.sum_apply, sum_mul] + rw [sum_comm] + +lemma sum_familyCenter_abs_le {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) (n : ℤ) (W : ℝ) + (hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W) + (hdegree : (actualPaddingDegree (univ.biUnion P) n : ℝ) ≤ 6 * W * J) : + (∑ d : (j : Fin J) → P j, + |familyCenter (fun j (p : P j) => p.val) (fun _ _ => 0) d n|) ≤ (8 * W) ^ J := by + have hb := abs_centeredTuple_sum_le P hprime hdisjoint n W hV hdegree + rw [primeTupleDivisors, sum_image] at hb + · simpa only [familyCenter_zero_eq_centeredTuple _ (fun j p => hprime j _ p.property) + _ (selectedPrimeValues_injective _ hdisjoint), familyTuple] using hb + · intro d _ e _ hde + exact primeTuple_injective hprime hdisjoint hde + +theorem prime_graph_test_deterministic {J : ℕ} {V : Type*} [Fintype V] [DecidableEq V] + (P : Fin J → Finset ℕ) (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (site : V → ℤ) (hinj : Function.Injective site) + (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → V → V → Prop) + (hL : 0 < L) (hK : 0 ≤ K) (hW : 0 ≤ W) + (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W) + (v : EuclideanSpace ℂ V) (hv : ∀ i, ‖v i‖ ≤ g (site i)) + (hdegree : ∀ i, v i ≠ 0 → + (actualPaddingDegree (univ.biUnion P) (site i) : ℝ) ≤ 6 * W * J) + (G : ℝ) (hG : 0 ≤ G) (hweight : ∀ i, v i ≠ 0 → (g (site i)) ^ 2 ≤ G) : + ‖inner ℂ v ((∑ d, primeFamilyGraphOperator (fun j (p : P j) => p.val) + (fun _ _ => 0) site Q u eligible g L K extra h gate d) v)‖ ≤ + Fintype.card V * (2 * K * (8 * W) ^ J) * G := by + let A (d : (j : Fin J) → P j) := maskedIntegerEdgeMatrix site Q u + (eligible (familyTuple (fun j (p : P j) => p.val) d)) g + (familyCenter (fun j (p : P j) => p.val) (fun _ _ => 0) d) + L K (extra (familyTuple (fun j (p : P j) => p.val) d)) h + (familyTuple (fun j (p : P j) => p.val) d) + (gate (familyTuple (fun j (p : P j) => p.val) d)) + have hrow (i : V) (hi : v i ≠ 0) : + (∑ j, ‖∑ d, A d i j‖ * g (site j) / g (site i)) ≤ 2 * K * (8 * W) ^ J := by + calc + _ ≤ ∑ j, (∑ d, ‖A d i j‖) * g (site j) / g (site i) := by + apply sum_le_sum + intro j _ + exact div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_right (norm_sum_le _ _) (hg _).le) (hg _).le + _ = ∑ d, ∑ j, ‖A d i j‖ * g (site j) / g (site i) := by + simp only [sum_mul, sum_div] + rw [sum_comm] + _ ≤ ∑ d : (j : Fin J) → P j, + 2 * K * |familyCenter (fun j (p : P j) => p.val) (fun _ _ => 0) d (site i)| := by + apply sum_le_sum + intro d _ + exact maskedIntegerEdgeMatrix_weighted_row site hinj Q u _ g _ L K _ h _ _ + hL hK hu hg (fun q _ n => familyCenter_padding_periodic _ _ d h q n) i + _ = 2 * K * ∑ d : (j : Fin J) → P j, + |familyCenter (fun j (p : P j) => p.val) (fun _ _ => 0) d (site i)| := by rw [mul_sum] + _ ≤ _ := mul_le_mul_of_nonneg_left + (sum_familyCenter_abs_le P hprime hdisjoint (site i) W hV (hdegree i hi)) (by positivity) + have ht := weighted_matrix_test_uniform (fun i j => ∑ d, A d i j) + (fun i => g (site i)) (2 * K * (8 * W) ^ J) G + (fun i => hg _) (by positivity) hG v hv hrow hweight + rw [matrixOperator_sum] at ht + exact ht + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/IndependentSampling.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/IndependentSampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2112d827a01b5c15fc33d041a93d524907a8858 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/IndependentSampling.lean @@ -0,0 +1,121 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteProbability +import OAI.NumberTheory.TwoPoint.Bounds.LinearPivots +import Mathlib.Logic.Equiv.Prod + +namespace OAI + +/-! Product sampling and the atom bound for independent linear equations. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι A : Type*} [Fintype ι] [DecidableEq ι] + +def joinCoordinates (S : Finset ι) (x : S → A) (y : {i // i ∉ S} → A) : ι → A := + fun i => if h : i ∈ S then x ⟨i, h⟩ else y ⟨i, h⟩ + +omit [Fintype ι] in +@[simp] lemma joinCoordinates_mem (S : Finset ι) (x : S → A) (y : {i // i ∉ S} → A) + (i : S) : joinCoordinates S x y i = x i := by simp [joinCoordinates, i.property] + +omit [Fintype ι] in +@[simp] lemma joinCoordinates_notMem (S : Finset ι) (x : S → A) (y : {i // i ∉ S} → A) + (i : {i // i ∉ S}) : joinCoordinates S x y i = y i := by simp [joinCoordinates, i.property] + +namespace FiniteLaw + +variable [Fintype A] + +lemma independent_probability_all (μ : ι → FiniteLaw A) (E : ι → A → Prop) : + (independent μ).probability (fun x => ∀ i, E i (x i)) = + ∏ i, (μ i).probability (E i) := by + classical + unfold probability + calc + _ = (independent μ).average (fun x => ∏ i, if E i (x i) then (1 : ℝ) else 0) := by + apply congrArg (independent μ).average + funext x + by_cases hx : ∀ i, E i (x i) <;> simp [Fintype.prod_boole, hx] + _ = _ := independent_average_product μ (fun i x => if E i x then 1 else 0) + +lemma independent_weight_join (μ : ι → FiniteLaw A) (S : Finset ι) + (x : S → A) (y : {i // i ∉ S} → A) : + (independent μ).weight (joinCoordinates S x y) = + (independent (fun i : S => μ i)).weight x * + (independent (fun i : {i // i ∉ S} => μ i)).weight y := by + change (∏ i, (μ i).weight (joinCoordinates S x y i)) = _ + rw [← Fintype.prod_subtype_mul_prod_subtype (fun i => i ∈ S)] + simp only [joinCoordinates_mem, joinCoordinates_notMem, independent] + have hinst : Subtype.fintype (fun i : ι => i ∈ S) = (inferInstance : Fintype S) := + Subsingleton.elim _ _ + rw [hinst] + +/-- Conditioning on coordinates outside `S` leaves the original product +law on `S`. -/ +lemma independent_average_split (μ : ι → FiniteLaw A) (S : Finset ι) (f : (ι → A) → ℝ) : + (independent μ).average f = + (independent (fun i : {i // i ∉ S} => μ i)).average (fun y => + (independent (fun i : S => μ i)).average (fun x => f (joinCoordinates S x y))) := by + let e := Equiv.piEquivPiSubtypeProd (fun i => i ∈ S) (fun _ => A) + calc + _ = ∑ z : (S → A) × ({i // i ∉ S} → A), + (independent μ).weight (joinCoordinates S z.1 z.2) * + f (joinCoordinates S z.1 z.2) := by + exact (e.symm.sum_comp (fun z => (independent μ).weight z * f z)).symm + _ = _ := by + rw [Fintype.sum_prod_type] + simp only [independent_weight_join, average, mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro y _ + apply sum_congr rfl + intro x _ + ring + +/-- An event that determines the coordinates in `S`, after all other +coordinates are fixed, has probability at most `α ^ #S`. -/ +theorem probability_le_of_determined_coordinates (μ : ι → FiniteLaw A) + (S : Finset ι) (α : ℝ) (hα : 0 ≤ α) (hatom : ∀ i x, (μ i).weight x ≤ α) + (E : (ι → A) → Prop) + (hunique : ∀ x y, E x → E y → (∀ i ∉ S, x i = y i) → x = y) : + (independent μ).probability E ≤ α ^ S.card := by + classical + rw [probability, independent_average_split μ S] + apply (average_mono _ (g := fun _ => α ^ S.card) ?_).trans_eq (average_const _ _) + intro y + apply probability_le_atom_bound + · exact pow_nonneg hα _ + · intro x + change (∏ i : S, (μ i).weight (x i)) ≤ _ + simpa only [prod_const, card_univ, Fintype.card_coe] using + prod_le_prod₀ (s := univ) (fun (i : S) _ => (μ i.val).nonneg (x i)) + (fun (i : S) _ => hatom i.val (x i)) + · intro x x' hx hx' + have hj := hunique (joinCoordinates S x y) (joinCoordinates S x' y) hx hx' + (fun i hi => by simp [joinCoordinates, hi]) + funext i + simpa only [joinCoordinates_mem] using congrFun hj i + +/-- Independent bounded atoms satisfy the expected codimension bound for +every surjective real linear system. -/ +theorem probability_linear_equations {K κ : Type*} [Field K] [Fintype κ] + (μ : ι → FiniteLaw A) (val : A → K) (hval : Function.Injective val) + (T : (ι → K) →ₗ[K] (κ → K)) (hT : Function.Surjective T) + (b : κ → K) (α : ℝ) (hα : 0 ≤ α) (hatom : ∀ i x, (μ i).weight x ≤ α) : + (independent μ).probability (fun x => T (fun i => val (x i)) = b) ≤ + α ^ Fintype.card κ := by + obtain ⟨S, hcard, hpivot⟩ := exists_pivot_coordinates T hT + rw [← hcard] + apply probability_le_of_determined_coordinates μ S α hα hatom + intro x y hx hy hxy + have heq := hpivot (fun i => val (x i)) (fun i => val (y i)) + (fun i hi => congrArg val (hxy i hi)) (hx.trans hy.symm) + funext i + exact hval (congrFun heq i) + +end FiniteLaw + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/InitialAverage.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/InitialAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c781cd7fd03e94cde52a2313032278c8cb2a650 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/InitialAverage.lean @@ -0,0 +1,30 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteAverages + +namespace OAI + +/-! Compare a nonnegative average on an initial interval with the average +on an integer multiple of that interval. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma uniformAverage_initial_le (f : ℕ → ℝ) (hf : ∀ n, 0 ≤ f n) + (l N : ℕ) (hl : 0 < l) (hN : 0 < N) : + uniformAverage (fun t : Fin N => f t.val) ≤ + (l : ℝ) * uniformAverage (fun t : Fin (l * N) => f t.val) := by + have hNl : N ≤ l * N := by nlinarith + have hs : (∑ t ∈ range N, f t) ≤ ∑ t ∈ range (l * N), f t := + sum_le_sum_of_subset_of_nonneg (range_mono hNl) (fun t _ _ => hf t) + have hlr : (l : ℝ) ≠ 0 := by positivity + have hNr : (N : ℝ) ≠ 0 := by positivity + simp only [uniformAverage, Fintype.card_fin, Fin.sum_univ_eq_sum_range f, + Nat.cast_mul] + calc + _ ≤ (∑ t ∈ range (l * N), f t) / N := + div_le_div_of_nonneg_right hs (Nat.cast_nonneg N) + _ = _ := by field_simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerClosedCatalog.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerClosedCatalog.lean new file mode 100644 index 0000000000000000000000000000000000000000..f17628975d9dc7cee15edd7d9e56dbe5850e3d2b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerClosedCatalog.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TwoPoint.Bounds.IntegerShiftGeometry + +namespace OAI + +/-! A fixed-length numerical closed word remembers both forced matrix paths. +Only their starting site and external copy indices remain outside this code. -/ + +namespace TwoPointCorrelations + +variable {D : Type*} + +theorem integerStepWord_injective (Q : Finset ℕ) (tuple : D → ℕ) + (hinj : Function.Injective tuple) (k : ℕ) : + Function.Injective (integerStepWord (D := D) Q tuple (k := k)) := by + intro a b hab + have hs : (fun i => SignedStep.mk (a i).2.2 (tuple (a i).1) (a i).2.1.val) = + (fun i => SignedStep.mk (b i).2.2 (tuple (b i).1) (b i).2.1.val) := by + apply List.ofFn_injective + simpa only [integerStepWord, List.map_ofFn, Function.comp_def] using hab + funext i + apply Prod.ext + · exact hinj (congrArg SignedStep.tuple (congrFun hs i)) + · apply Prod.ext + · exact Subtype.ext (congrArg SignedStep.padding (congrFun hs i)) + · exact congrArg SignedStep.forward (congrFun hs i) + +def integerClosedWordCode (Q : Finset ℕ) (tuple : D → ℕ) {k : ℕ} + (a : (Fin k → D × (Q × Bool)) × (Fin k → D × (Q × Bool))) : List SignedStep := + integerStepWord Q tuple a.1 ++ reverseWord (integerStepWord Q tuple a.2) + +theorem integerClosedWordCode_injective (Q : Finset ℕ) (tuple : D → ℕ) + (hinj : Function.Injective tuple) (k : ℕ) : + Function.Injective (integerClosedWordCode (D := D) Q tuple (k := k)) := by + intro a b hab + have hlen (w : Fin k → D × (Q × Bool)) : (integerStepWord Q tuple w).length = k := by + simp only [integerStepWord, List.length_map, List.length_ofFn] + have htake (w : Fin k → D × (Q × Bool)) : (integerStepWord Q tuple w).take k = + integerStepWord Q tuple w := by + simpa only [hlen] using (List.take_length (l := integerStepWord Q tuple w)) + have hdrop (w : Fin k → D × (Q × Bool)) : (integerStepWord Q tuple w).drop k = [] := by + simpa only [hlen] using (List.drop_length (l := integerStepWord Q tuple w)) + apply Prod.ext + · apply integerStepWord_injective Q tuple hinj k + have he := congrArg (List.take k) hab + simpa only [integerClosedWordCode, List.take_append, hlen, Nat.sub_self, + List.take_zero, List.append_nil, htake] using he + · apply integerStepWord_injective Q tuple hinj k + have he := congrArg (List.drop k) hab + have hr : reverseWord (integerStepWord Q tuple a.2) = + reverseWord (integerStepWord Q tuple b.2) := by + simpa only [integerClosedWordCode, List.drop_append, hlen, Nat.sub_self, + List.drop_zero, hdrop, List.nil_append] using he + simpa only [reverseWord_reverseWord] using congrArg reverseWord hr + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerEdgeOperators.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerEdgeOperators.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a6f610fc82cd2d1212489dd0ba0fae2ab006a66 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerEdgeOperators.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.TwoPoint.Bounds.IntegerEdgeRows + +namespace OAI + +/-! Operator consequences of the concrete integer weighted-row estimate. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι : Type*} [Fintype ι] + +/-- The localized matrix-square estimate for the actual cutoff graph. -/ +theorem integerEdgeMatrix_localized_square + (site : ι → ℤ) (hinj : Function.Injective site) + (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → Prop) + (g center : ℤ → ℝ) (L K : ℝ) (extra : ℤ → Prop) (h d : ℕ) + (hL : 0 < L) (hK : 0 ≤ K) (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (hperiod : ∀ q ∈ Q, ∀ n, center (n + (h * q * d : ℕ)) = center n) + (v : ι → ℂ) : + (∑ i, ‖∑ j, (integerEdgeMatrix site Q u eligible g center L K extra h d i j : ℂ) * v j‖ ^ 2) ≤ + 4 * K ^ 2 * ∑ i, |center (site i)| ^ 2 * ‖v i‖ ^ 2 := by + have hbound := weighted_matrix_localized_square + (fun i j => (integerEdgeMatrix site Q u eligible g center L K extra h d i j : ℂ)) + (fun i => g (site i)) (fun i => |center (site i)|) (2 * K) (by positivity) + (fun i => hg _) (fun i => abs_nonneg _) + (fun i j => by rw [integerEdgeMatrix_symmetric site Q u eligible g center L K extra h d i j]) + (fun i j hij => congrArg abs (integerEdgeMatrix_center_invariant Q u eligible g center L K extra h d + site hperiod i j (fun hz => hij (by simp [hz])))) + (fun i => by simpa only [Complex.norm_real, Real.norm_eq_abs] using + integerEdgeMatrix_weighted_row Q u eligible g center L K extra h d site hinj hL hK hu hg hperiod i) v + convert hbound using 1 + ring + +/-- The single-operator bound `2K` for the actual centered integer graph. -/ +theorem centeredIntegerEdge_operator_norm_le + (site : ι → ℤ) (hinj : Function.Injective site) + (Q P : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) (extra : ℤ → Prop) (h d : ℕ) + (hL : 0 < L) (hK : 0 ≤ K) (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (hP : ∀ p ∈ P, p.Prime) (hd : ∀ p ∈ P, p ∣ d) + (T : EuclideanSpace ℂ ι →L[ℂ] EuclideanSpace ℂ ι) + (hT : ∀ v i, T v i = ∑ j, + (integerEdgeMatrix site Q u eligible g (centeredTuple P) L K extra h d i j : ℂ) * v j) : + ‖T‖ ≤ 2 * K := by + have hperiod : ∀ q ∈ Q, ∀ n, centeredTuple P (n + (h * q * d : ℕ)) = centeredTuple P n := + fun q _ n => centeredTuple_padding_periodic P h d hd q n + apply weighted_operator_norm_le T + (fun i j => (integerEdgeMatrix site Q u eligible g (centeredTuple P) L K extra h d i j : ℂ)) + hT (fun i => g (site i)) (fun i => |centeredTuple P (site i)|) (2 * K) (by positivity) + (fun i => hg _) (fun i => abs_nonneg _) (fun i => centeredTuple_abs_le_one P hP _) + · intro i j + rw [integerEdgeMatrix_symmetric site Q u eligible g (centeredTuple P) L K extra h d i j] + · intro i j hij + exact congrArg abs (integerEdgeMatrix_center_invariant Q u eligible g (centeredTuple P) L K extra h d + site hperiod i j (fun hz => hij (by simp [hz]))) + · intro i + simpa only [Complex.norm_real, Real.norm_eq_abs] using + integerEdgeMatrix_weighted_row Q u eligible g (centeredTuple P) L K extra h d + site hinj hL hK hu hg hperiod i + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerEdgeRows.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerEdgeRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..500cb2520dc611137f222fb903215abf4a21f661 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerEdgeRows.lean @@ -0,0 +1,158 @@ +import OAI.NumberTheory.TwoPoint.Bounds.IntegerEdges + +namespace OAI + +/-! Derivation of the weighted row estimate for the concrete integer graph. -/ + +namespace TwoPointCorrelations + +open Finset + +variable (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → Prop) + (g center : ℤ → ℝ) (L K : ℝ) (extra : ℤ → Prop) (h d : ℕ) + +lemma directedIntegerEdge_forward_bound + (hL : 0 ≤ L) (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (q : ℕ) (hq : q ∈ Q) (n m : ℤ) : + |directedIntegerEdge Q u eligible g center L K extra h d q n m| * g m / g n ≤ + if m = n + (h * q * d : ℕ) then + |center n| * retainedPaddingAtom Q u eligible g L K extra n q else 0 := by + classical + unfold directedIntegerEdge + by_cases he : q ∈ Q ∧ m = n + (h * q * d : ℕ) ∧ eligible q ∧ (q : ℤ) ∣ n ∧ + integerEdgeKeep Q u eligible g L K extra n ∧ integerEdgeKeep Q u eligible g L K extra m + · rw [ite_eq_left he] + have hkeep : eligible q ∧ (q : ℤ) ∣ n ∧ integerEdgeKeep Q u eligible g L K extra n := + ⟨he.2.2.1, he.2.2.2.1, he.2.2.2.2.1⟩ + rw [ite_eq_left he.2.1, retainedPaddingAtom, ite_eq_left hkeep] + simp only [abs_div, abs_mul, abs_of_nonneg hL, abs_of_nonneg (hu q hq), + abs_of_pos (hg n), abs_of_pos (hg m)] + apply le_of_eq + field_simp [(hg n).ne', (hg m).ne'] + · rw [ite_eq_right he, abs_zero, zero_mul, zero_div] + split_ifs + · exact mul_nonneg (abs_nonneg _) (retainedPaddingAtom_nonneg Q u eligible g L K extra n q hL (hu q hq)) + · exact le_rfl + +lemma directedIntegerEdge_backward_bound + (hL : 0 ≤ L) (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (hperiod : ∀ q ∈ Q, ∀ n, center (n + (h * q * d : ℕ)) = center n) + (q : ℕ) (hq : q ∈ Q) (n m : ℤ) : + |directedIntegerEdge Q u eligible g center L K extra h d q m n| * g m / g n ≤ + if m = n - (h * q * d : ℕ) then + |center n| * retainedPaddingAtom Q u eligible g L K extra n q else 0 := by + classical + unfold directedIntegerEdge + by_cases he : q ∈ Q ∧ n = m + (h * q * d : ℕ) ∧ eligible q ∧ (q : ℤ) ∣ m ∧ + integerEdgeKeep Q u eligible g L K extra m ∧ integerEdgeKeep Q u eligible g L K extra n + · rw [ite_eq_left he] + have hm : m = n - (h * q * d : ℕ) := by omega + have hdiv : (q : ℤ) ∣ n := (padding_dvd_along_edge h q d m n he.2.1).mpr he.2.2.2.1 + have hkeep : eligible q ∧ (q : ℤ) ∣ n ∧ integerEdgeKeep Q u eligible g L K extra n := + ⟨he.2.2.1, hdiv, he.2.2.2.2.2⟩ + have hc : center m = center n := by rw [he.2.1, hperiod q hq m] + rw [ite_eq_left hm, retainedPaddingAtom, ite_eq_left hkeep, hc] + simp only [abs_div, abs_mul, abs_of_nonneg hL, abs_of_nonneg (hu q hq), + abs_of_pos (hg n), abs_of_pos (hg m)] + apply le_of_eq + field_simp [(hg n).ne', (hg m).ne'] + · rw [ite_eq_right he, abs_zero, zero_mul, zero_div] + split_ifs + · exact mul_nonneg (abs_nonneg _) (retainedPaddingAtom_nonneg Q u eligible g L K extra n q hL (hu q hq)) + · exact le_rfl + +lemma directedIntegerEdge_forward_row + {ι : Type*} [Fintype ι] (site : ι → ℤ) (hinj : Function.Injective site) + (hL : 0 ≤ L) (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (q : ℕ) (hq : q ∈ Q) (i : ι) : + (∑ j, |directedIntegerEdge Q u eligible g center L K extra h d q (site i) (site j)| * + g (site j) / g (site i)) ≤ + |center (site i)| * retainedPaddingAtom Q u eligible g L K extra (site i) q := by + apply le_trans (sum_le_sum (fun j _ => + directedIntegerEdge_forward_bound Q u eligible g center L K extra h d hL hu hg q hq _ _)) + exact sum_indicator_site_le site hinj _ _ (mul_nonneg (abs_nonneg _) + (retainedPaddingAtom_nonneg Q u eligible g L K extra _ q hL (hu q hq))) + +lemma directedIntegerEdge_backward_row + {ι : Type*} [Fintype ι] (site : ι → ℤ) (hinj : Function.Injective site) + (hL : 0 ≤ L) (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (hperiod : ∀ q ∈ Q, ∀ n, center (n + (h * q * d : ℕ)) = center n) + (q : ℕ) (hq : q ∈ Q) (i : ι) : + (∑ j, |directedIntegerEdge Q u eligible g center L K extra h d q (site j) (site i)| * + g (site j) / g (site i)) ≤ + |center (site i)| * retainedPaddingAtom Q u eligible g L K extra (site i) q := by + apply le_trans (sum_le_sum (fun j _ => + directedIntegerEdge_backward_bound Q u eligible g center L K extra h d hL hu hg hperiod q hq _ _)) + exact sum_indicator_site_le site hinj _ _ (mul_nonneg (abs_nonneg _) + (retainedPaddingAtom_nonneg Q u eligible g L K extra _ q hL (hu q hq))) + +/-- Both edge orientations are bounded by the same retained padding mass. +Incoming divisibility uses the actual integer step `h*q*d`. -/ +theorem integerEdgeMatrix_weighted_row + {ι : Type*} [Fintype ι] (site : ι → ℤ) (hinj : Function.Injective site) + (hL : 0 < L) (hK : 0 ≤ K) (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (hperiod : ∀ q ∈ Q, ∀ n, center (n + (h * q * d : ℕ)) = center n) + (i : ι) : + ∑ j, |integerEdgeMatrix site Q u eligible g center L K extra h d i j| * + g (site j) / g (site i) ≤ 2 * K * |center (site i)| := by + have habs (j : ι) : |integerEdgeMatrix site Q u eligible g center L K extra h d i j| ≤ + ∑ q ∈ Q, (|directedIntegerEdge Q u eligible g center L K extra h d q (site i) (site j)| + + |directedIntegerEdge Q u eligible g center L K extra h d q (site j) (site i)|) := by + apply (abs_sum_le_sum_abs _ _).trans + exact sum_le_sum (fun q _ => abs_add_le _ _) + calc + _ ≤ ∑ j, (∑ q ∈ Q, (|directedIntegerEdge Q u eligible g center L K extra h d q (site i) (site j)| + + |directedIntegerEdge Q u eligible g center L K extra h d q (site j) (site i)|)) * + g (site j) / g (site i) := by + apply sum_le_sum + intro j _ + exact div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_right (habs j) (hg _).le) (hg _).le + _ = ∑ q ∈ Q, ∑ j, (|directedIntegerEdge Q u eligible g center L K extra h d q (site i) (site j)| + + |directedIntegerEdge Q u eligible g center L K extra h d q (site j) (site i)|) * + g (site j) / g (site i) := by + simp only [sum_mul, sum_div] + rw [sum_comm] + _ = ∑ q ∈ Q, + ((∑ j, |directedIntegerEdge Q u eligible g center L K extra h d q (site i) (site j)| * g (site j) / g (site i)) + + ∑ j, |directedIntegerEdge Q u eligible g center L K extra h d q (site j) (site i)| * g (site j) / g (site i)) := by + simp only [add_mul, add_div, sum_add_distrib] + _ ≤ ∑ q ∈ Q, 2 * |center (site i)| * retainedPaddingAtom Q u eligible g L K extra (site i) q := by + apply sum_le_sum + intro q hq + have hf := directedIntegerEdge_forward_row Q u eligible g center L K extra h d site hinj hL.le hu hg q hq i + have hb := directedIntegerEdge_backward_row Q u eligible g center L K extra h d site hinj hL.le hu hg hperiod q hq i + exact (add_le_add hf hb).trans_eq (by ring) + _ = 2 * |center (site i)| * (∑ q ∈ Q, retainedPaddingAtom Q u eligible g L K extra (site i) q) := + (mul_sum ..).symm + _ ≤ 2 * |center (site i)| * K := mul_le_mul_of_nonneg_left + (retainedPaddingAtom_sum_le Q u eligible g L K extra _ hL hK) (by positivity) + _ = _ := by ring + +lemma integerEdgeMatrix_center_invariant + {ι : Type*} [Fintype ι] (site : ι → ℤ) + (hperiod : ∀ q ∈ Q, ∀ n, center (n + (h * q * d : ℕ)) = center n) + (i j : ι) + (hA : integerEdgeMatrix site Q u eligible g center L K extra h d i j ≠ 0) : + center (site i) = center (site j) := by + classical + by_contra hc + apply hA + unfold integerEdgeMatrix + apply sum_eq_zero + intro q hq + have hf : directedIntegerEdge Q u eligible g center L K extra h d q (site i) (site j) = 0 := by + unfold directedIntegerEdge + split_ifs with he + · exact False.elim (hc (by rw [he.2.1, hperiod q hq (site i)])) + · rfl + have hb : directedIntegerEdge Q u eligible g center L K extra h d q (site j) (site i) = 0 := by + unfold directedIntegerEdge + split_ifs with he + · exact False.elim (hc (by rw [he.2.1, hperiod q hq (site j)])) + · rfl + simp only [hf, hb, add_zero] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerEdges.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerEdges.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8789bc37372c9d0210b6905d067063d21c6f524 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerEdges.lean @@ -0,0 +1,145 @@ +import OAI.NumberTheory.TwoPoint.Bounds.WeightedRows +import OAI.NumberTheory.TwoPoint.Bounds.CenterDegree + +namespace OAI + +/-! Concrete centered integer edges and the padding-density cutoff. -/ + +namespace TwoPointCorrelations + +open Finset + +noncomputable def centeredTuple (P : Finset ℕ) (n : ℤ) : ℝ := + ∏ p ∈ P, ((if (p : ℤ) ∣ n then 1 else 0) - (p : ℝ)⁻¹) + +lemma centeredTuple_add (P : Finset ℕ) (n t : ℤ) + (ht : ∀ p ∈ P, (p : ℤ) ∣ t) : centeredTuple P (n + t) = centeredTuple P n := by + unfold centeredTuple + apply prod_congr rfl + intro p hp + simp only [dvd_add_left (ht p hp)] + +lemma centeredTuple_abs (P : Finset ℕ) (n : ℤ) : + |centeredTuple P n| = + ∏ p ∈ P, centerMagnitude (p : ℝ)⁻¹ (decide ((p : ℤ) ∣ n)) := by + simp [centeredTuple, abs_prod, centerMagnitude] + +noncomputable def paddingDensity (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g : ℤ → ℝ) (n : ℤ) : ℝ := by + classical + exact (∑ q ∈ Q, if eligible q ∧ (q : ℤ) ∣ n then u q else 0) / (g n) ^ 2 + +noncomputable def integerEdgeKeep (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g : ℤ → ℝ) (L K : ℝ) (extra : ℤ → Prop) (n : ℤ) : Prop := + paddingDensity Q u eligible g n ≤ K / L ∧ extra n + +/-- The increasing-edge coefficient, including the two endpoint cutoffs. +The auxiliary `extra` predicate carries the remaining vertex deletions. -/ +noncomputable def directedIntegerEdge (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g center : ℤ → ℝ) (L K : ℝ) + (extra : ℤ → Prop) (h d q : ℕ) (n m : ℤ) : ℝ := by + classical + exact if q ∈ Q ∧ m = n + (h * q * d : ℕ) ∧ eligible q ∧ (q : ℤ) ∣ n ∧ + integerEdgeKeep Q u eligible g L K extra n ∧ + integerEdgeKeep Q u eligible g L K extra m + then L * u q * center n / (g n * g m) else 0 + +noncomputable def integerEdgeMatrix {ι : Type*} [Fintype ι] + (site : ι → ℤ) (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g center : ℤ → ℝ) (L K : ℝ) + (extra : ℤ → Prop) (h d : ℕ) (i j : ι) : ℝ := + ∑ q ∈ Q, (directedIntegerEdge Q u eligible g center L K extra h d q (site i) (site j) + + directedIntegerEdge Q u eligible g center L K extra h d q (site j) (site i)) + +lemma integerEdgeMatrix_symmetric {ι : Type*} [Fintype ι] + (site : ι → ℤ) (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g center : ℤ → ℝ) (L K : ℝ) + (extra : ℤ → Prop) (h d : ℕ) (i j : ι) : + integerEdgeMatrix site Q u eligible g center L K extra h d i j = + integerEdgeMatrix site Q u eligible g center L K extra h d j i := by + simp only [integerEdgeMatrix, add_comm] + +lemma sum_indicator_site_le {ι : Type*} [Fintype ι] + (site : ι → ℤ) (hinj : Function.Injective site) (n : ℤ) + (C : ℝ) (hC : 0 ≤ C) : (∑ i, if site i = n then C else 0) ≤ C := by + classical + by_cases hex : ∃ i, site i = n + · obtain ⟨i, hi⟩ := hex + have heq (j : ι) : site j = n ↔ j = i := by + constructor + · intro hj + exact hinj (hj.trans hi.symm) + · rintro rfl + exact hi + simp [heq] + · have hn (i : ι) : site i ≠ n := fun hi => hex ⟨i, hi⟩ + simpa [hn] using hC + +/-- Divisibility by a padding divisor is unchanged along its integer edge. -/ +lemma padding_dvd_along_edge (h q d : ℕ) (n m : ℤ) + (hm : m = n + (h * q * d : ℕ)) : (q : ℤ) ∣ m ↔ (q : ℤ) ∣ n := by + rw [hm] + apply dvd_add_left + norm_cast + exact dvd_mul_of_dvd_left (dvd_mul_left q h) d + +noncomputable def retainedPaddingAtom (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g : ℤ → ℝ) (L K : ℝ) + (extra : ℤ → Prop) (n : ℤ) (q : ℕ) : ℝ := by + classical + exact if eligible q ∧ (q : ℤ) ∣ n ∧ integerEdgeKeep Q u eligible g L K extra n + then L * u q / (g n) ^ 2 else 0 + +lemma retainedPaddingAtom_nonneg (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g : ℤ → ℝ) (L K : ℝ) + (extra : ℤ → Prop) (n : ℤ) (q : ℕ) (hL : 0 ≤ L) (hu : 0 ≤ u q) : + 0 ≤ retainedPaddingAtom Q u eligible g L K extra n q := by + unfold retainedPaddingAtom + split_ifs + · exact div_nonneg (mul_nonneg hL hu) (sq_nonneg _) + · exact le_rfl + +lemma retainedPaddingAtom_sum_le (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g : ℤ → ℝ) (L K : ℝ) + (extra : ℤ → Prop) (n : ℤ) (hL : 0 < L) (hK : 0 ≤ K) : + ∑ q ∈ Q, retainedPaddingAtom Q u eligible g L K extra n q ≤ K := by + classical + by_cases hk : integerEdgeKeep Q u eligible g L K extra n + · have heq : (∑ q ∈ Q, retainedPaddingAtom Q u eligible g L K extra n q) = + L * paddingDensity Q u eligible g n := by + simp only [retainedPaddingAtom, paddingDensity] + rw [← mul_div_assoc, mul_sum, sum_div] + apply sum_congr rfl + intro q _ + by_cases hq : eligible q ∧ (q : ℤ) ∣ n + · simp [hq.1, hq.2, hk] + · simp only [show ¬(eligible q ∧ (q : ℤ) ∣ n ∧ integerEdgeKeep Q u eligible g L K extra n) from + fun hh => hq ⟨hh.1, hh.2.1⟩, hq, ite_false, mul_zero, zero_div] + rw [heq] + calc + _ ≤ L * (K / L) := mul_le_mul_of_nonneg_left hk.1 hL.le + _ = K := by field_simp + · simpa [retainedPaddingAtom, hk] using hK + +lemma centeredTuple_padding_periodic (P : Finset ℕ) (h d : ℕ) + (hd : ∀ p ∈ P, p ∣ d) (q : ℕ) (n : ℤ) : + centeredTuple P (n + (h * q * d : ℕ)) = centeredTuple P n := by + apply centeredTuple_add + intro p hp + exact_mod_cast dvd_mul_of_dvd_right (hd p hp) (h * q) + +lemma centeredTuple_abs_le_one (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (n : ℤ) : + |centeredTuple P n| ≤ 1 := by + rw [centeredTuple_abs] + apply prod_le_one₀ + · intro p _ + exact centerMagnitude_nonneg _ _ + · intro p hp + have hp1 : (1 : ℝ) ≤ p := by exact_mod_cast (hP p hp).one_lt.le + apply centerMagnitude_le_one + · positivity + · exact (inv_le_one₀ (by positivity)).mpr hp1 + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerLiouville.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerLiouville.lean new file mode 100644 index 0000000000000000000000000000000000000000..066de314c7b518afef7647a03d71ca6f1f0c5583 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerLiouville.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.TwoPoint.Basic +import OAI.NumberTheory.TwoPoint.Bounds.IntegerEdges + +namespace OAI + +/-! The real Liouville test function on ambient integer vertices and +the exact cancellation of the square-root weights on each directed edge. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +noncomputable def integerLiouville (n : ℤ) : ℂ := liouville n.toNat + +lemma liouville_norm_le_one (n : ℕ) : ‖liouville n‖ ≤ 1 := by + by_cases hn : n = 0 + · subst n + simp [liouville] + · exact liouville_oneBounded n (Nat.pos_of_ne_zero hn) + +lemma integerLiouville_norm_le_one (n : ℤ) : ‖integerLiouville n‖ ≤ 1 := + liouville_norm_le_one _ + +lemma integerLiouville_natCast (n : ℕ) : integerLiouville n = liouville n := by + simp [integerLiouville] + +lemma star_integerLiouville (n : ℤ) : star (integerLiouville n) = integerLiouville n := by + simp [integerLiouville, liouville] + +lemma directedEdge_liouville_test (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → Prop) + (g center : ℤ → ℝ) (L K : ℝ) (extra : ℤ → Prop) (h d q : ℕ) (n m : ℤ) + (hg : ∀ z, g z ≠ 0) : + star ((g n : ℂ) * integerLiouville n) * + (directedIntegerEdge Q u eligible g center L K extra h d q n m : ℂ) * + ((g m : ℂ) * integerLiouville m) = + if q ∈ Q ∧ m = n + (h * q * d : ℕ) ∧ eligible q ∧ (q : ℤ) ∣ n ∧ + integerEdgeKeep Q u eligible g L K extra n ∧ + integerEdgeKeep Q u eligible g L K extra m then + (L * u q * center n : ℝ) * integerLiouville n * integerLiouville m else 0 := by + unfold directedIntegerEdge + split_ifs with he + · simp only [star_mul, Complex.star_def, Complex.conj_ofReal, star_integerLiouville, + Complex.ofReal_div, Complex.ofReal_mul] + have hn : (g n : ℂ) ≠ 0 := by exact_mod_cast hg n + have hm : (g m : ℂ) ≠ 0 := by exact_mod_cast hg m + field_simp + · simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerPathProduct.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerPathProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..0865a41fe508d44577bfa516250c434641ddea14 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerPathProduct.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.TwoPoint.Walks.ClosedPathProduct + +namespace OAI + +/-! Separate the copy, block, and endpoint gates from the signed arithmetic +edge product along an actual forced matrix path. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +variable {D V : Type*} + +noncomputable def integerStepMask (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (h : ℕ) (gate : D → ℤ → ℤ → Prop) + (e : D × (Q × Bool)) (x : D × ℤ) : ℝ := + if x.1 ≠ e.1 ∧ gate e.1 x.2 (integerShiftNext Q tuple h e x).2 ∧ + integerShiftNext Q tuple h e x ∈ Set.range embed then 1 else 0 + +noncomputable def integerPathMask (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (h : ℕ) (gate : D → ℤ → ℤ → Prop) : + {k : ℕ} → D × ℤ → (Fin k → D × (Q × Bool)) → ℝ + | 0, _, _ => 1 + | _k + 1, x, w => + integerStepMask embed Q tuple h gate (w 0) x * + integerPathMask embed Q tuple h gate (integerShiftNext Q tuple h (w 0) x) (Fin.tail w) + +lemma integerPathMask_zero_or_one (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (h : ℕ) (gate : D → ℤ → ℤ → Prop) + {k : ℕ} (x : D × ℤ) (w : Fin k → D × (Q × Bool)) : + integerPathMask embed Q tuple h gate x w = 0 ∨ + integerPathMask embed Q tuple h gate x w = 1 := by + induction k generalizing x with + | zero => exact Or.inr rfl + | succ k ih => + simp only [integerPathMask, integerStepMask] + split_ifs + · simpa only [one_mul] using ih (integerShiftNext Q tuple h (w 0) x) (Fin.tail w) + · exact Or.inl (zero_mul _) + +variable [Fintype V] [DecidableEq D] + +lemma retained_integerShiftWeight_eq_mask (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (u : ℕ → ℝ) (eligible : D → ℕ → Prop) + (g : ℤ → ℝ) (center : D → ℤ → ℝ) (L K : ℝ) (extra : D → ℤ → Prop) + (h : ℕ) (gate : D → ℤ → ℤ → Prop) (e : D × (Q × Bool)) (x : D × ℤ) : + retainedShiftWeight embed (integerShiftNext Q tuple h) + (integerShiftWeight Q tuple u eligible g center L K extra h gate) e x = + integerStepMask embed Q tuple h gate e x * + signedIntegerWeight Q u (eligible e.1) g (center e.1) L K (extra e.1) h + ⟨e.2.2, tuple e.1, e.2.1⟩ x.2 := by + unfold integerStepMask + by_cases hc : x.1 ≠ e.1 + · by_cases hg : gate e.1 x.2 (integerShiftNext Q tuple h e x).2 + · by_cases hr : integerShiftNext Q tuple h e x ∈ Set.range embed + · simp [retainedShiftWeight, integerShiftWeight, hc, hg, hr] + · simp [retainedShiftWeight, hc, hg, hr] + · simp [retainedShiftWeight, integerShiftWeight, hc, hg] + · simp [retainedShiftWeight, integerShiftWeight, hc] + +theorem integerShiftWord_eq_mask_product (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (center : ℕ → ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) + (h : ℕ) (gate : D → ℤ → ℤ → Prop) {k : ℕ} + (x : D × ℤ) (w : Fin k → D × (Q × Bool)) : + shiftWordWeight embed (integerShiftNext Q tuple h) + (integerShiftWeight Q tuple u (fun d => eligible (tuple d)) g + (fun d => center (tuple d)) L K (fun d => extra (tuple d)) h gate) x w = + integerPathMask embed Q tuple h gate x w * + scalarWalkProduct h (fun t => signedIntegerWeight Q u (eligible t.tuple) g + (center t.tuple) L K (extra t.tuple) h t) x.2 (integerStepWord Q tuple w) := by + induction k generalizing x with + | zero => simp [shiftWordWeight, integerPathMask, integerStepWord, scalarWalkProduct] + | succ k ih => + rw [shiftWordWeight, retained_integerShiftWeight_eq_mask, ih] + simp only [integerPathMask, integerStepWord, List.ofFn_succ, List.map_cons, scalarWalkProduct] + dsimp only [integerShiftNext, Fin.tail_def] + ring + +theorem integerShiftWord_pair_product (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (center : ℕ → ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) + (h : ℕ) (gate : D → ℤ → ℤ → Prop) {k : ℕ} + (x : D × ℤ) (a b : Fin k → D × (Q × Bool)) + (hend : shiftWordEnd (integerShiftNext Q tuple h) x a = + shiftWordEnd (integerShiftNext Q tuple h) x b) : + shiftWordWeight embed (integerShiftNext Q tuple h) + (integerShiftWeight Q tuple u (fun d => eligible (tuple d)) g + (fun d => center (tuple d)) L K (fun d => extra (tuple d)) h gate) x a * + shiftWordWeight embed (integerShiftNext Q tuple h) + (integerShiftWeight Q tuple u (fun d => eligible (tuple d)) g + (fun d => center (tuple d)) L K (fun d => extra (tuple d)) h gate) x b = + (integerPathMask embed Q tuple h gate x a * integerPathMask embed Q tuple h gate x b) * + scalarWalkProduct h (fun t => signedIntegerWeight Q u (eligible t.tuple) g + (center t.tuple) L K (extra t.tuple) h t) x.2 + (integerStepWord Q tuple a ++ reverseWord (integerStepWord Q tuple b)) := by + have he := congrArg (fun y : D × ℤ => y.2) hend + rw [integerShiftEnd_site, integerShiftEnd_site] at he + have hd : wordDisplacement h (integerStepWord Q tuple a) = + wordDisplacement h (integerStepWord Q tuple b) := by omega + rw [integerShiftWord_eq_mask_product, integerShiftWord_eq_mask_product] + rw [← signedIntegerWeight_closed_pair Q u eligible g center L K extra h x.2 _ _ hd] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerShiftGeometry.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerShiftGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a702c6befb65173dfa1a71d918735edbff8c2a5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerShiftGeometry.lean @@ -0,0 +1,163 @@ +import OAI.NumberTheory.TwoPoint.Bounds.IntegerShiftWords +import OAI.NumberTheory.TwoPoint.Bounds.MatrixMomentNorm + +namespace OAI + +/-! Numerical words attached to the forced paths in the actual trace expansion. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +variable {D V : Type*} + +def integerStepWord (Q : Finset ℕ) (tuple : D → ℕ) {k : ℕ} + (w : Fin k → D × (Q × Bool)) : List SignedStep := + (List.ofFn w).map (fun e => ⟨e.2.2, tuple e.1, e.2.1⟩) + +lemma integerShiftEnd_site (Q : Finset ℕ) (tuple : D → ℕ) (h : ℕ) {k : ℕ} + (x : D × ℤ) (w : Fin k → D × (Q × Bool)) : + (shiftWordEnd (integerShiftNext Q tuple h) x w).2 = + x.2 + wordDisplacement h (integerStepWord Q tuple w) := by + induction k generalizing x with + | zero => simp [shiftWordEnd, integerStepWord] + | succ k ih => + rw [shiftWordEnd, ih] + simp only [integerStepWord, List.ofFn_succ, List.map_cons, wordDisplacement_cons, + integerShiftNext, Fin.tail_def] + ring + +lemma integer_closed_word_displacement (Q : Finset ℕ) (tuple : D → ℕ) (h : ℕ) {k : ℕ} + (x : D × ℤ) (u v : Fin k → D × (Q × Bool)) + (he : shiftWordEnd (integerShiftNext Q tuple h) x u = + shiftWordEnd (integerShiftNext Q tuple h) x v) : + wordDisplacement h (integerStepWord Q tuple u ++ reverseWord (integerStepWord Q tuple v)) = 0 := by + have hs := congrArg Prod.snd he + rw [integerShiftEnd_site, integerShiftEnd_site] at hs + rw [wordDisplacement_append, wordDisplacement_reverseWord] + omega + +lemma signedIntegerWeight_flip (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g center : ℤ → ℝ) (L K : ℝ) + (extra : ℤ → Prop) (h : ℕ) (a : SignedStep) (n : ℤ) : + signedIntegerWeight Q u eligible g center L K extra h a.flip (n + a.displacement h) = + signedIntegerWeight Q u eligible g center L K extra h a n := by + rcases a with ⟨b, d, q⟩ + cases b <;> simp [signedIntegerWeight, SignedStep.flip, SignedStep.displacement] + +/-- Periodicity permits using the departure center in both orientations. +All surviving cutoffs remain literal indicator conditions. -/ +lemma signedIntegerWeight_departure (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g center : ℤ → ℝ) (L K : ℝ) + (extra : ℤ → Prop) (h : ℕ) (a : SignedStep) (n : ℤ) + (hperiod : ∀ q ∈ Q, ∀ z, center (z + (h * q * a.tuple : ℕ)) = center z) : + signedIntegerWeight Q u eligible g center L K extra h a n = + if a.padding ∈ Q ∧ eligible a.padding ∧ (a.padding : ℤ) ∣ n ∧ + integerEdgeKeep Q u eligible g L K extra n ∧ + integerEdgeKeep Q u eligible g L K extra (n + a.displacement h) then + L * u a.padding * center n / (g n * g (n + a.displacement h)) else 0 := by + classical + rcases a with ⟨b, d, q⟩ + by_cases hq : q ∈ Q + · cases b + · have hd : (SignedStep.mk false d q).displacement h = -(h * q * d : ℕ) := by + simp [SignedStep.displacement, Nat.cast_mul] + have hn : n + -(h * q * d : ℕ) + (h * q * d : ℕ) = n := by ring + have hc : center (n + -(h * q * d : ℕ)) = center n := by + have hh := hperiod q hq (n + -(h * q * d : ℕ)) + rw [hn] at hh + exact hh.symm + have hqd : (q : ℤ) ∣ n + -(h * q * d : ℕ) ↔ (q : ℤ) ∣ n := by + apply dvd_add_left + apply dvd_neg.mpr + exact_mod_cast dvd_mul_of_dvd_left (dvd_mul_left q h) d + simp only [signedIntegerWeight, Bool.false_eq_true, ↓reduceIte, hd, directedIntegerEdge, + hq, hn, true_and, hqd, hc] + rw [mul_comm (g (n + -(h * q * d : ℕ))) (g n)] + congr 1 + apply propext + tauto + · have hd : (SignedStep.mk true d q).displacement h = (h * q * d : ℕ) := by + simp [SignedStep.displacement, Nat.cast_mul] + simp [signedIntegerWeight, directedIntegerEdge, hd] + · cases b <;> simp [signedIntegerWeight, directedIntegerEdge, hq] + +variable [DecidableEq D] + +lemma integerShiftWeight_nonzero (Q : Finset ℕ) (tuple : D → ℕ) + (u : ℕ → ℝ) (eligible : D → ℕ → Prop) (g : ℤ → ℝ) (center : D → ℤ → ℝ) + (L K : ℝ) (extra : D → ℤ → Prop) (h : ℕ) (gate : D → ℤ → ℤ → Prop) + (e : D × (Q × Bool)) (x : D × ℤ) + (he : integerShiftWeight Q tuple u eligible g center L K extra h gate e x ≠ 0) : + x.1 ≠ e.1 ∧ signedIntegerWeight Q u (eligible e.1) g (center e.1) L K (extra e.1) h + ⟨e.2.2, tuple e.1, e.2.1⟩ x.2 ≠ 0 := by + unfold integerShiftWeight at he + split_ifs at he with hc + · exact ⟨hc.1, he⟩ + · contradiction + +variable [Fintype V] + +/-- Every nonzero half of the trace is nonbacktracking in its tuple labels. +The two halves can be joined without imposing a new condition at the joins. -/ +theorem integerShiftWord_chain (embed : V → D × ℤ) (Q : Finset ℕ) (tuple : D → ℕ) + (u : ℕ → ℝ) (eligible : D → ℕ → Prop) (g : ℤ → ℝ) (center : D → ℤ → ℝ) + (L K : ℝ) (extra : D → ℤ → Prop) (h : ℕ) (gate : D → ℤ → ℤ → Prop) + {k : ℕ} (x : D × ℤ) (w : Fin k → D × (Q × Bool)) + (hw : shiftWordWeight embed (integerShiftNext Q tuple h) + (integerShiftWeight Q tuple u eligible g center L K extra h gate) x w ≠ 0) : + (x.1 :: (List.ofFn w).map Prod.fst).IsChain (fun a b => a ≠ b) := by + induction k generalizing x with + | zero => simp + | succ k ih => + have hp := mul_ne_zero_iff.mp hw + have he := (retainedShiftWeight_nonzero _ _ _ _ _ hp.1).2 + have hc := (integerShiftWeight_nonzero Q tuple u eligible g center L K extra h gate + (w 0) x he).1 + have ht := ih (integerShiftNext Q tuple h (w 0) x) (Fin.tail w) hp.2 + simp only [List.ofFn_succ, List.map_cons] + exact ht.cons_cons hc + +variable [Fintype D] [DecidableEq V] + +omit [DecidableEq D] [Fintype V] [Fintype D] [DecidableEq V] in +lemma integerStateEmbedding_injective (site : V → ℤ) (hinj : Function.Injective site) : + Function.Injective (fun x : D × V => (x.1, site x.2)) := by + intro x y he + exact Prod.ext (congrArg (fun z : D × ℤ => z.1) he) + (hinj (congrArg (fun z : D × ℤ => z.2) he)) + +/-- The concrete nonbacktracking integer matrix has the forced-word moment +formula, with exactly one freely chosen starting site. -/ +theorem integer_matrix_moment_forced_words + (site : V → ℤ) (hinj : Function.Injective site) (Q : Finset ℕ) (tuple : D → ℕ) + (u : ℕ → ℝ) (eligible : D → ℕ → Prop) (g : ℤ → ℝ) (center : D → ℤ → ℝ) + (L K : ℝ) (extra : D → ℤ → Prop) (h : ℕ) (gate : D → ℤ → ℤ → Prop) (k : ℕ) : + matrixFrobeniusSq (blockNonbacktrackingMatrix (fun d i j => + if gate d (site i) (site j) then + integerEdgeMatrix site Q u (eligible d) g (center d) L K (extra d) h (tuple d) i j + else 0) ^ k) = + ∑ x : D × V, ∑ a : Fin k → D × (Q × Bool), ∑ b : Fin k → D × (Q × Bool), + if shiftWordEnd (integerShiftNext Q tuple h) (x.1, site x.2) a = + shiftWordEnd (integerShiftNext Q tuple h) (x.1, site x.2) b then + shiftWordWeight (fun x : D × V => (x.1, site x.2)) (integerShiftNext Q tuple h) + (integerShiftWeight Q tuple u eligible g center L K extra h gate) (x.1, site x.2) a * + shiftWordWeight (fun x : D × V => (x.1, site x.2)) (integerShiftNext Q tuple h) + (integerShiftWeight Q tuple u eligible g center L K extra h gate) (x.1, site x.2) b + else 0 := by + classical + rw [block_integer_matrix_eq_shift] + refine (shiftMatrix_moment_forced_words (fun x : D × V => (x.1, site x.2)) + (integerStateEmbedding_injective (D := D) site hinj) (integerShiftNext Q tuple h) + (integerShiftWeight Q tuple u eligible g center L K extra h gate) k).trans ?_ + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + split_ifs <;> rfl + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerShiftWords.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerShiftWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c43723e53b82c7cd3245b922216ec4cebba64c4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerShiftWords.lean @@ -0,0 +1,183 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShiftMatrixWords +import OAI.NumberTheory.TwoPoint.Bounds.IntegerEdges +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedWords + +namespace OAI + +/-! The actual centered integer-edge matrix as a matrix of forced signed shifts. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def signedIntegerWeight (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g center : ℤ → ℝ) (L K : ℝ) + (extra : ℤ → Prop) (h : ℕ) (a : SignedStep) (n : ℤ) : ℝ := + if a.forward then + directedIntegerEdge Q u eligible g center L K extra h a.tuple a.padding n + (n + a.displacement h) + else + directedIntegerEdge Q u eligible g center L K extra h a.tuple a.padding + (n + a.displacement h) n + +lemma forward_edge_as_shift (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g center : ℤ → ℝ) (L K : ℝ) + (extra : ℤ → Prop) (h d q : ℕ) (n m : ℤ) : + directedIntegerEdge Q u eligible g center L K extra h d q n m = + if m = n + (SignedStep.mk true d q).displacement h then + signedIntegerWeight Q u eligible g center L K extra h ⟨true, d, q⟩ n else 0 := by + classical + have hd : (SignedStep.mk true d q).displacement h = (h * q * d : ℕ) := by + simp [SignedStep.displacement, Nat.cast_mul] + rw [hd] + by_cases he : m = n + (h * q * d : ℕ) + · subst m + simp only [signedIntegerWeight, ↓reduceIte, hd] + · have hf : ¬(q ∈ Q ∧ m = n + (h * q * d : ℕ) ∧ eligible q ∧ (q : ℤ) ∣ n ∧ + integerEdgeKeep Q u eligible g L K extra n ∧ + integerEdgeKeep Q u eligible g L K extra m) := fun hh => he hh.2.1 + rw [directedIntegerEdge, ite_eq_right hf, ite_eq_right he] + +lemma backward_edge_as_shift (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g center : ℤ → ℝ) (L K : ℝ) + (extra : ℤ → Prop) (h d q : ℕ) (n m : ℤ) : + directedIntegerEdge Q u eligible g center L K extra h d q m n = + if m = n + (SignedStep.mk false d q).displacement h then + signedIntegerWeight Q u eligible g center L K extra h ⟨false, d, q⟩ n else 0 := by + classical + have hd : (SignedStep.mk false d q).displacement h = -(h * q * d : ℕ) := by + simp [SignedStep.displacement, Nat.cast_mul] + rw [hd] + by_cases he : m = n + -(h * q * d : ℕ) + · subst m + simp only [signedIntegerWeight, Bool.false_eq_true, ↓reduceIte, hd] + · have hn : n ≠ m + (h * q * d : ℕ) := by omega + have hf : ¬(q ∈ Q ∧ n = m + (h * q * d : ℕ) ∧ eligible q ∧ (q : ℤ) ∣ m ∧ + integerEdgeKeep Q u eligible g L K extra m ∧ + integerEdgeKeep Q u eligible g L K extra n) := fun hh => hn hh.2.1 + rw [directedIntegerEdge, ite_eq_right hf, ite_eq_right he] + +lemma signedIntegerWeight_nonzero (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g center : ℤ → ℝ) (L K : ℝ) + (extra : ℤ → Prop) (h : ℕ) (a : SignedStep) (n : ℤ) + (ha : signedIntegerWeight Q u eligible g center L K extra h a n ≠ 0) : + a.padding ∈ Q ∧ eligible a.padding ∧ (a.padding : ℤ) ∣ n ∧ + integerEdgeKeep Q u eligible g L K extra n ∧ + integerEdgeKeep Q u eligible g L K extra (n + a.displacement h) := by + classical + rcases a with ⟨b, d, q⟩ + cases b + · simp only [signedIntegerWeight, Bool.false_eq_true, ↓reduceIte] at ha + unfold directedIntegerEdge at ha + split_ifs at ha with he + · refine ⟨he.1, he.2.2.1, ?_, he.2.2.2.2.2, he.2.2.2.2.1⟩ + exact (padding_dvd_along_edge h q d _ _ he.2.1).mpr he.2.2.2.1 + · contradiction + · simp only [signedIntegerWeight, ↓reduceIte] at ha + unfold directedIntegerEdge at ha + split_ifs at ha with he + · exact ⟨he.1, he.2.2.1, he.2.2.2.1, he.2.2.2.2.1, he.2.2.2.2.2⟩ + · contradiction + +lemma integerEdgeMatrix_signed_shifts {V : Type*} [Fintype V] + (site : V → ℤ) (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → Prop) (g center : ℤ → ℝ) (L K : ℝ) + (extra : ℤ → Prop) (h d : ℕ) (i j : V) : + integerEdgeMatrix site Q u eligible g center L K extra h d i j = + ∑ q : Q, ∑ b : Bool, + if site j = site i + (SignedStep.mk b d q).displacement h then + signedIntegerWeight Q u eligible g center L K extra h ⟨b, d, q⟩ (site i) + else 0 := by + classical + rw [integerEdgeMatrix, ← sum_coe_sort Q] + apply sum_congr rfl + intro q _ + rw [Fintype.sum_bool, forward_edge_as_shift, backward_edge_as_shift] + +variable {D V : Type*} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] + +def integerShiftNext (Q : Finset ℕ) (tuple : D → ℕ) (h : ℕ) + (e : D × (Q × Bool)) (x : D × ℤ) : D × ℤ := + (e.1, x.2 + (SignedStep.mk e.2.2 (tuple e.1) e.2.1).displacement h) + +noncomputable def integerShiftWeight (Q : Finset ℕ) (tuple : D → ℕ) + (u : ℕ → ℝ) (eligible : D → ℕ → Prop) (g : ℤ → ℝ) (center : D → ℤ → ℝ) + (L K : ℝ) (extra : D → ℤ → Prop) (h : ℕ) (gate : D → ℤ → ℤ → Prop) + (e : D × (Q × Bool)) (x : D × ℤ) : ℝ := by + classical + exact if x.1 ≠ e.1 ∧ gate e.1 x.2 (integerShiftNext Q tuple h e x).2 then + signedIntegerWeight Q u (eligible e.1) g (center e.1) L K (extra e.1) h + ⟨e.2.2, tuple e.1, e.2.1⟩ x.2 else 0 + +omit [DecidableEq V] in +/-- The step index is the actual tuple label, padding divisor and sign. +The finite state records the preceding tuple and the integer site. -/ +theorem block_integer_matrix_eq_shift + (site : V → ℤ) (Q : Finset ℕ) (tuple : D → ℕ) + (u : ℕ → ℝ) (eligible : D → ℕ → Prop) (g : ℤ → ℝ) (center : D → ℤ → ℝ) + (L K : ℝ) (extra : D → ℤ → Prop) (h : ℕ) (gate : D → ℤ → ℤ → Prop) : + blockNonbacktrackingMatrix (fun d i j => + if gate d (site i) (site j) then + integerEdgeMatrix site Q u (eligible d) g (center d) L K (extra d) h (tuple d) i j + else 0) = + shiftMatrix (fun x : D × V => (x.1, site x.2)) (integerShiftNext Q tuple h) + (integerShiftWeight Q tuple u eligible g center L K extra h gate) := by + classical + ext x y + change (if x.1 ≠ y.1 then + (if gate y.1 (site x.2) (site y.2) then + integerEdgeMatrix site Q u (eligible y.1) g (center y.1) L K (extra y.1) h + (tuple y.1) x.2 y.2 else 0) else 0) = + shiftMatrix (fun x : D × V => (x.1, site x.2)) (integerShiftNext Q tuple h) + (integerShiftWeight Q tuple u eligible g center L K extra h gate) x y + rw [shiftMatrix, Fintype.sum_prod_type] + rw [sum_eq_single y.1] + · rw [Fintype.sum_prod_type] + have ht (q : Q) (b : Bool) : + (if integerShiftNext Q tuple h (y.1, q, b) (x.1, site x.2) = (y.1, site y.2) + then integerShiftWeight Q tuple u eligible g center L K extra h gate + (y.1, q, b) (x.1, site x.2) else 0) = + if x.1 ≠ y.1 ∧ gate y.1 (site x.2) (site y.2) then + if site y.2 = site x.2 + (SignedStep.mk b (tuple y.1) q).displacement h then + signedIntegerWeight Q u (eligible y.1) g (center y.1) L K (extra y.1) h + ⟨b, tuple y.1, q⟩ (site x.2) else 0 + else 0 := by + by_cases he : site y.2 = site x.2 + (SignedStep.mk b (tuple y.1) q).displacement h + · simp only [integerShiftNext, ← he, ↓reduceIte] + simp [integerShiftWeight, integerShiftNext, ← he] + · simp [integerShiftNext, Ne.symm he, he] + trans ∑ q : Q, ∑ b : Bool, + if x.1 ≠ y.1 ∧ gate y.1 (site x.2) (site y.2) then + if site y.2 = site x.2 + (SignedStep.mk b (tuple y.1) q).displacement h then + signedIntegerWeight Q u (eligible y.1) g (center y.1) L K (extra y.1) h + ⟨b, tuple y.1, q⟩ (site x.2) else 0 + else 0 + · by_cases hc : x.1 ≠ y.1 ∧ gate y.1 (site x.2) (site y.2) + · rw [ite_eq_left hc.1, ite_eq_left hc.2] + simp only [ite_eq_left hc] + exact integerEdgeMatrix_signed_shifts site Q u (eligible y.1) g (center y.1) + L K (extra y.1) h (tuple y.1) x.2 y.2 + · simp only [hc, ↓reduceIte, sum_const_zero] + by_cases hd : x.1 ≠ y.1 + · have hg : ¬gate y.1 (site x.2) (site y.2) := fun hg => hc ⟨hd, hg⟩ + simp [hd, hg] + · simp [hd] + · apply sum_congr rfl + intro q _ + apply sum_congr rfl + intro b _ + convert (ht q b).symm using 1 + split_ifs <;> rfl + · intro d _ hd + apply sum_eq_zero + intro e _ + have hn : integerShiftNext Q tuple h (d, e) (x.1, site x.2) ≠ (y.1, site y.2) := by + intro he + exact hd (congrArg Prod.fst he) + simp only [hn, ↓reduceIte] + · simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerVertexMask.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerVertexMask.lean new file mode 100644 index 0000000000000000000000000000000000000000..cca52cf15401270f51afc520d7c62c72fcefed1e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/IntegerVertexMask.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.TwoPoint.Bounds.IntegerPathProduct +import OAI.NumberTheory.TwoPoint.Bounds.IntegerClosedCatalog + +namespace OAI + +/-! Separate literal vertex deletion from the numerical copy and block gates. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +variable {D V : Type*} + +def integerVertexGate (gate : D → ℤ → ℤ → Prop) (keep : ℤ → Prop) + (d : D) (n m : ℤ) : Prop := gate d n m ∧ keep n ∧ keep m + +noncomputable def vertexIndicator (keep : ℤ → Prop) (n : ℤ) : ℝ := + if keep n then 1 else 0 + +lemma integerStepMask_vertex (embed : V → D × ℤ) (Q : Finset ℕ) (tuple : D → ℕ) + (h : ℕ) (gate : D → ℤ → ℤ → Prop) (keep : ℤ → Prop) + (e : D × (Q × Bool)) (x : D × ℤ) : + integerStepMask embed Q tuple h (integerVertexGate gate keep) e x = + integerStepMask embed Q tuple h gate e x * + (vertexIndicator keep x.2 * vertexIndicator keep (integerShiftNext Q tuple h e x).2) := by + by_cases hc : x.1 ≠ e.1 ∧ gate e.1 x.2 (integerShiftNext Q tuple h e x).2 ∧ + integerShiftNext Q tuple h e x ∈ Set.range embed + · by_cases hx : keep x.2 <;> by_cases hy : keep (integerShiftNext Q tuple h e x).2 <;> + simp [integerStepMask, integerVertexGate, vertexIndicator, hc.1, hc.2.1, hc.2.2, hx, hy] + · have hbad : ¬(x.1 ≠ e.1 ∧ + integerVertexGate gate keep e.1 x.2 (integerShiftNext Q tuple h e x).2 ∧ + integerShiftNext Q tuple h e x ∈ Set.range embed) := by + rintro ⟨hcopy, hgate, hrange⟩ + exact hc ⟨hcopy, hgate.1, hrange⟩ + simp only [integerStepMask, ite_eq_right hc, ite_eq_right hbad, zero_mul] + +theorem integerPathMask_vertex (embed : V → D × ℤ) (Q : Finset ℕ) (tuple : D → ℕ) + (h : ℕ) (gate : D → ℤ → ℤ → Prop) (keep : ℤ → Prop) + {k : ℕ} (x : D × ℤ) (w : Fin k → D × (Q × Bool)) : + integerPathMask embed Q tuple h (integerVertexGate gate keep) x w = + integerPathMask embed Q tuple h gate x w * + scalarWalkProduct h (fun t n => vertexIndicator keep n * + vertexIndicator keep (n + t.displacement h)) x.2 (integerStepWord Q tuple w) := by + induction k generalizing x with + | zero => simp [integerPathMask, integerStepWord, scalarWalkProduct] + | succ k ih => + rw [integerPathMask, integerStepMask_vertex, ih] + simp only [integerPathMask, integerStepWord, List.ofFn_succ, List.map_cons, scalarWalkProduct] + dsimp only [integerShiftNext, Fin.tail_def] + ring + +lemma vertex_edge_flip (h : ℕ) (keep : ℤ → Prop) (t : SignedStep) (n : ℤ) : + (vertexIndicator keep (n + t.displacement h) * + vertexIndicator keep (n + t.displacement h + t.flip.displacement h)) = + vertexIndicator keep n * vertexIndicator keep (n + t.displacement h) := by + rw [SignedStep.displacement_flip] + have he : n + t.displacement h + -t.displacement h = n := by ring + rw [he, mul_comm] + +theorem integerPathMask_closed_vertex_pair (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (h : ℕ) (gate : D → ℤ → ℤ → Prop) (keep : ℤ → Prop) + {k : ℕ} (x : D × ℤ) (a b : Fin k → D × (Q × Bool)) + (hend : shiftWordEnd (integerShiftNext Q tuple h) x a = + shiftWordEnd (integerShiftNext Q tuple h) x b) : + integerPathMask embed Q tuple h (integerVertexGate gate keep) x a * + integerPathMask embed Q tuple h (integerVertexGate gate keep) x b = + (integerPathMask embed Q tuple h gate x a * integerPathMask embed Q tuple h gate x b) * + scalarWalkProduct h (fun t n => vertexIndicator keep n * + vertexIndicator keep (n + t.displacement h)) x.2 + (integerClosedWordCode Q tuple (a, b)) := by + have he := congrArg (fun y : D × ℤ => y.2) hend + rw [integerShiftEnd_site, integerShiftEnd_site] at he + have hd : wordDisplacement h (integerStepWord Q tuple a) = + wordDisplacement h (integerStepWord Q tuple b) := by omega + rw [integerPathMask_vertex, integerPathMask_vertex] + unfold integerClosedWordCode + rw [← scalarWalkProduct_closed_pair h _ (vertex_edge_flip h keep) x.2 _ _ hd] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/InternalRelationSelection.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/InternalRelationSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..14ee43752e51a5565607dd158794f4f277d48700 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/InternalRelationSelection.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.TwoPoint.Walks.WordRelations +import OAI.NumberTheory.TwoPoint.Bounds.OrderedElimination + +namespace OAI + +/-! Actual active witness intervals give a triangular system on the ambient labels. -/ + +namespace TwoPointCorrelations + +open Finset + +namespace LabeledPrimeWord + +variable {ι : Type*} [DecidableEq ι] + +/-- Record also an occurrence of the controlling prime. This proves that +later fresh labels cannot occur as an earlier controlling modulus. -/ +theorem active_relation_with_control (w : LabeledPrimeWord ι) (h : ℕ) (value : ι → ℕ) + (hinj : Function.Injective value) (hprime : ∀ j, (value j).Prime) + (hw : w.Realizes value) (y : ι) (hy : ActivePrime h w.word (value y)) : + ∃ c a b r, c ≠ y ∧ a ≤ b ∧ b ≤ w.word.length ∧ + TuplePrimeAt w.word (value c) r ∧ + primeRelationEvent (w.intervalRelation h a b) y c (fun j => (value j : ℤ)) := by + obtain ⟨p, a, b, hpy, hab, hb, ⟨r, hpr⟩, hdiv, hnonzero⟩ := hy.distinct_controller + obtain ⟨c, _, hc⟩ := w.occurrence_has_label value hprime hw p ⟨r, hpr.index_lt⟩ hpr + refine ⟨c, a, b, r, ?_, hab, hb, ?_, ?_, ?_⟩ + · intro heq + exact hpy (by simpa only [heq] using hc.symm) + · simpa only [hc] using hpr + · rw [w.intervalRelation_eval h a b value hw hb] + change (value c : ℤ) ∣ _ + simpa only [hc] using hdiv + · apply primeRelation_coefficient_nondegenerate + rw [w.intervalRelation_contribution h a b value hinj hprime hw hb y] + change ¬(value c : ℤ) ∣ _ + simpa only [hc] using hnonzero + +end LabeledPrimeWord + +/-- A family of active primes absent from all earlier witnesses gives +actual interval relations, ordered independently of the names of the +selected labels. The conclusion includes the controlling-prime exclusion. -/ +theorem select_internal_relations {κ ι : Type*} [Fintype κ] [LinearOrder κ] + [DecidableEq ι] (word : κ → LabeledPrimeWord ι) (h : ℕ) (value : ι → ℕ) + (hinj : Function.Injective value) (hprime : ∀ j, (value j).Prime) + (hw : ∀ i, (word i).Realizes value) + (hsq : ∀ i t, t ∈ (word i).word → Squarefree t.tuple) + (active : κ → ℕ) (hactive : ∀ i, ActivePrime h (word i).word (active i)) + (hfresh : ∀ i j, i < j → active j ∉ wordPrimeSupport (word i).word) : + ∃ selected control : κ → ι, ∃ left right : κ → ℕ, + Function.Injective selected ∧ + (∀ i, value (selected i) = active i) ∧ + (∀ i, control i ≠ selected i ∧ left i ≤ right i ∧ right i ≤ (word i).word.length ∧ + primeRelationEvent ((word i).intervalRelation h (left i) (right i)) + (selected i) (control i) (fun j => (value j : ℤ))) ∧ + ∀ i j, i < j → + selected j ∉ primeRelationSupport ((word i).intervalRelation h (left i) (right i)) ∧ + control i ≠ selected j := by + classical + have hsel (i : κ) : ∃ y : ι, value y = active i := by + have hm := (hactive i).mem_wordPrimeSupport (hsq i) + obtain ⟨r, hr⟩ := (mem_wordPrimeSupport_iff _ _ (hsq i)).mp hm + obtain ⟨y, _, hy⟩ := (word i).occurrence_has_label value hprime (hw i) (active i) + ⟨r, hr.index_lt⟩ hr + exact ⟨y, hy⟩ + choose selected hselected using hsel + have hrel (i : κ) := (word i).active_relation_with_control h value hinj hprime (hw i) + (selected i) (by simpa only [hselected i] using hactive i) + choose control left right occurrence hc hl hr hocc hevent using hrel + refine ⟨selected, control, left, right, ?_, hselected, + (fun i => ⟨hc i, hl i, hr i, hevent i⟩), ?_⟩ + · intro i j hij + by_contra hne + rcases lt_or_gt_of_ne hne with hij' | hji' + · apply hfresh i j hij' + rw [← hselected j, ← hij, hselected i] + exact (hactive i).mem_wordPrimeSupport (hsq i) + · apply hfresh j i hji' + rw [← hselected i, hij, hselected j] + exact (hactive j).mem_wordPrimeSupport (hsq j) + · intro i j hij + have hnot : ∀ r, ¬TuplePrimeAt (word i).word (value (selected j)) r := by + intro r hpr + apply hfresh i j hij + rw [← hselected j] + exact (mem_wordPrimeSupport_iff _ _ (hsq i)).mpr ⟨r, hpr⟩ + refine ⟨(word i).intervalRelation_not_mem h (left i) (right i) value hinj hprime + (hw i) (selected j) (fun r _ _ => hnot r), ?_⟩ + intro heq + exact hnot (occurrence i) (by simpa only [← heq] using hocc i) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LabeledForest.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LabeledForest.lean new file mode 100644 index 0000000000000000000000000000000000000000..d84509f7eccc7b499f888fafa479ef009a26dc87 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LabeledForest.lean @@ -0,0 +1,205 @@ +import Mathlib.Data.Tree.Basic +import Mathlib.Data.List.Nodup +import Mathlib.Tactic + +namespace OAI + +/-! +# Labeled ordered forests + +Binary trees use the first-child / next-sibling convention. The labels +are auxiliary: erasing them keeps the finite shape used by the code. +-/ + +namespace TwoPointCorrelations + +open BinaryTree + +variable {V : Type*} + +def forestNodes : BinaryTree V → List V + | .nil => [] + | .node v children siblings => v :: (forestNodes children ++ forestNodes siblings) + +def forestRoots : BinaryTree V → List V + | .nil => [] + | .node v _ siblings => v :: forestRoots siblings + +def forestAdjacent : BinaryTree V → V → V → Prop + | .nil, _, _ => False + | .node v children siblings, x, y => + (x = v ∧ y ∈ forestRoots children) ∨ (y = v ∧ x ∈ forestRoots children) ∨ + forestAdjacent children x y ∨ forestAdjacent siblings x y + +@[simp] lemma forestNodes_length (t : BinaryTree V) : (forestNodes t).length = t.numNodes := by + induction t with + | nil => rfl + | node v l r hl hr => simp [forestNodes, hl, hr] + +lemma forestRoots_subset (t : BinaryTree V) : forestRoots t ⊆ forestNodes t := by + induction t with + | nil => simp [forestRoots, forestNodes] + | node v l r hl hr => + intro x hx + simp only [forestRoots, List.mem_cons] at hx + rcases hx with rfl | hx + · simp [forestNodes] + · simp [forestNodes, hr hx] + +lemma forestAdjacent_symm (t : BinaryTree V) (x y : V) : + forestAdjacent t x y ↔ forestAdjacent t y x := by + induction t with + | nil => rfl + | node v l r hl hr => simp only [forestAdjacent, hl, hr]; tauto + +lemma forestAdjacent_mem (t : BinaryTree V) {x y : V} (h : forestAdjacent t x y) : + x ∈ forestNodes t ∧ y ∈ forestNodes t := by + induction t with + | nil => exact h.elim + | node v l r hl hr => + rcases h with ⟨rfl, hy⟩ | ⟨rfl, hx⟩ | h | h + · simp [forestNodes, forestRoots_subset l hy] + · simp [forestNodes, forestRoots_subset l hx] + · obtain ⟨hx, hy⟩ := hl h + simp [forestNodes, hx, hy] + · obtain ⟨hx, hy⟩ := hr h + simp [forestNodes, hx, hy] + +lemma forestAdjacent_irrefl (t : BinaryTree V) (ht : (forestNodes t).Nodup) (x : V) : + ¬forestAdjacent t x x := by + induction t with + | nil => exact id + | node v l r hl hr => + have hnodup := List.nodup_cons.mp ht + have hparts := List.nodup_append.mp hnodup.2 + intro h + rcases h with ⟨rfl, hx⟩ | ⟨rfl, hx⟩ | h | h + · exact hnodup.1 (List.mem_append_left _ (forestRoots_subset l hx)) + · exact hnodup.1 (List.mem_append_left _ (forestRoots_subset l hx)) + · exact hl hparts.1 h + · exact hr hparts.2.1 h + +/-- Add a fresh leaf as the first child of its unique parent. -/ +def attachForestLeaf [DecidableEq V] (parent leaf : V) : BinaryTree V → BinaryTree V + | .nil => .nil + | .node v children siblings => + if v = parent then .node v (.node leaf .nil children) siblings + else .node v (attachForestLeaf parent leaf children) (attachForestLeaf parent leaf siblings) + +lemma attachForestLeaf_of_not_mem [DecidableEq V] (parent leaf : V) (t : BinaryTree V) + (hp : parent ∉ forestNodes t) : attachForestLeaf parent leaf t = t := by + induction t with + | nil => rfl + | node v l r hl hr => + have hv : v ≠ parent := by intro h; subst v; exact hp (by simp [forestNodes]) + have hpl : parent ∉ forestNodes l := by intro h; exact hp (by simp [forestNodes, h]) + have hpr : parent ∉ forestNodes r := by intro h; exact hp (by simp [forestNodes, h]) + simp only [attachForestLeaf, ite_eq_right hv, hl hpl, hr hpr] + +@[simp] lemma attachForestLeaf_roots [DecidableEq V] (parent leaf : V) (t : BinaryTree V) : + forestRoots (attachForestLeaf parent leaf t) = forestRoots t := by + induction t with + | nil => rfl + | node v l r hl hr => + by_cases hv : v = parent <;> simp [attachForestLeaf, hv, forestRoots, hr] + +lemma attachForestLeaf_nodes_perm [DecidableEq V] (parent leaf : V) (t : BinaryTree V) + (ht : (forestNodes t).Nodup) (hp : parent ∈ forestNodes t) : + (forestNodes (attachForestLeaf parent leaf t)).Perm (leaf :: forestNodes t) := by + induction t with + | nil => simp [forestNodes] at hp + | node v l r hl hr => + have hnodup := List.nodup_cons.mp ht + have hparts := List.nodup_append.mp hnodup.2 + by_cases hv : v = parent + · simp only [attachForestLeaf, ite_eq_left hv, forestNodes, List.nil_append] + exact List.Perm.swap _ _ _ + · have hp' : parent ∈ forestNodes l ∨ parent ∈ forestNodes r := by + simpa only [forestNodes, List.mem_cons, List.mem_append, Ne.symm hv, false_or] using hp + rcases hp' with hp' | hp' + · have hpr : parent ∉ forestNodes r := by + intro hpr + exact hparts.2.2 parent hp' parent hpr rfl + rw [attachForestLeaf, ite_eq_right hv, attachForestLeaf_of_not_mem parent leaf r hpr] + simp only [forestNodes] + exact ((hl hparts.1 hp').append_right _).cons v |>.trans (List.Perm.swap _ _ _) + · have hpl : parent ∉ forestNodes l := by + intro hpl + exact hparts.2.2 parent hpl parent hp' rfl + rw [attachForestLeaf, ite_eq_right hv, attachForestLeaf_of_not_mem parent leaf l hpl] + simp only [forestNodes] + have hperm := ((hr hparts.2.1 hp').append_left (forestNodes l)).cons v + exact hperm.trans ((List.perm_middle.cons v).trans (List.Perm.swap _ _ _)) + + + +private lemma move_two_disjuncts (A B C D E F : Prop) : + (A ∨ B ∨ (C ∨ E ∨ F) ∨ D) ↔ (A ∨ B ∨ C ∨ D) ∨ E ∨ F := by + tauto + +lemma attachForestLeaf_adjacent [DecidableEq V] (parent leaf : V) (t : BinaryTree V) + (ht : (forestNodes t).Nodup) (hp : parent ∈ forestNodes t) (x y : V) : + forestAdjacent (attachForestLeaf parent leaf t) x y ↔ + forestAdjacent t x y ∨ (x = parent ∧ y = leaf) ∨ (y = parent ∧ x = leaf) := by + induction t with + | nil => simp [forestNodes] at hp + | node v l r hl hr => + have hnodup := List.nodup_cons.mp ht + have hparts := List.nodup_append.mp hnodup.2 + by_cases hv : v = parent + · subst v + rw [attachForestLeaf, ite_eq_left rfl] + simp only [forestAdjacent, forestRoots, List.mem_cons, + List.not_mem_nil, and_false, false_or, and_or_left] + constructor + · rintro ((h | h) | (h | h) | h | h) + · exact Or.inr (Or.inl h) + · exact Or.inl (Or.inl h) + · exact Or.inr (Or.inr h) + · exact Or.inl (Or.inr (Or.inl h)) + · exact Or.inl (Or.inr (Or.inr (Or.inl h))) + · exact Or.inl (Or.inr (Or.inr (Or.inr h))) + · rintro ((h | h | h | h) | h | h) + · exact Or.inl (Or.inr h) + · exact Or.inr (Or.inl (Or.inr h)) + · exact Or.inr (Or.inr (Or.inl h)) + · exact Or.inr (Or.inr (Or.inr h)) + · exact Or.inl (Or.inl h) + · exact Or.inr (Or.inl (Or.inl h)) + · have hp' : parent ∈ forestNodes l ∨ parent ∈ forestNodes r := by + simpa only [forestNodes, List.mem_cons, List.mem_append, Ne.symm hv, false_or] using hp + rcases hp' with hp' | hp' + · have hpr : parent ∉ forestNodes r := by + intro hpr + exact hparts.2.2 parent hp' parent hpr rfl + rw [attachForestLeaf, ite_eq_right hv, attachForestLeaf_of_not_mem parent leaf r hpr] + simp only [forestAdjacent, attachForestLeaf_roots, hl hparts.1 hp'] + exact move_two_disjuncts _ _ _ _ _ _ + · have hpl : parent ∉ forestNodes l := by + intro hpl + exact hparts.2.2 parent hpl parent hp' rfl + rw [attachForestLeaf, ite_eq_right hv, attachForestLeaf_of_not_mem parent leaf l hpl] + simp only [forestAdjacent, hr hparts.2.1 hp', or_assoc] + +lemma attachForestLeaf_nodup [DecidableEq V] (parent leaf : V) (t : BinaryTree V) + (ht : (forestNodes t).Nodup) (hp : parent ∈ forestNodes t) (hf : leaf ∉ forestNodes t) : + (forestNodes (attachForestLeaf parent leaf t)).Nodup := by + exact (attachForestLeaf_nodes_perm parent leaf t ht hp).nodup_iff.mpr + (List.nodup_cons.mpr ⟨hf, ht⟩) + +@[simp] lemma forestNodes_map {W : Type*} (f : V → W) (t : BinaryTree V) : + forestNodes (t.map f) = (forestNodes t).map f := by + induction t <;> simp [BinaryTree.map, forestNodes, *] + +@[simp] lemma forestRoots_map {W : Type*} (f : V → W) (t : BinaryTree V) : + forestRoots (t.map f) = (forestRoots t).map f := by + induction t <;> simp [BinaryTree.map, forestRoots, *] + +lemma forestAdjacent_map {W : Type*} (f : V → W) (hf : Function.Injective f) + (t : BinaryTree V) (x y : V) : + forestAdjacent (t.map f) (f x) (f y) ↔ forestAdjacent t x y := by + induction t <;> simp [BinaryTree.map, forestAdjacent, hf.eq_iff, *] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LabeledPrimeWords.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LabeledPrimeWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..92c9a2a7931802222b2759e95a9757914f1b0ad2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LabeledPrimeWords.lean @@ -0,0 +1,156 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ReciprocalSampling +import OAI.NumberTheory.TwoPoint.Walks.WitnessSelection +import Mathlib.Algebra.BigOperators.Associated + +namespace OAI + +/-! Identifying squarefree-label polynomials with numerical signed words. -/ + +namespace TwoPointCorrelations + +open Finset + +structure LabeledPrimeWord (ι : Type*) where + word : List SignedStep + labels : Fin word.length → Finset ι + +namespace LabeledPrimeWord + +variable {ι : Type*} [DecidableEq ι] + +def Realizes (w : LabeledPrimeWord ι) (value : ι → ℕ) : Prop := + ∀ i, ∏ j ∈ w.labels i, value j = (w.word[i.val]'i.isLt).tuple + +def monomial (w : LabeledPrimeWord ι) (h : ℕ) (i : Fin w.word.length) : PrimeMonomial ι where + coefficient := (if (w.word[i.val]'i.isLt).forward then 1 else -1) * (h : ℤ) * (w.word[i.val]'i.isLt).padding + labels := w.labels i + +omit [DecidableEq ι] in +lemma monomial_eval (w : LabeledPrimeWord ι) (h : ℕ) (value : ι → ℕ) + (hw : w.Realizes value) (i : Fin w.word.length) : + (w.monomial h i).eval (fun j => (value j : ℤ)) = wordStepDisplacement h w.word i := by + rw [wordStepDisplacement_getElem h w.word i i.isLt] + unfold monomial PrimeMonomial.eval SignedStep.displacement + rw [← Nat.cast_prod, hw i] + +omit [DecidableEq ι] in +lemma label_iff_occurrence (w : LabeledPrimeWord ι) (value : ι → ℕ) + (hinj : Function.Injective value) (hprime : ∀ j, (value j).Prime) + (hw : w.Realizes value) (y : ι) (i : Fin w.word.length) : + y ∈ w.labels i ↔ TuplePrimeAt w.word (value y) i := by + rw [tuplePrimeAt_iff_getElem w.word (value y) i i.isLt, ← hw i] + constructor + · intro hy + exact ⟨hprime y, Finset.dvd_prod_of_mem value hy⟩ + · rintro ⟨_, hy⟩ + obtain ⟨j, hj, hyj⟩ := ((hprime y).prime.dvd_finsetProd_iff value).mp hy + have heq := hinj ((Nat.prime_dvd_prime_iff_eq (hprime y) (hprime j)).mp hyj) + exact heq.symm ▸ hj + +/-- A genuine interval relation; omitted steps have empty supports as well +as zero coefficients. This matters for the later-variable exclusion. -/ +def intervalRelation (w : LabeledPrimeWord ι) (h a b : ℕ) (i : Fin w.word.length) : PrimeMonomial ι := + if a ≤ i.val ∧ i.val < b then w.monomial h i else ⟨0, ∅⟩ + +lemma intervalRelation_support (w : LabeledPrimeWord ι) (h a b : ℕ) (y : ι) : + y ∈ primeRelationSupport (w.intervalRelation h a b) ↔ + ∃ i : Fin w.word.length, a ≤ i.val ∧ i.val < b ∧ y ∈ w.labels i := by + simp only [primeRelationSupport, mem_biUnion, mem_univ, true_and] + constructor + · rintro ⟨i, hi⟩ + by_cases hab : a ≤ i.val ∧ i.val < b + · exact ⟨i, hab.1, hab.2, by simpa only [intervalRelation, ite_eq_left hab, monomial] using hi⟩ + · simp only [intervalRelation, ite_eq_right hab, notMem_empty] at hi + · rintro ⟨i, hai, hib, hi⟩ + exact ⟨i, by simpa only [intervalRelation, ite_eq_left (And.intro hai hib), monomial] using hi⟩ + +end LabeledPrimeWord + +lemma sum_fin_interval (n a b : ℕ) (D : ℕ → ℤ) (hb : b ≤ n) : + (∑ i : Fin n, if a ≤ i.val ∧ i.val < b then D i.val else 0) = ∑ i ∈ Ico a b, D i := by + rw [Fin.sum_univ_eq_sum_range (fun i : ℕ => if a ≤ i ∧ i < b then D i else 0) n] + rw [← sum_filter] + congr 1 + ext i + simp only [mem_filter, mem_range, mem_Ico] + omega + +namespace LabeledPrimeWord + +variable {ι : Type*} [DecidableEq ι] + +omit [DecidableEq ι] in +lemma intervalRelation_eval (w : LabeledPrimeWord ι) (h a b : ℕ) (value : ι → ℕ) + (hw : w.Realizes value) (hb : b ≤ w.word.length) : + primeRelationEval (w.intervalRelation h a b) (fun j => (value j : ℤ)) = + intervalDisplacement (wordStepDisplacement h w.word) a b := by + unfold primeRelationEval + have ht (i : Fin w.word.length) : + (w.intervalRelation h a b i).eval (fun j => (value j : ℤ)) = + if a ≤ i.val ∧ i.val < b then wordStepDisplacement h w.word i.val else 0 := by + by_cases hi : a ≤ i.val ∧ i.val < b + · simp only [intervalRelation, ite_eq_left hi] + exact w.monomial_eval h value hw i + · simp only [intervalRelation, ite_eq_right hi, PrimeMonomial.eval, zero_mul] + simp_rw [ht] + exact sum_fin_interval _ _ _ _ hb + +lemma intervalRelation_contribution (w : LabeledPrimeWord ι) (h a b : ℕ) + (value : ι → ℕ) (hinj : Function.Injective value) (hprime : ∀ j, (value j).Prime) + (hw : w.Realizes value) (hb : b ≤ w.word.length) (y : ι) : + primeRelationContribution (w.intervalRelation h a b) y (fun j => (value j : ℤ)) = + wordPrimeContribution h w.word (value y) a b := by + classical + unfold primeRelationContribution + have ht (i : Fin w.word.length) : + (if y ∈ (w.intervalRelation h a b i).labels + then (w.intervalRelation h a b i).eval (fun j => (value j : ℤ)) else 0) = + if a ≤ i.val ∧ i.val < b then + (if TuplePrimeAt w.word (value y) i.val then wordStepDisplacement h w.word i.val else 0) + else 0 := by + by_cases hi : a ≤ i.val ∧ i.val < b + · simp only [intervalRelation, ite_eq_left hi, monomial] + by_cases hy : y ∈ w.labels i + · have hp := (w.label_iff_occurrence value hinj hprime hw y i).mp hy + simp only [hy, hp, ite_true] + exact w.monomial_eval h value hw i + · have hp : ¬TuplePrimeAt w.word (value y) i.val := fun hp => + hy ((w.label_iff_occurrence value hinj hprime hw y i).mpr hp) + simp only [hy, hp, ite_false] + · simp only [intervalRelation, ite_eq_right hi, notMem_empty, ite_false] + simp_rw [ht] + unfold wordPrimeContribution + exact sum_fin_interval w.word.length a b + (fun i => if TuplePrimeAt w.word (value y) i then wordStepDisplacement h w.word i else 0) hb + +/-- A canonical finite label model, using the actual prime factors of each +whole tuple inside one finite prime pool. -/ +def fromPrimeSet (word : List SignedStep) (P : Finset ℕ) : LabeledPrimeWord P where + word := word + labels i := univ.filter (fun p : P => p.val ∈ word[i].tuple.primeFactors) + +lemma fromPrimeSet_realizes (word : List SignedStep) (P : Finset ℕ) + (hsq : ∀ t ∈ word, Squarefree t.tuple) + (hpool : ∀ t ∈ word, t.tuple.primeFactors ⊆ P) : + (fromPrimeSet word P).Realizes Subtype.val := by + intro i + have hiword : word[i] ∈ word := List.getElem_mem i.isLt + have himage : ((fromPrimeSet word P).labels i).image Subtype.val = word[i].tuple.primeFactors := by + ext p + constructor + · intro hp + obtain ⟨q, hq, rfl⟩ := mem_image.mp hp + exact (mem_filter.mp hq).2 + · intro hp + exact mem_image.mpr ⟨⟨p, hpool _ hiword hp⟩, mem_filter.mpr ⟨mem_univ _, hp⟩, rfl⟩ + calc + _ = ∏ p ∈ word[i].tuple.primeFactors, p := by + rw [← himage, prod_image] + exact fun a _ b _ hab => Subtype.ext hab + _ = _ := Nat.prod_primeFactors_of_squarefree (hsq _ hiword) + +end LabeledPrimeWord + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LabeledWordSegments.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LabeledWordSegments.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d24e3410ee3f0d2b456158b989955939f15cbc8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LabeledWordSegments.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TwoPoint.Walks.WordResampling + +namespace OAI + +/-! Splitting a coded word into the main path and its attached witness paths. -/ + +namespace TwoPointCorrelations +namespace LabeledPrimeWord + +variable {ι : Type*} [DecidableEq ι] + +/-- A segment inherits the original labels, including shared prime classes. -/ +def segment (w : LabeledPrimeWord ι) (a n : ℕ) : LabeledPrimeWord ι where + word := (w.word.drop a).take n + labels i := w.labels ⟨a + i.val, by + have hi : i.val < min n (w.word.length - a) := by + simpa only [List.length_take, List.length_drop] using i.isLt + have := (lt_min_iff.mp hi).2 + omega⟩ + +omit [DecidableEq ι] in +@[simp] lemma segment_length (w : LabeledPrimeWord ι) (a n : ℕ) : + (w.segment a n).word.length = min n (w.word.length - a) := by + simp only [segment, List.length_take, List.length_drop] + +omit [DecidableEq ι] in +lemma segment_resample_word (w : LabeledPrimeWord ι) (a n : ℕ) (value : ι → ℕ) : + ((w.segment a n).resample value).word = ((w.resample value).word.drop a).take n := by + apply List.ext_getElem + · simp only [resample_length, segment_length, List.length_take, List.length_drop] + · intro i hi hj + have hi' : i < ((w.word.drop a).take n).length := by + simpa only [resample_length, segment] using hi + have hj' : a + i < w.word.length := by + have ht : i < min n (w.word.length - a) := by + simpa only [List.length_take, List.length_drop] using hi' + have := (lt_min_iff.mp ht).2 + omega + rw [List.getElem_take, List.getElem_drop] + simp only [resample, List.getElem_ofFn] + change (⟨(((w.word.drop a).take n)[i]'hi').forward, + ∏ z ∈ w.labels ⟨a + i, hj'⟩, value z, + (((w.word.drop a).take n)[i]'hi').padding⟩ : SignedStep) = + ⟨(w.word[a + i]'hj').forward, ∏ z ∈ w.labels ⟨a + i, hj'⟩, value z, + (w.word[a + i]'hj').padding⟩ + simp only [List.getElem_take, List.getElem_drop] + +omit [DecidableEq ι] in +lemma segment_realizes (w : LabeledPrimeWord ι) (a n : ℕ) (value : ι → ℕ) + (hw : w.Realizes value) : (w.segment a n).Realizes value := by + intro i + simp only [segment, List.getElem_take, List.getElem_drop] + exact hw ⟨a + i.val, by + have hi : i.val < min n (w.word.length - a) := by + simpa only [segment_length] using i.isLt + have := (lt_min_iff.mp hi).2 + omega⟩ + +end LabeledPrimeWord +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LinearPivots.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LinearPivots.lean new file mode 100644 index 0000000000000000000000000000000000000000..c2419519c42d9d5b3acf9eff12475060f1671676 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LinearPivots.lean @@ -0,0 +1,66 @@ +import Mathlib.LinearAlgebra.Basis.VectorSpace +import Mathlib.LinearAlgebra.StdBasis +import Mathlib.LinearAlgebra.FiniteDimensional.Basic + +namespace OAI + +/-! +# Pivot coordinates over a field + +A surjective family of real linear equations has a set of pivot +coordinates of the same cardinality as the equations. Fixing all other +coordinates leaves at most one solution. This uses linear algebra over +the original field, without reducing a determinant modulo a prime. +-/ + +namespace TwoPointCorrelations + +open Finset Submodule + +theorem exists_pivot_coordinates {K ι κ : Type*} [Field K] + [Fintype ι] [DecidableEq ι] [Fintype κ] + (T : (ι → K) →ₗ[K] (κ → K)) (hT : Function.Surjective T) : + ∃ S : Finset ι, S.card = Fintype.card κ ∧ + ∀ x y : ι → K, (∀ i ∉ S, x i = y i) → T x = T y → x = y := by + classical + let v : ι → κ → K := fun i => T (Pi.basisFun K ι i) + have hv : span K (Set.range v) = ⊤ := by + change span K (Set.range (T ∘ Pi.basisFun K ι)) = ⊤ + rw [Set.range_comp, ← Submodule.map_span, (Pi.basisFun K ι).span_eq, + Submodule.map_top, LinearMap.range_eq_top.mpr hT] + obtain ⟨η, a, ha, hspan, hind⟩ := exists_linearIndependent' K v + let : Finite η := Finite.of_injective a ha + let : Fintype η := Fintype.ofFinite η + let b : Module.Basis η K (κ → K) := Module.Basis.mk hind (by rw [hspan, hv]) + let S : Finset ι := univ.image a + have hcard : S.card = Fintype.card κ := by + rw [show S.card = Fintype.card η by simp [S, card_image_of_injective _ ha]] + exact (Module.finrank_eq_card_basis b).symm.trans (Module.finrank_pi _) + refine ⟨S, hcard, ?_⟩ + have hreconstruct (z : ι → K) (hz : ∀ i ∉ S, z i = 0) : + ∑ j, z (a j) • Pi.basisFun K ι (a j) = z := by + ext i + by_cases hi : i ∈ S + · obtain ⟨j, _, rfl⟩ := mem_image.mp hi + simp [Pi.basisFun_apply, Pi.single_apply, ha.eq_iff] + · have hne (j : η) : a j ≠ i := by + intro heq + exact hi (mem_image.mpr ⟨j, mem_univ _, heq⟩) + simp [Pi.basisFun_apply, hne, hz i hi] + intro x y hxy hTx + let z := x - y + have hz (i : ι) (hi : i ∉ S) : z i = 0 := sub_eq_zero.mpr (hxy i hi) + have hTz : T z = 0 := by simp [z, hTx] + have hsum : ∑ j, z (a j) • (v ∘ a) j = 0 := by + rw [show (∑ j, z (a j) • (v ∘ a) j) = T (∑ j, z (a j) • Pi.basisFun K ι (a j)) by + simp only [map_sum, map_smul, Function.comp_apply, v]] + rw [hreconstruct z hz, hTz] + have hc := Fintype.linearIndependent_iff.mp hind (fun j => z (a j)) hsum + have hz0 : z = 0 := by + rw [← hreconstruct z hz] + simp [hc] + exact sub_eq_zero.mp hz0 + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LiouvilleDivisorExtraction.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LiouvilleDivisorExtraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5548399817849d37a5247d3ed8ca223f8c949b5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LiouvilleDivisorExtraction.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QuantitativeDivisorBins +import OAI.NumberTheory.TwoPoint.Bounds.DivisibilityPrefix + +namespace OAI + +/-! The exact partial-centering substitution n=u*v. Only u must be a +unit modulo l; the progression class and the removed product may be nonunits. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma unit_progression_cancel (l : ℕ) (b : ZMod l) (u z v : ℕ) + (hu : IsUnit (u : ZMod l)) : + ((u * v : ℕ) : ZMod l) = b * ((u * z : ℕ) : ZMod l) ↔ + (v : ZMod l) = b * (z : ZMod l) := by + simp only [Nat.cast_mul] + rw [show b * ((u : ZMod l) * z) = (u : ZMod l) * (b * z) by ring, + hu.mul_right_inj] + +lemma liouville_pair_dilate (u v z h : ℕ) (hu : 0 < u) : + liouville (u * v) * liouville (u * v + h * (u * z)) = + liouville v * liouville (v + h * z) := by + rw [show u * v + h * (u * z) = u * (v + h * z) by ring] + simp only [liouville_mul] + calc + _ = liouville u ^ 2 * (liouville v * liouville (v + h * z)) := by ring + _ = _ := by rw [liouville_sq hu.ne', one_mul] + +lemma liouville_progression_dilate (l : ℕ) [NeZero l] (b : ZMod l) + (u v z h : ℕ) (hu : 0 < u) (hunit : IsUnit (u : ZMod l)) : + progressionSequence liouville l (b * ((u * z : ℕ) : ZMod l)) (u * v) * + liouville (u * v + h * (u * z)) = + progressionSequence liouville l (b * (z : ZMod l)) v * liouville (v + h * z) := by + simp only [progressionSequence, unit_progression_cancel l b u z v hunit] + split_ifs + · exact liouville_pair_dilate u v z h hu + · simp only [zero_mul] + +noncomputable def partialLiouvilleProfile (l : ℕ) [NeZero l] (b : ZMod l) + (u : ℕ) (Z : Finset ℕ) (h n : ℕ) : ℂ := + natDivisibilityIndicator u n * ∑ z ∈ Z, (z : ℂ)⁻¹ * + (progressionSequence liouville l (b * ((u * z : ℕ) : ZMod l)) n * + liouville (n + h * (u * z))) + +lemma partialLiouvilleProfile_prefix (l : ℕ) [NeZero l] (b : ZMod l) + (u : ℕ) (Z : Finset ℕ) (h X : ℕ) (hu : 0 < u) + (hunit : IsUnit (u : ZMod l)) : + positivePrefix (partialLiouvilleProfile l b u Z h) X = + positivePrefix (residueScaledRoughProfile l b Z h) (X / u) := by + unfold partialLiouvilleProfile + rw [divisibility_positivePrefix _ u X hu] + congr 1 + funext v + apply sum_congr rfl + intro z _ + rw [liouville_progression_dilate l b u v z h hu hunit] + +lemma natDivisibilityIndicator_mul (a b n : ℕ) (hab : a.Coprime b) : + natDivisibilityIndicator a n * natDivisibilityIndicator b n = + natDivisibilityIndicator (a * b) n := by + have he : a * b ∣ n ↔ a ∣ n ∧ b ∣ n := + ⟨fun h => ⟨(dvd_mul_right a b).trans h, (dvd_mul_left b a).trans h⟩, + fun h => hab.mul_dvd_of_dvd_of_dvd h.1 h.2⟩ + simp only [natDivisibilityIndicator, he] + split_ifs <;> simp_all + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LiouvilleQuadraticIdentity.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LiouvilleQuadraticIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..126311a79ac9dd80d5f5ad39ca085df64b38e425 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LiouvilleQuadraticIdentity.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SymmetricEdgeTesting +import OAI.NumberTheory.TwoPoint.Walks.BlockEndpointSum + +namespace OAI + +/-! Testing the actual weighted matrix leaves twice L times the ambient +retained directed-edge correlation. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem maskedLiouville_quadratic {V : Type*} [Fintype V] [DecidableEq V] + (site : V → ℤ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → Prop) + (g center : ℤ → ℝ) (L K : ℝ) (extra keep : ℤ → Prop) (h d : ℕ) + (gate : V → V → Prop) (hgate : ∀ i j, gate i j ↔ gate j i) + (hg : ∀ z, g z ≠ 0) : + let v := WithLp.toLp 2 (fun i => retainedLiouvilleScalar g keep (site i)) + inner ℂ v (matrixOperator + (maskedIntegerEdgeMatrix site Q u eligible g center L K extra h d gate) v) = + (2 * (L : ℂ)) * ∑ i, ∑ j, if gate i j then + ∑ q ∈ Q, retainedLiouvilleEdge Q u eligible g center L K extra keep h d q (site i) (site j) + else 0 := by + dsimp only + let v : EuclideanSpace ℂ V := WithLp.toLp 2 (fun i => retainedLiouvilleScalar g keep (site i)) + have hv (i : V) : star (v i) = v i := retainedLiouvilleScalar_star g keep (site i) + have hterm (i j : V) : + ((if gate i j then ∑ q ∈ Q, + directedIntegerEdge Q u eligible g center L K extra h d q (site i) (site j) + else 0) : ℝ) * v i * v j = + (L : ℂ) * (if gate i j then ∑ q ∈ Q, + retainedLiouvilleEdge Q u eligible g center L K extra keep h d q (site i) (site j) + else 0) := by + by_cases hij : gate i j + · simp only [ite_eq_left hij, Complex.ofReal_sum, sum_mul, mul_sum] + apply sum_congr rfl + intro q _ + have ht := retainedLiouvilleEdge_test Q u eligible g center L K extra keep h d q + (site i) (site j) hg + rw [retainedLiouvilleScalar_star] at ht + calc + _ = retainedLiouvilleScalar g keep (site i) * + (directedIntegerEdge Q u eligible g center L K extra h d q (site i) (site j) : ℂ) * + retainedLiouvilleScalar g keep (site j) := by dsimp [v]; ring + _ = _ := ht + · simp [hij] + rw [maskedIntegerEdgeMatrix_quadratic site Q u eligible g center L K extra h d gate hgate v hv] + simp_rw [hterm] + simp only [← mul_sum, mul_assoc] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LitBlockGeometry.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LitBlockGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..81f158627b1e8af62d0f557b0c34e1fb038b4549 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LitBlockGeometry.lean @@ -0,0 +1,142 @@ +import OAI.NumberTheory.TwoPoint.Walks.ColumnWordSlices +import OAI.NumberTheory.TwoPoint.Bounds.LowRankColumnEncoding + +namespace OAI + +/-! Perfect blocks use only the lit divisibilities at their actual positions. -/ + +namespace TwoPointCorrelations + +open Finset + +theorem positiveWord_iff_departures (h : ℕ) (x : ℤ) (w : List SignedStep) : + PositiveWord h x w ↔ ∀ i : Fin w.length, + (w.get i).divisor ∣ x + wordDisplacement h (w.take i.val) := by + induction w generalizing x with + | nil => simp + | cons a w ih => + rw [positiveWord_cons, ih] + constructor + · rintro ⟨ha, hw⟩ i + rcases i with ⟨i, hi⟩ + cases i with + | zero => simpa using ha + | succ i => + simpa only [List.get_eq_getElem, List.getElem_cons_succ, List.take_succ_cons, + wordDisplacement_cons, add_assoc] using hw ⟨i, by simpa using hi⟩ + · intro hw + refine ⟨?_, ?_⟩ + · simpa using hw ⟨0, by simp⟩ + · intro i + simpa only [List.get_eq_getElem, List.getElem_cons_succ, List.take_succ_cons, + wordDisplacement_cons, add_assoc] using hw ⟨i.val + 1, by simp⟩ + +theorem positiveWord_slice_of_lit {h : ℕ} {x : ℤ} {w : List SignedStep} + (start len : ℕ) (hend : start + len ≤ w.length) + (hlit : ∀ i : Fin w.length, start ≤ i.val → i.val < start + len → + (w.get i).divisor ∣ x + wordDisplacement h (w.take i.val)) : + PositiveWord h (x + wordDisplacement h (w.take start)) (wordSlice w start (start + len)) := by + rw [positiveWord_iff_departures] + intro i + have hi : i.val < len := by + have hl : (wordSlice w start (start + len)).length = len := by + rw [wordSlice_length w (a := start) (b := start + len) (by omega) hend, Nat.add_sub_cancel_left] + exact i.isLt.trans_eq hl + have hp := hlit ⟨start + i.val, by omega⟩ + (show start ≤ start + i.val by omega) (show start + i.val < start + len by omega) + have htake : (wordSlice w start (start + len)).take i.val = wordSlice w start (start + i.val) := by + simp only [wordSlice, List.take_take, Nat.add_sub_cancel_left, Nat.min_eq_left hi.le] + have he := congrArg (wordDisplacement h) (wordSlice_split w (show start ≤ start + i.val by omega)) + rw [wordDisplacement_append] at he + change ((wordSlice w start (start + len))[i.val]).divisor ∣ _ + rw [htake] + simpa only [List.get_eq_getElem, wordSlice, List.getElem_take, List.getElem_drop, + ← he, add_assoc] using hp + +theorem wordVertex_slice {h : ℕ} {x y : ℤ} {w : List SignedStep} + (start len : ℕ) + (hy : WordVertex h (x + wordDisplacement h (w.take start)) + (wordSlice w start (start + len)) y) : WordVertex h x w y := by + obtain ⟨a, b, hab, hy⟩ := hy + refine ⟨w.take start ++ a, b ++ w.drop (start + len), ?_, ?_⟩ + · calc + w = w.take (start + len) ++ w.drop (start + len) := (List.take_append_drop _ _).symm + _ = (w.take start ++ wordSlice w start (start + len)) ++ w.drop (start + len) := by + rw [wordSlice_split w (by omega)] + _ = (w.take start ++ a) ++ (b ++ w.drop (start + len)) := by + rw [hab] + simp only [List.append_assoc] + · rw [wordDisplacement_append] + simpa only [add_assoc] using hy + +namespace ColumnWordPattern + +variable {α : Type*} [Fintype α] [DecidableEq α] + +omit [Fintype α] [DecidableEq α] in +/-- Every numerical perfect block has the geometric properties used by +the universal code. Positivity is assumed only at the perfect positions; +unlit positions elsewhere in the trace impose no condition here. -/ +theorem short_geometry_of_lit (w : ColumnWordPattern α) (hn : 0 < w.length) + (value : α → ℕ) (hvalue : Function.Injective value) (hprime : ∀ z, (value z).Prime) + (hother : ∀ z t, t < w.length → ¬value z ∣ w.otherColumns t) + {h s J : ℕ} {supply : ℕ → ℕ → Prop} {x : ℤ} (hh : 0 < h) + (perfect : Finset (Fin w.length)) + (hlit : ∀ i ∈ perfect, (w.step value i.val).divisor ∣ + x + wordDisplacement h ((w.word value).take i.val)) + (heligible : ∀ a ∈ w.word value, supply a.tuple a.padding) + (hq : ∀ a ∈ w.word value, 0 < a.padding) + (hsq : ∀ a ∈ w.word value, Squarefree a.tuple) + (hcard : ∀ a ∈ w.word value, a.tuple.primeFactors.card = J) + (hchain : ∀ start len, start + len ≤ w.length → len ≤ s → + (∀ t ∈ intervalPositions (start, len), columnNatPerfect perfect t = true) → + (wordSlice (w.word value) start (start + len)).IsChain (fun a b => a.tuple ≠ b.tuple)) + (hsupport : ∀ p j, TuplePrimeAt (w.word value) p j → + ¬p ∣ h ∧ ∀ a ∈ w.word value, ¬p ∣ a.padding) + (hsurvive : ∀ y, WordVertex h x (w.word value) y → ¬ProhibitedSite h s supply y) : + ShortColumnGeometry (fun i : Fin w.length => w.label i.val) hn + (fun t => (w.coefficient h t : ℝ)) perfect s := by + intro start len hend hlen hperfect + have hlabel (t : ℕ) (ht : t < w.length) : + columnNatLabel (fun i : Fin w.length => w.label i.val) hn t = w.label t := by + simp only [columnNatLabel, dite_eq_left ht] + have hpositive := positiveWord_slice_of_lit (h := h) (x := x) (w := w.word value) + start len (by simpa using hend) (by + intro i hlo hhi + have hit : i.val < w.length := by simpa only [word_length] using i.isLt + have hp := hperfect i.val (by + simp only [intervalPositions, List.mem_map, List.mem_range] + exact ⟨i.val - start, by omega, by omega⟩) + have him : (⟨i.val, hit⟩ : Fin w.length) ∈ perfect := by + simpa only [columnNatPerfect, dite_eq_left hit, decide_eq_true_eq] using hp + change ((w.word value)[i.val]).divisor ∣ _ + simpa only [word, List.getElem_ofFn] using hlit ⟨i.val, hit⟩ him) + have hg := w.block_geometry_of_slice value hvalue hprime hother start len hend hlen + hpositive hh heligible hq hsq hcard (hchain start len hend hlen hperfect) hsupport + (fun y hy => hsurvive y (wordVertex_slice start len hy)) + constructor + · intro i j k hij hjk he + have hi : i.val < len := by simpa only [blockLabelList, List.length_map, List.length_range] using i.isLt + have hj : j.val < len := by simpa only [blockLabelList, List.length_map, List.length_range] using j.isLt + have hk : k.val < len := by simpa only [blockLabelList, List.length_map, List.length_range] using k.isLt + have hget (q : Fin (blockLabelList (columnNatLabel (fun i : Fin w.length => w.label i.val) hn) start len).length) + (hq : q.val < len) : + (blockLabelList (columnNatLabel (fun i : Fin w.length => w.label i.val) hn) start len).get q = + w.label (start + q.val) := by + change (blockLabelList (columnNatLabel (fun i : Fin w.length => w.label i.val) hn) start len)[q.val] = _ + simp only [blockLabelList, List.getElem_map, List.getElem_range] + exact hlabel _ (by omega) + rw [hget i hi, hget k hk] at he + rw [hget j hj, hget i hi] + exact hg.1 ⟨i, hi⟩ ⟨j, hj⟩ ⟨k, hk⟩ hij hjk he + · intro a b z ha hab hb hc + apply hg.2 a b z ha hab hb + intro t ht + rw [← hlabel t (by have := (mem_Ico.mp ht).2; omega)] + exact hc t ht + +end ColumnWordPattern + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LitCommonOrigin.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LitCommonOrigin.lean new file mode 100644 index 0000000000000000000000000000000000000000..6dd3ac89cafff68fdc64cde67e22e2ed7a7811f8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LitCommonOrigin.lean @@ -0,0 +1,35 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResidueCentering + +namespace OAI + +/-! Consistent lit residues admit one integer origin for every selected departure. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem lit_consistency_common_origin {ι τ : Type*} [Fintype ι] [DecidableEq ι] + (B : ℕ) (p : ι → ℕ) (hprime : ∀ i, (p i).Prime) (hinj : Function.Injective p) + (hpB : ∀ i, p i ≤ B) (L : Finset τ) (label : τ → ι) (offset : τ → ℤ) + (base : ι → Fin B) + (hL : LitConsistent L label + (fun t => forcedResidue B (p (label t)) (hprime _).pos (hpB _) (offset t))) : + ∃ n : ℤ, ∀ t ∈ L, (p (label t) : ℤ) ∣ n + offset t := by + let (i : ι) : NeZero (p i) := ⟨(hprime i).ne_zero⟩ + have hcop : Pairwise (fun i j => (p i).Coprime (p j)) := by + intro i j hij + exact (Nat.coprime_primes (hprime i) (hprime j)).mpr (fun he => hij (hinj he)) + let target (t : τ) := forcedResidue B (p (label t)) (hprime _).pos (hpB _) (offset t) + let r (i : ι) : ZMod (p i) := ((litForcedTarget L label target base i).val : ZMod (p i)) + obtain ⟨n, hn⟩ := exists_common_integer_residue p hcop r + refine ⟨n, ?_⟩ + intro t ht + apply (residue_offset_divisibility (r (label t)) n (offset t) (hn _)).mpr + change ((litForcedTarget L label target base (label t)).val : ZMod (p (label t))) = _ + rw [litForcedTarget_at L label target base hL t ht] + exact ZMod.natCast_zmod_val _ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LitConsistency.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LitConsistency.lean new file mode 100644 index 0000000000000000000000000000000000000000..320ea21c42ee37ad72a183bfce88babe4f157edf --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LitConsistency.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PartialCentering +import OAI.NumberTheory.TwoPoint.Bounds.OccurrenceCounts + +namespace OAI + +/-! Compress all lit tests for one prime into one forced residue, or zero. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι τ A : Type*} [DecidableEq ι] [DecidableEq A] + +def LitConsistent (L : Finset τ) (label : τ → ι) (target : τ → A) : Prop := + ∀ t ∈ L, ∀ u ∈ L, label t = label u → target t = target u + +noncomputable def litForcedTarget (L : Finset τ) (label : τ → ι) (target : τ → A) + (base : ι → A) (i : ι) : A := by + classical + exact if hi : ∃ t ∈ L, label t = i then target (Classical.choose hi) else base i + +omit [DecidableEq A] in +lemma litForcedTarget_at (L : Finset τ) (label : τ → ι) (target : τ → A) + (base : ι → A) (hL : LitConsistent L label target) (t : τ) (ht : t ∈ L) : + litForcedTarget L label target base (label t) = target t := by + classical + have hex : ∃ u ∈ L, label u = label t := ⟨t, ht, rfl⟩ + simp only [litForcedTarget, dite_eq_left hex] + exact hL _ (Classical.choose_spec hex).1 t ht (Classical.choose_spec hex).2 + +/-- Repetitions of the same lit residue test contribute just one indicator. -/ +lemma lit_indicator_product (L : Finset τ) (label : τ → ι) (target : τ → A) + (base : ι → A) (hL : LitConsistent L label target) (x : ι → A) : + (∏ t ∈ L, if x (label t) = target t then (1 : ℝ) else 0) = + ∏ i ∈ L.image label, if x i = litForcedTarget L label target base i then (1 : ℝ) else 0 := by + classical + have hall : (∀ t ∈ L, x (label t) = target t) ↔ + ∀ i ∈ L.image label, x i = litForcedTarget L label target base i := by + constructor + · intro hx i hi + obtain ⟨t, ht, rfl⟩ := mem_image.mp hi + rw [litForcedTarget_at L label target base hL t ht] + exact hx t ht + · intro hx t ht + have hi := hx (label t) (mem_image.mpr ⟨t, ht, rfl⟩) + rwa [litForcedTarget_at L label target base hL t ht] at hi + simp only [Finset.prod_boole, hall] + +omit [DecidableEq ι] in +/-- Incompatible lit offsets give exactly zero before any estimate. -/ +lemma lit_indicator_product_eq_zero (L : Finset τ) (label : τ → ι) (target : τ → A) + (hL : ¬LitConsistent L label target) (x : ι → A) : + (∏ t ∈ L, if x (label t) = target t then (1 : ℝ) else 0) = 0 := by + classical + have hno : ¬∀ t ∈ L, x (label t) = target t := by + intro hx + apply hL + intro t ht u hu htu + exact (hx t ht).symm.trans (htu ▸ hx u hu) + rw [Finset.prod_boole, ite_eq_right hno] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LitOccurrenceWeights.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LitOccurrenceWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..051a0fdb05f686f2ee11beccdcb1804e81701237 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LitOccurrenceWeights.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CrudeTraceWeights + +namespace OAI + +/-! The exact reciprocal exponent of each nonsingleton lit designation. -/ + +namespace TwoPointCorrelations + +open Finset + +def litReciprocalExponent (lit unlit : ℕ) : ℕ := + unlit + if lit = 0 then 0 else 1 + +def extraReciprocalExponent (lit unlit : ℕ) : ℕ := + litReciprocalExponent lit unlit - 1 + +lemma litReciprocalExponent_pos (lit unlit : ℕ) (hm : 2 ≤ lit + unlit) : + 1 ≤ litReciprocalExponent lit unlit := by + unfold litReciprocalExponent + split_ifs <;> omega + +/-- An entirely unlit nonsingleton uses at most half its exponent for the +baseline reciprocal. Each unlit occurrence of a lit label is wholly extra. -/ +lemma unlit_le_twice_extra (lit unlit : ℕ) (hm : 2 ≤ lit + unlit) : + unlit ≤ 2 * extraReciprocalExponent lit unlit := by + unfold extraReciprocalExponent litReciprocalExponent + split_ifs <;> omega + +lemma total_unlit_le_twice_extra {ι : Type*} [Fintype ι] + (lit unlit : ι → ℕ) (hm : ∀ i, 2 ≤ lit i + unlit i) : + ∑ i, unlit i ≤ 2 * ∑ i, extraReciprocalExponent (lit i) (unlit i) := by + rw [mul_sum] + exact sum_le_sum (fun i _ => unlit_le_twice_extra _ _ (hm i)) + +/-- Factor off exactly one baseline reciprocal per nonsingleton label. -/ +lemma lit_reciprocal_product_factor {ι : Type*} [Fintype ι] + (lit unlit : ι → ℕ) (p : ι → ℝ) (hm : ∀ i, 2 ≤ lit i + unlit i) : + (∏ i, (p i)⁻¹ ^ litReciprocalExponent (lit i) (unlit i)) = + (∏ i, (p i)⁻¹) * ∏ i, (p i)⁻¹ ^ extraReciprocalExponent (lit i) (unlit i) := by + rw [← prod_mul_distrib] + apply prod_congr rfl + intro i _ + have he : litReciprocalExponent (lit i) (unlit i) = + extraReciprocalExponent (lit i) (unlit i) + 1 := by + have hp := litReciprocalExponent_pos _ _ (hm i) + unfold extraReciprocalExponent + omega + rw [he, pow_succ, mul_comm] + +/-- Retain the baseline reciprocal weight and bound every extra power by +`H⁻¹`; no nondivisibility condition is imposed on an unlit occurrence. -/ +theorem lit_reciprocal_product_bound {ι : Type*} [Fintype ι] + (lit unlit : ι → ℕ) (p : ι → ℝ) (H : ℝ) + (hm : ∀ i, 2 ≤ lit i + unlit i) (hH : 0 < H) (hp : ∀ i, H ≤ p i) : + (∏ i, (p i)⁻¹ ^ litReciprocalExponent (lit i) (unlit i)) ≤ + (∏ i, (p i)⁻¹) * H⁻¹ ^ (∑ i, extraReciprocalExponent (lit i) (unlit i)) := by + rw [lit_reciprocal_product_factor lit unlit p hm, ← prod_pow_eq_pow_sum] + apply mul_le_mul_of_nonneg_left + · apply prod_le_prod₀ + · intro i _ + exact pow_nonneg (inv_nonneg.mpr ((hH.trans_le (hp i)).le)) _ + · intro i _ + exact pow_le_pow_left₀ (inv_nonneg.mpr ((hH.trans_le (hp i)).le)) + (inv_anti₀ hH (hp i)) _ + · exact prod_nonneg (fun i _ => inv_nonneg.mpr ((hH.trans_le (hp i)).le)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LocalExpansion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LocalExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3f46fc498670797646970917720bea43fcd3444 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LocalExpansion.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.TwoPoint.Bounds.LocalFactors +import OAI.NumberTheory.TwoPoint.PretentiousDistance +import Mathlib.Algebra.BigOperators.Ring.Finset + +namespace OAI + +/-! +# Finite local expansions + +The local sequences in manuscript Lemma `lem:affine-dilation` have value zero +at exponent zero. A difference of two normalized local sequences represents +such a sequence. Expansion over subsets then produces ordinary multiplicative +components that retain the original prime values outside the fixed finite set. +-/ + +open scoped BigOperators + +namespace TwoPointCorrelations + +/-- A normalized multiplicative component with one of two local choices at each +prime in `P`. -/ +noncomputable def localComponent (f : ℕ → ℂ) (B C : ℕ → ℕ → ℂ) + (P E : Finset ℕ) : ℕ → ℂ := + fromPrimePowers (fun p k => if p ∈ P then if p ∈ E then C p k else B p k else f (p ^ k)) + +theorem localComponent_multiplicative (f : ℕ → ℂ) (B C : ℕ → ℕ → ℂ) + (P E : Finset ℕ) : Multiplicative (localComponent f B C P E) := + fromPrimePowers_multiplicative _ + +theorem localComponent_oneBounded (f : ℕ → ℂ) (B C : ℕ → ℕ → ℂ) + (P E : Finset ℕ) (hf : OneBounded f) + (hB : ∀ p k, p ∈ P → 0 < k → ‖B p k‖ ≤ 1) + (hC : ∀ p k, p ∈ P → 0 < k → ‖C p k‖ ≤ 1) : + OneBounded (localComponent f B C P E) := by + apply fromPrimePowers_oneBounded + intro p k hp hk + split_ifs with hpP hpE + · exact hC p k hpP hk + · exact hB p k hpP hk + · exact hf _ (pow_pos hp.pos _) + +theorem localComponent_prime (f : ℕ → ℂ) (B C : ℕ → ℕ → ℂ) + (P E : Finset ℕ) {p : ℕ} (hp : p.Prime) (hpP : p ∉ P) : + localComponent f B C P E p = f p := by + simp [localComponent, fromPrimePowers_prime _ hp, hpP] + +/-- Expanding the support of a prime-power product is valid when the additional +local factors have value one at exponent zero. -/ +theorem fromPrimePowers_split (F : ℕ → ℕ → ℂ) (P : Finset ℕ) + (hF : ∀ p, F p 0 = 1) (n : ℕ) : + fromPrimePowers F n = + (∏ p ∈ P, F p (n.factorization p)) * + ∏ p ∈ n.primeFactors \ P, F p (n.factorization p) := by + unfold fromPrimePowers + rw [Finsupp.prod_of_support_subset _ (s := P ∪ n.primeFactors) + (by simp) F (fun p _ => hF p)] + rw [← Finset.union_sdiff_self_eq_union (s := P) (t := n.primeFactors), + Finset.prod_union disjoint_sdiff_self_left.symm] + +theorem localComponent_split (f : ℕ → ℂ) (B C : ℕ → ℕ → ℂ) + (P E : Finset ℕ) (hE : E ⊆ P) (hf : f 1 = 1) + (hB : ∀ p, B p 0 = 1) (hC : ∀ p, C p 0 = 1) (n : ℕ) : + localComponent f B C P E n = + ((∏ p ∈ P \ E, B p (n.factorization p)) * ∏ p ∈ E, C p (n.factorization p)) * + ∏ p ∈ n.primeFactors \ P, f (p ^ n.factorization p) := by + unfold localComponent + rw [fromPrimePowers_split _ P (by intro p; simp [hB, hC, hf])] + congr 1 + · rw [← Finset.sdiff_union_of_subset hE, Finset.prod_union Finset.sdiff_disjoint] + congr 1 + · simp only [Finset.union_sdiff_cancel_right (Finset.sdiff_disjoint)] + apply Finset.prod_congr rfl + intro p hp + have hpP : p ∈ P := (Finset.mem_sdiff.mp hp).1 + have hpE : p ∉ E := (Finset.mem_sdiff.mp hp).2 + simp [hpP, hpE] + · apply Finset.prod_congr rfl + intro p hp + simp [hp, hE hp] + · apply Finset.prod_congr rfl + intro p hp + simp [(Finset.mem_sdiff.mp hp).2] + +/-- Exact finite expansion with one normalized multiplicative component for +each subset of the exceptional primes. -/ +theorem local_difference_expansion (f : ℕ → ℂ) (B C : ℕ → ℕ → ℂ) + (P : Finset ℕ) (hf : f 1 = 1) + (hB : ∀ p, B p 0 = 1) (hC : ∀ p, C p 0 = 1) (n : ℕ) : + (∏ p ∈ P, (B p (n.factorization p) - C p (n.factorization p))) * + (∏ p ∈ n.primeFactors \ P, f (p ^ n.factorization p)) = + ∑ E ∈ P.powerset, (-1 : ℂ) ^ E.card * localComponent f B C P E n := by + rw [Finset.prod_sub, Finset.sum_mul] + apply Finset.sum_congr rfl + intro E hE + rw [localComponent_split f B C P E (Finset.mem_powerset.mp hE) hf hB hC n] + ring + +/-- Every bounded component inherits nonpretentiousness from the original +factor. This uses only changes at the fixed finite prime set. -/ +theorem localComponent_nonpretentious (f : ℕ → ℂ) (B C : ℕ → ℕ → ℂ) + (P E : Finset ℕ) (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (hB : ∀ p k, p ∈ P → 0 < k → ‖B p k‖ ≤ 1) + (hC : ∀ p k, p ∈ P → 0 < k → ‖C p k‖ ≤ 1) : + UniformlyNonpretentious (localComponent f B C P E) := by + apply hfnp.finite_prime_change P hf (localComponent_oneBounded f B C P E hf hB hC) + intro p hp hpP + exact localComponent_prime f B C P E hp hpP + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LocalFactors.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LocalFactors.lean new file mode 100644 index 0000000000000000000000000000000000000000..c65a59058eb096d956a5a4754803e54ac51b5116 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LocalFactors.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.TwoPoint.Basic +import Mathlib.Data.Nat.Factorization.Induction +import Mathlib.Algebra.BigOperators.Finsupp.Basic +import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset + +namespace OAI + +/-! +# Multiplicative functions from local prime-power factors + +The finite local expansions in Part III of the manuscript replace values at +primes dividing a fixed dilation. The resulting functions are ordinary +multiplicative functions; complete multiplicativity is not required. +-/ + +namespace TwoPointCorrelations + +/-- Multiply local factors over the positive exponents in the prime factorization. -/ +noncomputable def fromPrimePowers (F : ℕ → ℕ → ℂ) (n : ℕ) : ℂ := + n.factorization.prod F + +@[simp] theorem fromPrimePowers_one (F : ℕ → ℕ → ℂ) : fromPrimePowers F 1 = 1 := by + simp [fromPrimePowers] + +/-- Coprime arguments have disjoint prime support, so arbitrary prime-power +values give an ordinary multiplicative function. -/ +theorem fromPrimePowers_multiplicative (F : ℕ → ℕ → ℂ) : + Multiplicative (fromPrimePowers F) := by + intro m n hm hn hcop + unfold fromPrimePowers + rw [Nat.factorization_mul hm.ne' hn.ne'] + apply Finsupp.prod_add_index_of_disjoint + simpa only [Nat.support_factorization] using hcop.disjoint_primeFactors + +theorem fromPrimePowers_oneBounded (F : ℕ → ℕ → ℂ) + (hF : ∀ p k, Nat.Prime p → 0 < k → ‖F p k‖ ≤ 1) : + OneBounded (fromPrimePowers F) := by + intro n hn + unfold fromPrimePowers Finsupp.prod + rw [norm_prod] + apply Finset.prod_le_one₀ + · intro p hp + exact norm_nonneg _ + · intro p hp + have hprime : p.Prime := Nat.prime_of_mem_primeFactors (by simpa using hp) + have hk : 0 < n.factorization p := Nat.pos_of_ne_zero (Finsupp.mem_support_iff.mp hp) + exact hF p _ hprime hk + +@[simp] theorem fromPrimePowers_prime (F : ℕ → ℕ → ℂ) {p : ℕ} (hp : Nat.Prime p) : + fromPrimePowers F p = F p 1 := by + simp [fromPrimePowers, hp.factorization, Finsupp.prod] + +/-- A change at finitely many prime-power sequences changes only those prime values. -/ +theorem fromPrimePowers_eq_at_prime (F G : ℕ → ℕ → ℂ) (P : Finset ℕ) + (hFG : ∀ p, p ∉ P → F p 1 = G p 1) {p : ℕ} (hp : Nat.Prime p) (hpP : p ∉ P) : + fromPrimePowers F p = fromPrimePowers G p := by + simp only [fromPrimePowers_prime F hp, fromPrimePowers_prime G hp] + exact hFG p hpP + +/-- The local construction recovers a normalized multiplicative function on +positive integers, without replacing its prime-power values by powers. -/ +theorem fromPrimePowers_reconstruct (f : ℕ → ℂ) (hf : Multiplicative f) + (h1 : f 1 = 1) {n : ℕ} (hn : 0 < n) : + fromPrimePowers (fun p k => f (p ^ k)) n = f n := by + symm + apply Nat.multiplicative_factorization f _ h1 hn.ne' + intro a b hab + by_cases ha : a = 0 + · subst a + have hb : b = 1 := by simpa using hab + subst b + simp [h1] + by_cases hb : b = 0 + · subst b + have ha : a = 1 := by simpa using hab + subst a + simp [h1] + exact hf a b (Nat.pos_of_ne_zero ha) (Nat.pos_of_ne_zero hb) hab + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LogSavingScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LogSavingScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..106a8b480ba94458dc07253a71cb6e42d87343cc --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LogSavingScale.lean @@ -0,0 +1,31 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QuantitativeParameterChoice + +namespace OAI + +/-! Convert the fixed prime-count saving into the final logarithmic +power, retaining a single exponent for all affine coefficients. -/ + +namespace TwoPointCorrelations + +lemma primeSupplyCount_log_saving (X W : ℝ) (A : ℕ) (hX : Real.exp 1 ≤ X) + (hW : 0 < W) (hA : 0 < A) : + Real.exp (-(primeSupplyCount W ((Real.log X) ^ (1 / (A : ℝ))) : ℝ)) ≤ + Real.exp 1 / (Real.log X) ^ (1 / (1200 * W * A) : ℝ) := by + have hlog : 1 ≤ Real.log X := by + simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos _) hX + have hlogp : 0 < Real.log X := by linarith + have hL : 1 ≤ (Real.log X) ^ (1 / (A : ℝ)) := + Real.one_le_rpow hlog (by positivity) + have hp := primeSupplyCount_saving ((Real.log X) ^ (1 / (A : ℝ))) W hL hW + apply hp.trans_eq + rw [← Real.rpow_mul hlogp.le] + have he : (1 / (A : ℝ)) * (-(1 / (1200 * W))) = -(1 / (1200 * W * A)) := by ring + rw [he, Real.rpow_neg hlogp.le] + rfl + +lemma log_saving_exponent_pos (W : ℝ) (A : ℕ) (hW : 0 < W) (hA : 0 < A) : + 0 < (1 / (1200 * W * A) : ℝ) := by positivity + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LowRankColumnCover.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LowRankColumnCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..b606a3f735ed86d3e90004941eb1ac70b43d9fbd --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LowRankColumnCover.lean @@ -0,0 +1,55 @@ +import OAI.NumberTheory.TwoPoint.Bounds.LowRankColumnEncoding +import OAI.NumberTheory.TwoPoint.Walks.ColumnCodeUniverse + +namespace OAI + +/-! Actual low-rank columns lie in one coefficient-independent finite universe. -/ + +namespace TwoPointCorrelations + +open Finset Filter + +theorem low_rank_column_in_budget_universe {α : Type*} [Fintype α] [DecidableEq α] + {n : ℕ} (label : Fin n → α) (hn : 0 < n) + (coefficient : ℕ → ℝ) (perfect : Finset (Fin n)) (s r : ℕ) (hs : 0 < s) + (L : ℝ) (hL : 1 ≤ L) (hnL : (n : ℝ) ≤ 2 * L) + (hsL : L ^ (1 / 10 : ℝ) / 2 ≤ (s : ℝ)) + (hrL : (r : ℝ) ≤ L ^ (1 / 50 : ℝ)) + (hI : (imperfectColumnCount perfect : ℝ) ≤ 2 * L ^ (1 / 4 : ℝ)) + (hno : ∀ S : Finset (EqualLabelPairs (fun i : perfect => label i.val)), S.card = r → + ¬LinearIndependent ℝ (pairFamily (labelPairVectors (fun i : perfect => label i.val) + (fun i => formalDeparture (columnNatLabel label hn) coefficient i.val.val)) S)) + (hgeometry : ShortColumnGeometry label hn coefficient perfect s) : + ∃ code : BudgetColumnCode (2 * n) L, + decodeBudgetColumnPattern (show n ≤ 2 * n by omega) code = + fun i j => decide (label i = label j) := by + obtain ⟨O, B, S, R, hO, hB, hS, hR, hSn, hRn, code, hcode⟩ := + low_rank_short_column_code label hn coefficient perfect s r hs hno hgeometry + have hO' : (O : ℝ) ≤ 2 * L ^ (1 / 50 : ℝ) := by + have : (O : ℝ) < 2 * r := by exact_mod_cast hO + linarith + have hbudget := column_budget_bound L hL n s (imperfectColumnCount perfect) O B S R + hnL hsL hI hO' (by omega) hS hR + obtain ⟨full, hfull⟩ := budget_column_code_of_counts (by omega : n ≤ 2 * n) + (by omega : S ≤ 2 * n) (by omega : R ≤ 2 * n) + ((imperfectColumnCount_le perfect).trans (by omega)) hbudget code + exact ⟨full, hfull.trans hcode⟩ + +/-- This universe covers all low-rank admissible columns at the given +scale, while its size has an absolute exponential bound. -/ +theorem eventually_low_rank_column_universe : + ∀ᶠ L : ℝ in atTop, ∀ k : ℕ, + L / 2 ≤ (k : ℝ) → (k : ℝ) ≤ L → 0 < k → + (Nat.card (Set.range (@decodeBudgetColumnPattern (2 * k) (4 * k) L + (show 2 * k ≤ 4 * k by omega))) : ℝ) ≤ Real.exp (64 * k) := by + filter_upwards [eventually_budget_column_code_card] with L h + intro k hklo hkhi hk + have hc := h k (4 * k) hklo hkhi (by omega) le_rfl + have hr := card_budget_column_patterns (L := L) (show 2 * k ≤ 4 * k by omega) + exact (show (Nat.card (Set.range (@decodeBudgetColumnPattern (2 * k) (4 * k) L + (show 2 * k ≤ 4 * k by omega))) : ℝ) ≤ Fintype.card (BudgetColumnCode (4 * k) L) + by exact_mod_cast hr).trans hc + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/LowRankColumnEncoding.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/LowRankColumnEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d8d3fd16b838673bf97705140c4a8000f35037c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/LowRankColumnEncoding.lean @@ -0,0 +1,121 @@ +import OAI.NumberTheory.TwoPoint.Walks.ColumnGeometryEncoding +import OAI.NumberTheory.TwoPoint.Bounds.ShortColumnBlocks +import OAI.NumberTheory.TwoPoint.Bounds.RegularLineAnchors +import OAI.NumberTheory.TwoPoint.Walks.ColumnBudget + +namespace OAI + +/-! Low-rank lit departures give a full code for the actual short-block column. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {α : Type*} [Fintype α] [DecidableEq α] {n : ℕ} + +def imperfectColumnCount (perfect : Finset (Fin n)) : ℕ := + ((columnPositionEntries perfect).filter (fun p => !p.2)).length + +theorem imperfectColumnCount_le (perfect : Finset (Fin n)) : + imperfectColumnCount perfect ≤ n := by + exact (List.length_filter_le _ _).trans (by simp [columnPositionEntries]) + +/-- The geometric conclusions required on every actual short perfect block. -/ +def ShortColumnGeometry (label : Fin n → α) (hn : 0 < n) + (coefficient : ℕ → ℝ) (perfect : Finset (Fin n)) (s : ℕ) : Prop := + ∀ start len, start + len ≤ n → len ≤ s → + (∀ t ∈ intervalPositions (start, len), columnNatPerfect perfect t = true) → + (∀ i j k : Fin (blockLabelList (columnNatLabel label hn) start len).length, + i ≤ j → j ≤ k → + (blockLabelList (columnNatLabel label hn) start len).get i = + (blockLabelList (columnNatLabel label hn) start len).get k → + (blockLabelList (columnNatLabel label hn) start len).get j = + (blockLabelList (columnNatLabel label hn) start len).get i) ∧ + (∀ a b z, start ≤ a → a < b → b ≤ start + len → + (∀ t ∈ Ico a b, columnNatLabel label hn t = z) → + (∑ t ∈ Ico a b, coefficient t) ≠ 0) + +/-- Only actual lit departures enter the low-rank premise. The short +blocks and their complete decoder are constructed, not supplied as data. -/ +theorem low_rank_short_column_code (label : Fin n → α) (hn : 0 < n) + (coefficient : ℕ → ℝ) (perfect : Finset (Fin n)) (s r : ℕ) (hs : 0 < s) + (hno : ∀ S : Finset (EqualLabelPairs (fun i : perfect => label i.val)), S.card = r → + ¬LinearIndependent ℝ (pairFamily (labelPairVectors (fun i : perfect => label i.val) + (fun i => formalDeparture (columnNatLabel label hn) coefficient i.val.val)) S)) + (hgeometry : ShortColumnGeometry label hn coefficient perfect s) : + ∃ omittedLabels blocks segments omittedRuns : ℕ, + omittedLabels < 2 * r ∧ + blocks ≤ n / s + imperfectColumnCount perfect + 1 ∧ + segments ≤ (omittedLabels + 1) * blocks ∧ + omittedRuns ≤ omittedLabels * blocks ∧ + segments ≤ n ∧ omittedRuns ≤ n ∧ + ∃ code : ColumnDecoderCode (2 * n) segments omittedRuns (imperfectColumnCount perfect), + decodeColumnPrefixPattern (show n ≤ 2 * n by omega) code = + fun i j => decide (label i = label j) := by + classical + let labelNat := columnNatLabel label hn + let chunks := shortColumnChunks label hn perfect s + obtain ⟨blocks, hblocks, hsum, hcount, hvalid⟩ := shortColumnChunks_blocks label hn perfect s hs + obtain ⟨D, regular, anchor, hsmall, hind, hline⟩ := + exists_regular_line_anchors (fun i : perfect => label i.val) + (fun i => formalDeparture labelNat coefficient i.val.val) r hno + have hl : ∀ b ∈ blocks, ∀ t ∈ Ico b.1 (b.1 + b.2), ∀ ht : labelNat t ∈ regular, + ∃ c : ℝ, D.mkQ (formalDeparture labelNat coefficient t) = + anchor ⟨labelNat t, ht⟩ + c • D.mkQ (Pi.basisFun ℝ α (labelNat t)) := by + intro b hb t ht hr + obtain ⟨htlo, hthi⟩ := mem_Ico.mp ht + have htn : t < n := (mem_Ico.mp ht).2.trans_le (hvalid b hb).1 + have htp : columnNatPerfect perfect t = true := (hvalid b hb).2.2 t (by + simp only [intervalPositions, List.mem_map, List.mem_range] + exact ⟨t - b.1, by omega, by omega⟩) + have hip : (⟨t, htn⟩ : Fin n) ∈ perfect := by + simpa only [columnNatPerfect, dite_eq_left htn, decide_eq_true_eq] using htp + exact hline ⟨labelNat t, hr⟩ ⟨⟨t, htn⟩, hip⟩ (by + change label ⟨t, htn⟩ = columnNatLabel label hn t + simp only [columnNatLabel, dite_eq_left htn]) + have hg (b) (hb : b ∈ blocks) := hgeometry b.1 b.2 + (hvalid b hb).1 (hvalid b hb).2.1 (hvalid b hb).2.2 + have hi : ∀ l, Sum.inl l ∈ chunks → ∀ i j k : Fin l.length, + i ≤ j → j ≤ k → l.get i = l.get k → l.get j = l.get i := by + intro l hl + have hm : l ∈ chunks.filterMap (Sum.elim some (fun _ => none)) := + List.mem_filterMap.mpr ⟨.inl l, hl, rfl⟩ + rw [hblocks] at hm + obtain ⟨b, hb, rfl⟩ := List.mem_map.mp hm + exact (hg b hb).1 + have ho := columnChunk_piece_budgets chunks regularᶜ hi + let pieces := columnChunkPieces (fun z => decide (z ∉ regular)) chunks + let S := (indexedRegularSegments labelNat (fun z => decide (z ∉ regular)) blocks).length + let O := omittedPieceCount pieces + have hp : (indexedRegularSegments labelNat (fun z => decide (z ∉ regular)) blocks).map + (List.map Prod.snd) = pieces.filterMap (Sum.elim some (fun _ => none)) := + indexedRegularSegments_eq_regular_pieces labelNat _ chunks blocks hblocks + have hS : S = regularPieceCount pieces := by + have he := congrArg List.length hp + simpa only [List.length_map, regularPieceCount] using he + have hB : perfectChunkCount chunks = blocks.length := by + change (chunks.filterMap (Sum.elim some (fun _ => none))).length = blocks.length + change (shortColumnChunks label hn perfect s |>.filterMap (Sum.elim some (fun _ => none))).length = _ + rw [hblocks, List.length_map] + have hO : O ≤ regularᶜ.card * blocks.length := by + simpa only [pieces, mem_compl, hB] using ho.1 + have hSbound : S ≤ (regularᶜ.card + 1) * blocks.length := by + rw [hS] + simpa only [pieces, mem_compl, hB] using ho.2 + have hentries := shortColumnChunks_entries label hn perfect s + have hpieces : pieces.length ≤ n := (columnChunkPieces_length_le _ chunks).trans (by + rw [hentries] + simp only [List.length_map, columnPositionEntries, List.length_ofFn] + exact le_rfl) + have hSn : S ≤ n := by + rw [hS] + exact (List.length_filterMap_le _ _).trans hpieces + have hOn : O ≤ n := (List.length_filterMap_le _ _).trans hpieces + obtain ⟨code, hcode⟩ := column_code_from_quotient_geometry (by omega : 0 < 2 * n) + (by omega : n ≤ 2 * n) label perfect regular labelNat coefficient chunks blocks hentries hblocks + D anchor hind hl (fun b hb => (hg b hb).2) (Nat.mul_le_mul_left 2 hsum) le_rfl le_rfl + exact ⟨regularᶜ.card, blocks.length, S, O, hsmall, hcount, hSbound, hO, hSn, hOn, code, hcode⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MainPaddingTests.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MainPaddingTests.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8a75b203aa680103677e413b8149ea1ef9f26f4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MainPaddingTests.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingWitnessProbability + +namespace OAI + +/-! The actual main-word padding tests imply all tests retained after tuple centering. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def MainPaddingTests {ι : Type*} (p : ι → ℕ) (h B : ℕ) + (main : List SignedStep) (x : ι → Fin B) : Prop := + ∀ (k : Fin main.length) (i : ι), p i ∈ (main.get k).padding.primeFactors → + ((x i).val : ZMod (p i)) = -((wordDisplacement h (main.take k.val) : ℤ) : ZMod (p i)) + +theorem mainPaddingTests_retained {ι : Type*} [DecidableEq ι] + (p : ι → ℕ) (S : Finset ι) (h B : ℕ) (main : List SignedStep) (x : ι → Fin B) + (hpad : ∀ t ∈ main, t.padding ≠ 0) (htuple : ∀ t ∈ main, t.tuple ≠ 0) + (hcover : ∀ (k : Fin main.length) i, p i ∈ (main.get k).tuple.primeFactors → i ∈ S) + (hx : MainPaddingTests p h B main x) : RetainedMainTests p S h B main x := by + intro i hi k hk + rw [Nat.primeFactors_mul (hpad _ (List.get_mem main k)) + (htuple _ (List.get_mem main k)), mem_union] at hk + rcases hk with hk | hk + · exact hx k i hk + · exact (hi (hcover k i hk)).elim + +theorem mainPaddingTests_congr {ι : Type*} [DecidableEq ι] + (p : ι → ℕ) (S : Finset ι) (h B : ℕ) (main : List SignedStep) + (hsep : ∀ (k : Fin main.length) i, p i ∈ (main.get k).padding.primeFactors → i ∉ S) + (x y : ι → Fin B) (hxy : ∀ i, i ∉ S → x i = y i) : + MainPaddingTests p h B main x ↔ MainPaddingTests p h B main y := by + constructor + · intro hx k i hi + rw [← hxy i (hsep k i hi)] + exact hx k i hi + · intro hy k i hi + rw [hxy i (hsep k i hi)] + exact hy k i hi + +noncomputable def paddingWeightedFunction {ι : Type*} (p : ι → ℕ) + (h B : ℕ) (main : List SignedStep) (R : (ι → Fin B) → ℝ) (x : ι → Fin B) : ℝ := + if MainPaddingTests p h B main x then R x else 0 + +lemma paddingWeightedFunction_nonneg {ι : Type*} (p : ι → ℕ) + (h B : ℕ) (main : List SignedStep) (R : (ι → Fin B) → ℝ) + (hR : ∀ x, 0 ≤ R x) (x : ι → Fin B) : + 0 ≤ paddingWeightedFunction p h B main R x := by + unfold paddingWeightedFunction + split_ifs + · exact hR x + · exact le_rfl + +lemma paddingWeightedFunction_le {ι : Type*} (p : ι → ℕ) + (h B : ℕ) (main : List SignedStep) (R : (ι → Fin B) → ℝ) (C : ℝ) + (hC : 0 ≤ C) (hR : ∀ x, R x ≤ C) (x : ι → Fin B) : + paddingWeightedFunction p h B main R x ≤ C := by + unfold paddingWeightedFunction + split_ifs + · exact hR x + · exact hC + +theorem paddingWeightedFunction_retained {ι : Type*} [DecidableEq ι] + (p : ι → ℕ) (S : Finset ι) (h B : ℕ) (main : List SignedStep) + (R : (ι → Fin B) → ℝ) (x : ι → Fin B) + (hpad : ∀ t ∈ main, t.padding ≠ 0) (htuple : ∀ t ∈ main, t.tuple ≠ 0) + (hcover : ∀ (k : Fin main.length) i, p i ∈ (main.get k).tuple.primeFactors → i ∈ S) + (hx : paddingWeightedFunction p h B main R x ≠ 0) : + RetainedMainTests p S h B main x := by + apply mainPaddingTests_retained p S h B main x hpad htuple hcover + by_contra hn + exact hx (ite_eq_right hn) + +theorem paddingWeightedFunction_invariant {ι : Type*} [DecidableEq ι] + (p : ι → ℕ) (S : Finset ι) (h B : ℕ) (main : List SignedStep) + (R : (ι → Fin B) → ℝ) + (hsep : ∀ (k : Fin main.length) i, p i ∈ (main.get k).padding.primeFactors → i ∉ S) + (hR : ∀ x y, (∀ i, i ∉ S → x i = y i) → R x = R y) + (x y : ι → Fin B) (hxy : ∀ i, i ∉ S → x i = y i) : + paddingWeightedFunction p h B main R x = paddingWeightedFunction p h B main R y := by + unfold paddingWeightedFunction + rw [mainPaddingTests_congr p S h B main hsep x y hxy, hR x y hxy] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MaskedClosedWordAverage.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MaskedClosedWordAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..22c5e6d4de24f61a409f3cbe3f463d0755730ae1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MaskedClosedWordAverage.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShiftedIntegerPaths +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedWordIdentity + +namespace OAI + +/-! Identify the scalar word expectations appearing in the matrix bound. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +theorem maskedClosedWord_residue_average {h J M R B : ℕ} {P : Fin J → Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (w : ColumnPrimeAssignment J R P) (forward : Fin R → Bool) (padding : Fin R → ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (hlabel : ∀ i j, (label (i, j)).val = (w j i).val) + (s budget : ℕ) (hR : 0 < R) (hRD : R ≤ budget) + (hclosed : wordDisplacement h (columnTupleWord w forward padding) = 0) + (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) (g : ℤ → ℝ) + (L K : ℝ) (extra : ℕ → ℤ → Prop) (hg : ∀ n, g n ≠ 0) : + (data.residueLaw B hB).average (fun x => scalarWalkProduct h + (maskedSignedIntegerWeight Q u eligible g (fun d => centeredTuple d.primeFactors) + L K extra h (fun n => ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) n)) + (data.residueOrigin x) (columnTupleWord w forward padding)) = + prohibitedCenteredAverage data hB s budget (columnTupleWord w forward padding) label + (data.residueValue (fun n => scalarWalkProduct h + (retainedEdgeDeparture Q u (fun t => eligible t.tuple) g L K + (fun t => extra t.tuple) h) n (columnTupleWord w forward padding))) := by + have hw : maskedSignedIntegerWeight Q u eligible g (fun d => centeredTuple d.primeFactors) + L K extra h (fun n => ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) n) = + fun t n => + (if ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) n then (0 : ℝ) else 1) * + signedIntegerWeight Q u (eligible t.tuple) g (centeredTuple t.tuple.primeFactors) + L K (extra t.tuple) h t n * + (if ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) (n + t.displacement h) + then (0 : ℝ) else 1) := by + funext t n + by_cases hn : ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) n <;> + by_cases hm : ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) + (n + t.displacement h) <;> + simp [maskedSignedIntegerWeight, vertexIndicator, hn, hm] + rw [hw] + exact closed_masked_word_average data hB w forward padding hprime hdisjoint label hlabel + s budget hR hRD hclosed Q u (fun t => eligible t.tuple) g L K + (fun t => extra t.tuple) hg + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MaskedIntegerEdges.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MaskedIntegerEdges.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd813cf0439c8964e10994afb6e00f51f8e54526 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MaskedIntegerEdges.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.TwoPoint.Bounds.IntegerEdgeOperators +import OAI.NumberTheory.TwoPoint.Bounds.MaskedRows + +namespace OAI + +/-! Extra symmetric edge restrictions preserve the concrete graph estimates. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι : Type*} [Fintype ι] + +noncomputable def maskedIntegerEdgeMatrix + (site : ι → ℤ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → Prop) + (g center : ℤ → ℝ) (L K : ℝ) (extra : ℤ → Prop) (h d : ℕ) + (gate : ι → ι → Prop) : ι → ι → ℂ := + maskMatrix gate (fun i j => (integerEdgeMatrix site Q u eligible g center L K extra h d i j : ℂ)) + +lemma maskedIntegerEdgeMatrix_symmetric + (site : ι → ℤ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → Prop) + (g center : ℤ → ℝ) (L K : ℝ) (extra : ℤ → Prop) (h d : ℕ) + (gate : ι → ι → Prop) (hgate : ∀ i j, gate i j ↔ gate j i) (i j : ι) : + maskedIntegerEdgeMatrix site Q u eligible g center L K extra h d gate i j = + star (maskedIntegerEdgeMatrix site Q u eligible g center L K extra h d gate j i) := by + classical + simp only [maskedIntegerEdgeMatrix, maskMatrix, hgate i j] + split_ifs + · simp only [Complex.star_def, Complex.conj_ofReal] + rw [integerEdgeMatrix_symmetric site Q u eligible g center L K extra h d i j] + · simp + +lemma maskedIntegerEdgeMatrix_weighted_row + (site : ι → ℤ) (hinj : Function.Injective site) + (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → Prop) + (g center : ℤ → ℝ) (L K : ℝ) (extra : ℤ → Prop) (h d : ℕ) + (gate : ι → ι → Prop) + (hL : 0 < L) (hK : 0 ≤ K) (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (hperiod : ∀ q ∈ Q, ∀ n, center (n + (h * q * d : ℕ)) = center n) (i : ι) : + ∑ j, ‖maskedIntegerEdgeMatrix site Q u eligible g center L K extra h d gate i j‖ * + g (site j) / g (site i) ≤ 2 * K * |center (site i)| := by + apply maskMatrix_weighted_row gate _ (fun i => g (site i)) (fun i => |center (site i)|) + (2 * K) (fun i => hg _) + intro k + simpa only [Complex.norm_real, Real.norm_eq_abs] using + integerEdgeMatrix_weighted_row Q u eligible g center L K extra h d site hinj hL hK hu hg hperiod k + +lemma maskedIntegerEdgeMatrix_level + (site : ι → ℤ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → Prop) + (g center : ℤ → ℝ) (L K : ℝ) (extra : ℤ → Prop) (h d : ℕ) + (gate : ι → ι → Prop) + (hperiod : ∀ q ∈ Q, ∀ n, center (n + (h * q * d : ℕ)) = center n) (i j : ι) + (hij : maskedIntegerEdgeMatrix site Q u eligible g center L K extra h d gate i j ≠ 0) : + |center (site i)| = |center (site j)| := by + apply maskMatrix_level gate _ (fun i => |center (site i)|) _ i j hij + intro k m hkm + exact congrArg abs (integerEdgeMatrix_center_invariant Q u eligible g center L K extra h d + site hperiod k m (fun hz => hkm (by simp [hz]))) + +/-- The full localized estimate survives all symmetric entry restrictions. -/ +theorem maskedIntegerEdgeMatrix_localized_square + (site : ι → ℤ) (hinj : Function.Injective site) + (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → Prop) + (g center : ℤ → ℝ) (L K : ℝ) (extra : ℤ → Prop) (h d : ℕ) + (gate : ι → ι → Prop) (hgate : ∀ i j, gate i j ↔ gate j i) + (hL : 0 < L) (hK : 0 ≤ K) (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (hperiod : ∀ q ∈ Q, ∀ n, center (n + (h * q * d : ℕ)) = center n) + (v : ι → ℂ) : + (∑ i, ‖∑ j, maskedIntegerEdgeMatrix site Q u eligible g center L K extra h d gate i j * v j‖ ^ 2) ≤ + 4 * K ^ 2 * ∑ i, |center (site i)| ^ 2 * ‖v i‖ ^ 2 := by + have hs := weighted_matrix_localized_square + (maskedIntegerEdgeMatrix site Q u eligible g center L K extra h d gate) + (fun i => g (site i)) (fun i => |center (site i)|) (2 * K) (by positivity) + (fun i => hg _) (fun i => abs_nonneg _) + (fun i j => by rw [maskedIntegerEdgeMatrix_symmetric site Q u eligible g center L K extra h d gate hgate i j, norm_star]) + (maskedIntegerEdgeMatrix_level site Q u eligible g center L K extra h d gate hperiod) + (maskedIntegerEdgeMatrix_weighted_row site hinj Q u eligible g center L K extra h d gate hL hK hu hg hperiod) v + convert hs using 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MaskedRows.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MaskedRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3096885409808f8ce50e158036aa1932f135398 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MaskedRows.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.TwoPoint.Bounds.WeightedRows + +namespace OAI + +/-! Edge deletions preserve the weighted-row estimates. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι : Type*} [Fintype ι] + +noncomputable def maskMatrix (gate : ι → ι → Prop) (A : ι → ι → ℂ) (i j : ι) : ℂ := by + classical + exact if gate i j then A i j else 0 + +omit [Fintype ι] in +lemma maskMatrix_norm_le (gate : ι → ι → Prop) (A : ι → ι → ℂ) (i j : ι) : + ‖maskMatrix gate A i j‖ ≤ ‖A i j‖ := by + classical + unfold maskMatrix + split_ifs + · exact le_rfl + · simp + +omit [Fintype ι] in +lemma maskMatrix_norm_symmetric (gate : ι → ι → Prop) (A : ι → ι → ℂ) + (hgate : ∀ i j, gate i j ↔ gate j i) + (hA : ∀ i j, ‖A i j‖ = ‖A j i‖) (i j : ι) : + ‖maskMatrix gate A i j‖ = ‖maskMatrix gate A j i‖ := by + classical + simp only [maskMatrix, hgate i j] + split_ifs + · exact hA i j + · rfl + +omit [Fintype ι] in +lemma maskMatrix_level (gate : ι → ι → Prop) (A : ι → ι → ℂ) (a : ι → ℝ) + (hlevel : ∀ i j, A i j ≠ 0 → a i = a j) (i j : ι) + (hij : maskMatrix gate A i j ≠ 0) : a i = a j := by + classical + apply hlevel i j + intro hz + exact hij (by simp [maskMatrix, hz]) + +lemma maskMatrix_weighted_row (gate : ι → ι → Prop) (A : ι → ι → ℂ) + (g a : ι → ℝ) (c : ℝ) (hg : ∀ i, 0 < g i) + (hrow : ∀ i, ∑ j, ‖A i j‖ * g j / g i ≤ c * a i) (i : ι) : + ∑ j, ‖maskMatrix gate A i j‖ * g j / g i ≤ c * a i := by + apply le_trans _ (hrow i) + apply sum_le_sum + intro j _ + exact div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_right (maskMatrix_norm_le gate A i j) (hg j).le) (hg i).le + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MaskedWeightPeriodicity.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MaskedWeightPeriodicity.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f8eee78ecd9a5e8f14c6bc9be3681475ece42fd --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MaskedWeightPeriodicity.lean @@ -0,0 +1,108 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShiftedIntegerPaths +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedWeightIndependence + +namespace OAI + +/-! The literal masked arithmetic weights depend only on the finite prime residues. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma centeredTuple_eq_of_prime_residues (P : Finset ℕ) (n m : ℤ) + (hnm : ∀ p ∈ P, (n : ZMod p) = (m : ZMod p)) : + centeredTuple P n = centeredTuple P m := by + unfold centeredTuple + apply prod_congr rfl + intro p hp + have he : (p : ℤ) ∣ n ↔ (p : ℤ) ∣ m := by + rw [← ZMod.intCast_zmod_eq_zero_iff_dvd, ← ZMod.intCast_zmod_eq_zero_iff_dvd, hnm p hp] + simp only [he] + +lemma ProhibitedPrimeFamily.prohibitedSite_congr {h J M B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (s : ℕ) (n m : ℤ) + (hnm : ∀ p : ↥(data.P ∪ data.Q), (n : ZMod p.val) = (m : ZMod p.val)) : + ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) n ↔ + ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) m := by + let (p : ↥(data.P ∪ data.Q)) : NeZero p.val := ⟨(data.prime p).ne_zero⟩ + let x (p : ↥(data.P ∪ data.Q)) : Fin B := + ⟨(n : ZMod p.val).val, (ZMod.val_lt _).trans_le (hB _ p.property)⟩ + have hn (p : ↥(data.P ∪ data.Q)) : (n : ZMod p.val) = ((x p).val : ZMod p.val) := + (ZMod.natCast_zmod_val _).symm + exact (data.deletedEvent_iff s B x n hn).symm.trans + (data.deletedEvent_iff s B x m (fun p => (hnm p).symm.trans (hn p))) + +lemma maskedSignedIntegerWeight_residue_congr {h J M B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (s : ℕ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) + (hsq : ∀ q ∈ Q, Squarefree q) (hpool : ∀ q ∈ Q, q.primeFactors ⊆ data.Q) + (hg : ∀ n m : ℤ, (∀ p ∈ data.Q, (n : ZMod p) = (m : ZMod p)) → g n = g m) + (hextra : ∀ d n m, (∀ p ∈ data.Q, (n : ZMod p) = (m : ZMod p)) → + (extra d n ↔ extra d m)) + (t : SignedStep) (htuple : t.tuple.primeFactors ⊆ data.P) (n m : ℤ) + (hnm : ∀ p : ↥(data.P ∪ data.Q), (n : ZMod p.val) = (m : ZMod p.val)) : + maskedSignedIntegerWeight Q u eligible g (fun d => centeredTuple d.primeFactors) + L K extra h (fun z => ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) z) t n = + maskedSignedIntegerWeight Q u eligible g (fun d => centeredTuple d.primeFactors) + L K extra h (fun z => ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) z) t m := by + have hQ : ∀ p ∈ data.Q, (n : ZMod p) = (m : ZMod p) := + fun p hp => hnm ⟨p, mem_union_right _ hp⟩ + have hshift : ∀ p : ↥(data.P ∪ data.Q), + ((n + t.displacement h : ℤ) : ZMod p.val) = + ((m + t.displacement h : ℤ) : ZMod p.val) := by + intro p + simp only [Int.cast_add, hnm p] + have hkeep (a b : ℤ) (hab : ∀ p ∈ data.Q, (a : ZMod p) = (b : ZMod p)) : + integerEdgeKeep Q u (eligible t.tuple) g L K (extra t.tuple) a ↔ + integerEdgeKeep Q u (eligible t.tuple) g L K (extra t.tuple) b := by + unfold integerEdgeKeep + rw [paddingDensity_eq_of_prime_residues data.Q Q u (eligible t.tuple) g hsq hpool a b hab + (hg a b hab), hextra t.tuple a b hab] + have hcenter : centeredTuple t.tuple.primeFactors n = centeredTuple t.tuple.primeFactors m := + centeredTuple_eq_of_prime_residues _ n m + (fun p hp => hnm ⟨p, mem_union_left _ (htuple hp)⟩) + have hperiod : ∀ q ∈ Q, ∀ z, + centeredTuple t.tuple.primeFactors (z + (h * q * t.tuple : ℕ)) = + centeredTuple t.tuple.primeFactors z := + fun q _ z => centeredTuple_padding_periodic _ h t.tuple + (fun p hp => (Nat.mem_primeFactors.mp hp).2.1) q z + have hedge : signedIntegerWeight Q u (eligible t.tuple) g (centeredTuple t.tuple.primeFactors) + L K (extra t.tuple) h t n = + signedIntegerWeight Q u (eligible t.tuple) g (centeredTuple t.tuple.primeFactors) + L K (extra t.tuple) h t m := by + rw [signedIntegerWeight_departure Q u _ g _ L K _ h t n hperiod, + signedIntegerWeight_departure Q u _ g _ L K _ h t m hperiod] + by_cases hq : t.padding ∈ Q + · have hd := squarefree_divisor_congr data.Q t.padding (hsq _ hq) (hpool _ hq) n m hQ + have hQs : ∀ p ∈ data.Q, + ((n + t.displacement h : ℤ) : ZMod p) = + ((m + t.displacement h : ℤ) : ZMod p) := + fun p hp => hshift ⟨p, mem_union_right _ hp⟩ + simp only [hq, true_and, hd, hkeep n m hQ, hkeep _ _ hQs, hcenter, + hg n m hQ, hg _ _ hQs] + · simp only [hq, false_and, ite_false] + dsimp only [maskedSignedIntegerWeight, vertexIndicator] + simp only [data.prohibitedSite_congr hB s n m hnm, + data.prohibitedSite_congr hB s _ _ hshift, hedge] + split_ifs <;> rfl + +lemma scalarWalkProduct_residue_congr (P : Finset ℕ) (h : ℕ) + (weight : SignedStep → ℤ → ℝ) (w : List SignedStep) + (hw : ∀ t ∈ w, ∀ n m : ℤ, (∀ p ∈ P, (n : ZMod p) = (m : ZMod p)) → + weight t n = weight t m) (n m : ℤ) + (hnm : ∀ p ∈ P, (n : ZMod p) = (m : ZMod p)) : + scalarWalkProduct h weight n w = scalarWalkProduct h weight m w := by + induction w generalizing n m with + | nil => rfl + | cons t w ih => + rw [scalarWalkProduct, scalarWalkProduct, hw t (List.mem_cons_self ..) n m hnm, + ih (fun a ha => hw a (List.mem_cons_of_mem t ha))] + intro p hp + simp only [Int.cast_add, hnm p hp] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixAction.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixAction.lean new file mode 100644 index 0000000000000000000000000000000000000000..06de97f8ba3320da23abebc9405907a1d3d52cca --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixAction.lean @@ -0,0 +1,31 @@ +import Mathlib.Analysis.Matrix.Hermitian +import Mathlib.Analysis.Normed.Module.FiniteDimension + +namespace OAI + +/-! Concrete continuous operators associated with finite matrices. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def matrixOperator (A : ι → ι → ℂ) : + EuclideanSpace ℂ ι →L[ℂ] EuclideanSpace ℂ ι := + (Matrix.toEuclideanLin A).toContinuousLinearMap + +@[simp] lemma matrixOperator_apply (A : ι → ι → ℂ) (v : EuclideanSpace ℂ ι) (i : ι) : + matrixOperator A v i = ∑ j, A i j * v j := rfl + +lemma matrixOperator_selfAdjoint (A : ι → ι → ℂ) + (hA : ∀ i j, A i j = star (A j i)) : IsSelfAdjoint (matrixOperator A) := by + apply ContinuousLinearMap.isSelfAdjoint_iff_isSymmetric.mpr + change (Matrix.toEuclideanLin A).IsSymmetric + apply Matrix.isSymmetric_toEuclideanLin_iff.mpr + ext i j + exact (hA i j).symm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixClosedWords.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixClosedWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..a592a23ef42d4ce1fb1353aff110bd8b6a76274d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixClosedWords.lean @@ -0,0 +1,182 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteAverages +import OAI.NumberTheory.TwoPoint.Bounds.FiniteProbability +import Mathlib.Data.Matrix.Mul +import Mathlib.Data.Fin.Tuple.Basic +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Data.List.Chain + +namespace OAI + +/-! Signed closed-word expansion of the actual matrix power moment. -/ + +namespace TwoPointCorrelations + +open Finset + +section Paths + +variable {V : Type*} [Fintype V] [DecidableEq V] + +def matrixPathWeight (A : Matrix V V ℝ) : {k : ℕ} → V → (Fin k → V) → ℝ + | 0, _, _ => 1 + | _k + 1, x, v => A x (v 0) * matrixPathWeight A (v 0) (Fin.tail v) + +def matrixPathEnd : {k : ℕ} → V → (Fin k → V) → V + | 0, x, _ => x + | _k + 1, _, v => matrixPathEnd (v 0) (Fin.tail v) + +def matrixPathTerm (A : Matrix V V ℝ) {k : ℕ} (x y : V) (v : Fin k → V) : ℝ := + if matrixPathEnd x v = y then matrixPathWeight A x v else 0 + +def matrixPathVertices {k : ℕ} (x : V) (v : Fin k → V) : List V := x :: List.ofFn v + +omit [Fintype V] [DecidableEq V] in +lemma matrixPathEnd_eq_last {k : ℕ} (x : V) (v : Fin (k + 1) → V) : + matrixPathEnd x v = v (Fin.last k) := by + induction k generalizing x with + | zero => rfl + | succ k ih => + change matrixPathEnd (v 0) (Fin.tail v) = _ + rw [ih] + rfl + +omit [Fintype V] in +lemma matrixPathTerm_ne_zero (A : Matrix V V ℝ) {k : ℕ} (x y : V) (v : Fin k → V) + (h : matrixPathTerm A x y v ≠ 0) : + matrixPathEnd x v = y ∧ matrixPathWeight A x v ≠ 0 := by + unfold matrixPathTerm at h + split_ifs at h with he + · exact ⟨he, h⟩ + · contradiction + +omit [Fintype V] [DecidableEq V] in +lemma matrixPathWeight_chain (A : Matrix V V ℝ) (R : V → V → Prop) + (hA : ∀ x y, A x y ≠ 0 → R x y) {k : ℕ} (x : V) (v : Fin k → V) + (h : matrixPathWeight A x v ≠ 0) : (matrixPathVertices x v).IsChain R := by + induction k generalizing x with + | zero => simp [matrixPathVertices] + | succ k ih => + have hp : A x (v 0) ≠ 0 ∧ matrixPathWeight A (v 0) (Fin.tail v) ≠ 0 := + mul_ne_zero_iff.mp h + have ht := ih (v 0) (Fin.tail v) hp.2 + change (x :: List.ofFn v).IsChain R + rw [List.ofFn_succ] + exact ht.cons_cons (hA x (v 0) hp.1) + +omit [DecidableEq V] in +lemma sum_fin_cons {k : ℕ} (f : (Fin (k + 1) → V) → ℝ) : + ∑ v, f v = ∑ a, ∑ v : Fin k → V, f (Fin.cons a v) := by + have he := (Fin.consEquiv (fun _ : Fin (k + 1) => V)).sum_comp f + change (∑ p : V × (Fin k → V), f (Fin.cons p.1 p.2)) = ∑ v, f v at he + simpa only [Fintype.sum_prod_type] using he.symm + +omit [Fintype V] in +lemma matrixPathTerm_cons (A : Matrix V V ℝ) {k : ℕ} (x y a : V) (v : Fin k → V) : + matrixPathTerm A x y (Fin.cons a v) = A x a * matrixPathTerm A a y v := by + simp only [matrixPathTerm, matrixPathEnd, matrixPathWeight, Fin.cons_zero, Fin.tail_cons] + split_ifs <;> simp + +/-- Every power entry is an exact signed sum over its successive states. -/ +theorem matrix_pow_path_sum (A : Matrix V V ℝ) (k : ℕ) (x y : V) : + (A ^ k) x y = ∑ v : Fin k → V, matrixPathTerm A x y v := by + induction k generalizing x with + | zero => + simp [matrixPathTerm, matrixPathEnd, matrixPathWeight, Matrix.one_apply] + split_ifs <;> simp_all + | succ k ih => + rw [pow_succ', Matrix.mul_apply, sum_fin_cons] + simp_rw [ih, mul_sum, matrixPathTerm_cons] + +def matrixFrobeniusSq (A : Matrix V V ℝ) : ℝ := ∑ x, ∑ y, (A x y) ^ 2 + +omit [DecidableEq V] in +lemma matrixFrobeniusSq_nonneg (A : Matrix V V ℝ) : 0 ≤ matrixFrobeniusSq A := + sum_nonneg (fun _ _ => sum_nonneg (fun _ _ => sq_nonneg _)) + +/-- Squaring joins two paths with the same endpoints. No absolute values +are taken in this identity, which is the step needed before centering. -/ +theorem matrix_power_closed_words (A : Matrix V V ℝ) (k : ℕ) : + matrixFrobeniusSq (A ^ k) = + ∑ x, ∑ y, ∑ u : Fin k → V, ∑ v : Fin k → V, + matrixPathTerm A x y u * matrixPathTerm A x y v := by + unfold matrixFrobeniusSq + apply sum_congr rfl + intro x _ + apply sum_congr rfl + intro y _ + rw [matrix_pow_path_sum, pow_two, sum_mul] + simp_rw [mul_sum] + +/-- Move the finite-law average through the full signed expansion. The +triangle inequality is applied to each word expectation only afterwards. -/ +theorem average_matrix_power_le_closed_words {Ω : Type*} [Fintype Ω] + (μ : FiniteLaw Ω) (A : Ω → Matrix V V ℝ) (k : ℕ) : + μ.average (fun ω => matrixFrobeniusSq (A ω ^ k)) ≤ + ∑ x, ∑ y, ∑ u : Fin k → V, ∑ v : Fin k → V, + |μ.average (fun ω => matrixPathTerm (A ω) x y u * matrixPathTerm (A ω) x y v)| := by + have he : μ.average (fun ω => matrixFrobeniusSq (A ω ^ k)) = + ∑ x, ∑ y, ∑ u : Fin k → V, ∑ v : Fin k → V, + μ.average (fun ω => matrixPathTerm (A ω) x y u * matrixPathTerm (A ω) x y v) := by + simp only [FiniteLaw.average, matrix_power_closed_words] + simp_rw [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro x _ + rw [sum_comm] + apply sum_congr rfl + intro y _ + rw [sum_comm] + apply sum_congr rfl + intro u _ + rw [sum_comm] + rw [he] + exact sum_le_sum (fun _ _ => sum_le_sum (fun _ _ => + sum_le_sum (fun _ _ => sum_le_sum (fun _ _ => le_abs_self _)))) + +end Paths + +section Nonbacktracking + +variable {D V : Type*} [DecidableEq D] + +/-- The manuscript's concrete block matrix `H[d,d'] = 1[d≠d'] A[d']`. -/ +def blockNonbacktrackingMatrix (A : D → Matrix V V ℝ) : Matrix (D × V) (D × V) ℝ := + fun x y => if x.1 ≠ y.1 then A y.1 x.2 y.2 else 0 + +lemma blockNonbacktrackingMatrix_ne_zero (A : D → Matrix V V ℝ) (x y : D × V) + (h : blockNonbacktrackingMatrix A x y ≠ 0) : + x.1 ≠ y.1 ∧ A y.1 x.2 y.2 ≠ 0 := by + unfold blockNonbacktrackingMatrix at h + split_ifs at h with hne + · exact ⟨hne, h⟩ + · contradiction + +variable [DecidableEq V] + +lemma block_path_copy_chain (A : D → Matrix V V ℝ) {k : ℕ} + (x y : D × V) (v : Fin k → D × V) + (hv : matrixPathTerm (blockNonbacktrackingMatrix A) x y v ≠ 0) : + ((List.ofFn v).map Prod.fst).IsChain (fun a b => a ≠ b) := by + have hc := matrixPathWeight_chain (blockNonbacktrackingMatrix A) + (fun a b => a.1 ≠ b.1) + (fun a b hab => (blockNonbacktrackingMatrix_ne_zero A a b hab).1) + x v (matrixPathTerm_ne_zero _ x y v hv).2 + exact (List.isChain_map Prod.fst).mpr hc.tail + +/-- The two halves of a nonzero closed-word term are nonbacktracking. +There is deliberately no condition across the two joins. -/ +theorem closed_copy_halves_chain (A : D → Matrix V V ℝ) {k : ℕ} + (x y : D × V) (u v : Fin k → D × V) + (hu : matrixPathTerm (blockNonbacktrackingMatrix A) x y u ≠ 0) + (hv : matrixPathTerm (blockNonbacktrackingMatrix A) x y v ≠ 0) : + ((List.ofFn u).map Prod.fst).IsChain (fun a b => a ≠ b) ∧ + (((List.ofFn v).map Prod.fst).reverse).IsChain (fun a b => a ≠ b) := by + refine ⟨block_path_copy_chain A x y u hu, ?_⟩ + exact List.isChain_reverse.mpr ((block_path_copy_chain A x y v hv).imp + (fun _ _ hne => hne.symm)) + +end Nonbacktracking + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixMomentNorm.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixMomentNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba920855715a463cf924bdf3509adf4434bd0cb7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixMomentNorm.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MatrixClosedWords +import OAI.NumberTheory.TwoPoint.Bounds.MatrixAction +import OAI.NumberTheory.TwoPoint.Bounds.WeightedRows + +namespace OAI + +/-! The unnormalized matrix moment controls the operator norm used in the spectral step. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {V : Type*} [Fintype V] [DecidableEq V] + +omit [DecidableEq V] in +lemma real_matrix_row_square (A : Matrix V V ℝ) (v : V → ℂ) (i : V) : + ‖∑ j, (A i j : ℂ) * v j‖ ^ 2 ≤ + (∑ j, (A i j) ^ 2) * ∑ j, ‖v j‖ ^ 2 := by + have htri : ‖∑ j, (A i j : ℂ) * v j‖ ≤ ∑ j, |A i j| * ‖v j‖ := by + simpa only [norm_mul, Complex.norm_real, Real.norm_eq_abs] using + norm_sum_le univ (fun j => (A i j : ℂ) * v j) + have hcs := sum_mul_sq_le_sq_mul_sq univ (fun j => |A i j|) (fun j => ‖v j‖) + have hsq := (sq_le_sq₀ (norm_nonneg _) + (sum_nonneg (fun j _ => mul_nonneg (abs_nonneg _) (norm_nonneg _)))).mpr htri + exact hsq.trans (by simpa only [sq_abs] using hcs) + +theorem real_matrix_operator_norm_le (A : Matrix V V ℝ) : + ‖matrixOperator (fun i j => (A i j : ℂ))‖ ≤ Real.sqrt (matrixFrobeniusSq A) := by + apply ContinuousLinearMap.opNorm_le_bound _ (Real.sqrt_nonneg _) + intro v + have hsum : ‖matrixOperator (fun i j => (A i j : ℂ)) v‖ ^ 2 ≤ + matrixFrobeniusSq A * ‖v‖ ^ 2 := by + rw [EuclideanSpace.norm_sq_eq, EuclideanSpace.norm_sq_eq] + simp only [matrixOperator_apply] + calc + _ ≤ ∑ i, (∑ j, (A i j) ^ 2) * ∑ j, ‖v j‖ ^ 2 := + sum_le_sum (fun i _ => real_matrix_row_square A (fun j => v j) i) + _ = _ := by rw [← sum_mul]; rfl + have hroot := Real.sq_sqrt (matrixFrobeniusSq_nonneg A) + have hn := norm_nonneg (matrixOperator (fun i j => (A i j : ℂ)) v) + have hprod : 0 ≤ Real.sqrt (matrixFrobeniusSq A) * ‖v‖ := by positivity + nlinarith + +lemma matrixOperator_mul (A B : Matrix V V ℂ) : + matrixOperator (A * B) = matrixOperator A * matrixOperator B := by + ext v i + change (∑ j, (A * B) i j * v j) = + ∑ j, A i j * (∑ k, B j k * v k) + simp only [Matrix.mul_apply] + simp_rw [sum_mul, mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro j _ + apply sum_congr rfl + intro k _ + ring + +lemma matrixOperator_one : matrixOperator (1 : Matrix V V ℂ) = 1 := by + ext v i + change (∑ j, (1 : Matrix V V ℂ) i j * v j) = v i + simp [Matrix.one_apply] + +lemma matrixOperator_pow (A : Matrix V V ℂ) (k : ℕ) : + matrixOperator (A ^ k) = matrixOperator A ^ k := by + induction k with + | zero => simp only [pow_zero, matrixOperator_one] + | succ k ih => rw [pow_succ, matrixOperator_mul, ih, pow_succ] + +def complexifyMatrix (A : Matrix V V ℝ) : Matrix V V ℂ := A.map Complex.ofReal + +omit [DecidableEq V] in +lemma real_matrix_cast_mul (A B : Matrix V V ℝ) : + complexifyMatrix (A * B) = complexifyMatrix A * complexifyMatrix B := by + ext i j + change ((∑ x, A i x * B x j : ℝ) : ℂ) = ∑ x, (A i x : ℂ) * (B x j : ℂ) + simp only [Complex.ofReal_sum, Complex.ofReal_mul] + +lemma real_matrix_cast_pow (A : Matrix V V ℝ) (k : ℕ) : + complexifyMatrix (A ^ k) = complexifyMatrix A ^ k := by + induction k with + | zero => + ext i j + change (((1 : Matrix V V ℝ) i j : ℝ) : ℂ) = (1 : Matrix V V ℂ) i j + simp only [Matrix.one_apply] + split_ifs <;> simp + | succ k ih => rw [pow_succ, real_matrix_cast_mul, ih, pow_succ] + +/-- The precise moment-to-operator inequality used by spectral transfer. -/ +theorem real_matrix_operator_power_norm_le (A : Matrix V V ℝ) (k : ℕ) : + ‖matrixOperator (fun i j => (A i j : ℂ)) ^ k‖ ≤ + Real.sqrt (matrixFrobeniusSq (A ^ k)) := by + have hpow := matrixOperator_pow (complexifyMatrix A) k + have hcast := congrArg matrixOperator (real_matrix_cast_pow A k) + calc + _ = ‖matrixOperator (fun i j => ((A ^ k) i j : ℂ))‖ := + congrArg norm (hpow.symm.trans hcast.symm) + _ ≤ _ := real_matrix_operator_norm_le (A ^ k) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixSpectralTail.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixSpectralTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..dde3771c06399f33bd71d80849e2d038d27c597c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixSpectralTail.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MatrixMomentNorm +import OAI.NumberTheory.TwoPoint.Bounds.SpectralTransfer + +namespace OAI + +/-! The exact unnormalized moment controls the exceptional block origins. +No self-adjointness of the nonbacktracking matrix is needed. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def realMatrixSpectralRadius {V : Type*} [Fintype V] [DecidableEq V] + (A : Matrix V V ℝ) : ℝ := + (spectralRadius ℂ (matrixOperator (fun i j => (A i j : ℂ)))).toReal + +lemma real_matrix_spectral_power_le {V : Type*} [Fintype V] [DecidableEq V] + (A : Matrix V V ℝ) (k : ℕ) (hk : 0 < k) : + realMatrixSpectralRadius A ^ (2 * k) ≤ matrixFrobeniusSq (A ^ k) := by + let T := matrixOperator (fun i j => (A i j : ℂ)) + have hp := (spectrum.spectralRadius_pow_le (𝕜 := ℂ) T k (by omega)).trans + (spectralRadius_le_nnnorm (𝕜 := ℂ) (T ^ k)) + have hr : realMatrixSpectralRadius A ^ k ≤ ‖T ^ k‖ := by + have ht := ENNReal.toReal_mono (by exact ENNReal.coe_ne_top) hp + simpa only [realMatrixSpectralRadius, ENNReal.toReal_pow, ENNReal.coe_toReal, + coe_nnnorm] using ht + have hm := hr.trans (real_matrix_operator_power_norm_le A k) + have hnonneg : 0 ≤ realMatrixSpectralRadius A ^ k := pow_nonneg ENNReal.toReal_nonneg _ + have hs := (sq_le_sq₀ hnonneg (Real.sqrt_nonneg _)).mpr hm + rw [Real.sq_sqrt (matrixFrobeniusSq_nonneg _)] at hs + simpa only [Nat.mul_comm 2 k, pow_mul] using hs + +theorem FiniteLaw.matrix_spectral_tail {V Ω : Type*} + [Fintype V] [DecidableEq V] [Fintype Ω] + (μ : FiniteLaw Ω) (A : Ω → Matrix V V ℝ) (k : ℕ) (hk : 0 < k) + (B : ℝ) (hB : 0 < B) + (hmoment : μ.average (fun x => matrixFrobeniusSq (A x ^ k)) ≤ B ^ (2 * k)) : + μ.probability (fun x => Real.exp 1 * B < realMatrixSpectralRadius (A x)) ≤ + Real.exp (-(2 * k : ℕ)) := by + have hden : 0 < (Real.exp 1 * B) ^ (2 * k) := pow_pos (mul_pos (Real.exp_pos _) hB) _ + calc + _ ≤ μ.average (fun x => matrixFrobeniusSq (A x ^ k) / (Real.exp 1 * B) ^ (2 * k)) := by + apply μ.average_mono + intro x + by_cases hx : Real.exp 1 * B < realMatrixSpectralRadius (A x) + · rw [ite_eq_left hx] + apply (one_le_div hden).mpr + exact (pow_le_pow_left₀ (by positivity) hx.le _).trans + (real_matrix_spectral_power_le (A x) k hk) + · rw [ite_eq_right hx] + exact div_nonneg (matrixFrobeniusSq_nonneg _) hden.le + _ = μ.average (fun x => matrixFrobeniusSq (A x ^ k)) / (Real.exp 1 * B) ^ (2 * k) := by + simp only [div_eq_mul_inv, μ.average_mul_const] + _ ≤ B ^ (2 * k) / (Real.exp 1 * B) ^ (2 * k) := + div_le_div_of_nonneg_right hmoment hden.le + _ = ((Real.exp 1) ^ (2 * k))⁻¹ := by + rw [mul_pow] + field_simp + _ = _ := by + rw [← Real.exp_nat_mul, ← Real.exp_neg] + congr 1 + simp + +lemma trace_moment_add_one_le (B : ℝ) (hB : 1 ≤ B) (n : ℕ) (hn : 0 < n) : + B ^ n + 1 ≤ (2 * B) ^ n := by + have hb : 1 ≤ B ^ n := one_le_pow₀ hB + have ht : (2 : ℝ) ≤ 2 ^ n := by + obtain ⟨m, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : n ≠ 0) + rw [pow_succ] + nlinarith [(one_le_pow₀ (by norm_num : (1 : ℝ) ≤ 2) : (1 : ℝ) ≤ 2 ^ m)] + rw [mul_pow] + nlinarith + +theorem FiniteLaw.matrix_spectral_tail_add_one {V Ω : Type*} + [Fintype V] [DecidableEq V] [Fintype Ω] + (μ : FiniteLaw Ω) (A : Ω → Matrix V V ℝ) (k : ℕ) (hk : 0 < k) + (B : ℝ) (hB : 1 ≤ B) + (hmoment : μ.average (fun x => matrixFrobeniusSq (A x ^ k)) ≤ B ^ (2 * k) + 1) : + μ.probability (fun x => Real.exp 1 * (2 * B) < realMatrixSpectralRadius (A x)) ≤ + Real.exp (-(2 * k : ℕ)) := by + exact μ.matrix_spectral_tail A k hk (2 * B) (by linarith) + (hmoment.trans (trace_moment_add_one_le B hB (2 * k) (by omega))) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixTraceSummation.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixTraceSummation.lean new file mode 100644 index 0000000000000000000000000000000000000000..f19ecf9186f5c1734fb8b724251463e2156c8a41 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MatrixTraceSummation.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualColumnTrace + +namespace OAI + +/-! Sum the actual column bounds over signs and starting vertices. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma trace_dimension_allowance (L : ℝ) (k N : ℕ) (_hL : 0 ≤ L) + (hk : (k : ℝ) ≤ L) (hN : (N : ℝ) ≤ Real.exp (106 * L)) : + (N : ℝ) * (2 : ℝ) ^ (2 * k) ≤ Real.exp (108 * L) := by + have hlog : Real.log 2 ≤ 1 := by + have ht := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + linarith + calc + _ ≤ Real.exp (106 * L) * (2 : ℝ) ^ (2 * k) := + mul_le_mul_of_nonneg_right hN (by positivity) + _ = Real.exp (106 * L + (2 * k : ℕ) * Real.log 2) := by + rw [Real.exp_add, Real.exp_nat_mul, Real.exp_log (by norm_num : (0 : ℝ) < 2)] + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have hb := mul_le_mul_of_nonneg_left hlog (show (0 : ℝ) ≤ 2 * k by positivity) + push_cast at hb ⊢ + nlinarith + +theorem matrix_residue_trace_of_column_bounds {h J M B k : ℕ} {P : Fin J → Finset ℕ} + {V : Type*} [Fintype V] [DecidableEq V] + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (hP : ∀ j, P j ⊆ data.P) (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (s budget : ℕ) (hk : 0 < 2 * k) (hbudget : 2 * k ≤ budget) + (embed : V → ((j : Fin J) → P j) × ℤ) (hinj : Function.Injective embed) + (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K T : ℝ) (extra : ℕ → ℤ → Prop) + (gate : ((j : Fin J) → P j) → ℤ → ℤ → Prop) + (hsq : ∀ q ∈ Q, Squarefree q) (hpool : ∀ q ∈ Q, q.primeFactors ⊆ data.Q) + (hg : ∀ n, g n ≠ 0) + (hgdep : ∀ n m : ℤ, (∀ p ∈ data.Q, (n : ZMod p) = (m : ZMod p)) → g n = g m) + (hextra : ∀ d n m, (∀ p ∈ data.Q, (n : ZMod p) = (m : ZMod p)) → + (extra d n ↔ extra d m)) + (hallowed : ∀ d q, eligible d q → (d, q) ∈ data.pairs) + (hT : 0 ≤ T) + (hdim : (Fintype.card V : ℝ) * (2 : ℝ) ^ (2 * k) ≤ Real.exp (108 * L)) + (hcolumn : ∀ (x : ((j : Fin J) → P j) × ℤ) (forward : Fin (2 * k) → Bool), + Real.exp (108 * L) * (∑ a ∈ closedTraceFiber Q + (actualClosedPairCatalog embed Q (fun d => ∏ j, (d j).val) h gate data.pairs k x) forward, + |prohibitedCenteredAverage data hB s budget + (columnTupleWord a.1 forward (fun i => (a.2 i).val)) (actualColumnLabel data hP a.1) + (actualColumnWeight data u eligible g L K extra forward a)|) ≤ T) : + let tuple := fun d : (j : Fin J) → P j => ∏ j, (d j).val + let weight := maskedSignedIntegerWeight Q u eligible g (fun d => centeredTuple d.primeFactors) + L K extra h (fun n => ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) n) + (data.residueLaw B hB).average (fun r => matrixFrobeniusSq + (shiftMatrix embed (integerShiftNext Q tuple h) (physicalShiftWeight Q tuple h gate + (fun t n => weight t (n + data.residueOrigin r))) ^ k)) ≤ T := by + dsimp only + have hb := columnMatrix_residue_trace_le data hB hP hprime hdisjoint s budget hk hbudget + embed hinj Q u eligible g L K extra gate hsq hpool hg hgdep hextra hallowed + apply (mul_le_mul_iff_right₀ (Real.exp_pos (108 * L))).mp + calc + _ ≤ Real.exp (108 * L) * (∑ i : V, ∑ forward, ∑ a ∈ closedTraceFiber Q + (actualClosedPairCatalog embed Q (fun d => ∏ j, (d j).val) h gate data.pairs k (embed i)) forward, + |prohibitedCenteredAverage data hB s budget + (columnTupleWord a.1 forward (fun j => (a.2 j).val)) (actualColumnLabel data hP a.1) + (actualColumnWeight data u eligible g L K extra forward a)|) := + mul_le_mul_of_nonneg_left hb (Real.exp_pos _).le + _ ≤ ∑ _i : V, ∑ _forward : Fin (2 * k) → Bool, T := by + simp only [mul_sum] + apply sum_le_sum + intro i _ + apply sum_le_sum + intro forward _ + simpa only [mul_sum] using hcolumn (embed i) forward + _ = ((Fintype.card V : ℝ) * (2 : ℝ) ^ (2 * k)) * T := by + simp only [sum_const, card_univ, Fintype.card_fun, Fintype.card_bool, + Fintype.card_fin, nsmul_eq_mul, Nat.cast_pow, Nat.cast_ofNat] + ring + _ ≤ Real.exp (108 * L) * T := mul_le_mul_of_nonneg_right hdim hT + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MaximalPairs.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MaximalPairs.lean new file mode 100644 index 0000000000000000000000000000000000000000..94b374f711fa9e198e0a5f84a9c42e68c3f1acf9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MaximalPairs.lean @@ -0,0 +1,133 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QuotientLines +import Mathlib.Data.Finset.Max + +namespace OAI + +/-! Finite maximal selection of jointly independent direction/difference pairs. -/ + +namespace TwoPointCorrelations + +open Finset Submodule + +variable {K κ V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Fintype κ] [DecidableEq κ] + +def pairFamily (v : κ → Fin 2 → V) (S : Finset κ) : S × Fin 2 → V := + fun z => v z.1 z.2 + +private noncomputable def insertPairEquiv (S : Finset κ) (k : κ) (hk : k ∉ S) : + (S × Fin 2) ⊕ Fin 2 ≃ ↥(insert k S) × Fin 2 := + Equiv.ofBijective + (Sum.elim (fun z => (⟨z.1, mem_insert_of_mem z.1.property⟩, z.2)) + (fun b => (⟨k, mem_insert_self k S⟩, b))) (by + constructor + · intro z w heq + cases z with + | inl z => + cases w with + | inl w => + apply congrArg Sum.inl + apply Prod.ext + · apply Subtype.ext + exact congrArg (fun a : ↥(insert k S) × Fin 2 => (a.1 : κ)) heq + · exact congrArg (fun a : ↥(insert k S) × Fin 2 => a.2) heq + | inr b => + have hz : (z.1 : κ) = k := + congrArg (fun a : ↥(insert k S) × Fin 2 => (a.1 : κ)) heq + exact (hk (hz ▸ z.1.property)).elim + | inr b => + cases w with + | inl w => + have hw : k = (w.1 : κ) := + congrArg (fun a : ↥(insert k S) × Fin 2 => (a.1 : κ)) heq + exact (hk (hw ▸ w.1.property)).elim + | inr c => exact congrArg Sum.inr (congrArg Prod.snd heq) + · rintro ⟨⟨j, hj⟩, b⟩ + rcases mem_insert.mp hj with rfl | hj + · exact ⟨.inr b, rfl⟩ + · exact ⟨.inl (⟨j, hj⟩, b), rfl⟩) + +omit [Fintype κ] in +private theorem independent_insert_pair (v : κ → Fin 2 → V) (S : Finset κ) + (k : κ) (hk : k ∉ S) + (h : LinearIndependent K (Sum.elim (pairFamily v S) (v k))) : + LinearIndependent K (pairFamily v (insert k S)) := by + apply (linearIndependent_equiv (insertPairEquiv S k hk)).mp + convert h using 1 + funext z + cases z <;> rfl + +/-- A maximal collection exists among the finitely many candidate pairs. +No further pair can be adjoined, and its span has twice the selected size. -/ +theorem exists_maximal_independent_pairs (v : κ → Fin 2 → V) : + ∃ S : Finset κ, LinearIndependent K (pairFamily v S) ∧ + Module.finrank K (span K (Set.range (pairFamily v S))) = 2 * S.card ∧ + ∀ k ∉ S, ¬LinearIndependent K (Sum.elim (pairFamily v S) (v k)) := by + classical + let good : Finset (Finset κ) := univ.filter (fun S => LinearIndependent K (pairFamily v S)) + have hempty : (∅ : Finset κ) ∈ good := by + simp only [good, mem_filter, mem_univ, true_and] + exact linearIndependent_empty_type + obtain ⟨S, hS, hmax⟩ := good.exists_max_image Finset.card ⟨∅, hempty⟩ + have hind := (mem_filter.mp hS).2 + refine ⟨S, hind, ?_, ?_⟩ + · rw [finrank_span_eq_card hind, Fintype.card_prod, Fintype.card_coe, Fintype.card_fin] + omega + · intro k hk hnew + have hgood : insert k S ∈ good := by + exact mem_filter.mpr ⟨mem_univ _, independent_insert_pair v S k hk hnew⟩ + have hc := hmax (insert k S) hgood + rw [card_insert_of_notMem hk] at hc + omega + +/-- Maximal pair selection forces each unselected direction/difference +pair onto one line in the quotient by the selected span. -/ +theorem exists_maximal_pair_quotient (v : κ → Fin 2 → V) : + ∃ S : Finset κ, LinearIndependent K (pairFamily v S) ∧ + Module.finrank K (span K (Set.range (pairFamily v S))) = 2 * S.card ∧ + ∀ k, (span K (Set.range (pairFamily v S))).mkQ (v k 1) ≠ 0 → + ∃ c : K, (span K (Set.range (pairFamily v S))).mkQ (v k 0) = + c • (span K (Set.range (pairFamily v S))).mkQ (v k 1) := by + classical + obtain ⟨S, hS, hdim, hmax⟩ := exists_maximal_independent_pairs (K := K) v + refine ⟨S, hS, hdim, ?_⟩ + intro k hk + have hkS : k ∉ S := by + intro hmem + apply hk + rw [Submodule.mkQ_apply, Submodule.Quotient.mk_eq_zero] + exact subset_span ⟨(⟨k, hmem⟩, 1), rfl⟩ + have hpair : v k = ![v k 0, v k 1] := by ext b; fin_cases b <;> rfl + exact quotient_line_of_nonextendable_pair (pairFamily v S) hS (v k 1) (v k 0) hk + (by simpa only [← hpair] using hmax k hkS) + + +omit [Fintype κ] [DecidableEq κ] in +/-- Restriction to fewer candidate pairs preserves joint independence. -/ +theorem independent_pairFamily_mono (v : κ → Fin 2 → V) {S T : Finset κ} + (hTS : T ⊆ S) (hS : LinearIndependent K (pairFamily v S)) : + LinearIndependent K (pairFamily v T) := by + let f : T × Fin 2 → S × Fin 2 := fun z => (⟨z.1, hTS z.1.property⟩, z.2) + have hf : Function.Injective f := by + intro x y hxy + apply Prod.ext + · apply Subtype.ext + exact congrArg (fun z : S × Fin 2 => (z.1 : κ)) hxy + · exact congrArg (fun z : S × Fin 2 => z.2) hxy + exact hS.comp f hf + +/-- Excluding `r` independent pairs bounds every maximal collection by `r-1`. -/ +theorem exists_small_maximal_independent_pairs (v : κ → Fin 2 → V) (r : ℕ) + (hno : ∀ S : Finset κ, S.card = r → ¬LinearIndependent K (pairFamily v S)) : + ∃ S : Finset κ, S.card < r ∧ LinearIndependent K (pairFamily v S) ∧ + Module.finrank K (span K (Set.range (pairFamily v S))) = 2 * S.card ∧ + ∀ k ∉ S, ¬LinearIndependent K (Sum.elim (pairFamily v S) (v k)) := by + obtain ⟨S, hS, hdim, hmax⟩ := exists_maximal_independent_pairs (K := K) v + refine ⟨S, ?_, hS, hdim, hmax⟩ + by_contra h + obtain ⟨T, hTS, hcard⟩ := Finset.exists_subset_card_eq (Nat.le_of_not_gt h) + exact hno T hcard (independent_pairFamily_mono v hTS hS) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MertensScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MertensScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..70ed8879bcb968374e976a321bd82e53003b22db --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MertensScale.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveProducts +import Mathlib.Analysis.SpecialFunctions.Log.Basic +import Mathlib.Data.Nat.Prime.Basic + +namespace OAI + +/-! The exact classical reciprocal-prime input and its sole required scale. + +Published source: J. B. Rosser and L. Schoenfeld, *Approximate formulas for +some functions of prime numbers*, Illinois J. Math. 6 (1962), 64–94, +Theorem 5, (3.17)–(3.18), bounded-error consequence of Mertens' second +theorem. DOI: https://doi.org/10.1215/ijm/1255631807. +The formal proof uses the bounded-error statement +`RS_prime.mertens_second_theorem'`. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def sievePrimesUpTo (y : ℝ) : Finset ℕ := (Iic ⌊y⌋₊).filter Nat.Prime + +/-- The bounded-error consequence of published Mertens' second theorem, +stated exactly as the existing library declaration except for this name. -/ +def PrimeReciprocalInput : Prop := + ∃ C : ℝ, ∀ y : ℝ, 2 ≤ y → + |(∑ p ∈ sievePrimesUpTo y, 1 / (p : ℝ)) - Real.log (Real.log y)| ≤ C + +lemma sievePrimesUpTo_prime (y : ℝ) (p : ℕ) (hp : p ∈ sievePrimesUpTo y) : + Nat.Prime p := (mem_filter.mp hp).2 + +lemma sievePrimesUpTo_le (y : ℝ) (hy : 0 ≤ y) (p : ℕ) + (hp : p ∈ sievePrimesUpTo y) : (p : ℝ) ≤ y := by + exact (Nat.le_floor_iff hy).mp (mem_Iic.mp (mem_filter.mp hp).1) + +lemma sievePrimesUpTo_card_le (y : ℝ) (hy : 0 ≤ y) : + ((sievePrimesUpTo y).card : ℝ) ≤ y := by + have hs : sievePrimesUpTo y ⊆ Icc 1 ⌊y⌋₊ := by + intro p hp + exact mem_Icc.mpr ⟨(sievePrimesUpTo_prime y p hp).pos, + mem_Iic.mp (mem_filter.mp hp).1⟩ + have hc : (sievePrimesUpTo y).card ≤ ⌊y⌋₊ := by + simpa using card_le_card hs + exact (show ((sievePrimesUpTo y).card : ℝ) ≤ (⌊y⌋₊ : ℝ) by exact_mod_cast hc).trans + (Nat.floor_le hy) + +/-- Precisely the prime reciprocal bounds used in the rough sieve, at +`y=exp(L^.99)`. The upper coefficient leaves room below `5/4`. -/ +theorem PrimeReciprocalInput.rough_scale (hM : PrimeReciprocalInput) : + ∃ C : ℝ, 0 ≤ C ∧ ∀ᶠ L : ℝ in atTop, + (99 / 100 : ℝ) * Real.log L - C ≤ + ∑ p ∈ sievePrimesUpTo (Real.exp (L ^ (99 / 100 : ℝ))), 1 / (p : ℝ) ∧ + (∑ p ∈ sievePrimesUpTo (Real.exp (L ^ (99 / 100 : ℝ))), 1 / (p : ℝ)) ≤ + (5 / 4 : ℝ) * Real.log L := by + obtain ⟨C, hC⟩ := hM + have hC₀ : 0 ≤ C := (abs_nonneg _).trans (hC 2 (by norm_num)) + refine ⟨C, hC₀, ?_⟩ + filter_upwards [eventually_ge_atTop (Real.exp (4 * C + 1))] with L hL + have hL₁ : 1 ≤ L := (Real.one_le_exp (by linarith)).trans hL + have hLp : 0 < L := zero_lt_one.trans_le hL₁ + have hlog : 4 * C + 1 ≤ Real.log L := by + rw [← Real.log_exp (4 * C + 1)] + exact Real.log_le_log (Real.exp_pos _) hL + have hX : 1 ≤ L ^ (99 / 100 : ℝ) := Real.one_le_rpow hL₁ (by norm_num) + have hy : 2 ≤ Real.exp (L ^ (99 / 100 : ℝ)) := by + linarith [Real.add_one_le_exp (L ^ (99 / 100 : ℝ))] + have hm := abs_le.mp (hC (Real.exp (L ^ (99 / 100 : ℝ))) hy) + rw [Real.log_exp, Real.log_rpow hLp] at hm + constructor <;> linarith [Real.log_nonneg hL₁] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MidpointCut.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MidpointCut.lean new file mode 100644 index 0000000000000000000000000000000000000000..c11897a0c13424be69854aa96d871fe1dd81d83f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MidpointCut.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.TwoPoint.Bounds.LitBlockGeometry + +namespace OAI + +/-! Force the trace midpoint boundary by charging one extra imperfect position. -/ + +namespace TwoPointCorrelations + +open Finset + +theorem imperfectColumnCount_eq_card_compl {n : ℕ} (perfect : Finset (Fin n)) : + imperfectColumnCount perfect = perfectᶜ.card := by + classical + let entries := (List.finRange n).filter (fun i => !decide (i ∈ perfect)) + have he : columnPositionEntries perfect = + (List.finRange n).map (fun i => (i, decide (i ∈ perfect))) := by + simp [columnPositionEntries, List.finRange, List.map_ofFn, Function.comp_def] + have hn : entries.Nodup := (List.nodup_finRange n).filter _ + have hs : entries.toFinset = perfectᶜ := by + ext i + simp [entries] + rw [imperfectColumnCount, he, List.filter_map, List.length_map] + change entries.length = perfectᶜ.card + rw [← List.toFinset_card_of_nodup hn, hs] + +theorem imperfectColumnCount_erase_le {n : ℕ} (perfect : Finset (Fin n)) (cut : Fin n) : + imperfectColumnCount (perfect.erase cut) ≤ imperfectColumnCount perfect + 1 := by + classical + rw [imperfectColumnCount_eq_card_compl, imperfectColumnCount_eq_card_compl] + have hs : (perfect.erase cut)ᶜ ⊆ insert cut perfectᶜ := by + intro i hi + by_cases he : i = cut + · simp [he] + · have hp : i ∉ perfect := by + intro hip + exact (mem_compl.mp hi) (mem_erase.mpr ⟨he, hip⟩) + exact mem_insert_of_mem (mem_compl.mpr hp) + exact (card_le_card hs).trans (card_insert_le _ _) + +/-- A block containing only retained perfect positions cannot cross the +erased midpoint. The erased step is still encoded by its ordinary +imperfect-position reference. -/ +theorem perfect_block_avoids_cut {n : ℕ} (perfect : Finset (Fin n)) (cut : Fin n) + (start len : ℕ) (_hend : start + len ≤ n) + (hperfect : ∀ t ∈ intervalPositions (start, len), + columnNatPerfect (perfect.erase cut) t = true) : + start + len ≤ cut.val ∨ cut.val < start := by + by_contra h + have hlo : start ≤ cut.val := by omega + have hhi : cut.val < start + len := by omega + have hm : cut.val ∈ intervalPositions (start, len) := by + simp only [intervalPositions, List.mem_map, List.mem_range] + exact ⟨cut.val - start, by omega, by omega⟩ + have hp := hperfect cut.val hm + simp [columnNatPerfect_fin] at hp + +theorem isChain_slice_of_two_halves {α : Type*} {R : α → α → Prop} + (w : List α) (cut start len : ℕ) + (hleft : (w.take cut).IsChain R) (hright : (w.drop cut).IsChain R) + (hside : start + len ≤ cut ∨ cut ≤ start) : + ((w.drop start).take len).IsChain R := by + rcases hside with hl | hr + · have hs := (hleft.drop start).take len + simpa only [List.drop_take, List.take_take, Nat.min_eq_left (by omega : len ≤ cut - start)] using hs + · have hs := (hright.drop (start - cut)).take len + simpa only [List.drop_drop, Nat.add_sub_cancel' hr] using hs + +/-- The two actual nonbacktracking halves suffice for every retained +perfect block; no relation between the two midpoint tuples is needed. -/ +theorem trace_perfect_block_chain {n : ℕ} (perfect : Finset (Fin n)) (cut : Fin n) + (w : List SignedStep) + (hleft : (w.take cut.val).IsChain (fun a b => a.tuple ≠ b.tuple)) + (hright : (w.drop cut.val).IsChain (fun a b => a.tuple ≠ b.tuple)) + (start len : ℕ) (hend : start + len ≤ n) + (hperfect : ∀ t ∈ intervalPositions (start, len), + columnNatPerfect (perfect.erase cut) t = true) : + (wordSlice w start (start + len)).IsChain (fun a b => a.tuple ≠ b.tuple) := by + have hs := perfect_block_avoids_cut perfect cut start len hend hperfect + have hc := isChain_slice_of_two_halves w cut.val start len hleft hright + (hs.imp_right Nat.le_of_lt) + simpa only [wordSlice, Nat.add_sub_cancel_left] using hc + +/-- The one additional midpoint reference fits inside the same imperfect +budget once the singleton and unlit exceptional classes have been removed. -/ +theorem eventually_imperfect_with_cut_bound : + ∀ᶠ L : ℝ in Filter.atTop, ∀ singletons unlit imperfect : ℕ, + imperfect ≤ singletons + unlit + 1 → + (singletons : ℝ) ≤ L ^ (1 / 4 : ℝ) → + (unlit : ℝ) ≤ L ^ (1 / 50 : ℝ) → + (imperfect : ℝ) ≤ 2 * L ^ (1 / 4 : ℝ) := by + have hp := (tendsto_rpow_atTop (show 0 < (23 / 100 : ℝ) by norm_num)).eventually + (Filter.eventually_ge_atTop 2) + filter_upwards [Filter.eventually_ge_atTop (1 : ℝ), hp] with L hL hp + intro S U I hI hS hU + have hone : 1 ≤ L ^ (1 / 50 : ℝ) := Real.one_le_rpow hL (by norm_num) + have he : L ^ (1 / 50 : ℝ) * L ^ (23 / 100 : ℝ) = L ^ (1 / 4 : ℝ) := by + rw [← Real.rpow_add (by linarith : 0 < L)] + norm_num + have hprod := mul_le_mul_of_nonneg_left hp (Real.rpow_nonneg (by linarith) (1 / 50 : ℝ)) + have hi : (I : ℝ) ≤ (S : ℝ) + U + 1 := by exact_mod_cast hI + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MixedDifference.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MixedDifference.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5b9f3a0a115eb096f40ce54b0da29e1a163384d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MixedDifference.lean @@ -0,0 +1,236 @@ +import OAI.NumberTheory.TwoPoint.Bounds.IndependentSampling + +namespace OAI + +/-! +# Exact singleton centering + +The product sampling law is kept fixed. Forcing a coordinate overwrites +that coordinate of the same sample, rather than drawing fresh coordinates +at different sites. This is the algebraic part of `q:mixed-difference`. +-/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι A : Type*} [Fintype ι] [DecidableEq ι] [Fintype A] [DecidableEq A] + +def forceCoordinates (S : Finset ι) (a x : ι → A) : ι → A := S.piecewise a x + +omit [Fintype ι] [Fintype A] [DecidableEq A] in +@[simp] lemma forceCoordinates_apply (S : Finset ι) (a x : ι → A) (i : ι) : + forceCoordinates S a x i = if i ∈ S then a i else x i := rfl + +noncomputable def mixedDifference (a : ι → A) (F : (ι → A) → ℝ) (x : ι → A) : ℝ := + ∑ S : Finset ι, (-1 : ℝ) ^ Sᶜ.card * F (forceCoordinates S a x) + +namespace FiniteLaw + +omit [DecidableEq A] in +lemma average_const_mul (μ : FiniteLaw A) (c : ℝ) (f : A → ℝ) : + μ.average (fun x => c * f x) = c * μ.average f := by + simp only [average, Finset.mul_sum] + apply sum_congr rfl + intro x _ + ring + +omit [DecidableEq A] in +lemma abs_average_le (μ : FiniteLaw A) (f : A → ℝ) : + |μ.average f| ≤ μ.average (fun x => |f x|) := by + unfold average + apply (abs_sum_le_sum_abs _ _).trans_eq + apply sum_congr rfl + intro x _ + rw [abs_mul, abs_of_nonneg (μ.nonneg x)] + +lemma average_singleton_pin (μ : FiniteLaw A) (a : A) (F : A → ℝ) : + μ.average (fun x => (if x = a then (1 : ℝ) else 0) * F x) = μ.weight a * F a := by + simp [average] + +lemma singleton_centering (μ : FiniteLaw A) (a : A) (F : A → ℝ) : + μ.average (fun x => ((if x = a then (1 : ℝ) else 0) - μ.weight a) * F x) = + μ.weight a * μ.average (fun x => F a - F x) := by + have hexp : μ.average (fun x => ((if x = a then (1 : ℝ) else 0) - μ.weight a) * F x) = + μ.average (fun x => (if x = a then (1 : ℝ) else 0) * F x) - μ.weight a * μ.average F := by + simp only [average, mul_sub, sub_mul, sum_sub_distrib, mul_sum] + congr 1 + apply sum_congr rfl + intro x _ + ring + rw [hexp, average_singleton_pin] + have hsub : μ.average (fun x => F a - F x) = F a - μ.average F := by + simp only [average, mul_sub, sum_sub_distrib, ← sum_mul, μ.total, one_mul] + rw [hsub] + ring + +lemma independent_average_pin (μ : ι → FiniteLaw A) (a : ι → A) (F : (ι → A) → ℝ) : + (independent μ).average (fun x => (∏ i, if x i = a i then (1 : ℝ) else 0) * F x) = + (∏ i, (μ i).weight (a i)) * F a := by + have hpin (x : ι → A) : (∏ i, if x i = a i then (1 : ℝ) else 0) = + if x = a then (1 : ℝ) else 0 := by + by_cases hx : x = a + · simp [hx] + · have hn : ¬∀ i, x i = a i := fun h => hx (funext h) + simp [Fintype.prod_boole, hx, hn] + simp only [hpin] + exact average_singleton_pin (independent μ) a F + +omit [Fintype ι] [Fintype A] [DecidableEq A] in +lemma force_join (S : Finset ι) (a : ι → A) + (x : S → A) (y : {i // i ∉ S} → A) : + forceCoordinates S a (joinCoordinates S x y) = + joinCoordinates S (fun i : S => a i) y := by + funext i + by_cases hi : i ∈ S <;> simp [forceCoordinates, piecewise, joinCoordinates, hi] + +/-- Forcing a selected set has precisely the product mass of its forced +atoms, even when the observable depends on every other coordinate. -/ +theorem independent_forcing (μ : ι → FiniteLaw A) (S : Finset ι) + (a : ι → A) (F : (ι → A) → ℝ) : + (independent μ).average (fun x => + (∏ i ∈ S, if x i = a i then (1 : ℝ) else 0) * F x) = + (∏ i ∈ S, (μ i).weight (a i)) * + (independent μ).average (fun x => F (forceCoordinates S a x)) := by + rw [independent_average_split μ S] + have hin (y : {i // i ∉ S} → A) : + (independent (fun i : S => μ i)).average (fun x => + (∏ i ∈ S, if joinCoordinates S x y i = a i then (1 : ℝ) else 0) * + F (joinCoordinates S x y)) = + (∏ i ∈ S, (μ i).weight (a i)) * F (joinCoordinates S (fun i : S => a i) y) := by + have hpin := independent_average_pin (fun i : S => μ i) (fun i : S => a i) + (fun x => F (joinCoordinates S x y)) + have hp (x : S → A) : + (∏ i ∈ S, if joinCoordinates S x y i = a i then (1 : ℝ) else 0) = + ∏ i : S, if x i = a i then (1 : ℝ) else 0 := by + rw [← Finset.prod_coe_sort S] + simp only [joinCoordinates_mem] + simp_rw [hp] + rw [← Finset.prod_coe_sort S] + exact hpin + simp_rw [hin] + rw [average_const_mul, independent_average_split μ S (fun x => F (forceCoordinates S a x))] + congr 1 + apply congrArg (independent (fun i : {i // i ∉ S} => μ i)).average + funext y + simp only [force_join, average_const] + +/-- Centering every singleton is exactly the alternating sum over forcing +subsets, before any absolute value is taken. -/ +theorem exact_mixed_centering (μ : ι → FiniteLaw A) (a : ι → A) + (F : (ι → A) → ℝ) : + (independent μ).average (fun x => + (∏ i, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i))) * F x) = + (∏ i, (μ i).weight (a i)) * (independent μ).average (mixedDifference a F) := by + have hexp (x : ι → A) : + (∏ i, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i))) = + ∑ S : Finset ι, (-1 : ℝ) ^ Sᶜ.card * (∏ i ∈ Sᶜ, (μ i).weight (a i)) * + ∏ i ∈ S, if x i = a i then (1 : ℝ) else 0 := by + simp only [sub_eq_add_neg, Fintype.prod_add, prod_neg] + apply sum_congr rfl + intro S _ + ring + have hm : (independent μ).average (mixedDifference a F) = + ∑ S : Finset ι, (-1 : ℝ) ^ Sᶜ.card * + (independent μ).average (fun x => F (forceCoordinates S a x)) := by + unfold mixedDifference + rw [average_sum] + simp_rw [average_const_mul] + simp_rw [hexp, sum_mul] + rw [average_sum, hm, mul_sum] + apply sum_congr rfl + intro S _ + have hc : (∏ i ∈ Sᶜ, (μ i).weight (a i)) * + (∏ i ∈ S, (μ i).weight (a i)) = ∏ i, (μ i).weight (a i) := by + rw [mul_comm, prod_mul_prod_compl] + calc + _ = ((-1 : ℝ) ^ Sᶜ.card * (∏ i ∈ Sᶜ, (μ i).weight (a i))) * + (independent μ).average (fun x => + (∏ i ∈ S, if x i = a i then (1 : ℝ) else 0) * F x) := by + rw [← average_const_mul] + congr 1 + funext x + ring + _ = ((-1 : ℝ) ^ Sᶜ.card * (∏ i ∈ Sᶜ, (μ i).weight (a i))) * + ((∏ i ∈ S, (μ i).weight (a i)) * + (independent μ).average (fun x => F (forceCoordinates S a x))) := by + rw [independent_forcing] + _ = (-1 : ℝ) ^ Sᶜ.card * + ((∏ i ∈ Sᶜ, (μ i).weight (a i)) * (∏ i ∈ S, (μ i).weight (a i))) * + (independent μ).average (fun x => F (forceCoordinates S a x)) := by ring + _ = _ := by rw [hc]; ring + +theorem mixed_centering_bound (μ : ι → FiniteLaw A) (a : ι → A) + (F : (ι → A) → ℝ) : + |(independent μ).average (fun x => + (∏ i, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i))) * F x)| ≤ + (∏ i, (μ i).weight (a i)) * + (independent μ).average (fun x => |mixedDifference a F x|) := by + rw [exact_mixed_centering, abs_mul, abs_of_nonneg + (prod_nonneg (fun i _ => (μ i).nonneg _))] + exact mul_le_mul_of_nonneg_left (abs_average_le _ _) + (prod_nonneg (fun i _ => (μ i).nonneg _)) + +/-- A designated trace term: lit nonsingletons are pinned and singleton +coordinates are centered. The scalar includes all unlit signs and every +factor independent of these residue draws. -/ +theorem exact_designated_centering {κ C : Type*} [Fintype κ] [DecidableEq κ] + [Fintype C] [DecidableEq C] + (μ : ι → FiniteLaw A) (ν : κ → FiniteLaw C) (a : ι → A) (b : κ → C) + (s : ℝ) (F : (ι → A) → (κ → C) → ℝ) : + (independent μ).average (fun x => (independent ν).average (fun y => + s * (∏ i, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i))) * + (∏ j, if y j = b j then (1 : ℝ) else 0) * F x y)) = + s * (∏ j, (ν j).weight (b j)) * (∏ i, (μ i).weight (a i)) * + (independent μ).average (mixedDifference a (fun x => F x b)) := by + have hpin (x : ι → A) : + (independent ν).average (fun y => + s * (∏ i, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i))) * + (∏ j, if y j = b j then (1 : ℝ) else 0) * F x y) = + s * (∏ j, (ν j).weight (b j)) * + ((∏ i, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i))) * F x b) := by + calc + _ = (s * (∏ i, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i)))) * + (independent ν).average (fun y => + (∏ j, if y j = b j then (1 : ℝ) else 0) * F x y) := by + rw [← average_const_mul] + congr 1 + funext y + ring + _ = _ := by rw [independent_average_pin]; ring + simp_rw [hpin] + rw [average_const_mul, exact_mixed_centering] + ring + +end FiniteLaw + +omit [Fintype A] [DecidableEq A] in +theorem abs_mixedDifference_le (a : ι → A) (F : (ι → A) → ℝ) + (hF : ∀ x, |F x| ≤ 1) (x : ι → A) : + |mixedDifference a F x| ≤ 2 ^ Fintype.card ι := by + unfold mixedDifference + calc + _ ≤ ∑ S : Finset ι, |(-1 : ℝ) ^ Sᶜ.card * F (forceCoordinates S a x)| := + abs_sum_le_sum_abs _ _ + _ ≤ ∑ _S : Finset ι, (1 : ℝ) := by + apply sum_le_sum + intro S _ + simpa only [abs_mul, abs_pow, abs_neg, abs_one, one_pow, one_mul] using + hF (forceCoordinates S a x) + _ = _ := by simp + +omit [Fintype A] [DecidableEq A] in +/-- A nonzero alternating difference has a nonzero hybrid term. -/ +theorem exists_forced_value_ne_zero (a : ι → A) (F : (ι → A) → ℝ) (x : ι → A) + (h : mixedDifference a F x ≠ 0) : + ∃ S : Finset ι, F (forceCoordinates S a x) ≠ 0 := by + by_contra! hc + apply h + unfold mixedDifference + apply sum_eq_zero + intro S _ + rw [hc S, mul_zero] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ModifiedShortSums.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ModifiedShortSums.lean new file mode 100644 index 0000000000000000000000000000000000000000..354f985e2140bebc2f60eed03ee988125504c013 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ModifiedShortSums.lean @@ -0,0 +1,43 @@ +import OAI.NumberTheory.TwoPoint.Bounds.WindowPolynomialBounds + +namespace OAI + +/-! The precise MRT input on actual progression windows, uniformly over +all multiplicative finite-prime changes of the original nonpretentious factor. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem MRTShortExponentialInput.modified_windows + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) : + ∃ C : ℝ, 0 < C ∧ ∀ (P : Finset ℕ) (D : ℕ), 10 ≤ D → ∀ M : ℝ, + ∀ᶠ Y : ℕ in atTop, ∀ b : ℕ → ℂ, Multiplicative b → OneBounded b → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → + ∀ (l : ℕ) [NeZero l] (a : ZMod l) (θ : AddCircle (1 : ℝ)), + (∑ v ∈ range Y, + ‖forwardWindowPolynomial (progressionSequence b l a) D (v + 1) θ‖) / + ((D : ℝ) * (Y + 1 : ℕ)) ≤ + C * (Real.exp (-M / 20) + mrtShortError (Y + 1) D) := by + obtain ⟨C, hC, hbound⟩ := hMRT + refine ⟨C, hC, ?_⟩ + intro P D hD M + obtain ⟨N₀, hN₀⟩ := eventually_atTop.mp (hfnp.eventually_mrt_lower_bound hf P D M) + filter_upwards [eventually_ge_atTop N₀, eventually_ge_atTop D] with Y hYN hYD + intro b hb hbounded heq l _ a θ + have hdist := hN₀ (Y + 1) (by omega) b hbounded heq + have hDr : (0 : ℝ) < D := by exact_mod_cast (by omega : 0 < D) + have hYr : (0 : ℝ) < (Y + 1 : ℕ) := by positivity + apply (div_le_iff₀ (mul_pos hDr hYr)).mpr + have hh := progression_window_sum_from_integral b D Y l a + (C * (D : ℝ) * (Y + 1 : ℕ) * + (Real.exp (-M / 20) + mrtShortError (Y + 1) D)) + (fun α => hbound (Y + 1) D hD (by omega) b hb hbounded M hdist α) θ + convert hh using 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MultiplicativeExtraction.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MultiplicativeExtraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d468e0c13896276c000ec7df8f75a2018f8f061 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MultiplicativeExtraction.lean @@ -0,0 +1,175 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CoprimeExceptionDensity +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftBoundary + +namespace OAI + +/-! Extracting a fixed divisor from two ordinary multiplicative functions. +The failure of coprimality is counted explicitly, including its finite +interval boundary term. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def multiplicativeExtractionGap (f g : ℕ → ℂ) (u d n : ℕ) : ℂ := + f (u * n) * g (u * (n + d)) - f u * g u * f n * g (n + d) + +lemma multiplicativeExtractionGap_eq_zero {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (u d n : ℕ) (hu : 0 < u) (hn : 0 < n) + (hcop : u.Coprime (n * (n + d))) : + multiplicativeExtractionGap f g u d n = 0 := by + obtain ⟨h₁, h₂⟩ := Nat.coprime_mul_iff_right.mp hcop + unfold multiplicativeExtractionGap + rw [hfm u n hu hn h₁, hgm u (n + d) hu (by omega) h₂] + ring + +lemma norm_multiplicativeExtractionGap_le {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf : OneBounded f) (hg : OneBounded g) + (u d n : ℕ) (hu : 0 < u) (hn : 0 < n) : + ‖multiplicativeExtractionGap f g u d n‖ ≤ + 2 * (if ¬u.Coprime (n * (n + d)) then (1 : ℝ) else 0) := by + by_cases hcop : u.Coprime (n * (n + d)) + · rw [multiplicativeExtractionGap_eq_zero hfm hgm u d n hu hn hcop] + simp [hcop] + · simp only [hcop, not_false_eq_true, ite_true, mul_one] + have hn' : 0 < n + d := by omega + have h₁ : ‖f (u * n) * g (u * (n + d))‖ ≤ 1 := by + rw [norm_mul] + calc + _ ≤ (1 : ℝ) * 1 := mul_le_mul (hf _ (Nat.mul_pos hu hn)) + (hg _ (Nat.mul_pos hu hn')) (norm_nonneg _) zero_le_one + _ = _ := one_mul _ + have h₂ : ‖f u * g u * f n * g (n + d)‖ ≤ 1 := by + simp only [norm_mul] + calc + _ ≤ ((1 : ℝ) * 1) * 1 * 1 := by gcongr <;> first | exact hf _ hu | exact hg _ hu | exact hf _ hn | exact hg _ hn' + _ = _ := by norm_num + exact (norm_sub_le _ _).trans (by linarith) + +theorem multiplicativeExtraction_sum_bound {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf : OneBounded f) (hg : OneBounded g) + (u d Y : ℕ) (hu : 0 < u) (P : Finset ℕ) + (hP : ∀ p ∈ P, Nat.Prime p) + (hcover : ∀ p, Nat.Prime p → p ∣ u → p ∈ P) : + ‖positivePrefix (multiplicativeExtractionGap f g u d) Y‖ ≤ + 4 * (Y : ℝ) * (∑ p ∈ P, 1 / (p : ℝ)) + 4 * P.card := by + have hb : ‖positivePrefix (multiplicativeExtractionGap f g u d) Y‖ ≤ + 2 * (coprimeExceptionCount u d Y : ℝ) := by + unfold positivePrefix + calc + _ ≤ ∑ v ∈ range Y, ‖multiplicativeExtractionGap f g u d (v + 1)‖ := norm_sum_le _ _ + _ ≤ ∑ v ∈ range Y, + 2 * (if ¬u.Coprime ((v + 1) * (v + 1 + d)) then (1 : ℝ) else 0) := by + apply sum_le_sum + intro v _ + exact norm_multiplicativeExtractionGap_le hfm hgm hf hg u d (v + 1) hu (by omega) + _ = _ := by simp [coprimeExceptionCount, mul_sum] + have hc := coprimeExceptionCount_bound u d Y P hP hcover + nlinarith only [hb, hc] + +/-- Bounded cutoffs and progression indicators may be inserted before +the absolute value; their dependence on the integer is unrestricted. -/ +theorem weightedMultiplicativeExtraction_sum_bound {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf : OneBounded f) (hg : OneBounded g) + (u d Y : ℕ) (hu : 0 < u) (P : Finset ℕ) + (hP : ∀ p ∈ P, Nat.Prime p) + (hcover : ∀ p, Nat.Prime p → p ∣ u → p ∈ P) + (q : ℕ → ℂ) (K : ℝ) (hK : 0 ≤ K) (hq : ∀ n, 0 < n → ‖q n‖ ≤ K) : + ‖positivePrefix (fun n => q n * multiplicativeExtractionGap f g u d n) Y‖ ≤ + K * (4 * (Y : ℝ) * (∑ p ∈ P, 1 / (p : ℝ)) + 4 * P.card) := by + have hb : ‖positivePrefix (fun n => q n * multiplicativeExtractionGap f g u d n) Y‖ ≤ + (K * 2) * (coprimeExceptionCount u d Y : ℝ) := by + unfold positivePrefix + calc + _ ≤ ∑ v ∈ range Y, ‖q (v + 1) * multiplicativeExtractionGap f g u d (v + 1)‖ := + norm_sum_le _ _ + _ ≤ ∑ v ∈ range Y, + K * (2 * (if ¬u.Coprime ((v + 1) * (v + 1 + d)) then (1 : ℝ) else 0)) := by + apply sum_le_sum + intro v _ + rw [norm_mul] + exact mul_le_mul (hq (v + 1) (by omega)) + (norm_multiplicativeExtractionGap_le hfm hgm hf hg u d (v + 1) hu (by omega)) + (norm_nonneg _) hK + _ = _ := by simp [coprimeExceptionCount, mul_sum] + have hc := mul_le_mul_of_nonneg_left (coprimeExceptionCount_bound u d Y P hP hcover) (by positivity : 0 ≤ K * 2) + nlinarith only [hb, hc] + +/-- Arbitrary finite shift families retain only their coefficient mass; +the exceptional-residue bound is uniform in the chosen shifts. -/ +theorem finiteShift_extraction_sum_bound {ι : Type*} {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf : OneBounded f) (hg : OneBounded g) + (u Y : ℕ) (hu : 0 < u) (P : Finset ℕ) + (hP : ∀ p ∈ P, Nat.Prime p) + (hcover : ∀ p, Nat.Prime p → p ∣ u → p ∈ P) + (S : Finset ι) (a : ι → ℂ) (d : ι → ℕ) (q : ι → ℕ → ℂ) + (K : ℝ) (hK : 0 ≤ K) (hq : ∀ i ∈ S, ∀ n, 0 < n → ‖q i n‖ ≤ K) : + ‖∑ i ∈ S, a i * positivePrefix (fun n => q i n * multiplicativeExtractionGap f g u (d i) n) Y‖ ≤ + (∑ i ∈ S, ‖a i‖) * + (K * (4 * (Y : ℝ) * (∑ p ∈ P, 1 / (p : ℝ)) + 4 * P.card)) := by + calc + _ ≤ ∑ i ∈ S, ‖a i * positivePrefix + (fun n => q i n * multiplicativeExtractionGap f g u (d i) n) Y‖ := norm_sum_le _ _ + _ ≤ ∑ i ∈ S, ‖a i‖ * + (K * (4 * (Y : ℝ) * (∑ p ∈ P, 1 / (p : ℝ)) + 4 * P.card)) := by + apply sum_le_sum + intro i hi + rw [norm_mul] + exact mul_le_mul_of_nonneg_left + (weightedMultiplicativeExtraction_sum_bound hfm hgm hf hg u (d i) Y hu P hP hcover + (q i) K hK (hq i hi)) (norm_nonneg _) + _ = _ := (sum_mul _ _ _).symm + +theorem multiplicativeExtraction_average_bound {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf : OneBounded f) (hg : OneBounded g) + (u d Y : ℕ) (hu : 0 < u) (hY : 0 < Y) (P : Finset ℕ) + (hP : ∀ p ∈ P, Nat.Prime p) + (hcover : ∀ p, Nat.Prime p → p ∣ u → p ∈ P) : + ‖positivePrefix (multiplicativeExtractionGap f g u d) Y / (Y : ℂ)‖ ≤ + 4 * (∑ p ∈ P, 1 / (p : ℝ)) + 4 * P.card / (Y : ℝ) := by + have hY' : (0 : ℝ) < Y := by exact_mod_cast hY + rw [norm_div, Complex.norm_natCast] + apply (div_le_iff₀ hY').mpr + calc + _ ≤ 4 * (Y : ℝ) * (∑ p ∈ P, 1 / (p : ℝ)) + 4 * P.card := + multiplicativeExtraction_sum_bound hfm hgm hf hg u d Y hu P hP hcover + _ = _ := by field_simp + +lemma primeReciprocalSum_le_card_div (P : Finset ℕ) (P₀ : ℝ) (hP₀ : 0 < P₀) + (hlarge : ∀ p ∈ P, P₀ ≤ (p : ℝ)) : + (∑ p ∈ P, 1 / (p : ℝ)) ≤ P.card / P₀ := by + calc + _ ≤ ∑ _p ∈ P, 1 / P₀ := by + apply sum_le_sum + intro p hp + exact one_div_le_one_div_of_le hP₀ (hlarge p hp) + _ = _ := by simp [div_eq_mul_inv] + +theorem multiplicativeExtraction_rough_bound {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf : OneBounded f) (hg : OneBounded g) + (u d Y : ℕ) (hu : 0 < u) (hY : 0 < Y) (P : Finset ℕ) + (hP : ∀ p ∈ P, Nat.Prime p) + (hcover : ∀ p, Nat.Prime p → p ∣ u → p ∈ P) + (P₀ : ℝ) (hP₀ : 0 < P₀) (hlarge : ∀ p ∈ P, P₀ ≤ (p : ℝ)) : + ‖positivePrefix (multiplicativeExtractionGap f g u d) Y / (Y : ℂ)‖ ≤ + 4 * (P.card : ℝ) / P₀ + 4 * P.card / (Y : ℝ) := by + have hb := multiplicativeExtraction_average_bound hfm hgm hf hg u d Y hu hY P hP hcover + have hs := primeReciprocalSum_le_card_div P P₀ hP₀ hlarge + calc + _ ≤ 4 * ((P.card : ℝ) / P₀) + 4 * P.card / (Y : ℝ) := + hb.trans (add_le_add + (mul_le_mul_of_nonneg_left hs (show (0 : ℝ) ≤ 4 by norm_num)) + (le_refl (4 * P.card / (Y : ℝ)))) + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/MultiplicativePrimeProducts.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/MultiplicativePrimeProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..415f98e705e70c65f1a513c07676700c1999d21f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/MultiplicativePrimeProducts.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Basic +import Mathlib.Data.Nat.GCD.BigOperators + +namespace OAI + +/-! Finite squarefree products of an ordinary multiplicative function, +and the elementary defect inequality used in selecting raw divisors. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma Multiplicative.prime_product {f : ℕ → ℂ} (hf : Multiplicative f) + (hf1 : f 1 = 1) (S : Finset ℕ) (hS : ∀ p ∈ S, p.Prime) : + f (∏ p ∈ S, p) = ∏ p ∈ S, f p := by + induction S using Finset.induction_on with + | empty => simp [hf1] + | @insert p S hp ih => + have hprime : p.Prime := hS p (mem_insert_self _ _) + have hsub : ∀ q ∈ S, q.Prime := fun q hq => hS q (mem_insert_of_mem hq) + have hcop : p.Coprime (∏ q ∈ S, q) := by + apply Nat.coprime_prod_right_iff.mpr + intro q hq + exact (Nat.coprime_primes hprime (hsub q hq)).mpr (by + intro he + exact hp (he ▸ hq)) + rw [prod_insert hp, hf p _ hprime.pos (prod_pos (fun q hq => (hsub q hq).pos)) hcop, + ih hsub, prod_insert hp] + +lemma one_sub_prod_le_sum {ι : Type*} (S : Finset ι) (r : ι → ℝ) + (h0 : ∀ i ∈ S, 0 ≤ r i) (h1 : ∀ i ∈ S, r i ≤ 1) : + 1 - ∏ i ∈ S, r i ≤ ∑ i ∈ S, (1 - r i) := by + classical + induction S using Finset.induction_on with + | empty => simp + | @insert i S hi ih => + have hs0 : ∀ j ∈ S, 0 ≤ r j := fun j hj => h0 j (mem_insert_of_mem hj) + have hs1 : ∀ j ∈ S, r j ≤ 1 := fun j hj => h1 j (mem_insert_of_mem hj) + have hp := prod_le_one₀ hs0 hs1 + have hr := h1 i (mem_insert_self _ _) + have hm := mul_le_of_le_one_left (sub_nonneg.mpr hp) hr + rw [prod_insert hi, sum_insert hi] + have hh := ih hs0 hs1 + nlinarith + +lemma multiplicative_prime_product_defect {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf1 : f 1 = 1) (hg1 : g 1 = 1) + (hf : OneBounded f) (hg : OneBounded g) + (S : Finset ℕ) (hS : ∀ p ∈ S, p.Prime) : + 1 - ‖f (∏ p ∈ S, p) * g (∏ p ∈ S, p)‖ ≤ + ∑ p ∈ S, (1 - ‖f p * g p‖) := by + rw [hfm.prime_product hf1 S hS, hgm.prime_product hg1 S hS, + ← prod_mul_distrib, norm_prod] + apply one_sub_prod_le_sum + · intro p _ + positivity + · intro p hp + rw [norm_mul] + exact (mul_le_mul (hf p (hS p hp).pos) (hg p (hS p hp).pos) + (norm_nonneg _) zero_le_one).trans (by norm_num) + +lemma prime_product_pair_defect {f g : ℕ → ℂ} + (hf : OneBounded f) (hg : OneBounded g) (p : ℕ) (hp : 0 < p) : + 1 - ‖f p * g p‖ ≤ (1 - ‖f p‖) + (1 - ‖g p‖) := by + rw [norm_mul] + nlinarith [mul_nonneg (sub_nonneg.mpr (hf p hp)) (sub_nonneg.mpr (hg p hp))] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/NearbyCutoffs.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/NearbyCutoffs.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f88d385caaf4b153be95b7b21cbaebb5fbef170 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/NearbyCutoffs.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftBoundary +import Mathlib.Analysis.SpecialFunctions.Exp + +namespace OAI + +/-! A bounded positive-prefix mean changes little when the real cutoff +is moved within one logarithmic bin. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma positivePrefix_sub_norm_le (f : ℕ → ℂ) (hf : OneBounded f) + (N M : ℕ) (hNM : N ≤ M) : + ‖positivePrefix f M - positivePrefix f N‖ ≤ (M - N : ℕ) := by + have he : positivePrefix f M = positivePrefix f N + + positivePrefix (fun n => f (N + n)) (M - N) := by + unfold positivePrefix + have hs := sum_range_add (fun n => f (n + 1)) N (M - N) + rw [Nat.add_sub_of_le hNM] at hs + simpa only [Nat.add_assoc] using hs + rw [he, add_sub_cancel_left] + simpa only [mul_one] using norm_positivePrefix_le (fun n => f (N + n)) (M - N) 1 + (fun n hn => hf _ (by omega)) + +lemma real_prefix_nearby (f : ℕ → ℂ) (hf : OneBounded f) (X Y : ℝ) + (hY : 0 < Y) (hYX : Y ≤ X) : + ‖positivePrefix f ⌊Y⌋₊ / (Y : ℂ) - positivePrefix f ⌊X⌋₊ / (X : ℂ)‖ ≤ + 2 * (X - Y) / X + 1 / X := by + have hX : 0 < X := hY.trans_le hYX + have hNM : ⌊Y⌋₊ ≤ ⌊X⌋₊ := Nat.floor_mono hYX + have hN : (⌊Y⌋₊ : ℝ) ≤ Y := Nat.floor_le hY.le + have hM : (⌊X⌋₊ : ℝ) ≤ X := Nat.floor_le hX.le + have hlow := Nat.lt_floor_add_one Y + have hdiff : ((⌊X⌋₊ - ⌊Y⌋₊ : ℕ) : ℝ) ≤ X - Y + 1 := by + rw [Nat.cast_sub hNM] + linarith + have hnormN : ‖positivePrefix f ⌊Y⌋₊‖ ≤ (⌊Y⌋₊ : ℝ) := by + simpa only [mul_one] using norm_positivePrefix_le f ⌊Y⌋₊ 1 hf + have hnorm : ‖positivePrefix f ⌊Y⌋₊‖ ≤ Y := hnormN.trans hN + have hinv : 0 ≤ 1 / Y - 1 / X := by + exact sub_nonneg.mpr (one_div_le_one_div_of_le hY hYX) + have he : positivePrefix f ⌊Y⌋₊ / (Y : ℂ) - positivePrefix f ⌊X⌋₊ / (X : ℂ) = + positivePrefix f ⌊Y⌋₊ * (((1 / Y - 1 / X : ℝ) : ℂ)) - + (positivePrefix f ⌊X⌋₊ - positivePrefix f ⌊Y⌋₊) / (X : ℂ) := by + push_cast + ring + rw [he] + calc + _ ≤ ‖positivePrefix f ⌊Y⌋₊ * (((1 / Y - 1 / X : ℝ) : ℂ))‖ + + ‖(positivePrefix f ⌊X⌋₊ - positivePrefix f ⌊Y⌋₊) / (X : ℂ)‖ := norm_sub_le _ _ + _ = ‖positivePrefix f ⌊Y⌋₊‖ * (1 / Y - 1 / X) + + ‖positivePrefix f ⌊X⌋₊ - positivePrefix f ⌊Y⌋₊‖ / X := by + rw [norm_mul, norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg hinv, + Complex.norm_real, Real.norm_eq_abs, abs_of_pos hX] + _ ≤ Y * (1 / Y - 1 / X) + (X - Y + 1) / X := by + exact add_le_add (mul_le_mul_of_nonneg_right hnorm hinv) + (div_le_div_of_nonneg_right + ((positivePrefix_sub_norm_le f hf _ _ hNM).trans hdiff) hX.le) + _ = _ := by field_simp; ring + +lemma real_prefix_log_bin (f : ℕ → ℂ) (hf : OneBounded f) (X Y η : ℝ) + (hX : 0 < X) (_hη : 0 ≤ η) (hYlow : X * Real.exp (-η) ≤ Y) (hYX : Y ≤ X) : + ‖positivePrefix f ⌊Y⌋₊ / (Y : ℂ) - positivePrefix f ⌊X⌋₊ / (X : ℂ)‖ ≤ + 2 * η + 1 / X := by + have hY : 0 < Y := (mul_pos hX (Real.exp_pos _)).trans_le hYlow + apply (real_prefix_nearby f hf X Y hY hYX).trans + have hexp : 1 - η ≤ Real.exp (-η) := by + have he := Real.add_one_le_exp (-η) + linarith + have hy : X - Y ≤ X * η := by nlinarith + have hd : (X - Y) / X ≤ η := (div_le_iff₀ hX).mpr (by nlinarith) + calc + _ = 2 * ((X - Y) / X) + 1 / X := by ring + _ ≤ _ := by linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/Nonbacktracking.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/Nonbacktracking.lean new file mode 100644 index 0000000000000000000000000000000000000000..576051320122151346c3e84d3d6c32b2d17b7eac --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/Nonbacktracking.lean @@ -0,0 +1,75 @@ +import Mathlib.LinearAlgebra.Pi +import Mathlib.Algebra.BigOperators.Module +import Mathlib.Basic.Complex.Basic + +namespace OAI + +/-! +# Algebraic resolvent transfer for a nonbacktracking operator + +This is the kernel argument in manuscript Lemma `q:noncommuting`. Each +edge operator has its own resolvent; distinct edge operators are never +commuted. The positivity and norm steps are separate from this algebraic +transfer. +-/ + +open scoped BigOperators + +namespace TwoPointCorrelations + +section + +variable {ι E : Type*} [Fintype ι] [DecidableEq ι] + [AddCommGroup E] [Module ℂ E] + +/-- The copy indexed by `i` receives all transitions except the one with +the same index. -/ +def nonbacktracking (B : ι → E →ₗ[ℂ] E) : (ι → E) →ₗ[ℂ] (ι → E) where + toFun z i := ∑ j ∈ Finset.univ.erase i, B j (z j) + map_add' x y := by + funext i + simp [Finset.sum_add_distrib] + map_smul' c x := by + funext i + simp [Finset.smul_sum, smul_sub] + +/-- `R i` is the inverse of `1 + u B i`. These are the only inverse +identities needed to transfer injectivity. -/ +theorem resolvent_transfer_injective (B : ι → E →ₗ[ℂ] E) (u : ℂ) + (R : ι → E →ₗ[ℂ] E) + (hR : ∀ i v, R i v + u • B i (R i v) = v) + (hinj : Function.Injective (fun z : ι → E => z - u • nonbacktracking B z)) : + Function.Injective (fun v : E => v - ∑ i, u • B i (R i v)) := by + intro v w hvw + let z : ι → E := fun i => R i (v - w) + have hsum : ∑ i, u • B i (z i) = v - w := by + have hs : (∑ i, u • B i (R i v)) - (∑ i, u • B i (R i w)) = v - w := by + exact (sub_eq_sub_iff_sub_eq_sub.mp hvw).symm + simpa only [z, map_sub, smul_sub, Finset.sum_sub_distrib] using hs + have hkernel : z - u • nonbacktracking B z = 0 := by + funext i + have hsplit := Finset.sum_erase_add (Finset.univ : Finset ι) + (fun j => u • B j (z j)) (Finset.mem_univ i) + have hri := hR i (v - w) + change z i - u • (∑ j ∈ Finset.univ.erase i, B j (z j)) = 0 + rw [Finset.smul_sum] + change z i - (∑ j ∈ Finset.univ.erase i, u • B j (z j)) = 0 + change z i + u • B i (z i) = v - w at hri + rw [hsum] at hsplit + exact sub_eq_zero.mpr (add_right_cancel (hri.trans hsplit.symm)) + have hz : z = 0 := hinj (by simpa using hkernel) + by_cases hι : Nonempty ι + · obtain ⟨i⟩ := hι + have hzi : R i (v - w) = 0 := by + simpa [z] using congrFun hz i + have hvwzero := hR i (v - w) + rw [hzi, map_zero, smul_zero, add_zero] at hvwzero + exact sub_eq_zero.mp hvwzero.symm + · have : IsEmpty ι := not_nonempty_iff.mp hι + simpa using hvw + +end + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/NonnegativeProgressionAverage.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/NonnegativeProgressionAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..6721ebe2ce047e1ad6867bb4fb2df820a9c346ee --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/NonnegativeProgressionAverage.lean @@ -0,0 +1,41 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteAverages + +namespace OAI + +/-! Positive costs on one progression are controlled by a full interval. +The fixed modulus factor is allowed in the final progression constant. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma uniformAverage_progression_le (f : ℕ → ℝ) (hf : ∀ n, 0 ≤ f n) + (a l N : ℕ) (hl : 0 < l) : + uniformAverage (fun x : Fin N => f (a + l * x.val)) ≤ + (l : ℝ) * uniformAverage (fun y : Fin (l * N) => f (a + y.val)) := by + by_cases hN : N = 0 + · subst N + simp [uniformAverage] + let g : Fin N → Fin (l * N) := fun x => ⟨l * x.val, Nat.mul_lt_mul_of_pos_left x.isLt hl⟩ + have hg : Function.Injective g := by + intro x y he + apply Fin.ext + exact Nat.eq_of_mul_eq_mul_left hl (congrArg Fin.val he) + have hsum : (∑ x : Fin N, f (a + l * x.val)) ≤ + ∑ y : Fin (l * N), f (a + y.val) := by + calc + _ = ∑ y ∈ univ.image g, f (a + y.val) := by + rw [sum_image] + exact fun x _ y _ hxy => hg hxy + _ ≤ _ := sum_le_sum_of_subset_of_nonneg (subset_univ _) (fun y _ _ => hf _) + have hNr : 0 < (N : ℝ) := by exact_mod_cast Nat.pos_of_ne_zero hN + have hlr : 0 < (l : ℝ) := by exact_mod_cast hl + simp only [uniformAverage, Fintype.card_fin, Nat.cast_mul] + calc + _ ≤ (∑ y : Fin (l * N), f (a + y.val)) / N := div_le_div_of_nonneg_right hsum hNr.le + _ = _ := by field_simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/NonrawPrefix.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/NonrawPrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa17c938619b9a073a8a1e7ffb06f34a112eb83a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/NonrawPrefix.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.TwoPoint.Bounds.NonrawReindex +import OAI.NumberTheory.TwoPoint.Bounds.DivisibilityPrefix + +namespace OAI + +/-! Exact finite-prefix assembly of the nonraw expansion at the retained +divisor scale. No endpoint terms are discarded. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma positivePrefix_finset_sum (U : Finset ℕ) (F : ℕ → ℕ → ℂ) (X : ℕ) : + positivePrefix (fun n => ∑ u ∈ U, F u n) X = + ∑ u ∈ U, positivePrefix (F u) X := by + unfold positivePrefix + exact sum_comm + +lemma positivePrefix_const_mul (c : ℂ) (F : ℕ → ℂ) (X : ℕ) : + positivePrefix (fun n => c * F n) X = c * positivePrefix F X := by + simp only [positivePrefix, mul_sum] + +theorem centerDifference_prefix (S T C : Finset ℕ) + (hS : ∀ p ∈ S, Nat.Prime p) (hT : T ⊆ S) (hCT : Disjoint C T) + (a : ℕ → ℂ) (A H τ : ℝ) (θ : ℂ) (F : ℕ → ℕ → ℂ) (X : ℕ) : + positivePrefix (fun x => centerDifference S T C a A H τ θ x (F x)) X = + ∑ u ∈ retainedPrimeDivisors S, (A : ℂ) ^ (u.primeFactors ∩ C).card * + ∑ w ∈ nonrawRoughSupport T H τ u, + ((nonrawRoughData T H τ a θ u).coefficient w / (w : ℂ)) * + positivePrefix (fun z => F (u * z) (u * w)) (X / u) := by + have hpoint (x : ℕ) : centerDifference S T C a A H τ θ x (F x) = + ∑ u ∈ retainedPrimeDivisors S, (A : ℂ) ^ (u.primeFactors ∩ C).card * + ∑ w ∈ nonrawRoughSupport T H τ u, + ((nonrawRoughData T H τ a θ u).coefficient w / (w : ℂ)) * + (natDivisibilityIndicator u x * F x (u * w)) := by + rw [centerDifference_eq_nonraw_sum S T C hS hT hCT a A H τ θ x (F x)] + apply sum_congr rfl + intro u _ + congr 1 + apply sum_congr rfl + intro w _ + ring + calc + _ = positivePrefix (fun x => + ∑ u ∈ retainedPrimeDivisors S, (A : ℂ) ^ (u.primeFactors ∩ C).card * + ∑ w ∈ nonrawRoughSupport T H τ u, + ((nonrawRoughData T H τ a θ u).coefficient w / (w : ℂ)) * + (natDivisibilityIndicator u x * F x (u * w))) X := by + congr 1 + funext x + exact hpoint x + _ = ∑ u ∈ retainedPrimeDivisors S, (A : ℂ) ^ (u.primeFactors ∩ C).card * + ∑ w ∈ nonrawRoughSupport T H τ u, + ((nonrawRoughData T H τ a θ u).coefficient w / (w : ℂ)) * + positivePrefix (fun x => natDivisibilityIndicator u x * F x (u * w)) X := by + rw [positivePrefix_finset_sum] + apply sum_congr rfl + intro u _ + rw [positivePrefix_const_mul, positivePrefix_finset_sum] + congr 1 + apply sum_congr rfl + intro w _ + exact positivePrefix_const_mul _ _ _ + _ = _ := by + apply sum_congr rfl + intro u hu + congr 1 + apply sum_congr rfl + intro w _ + rw [divisibility_positivePrefix _ u X (retainedPrimeDivisor_pos S hS hu)] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/NonrawReindex.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/NonrawReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..719bd462ec3818924f0a31d85ecd5624fd7b99b9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/NonrawReindex.lean @@ -0,0 +1,128 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeSubsetSplitting + +namespace OAI + +/-! Exact numerical reindexing of all nonraw center-band terms. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma primeSubset_product_one_lt_iff (W : Finset ℕ) + (hW : ∀ p ∈ W, Nat.Prime p) : + 1 < (∏ p ∈ W, p) ↔ W.Nonempty := by + constructor + · intro h + by_contra he + have hzero : W = ∅ := not_nonempty_iff_eq_empty.mp he + simp only [hzero, prod_empty, lt_self_iff_false] at h + · exact primeSubset_product_one_lt W hW + +/-- A term is indexed uniquely by its retained integer and removed +integer. The original divisor is their product, without multiplicity. -/ +theorem nonraw_prime_reindex (S T : Finset ℕ) + (hS : ∀ p ∈ S, Nat.Prime p) (hT : T ⊆ S) + (H τ : ℝ) (θ : ℂ) (G : ℕ → ℕ → ℂ) : + (∑ D ∈ S.powerset, ∑ W ∈ (D ∩ T).powerset, + if W.Nonempty ∧ H < ((∏ p ∈ D, p : ℕ) : ℝ) ∧ + ((∏ p ∈ D, p : ℕ) : ℝ) ≤ τ * H + then ((-θ) ^ W.card / ((∏ p ∈ W, p : ℕ) : ℂ)) * + G (∏ p ∈ D \ W, p) (∏ p ∈ D, p) + else 0) = + ∑ u ∈ retainedPrimeDivisors S, ∑ w ∈ nonrawRoughSupport T H τ u, + ((-θ) ^ w.primeFactors.card / (w : ℂ)) * G u (u * w) := by + let F : Finset ℕ → Finset ℕ → ℂ := fun U W => + if 1 < (∏ p ∈ W, p) ∧ + H < (((∏ p ∈ U, p) * (∏ p ∈ W, p) : ℕ) : ℝ) ∧ + (((∏ p ∈ U, p) * (∏ p ∈ W, p) : ℕ) : ℝ) ≤ τ * H + then ((-θ) ^ W.card / ((∏ p ∈ W, p : ℕ) : ℂ)) * + G (∏ p ∈ U, p) ((∏ p ∈ U, p) * (∏ p ∈ W, p)) + else 0 + calc + _ = ∑ D ∈ S.powerset, ∑ W ∈ (D ∩ T).powerset, F (D \ W) W := by + apply sum_congr rfl + intro D hD + apply sum_congr rfl + intro W hW + have hWD : W ⊆ D := (mem_powerset.mp hW).trans inter_subset_left + have hprime : ∀ p ∈ W, Nat.Prime p := fun p hp => hS p (mem_powerset.mp hD (hWD hp)) + dsimp only [F] + simp only [primeSubset_factorization D W hWD, + primeSubset_product_one_lt_iff W hprime] + _ = ∑ U ∈ S.powerset, ∑ W ∈ (T \ U).powerset, F U W := + centerBand_reindex_retained S T hT F + _ = ∑ U ∈ S.powerset, ∑ w ∈ nonrawRoughSupport T H τ (∏ p ∈ U, p), + ((-θ) ^ w.primeFactors.card / (w : ℂ)) * + G (∏ p ∈ U, p) ((∏ p ∈ U, p) * w) := by + apply sum_congr rfl + intro U hU + exact nonraw_subset_sum U T (fun p hp => hS p (mem_powerset.mp hU hp)) + (fun p hp => hS p (hT hp)) H τ θ + (fun w => G (∏ p ∈ U, p) ((∏ p ∈ U, p) * w)) + _ = _ := by + symm + rw [retainedPrimeDivisors, sum_image (primeSubset_product_injective S hS)] + +noncomputable def centerDifference (S T C : Finset ℕ) (a : ℕ → ℂ) + (A H τ : ℝ) (θ : ℂ) (x : ℕ) (F : ℕ → ℂ) : ℂ := + ∑ D ∈ S.powerset, + if H < ((∏ p ∈ D, p : ℕ) : ℝ) ∧ ((∏ p ∈ D, p : ℕ) : ℝ) ≤ τ * H + then a (∏ p ∈ D, p) * (A : ℂ) ^ (D ∩ C).card * F (∏ p ∈ D, p) * + (natDivisibilityIndicator (∏ p ∈ D \ T, p) x * + (∏ p ∈ D ∩ T, (natDivisibilityIndicator p x - θ / (p : ℂ))) - + natDivisibilityIndicator (∏ p ∈ D, p) x) + else 0 + +/-- The literal partially centered-minus-raw sum is exactly the +numerical `u*w` expansion, before estimating or using multiplicativity. -/ +theorem centerDifference_eq_nonraw_sum (S T C : Finset ℕ) + (hS : ∀ p ∈ S, Nat.Prime p) (hT : T ⊆ S) (hCT : Disjoint C T) + (a : ℕ → ℂ) (A H τ : ℝ) (θ : ℂ) (x : ℕ) (F : ℕ → ℂ) : + centerDifference S T C a A H τ θ x F = + ∑ u ∈ retainedPrimeDivisors S, (A : ℂ) ^ (u.primeFactors ∩ C).card * + ∑ w ∈ nonrawRoughSupport T H τ u, + ((nonrawRoughData T H τ a θ u).coefficient w / (w : ℂ)) * + F (u * w) * natDivisibilityIndicator u x := by + let G : ℕ → ℕ → ℂ := fun u d => + (A : ℂ) ^ (u.primeFactors ∩ C).card * a d * F d * natDivisibilityIndicator u x + calc + _ = ∑ D ∈ S.powerset, ∑ W ∈ (D ∩ T).powerset, + if W.Nonempty ∧ H < ((∏ p ∈ D, p : ℕ) : ℝ) ∧ + ((∏ p ∈ D, p : ℕ) : ℝ) ≤ τ * H + then ((-θ) ^ W.card / ((∏ p ∈ W, p : ℕ) : ℂ)) * + G (∏ p ∈ D \ W, p) (∏ p ∈ D, p) + else 0 := by + unfold centerDifference + apply sum_congr rfl + intro D hD + have hprimeD : ∀ p ∈ D, Nat.Prime p := fun p hp => hS p (mem_powerset.mp hD hp) + by_cases hb : H < ((∏ p ∈ D, p : ℕ) : ℝ) ∧ ((∏ p ∈ D, p : ℕ) : ℝ) ≤ τ * H + · simp only [hb, ite_true, and_true] + rw [partialCenterBand_nonraw_expansion D T hprimeD θ x, sum_filter, mul_sum] + apply sum_congr rfl + intro W hW + have hWT : W ⊆ T := (mem_powerset.mp hW).trans inter_subset_right + have hcore : ((∏ p ∈ D \ W, p : ℕ).primeFactors ∩ C).card = (D ∩ C).card := by + rw [Nat.primeFactors_prod (fun p hp => hprimeD p (mem_sdiff.mp hp).1), + primeSubset_core_retained C D W (hCT.mono_right hWT)] + by_cases hne : W.Nonempty + · simp only [hne, ite_true, G, hcore] + ring + · simp only [hne, ite_false, mul_zero] + · simp only [hb, ite_false, and_false, sum_const_zero] + _ = ∑ u ∈ retainedPrimeDivisors S, ∑ w ∈ nonrawRoughSupport T H τ u, + ((-θ) ^ w.primeFactors.card / (w : ℂ)) * G u (u * w) := + nonraw_prime_reindex S T hS hT H τ θ G + _ = _ := by + apply sum_congr rfl + intro u _ + rw [mul_sum] + apply sum_congr rfl + intro w _ + dsimp only [G, nonrawRoughData] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/NonrawRoughData.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/NonrawRoughData.lean new file mode 100644 index 0000000000000000000000000000000000000000..ddd47e3f9f488777b3e3b7560fcc6644f403c25b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/NonrawRoughData.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CutoffDivisorTransfer +import OAI.NumberTheory.TwoPoint.Walks.RetainedDivisorMass +import OAI.NumberTheory.TwoPoint.Bounds.PrimeCountDilation + +namespace OAI + +/-! The rough coefficient families obtained by selecting at least one +constant term in the center-band expansion. Their support and unit bound +are derived from the actual finite prime products. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def nonrawRoughSupport (T : Finset ℕ) (H τ : ℝ) (u : ℕ) : Finset ℕ := + (retainedPrimeDivisors T).filter (fun w => + 1 < w ∧ H < ((u * w : ℕ) : ℝ) ∧ ((u * w : ℕ) : ℝ) ≤ τ * H ∧ u.Coprime w) + +noncomputable def nonrawRoughData (T : Finset ℕ) (H τ : ℝ) + (a : ℕ → ℂ) (θ : ℂ) (u : ℕ) : RoughCoefficients where + support := nonrawRoughSupport T H τ u + coefficient w := a (u * w) * (-θ) ^ w.primeFactors.card + +noncomputable def activeNonrawDivisors (S T : Finset ℕ) (H τ : ℝ) : Finset ℕ := + (retainedPrimeDivisors S).filter (fun u => (nonrawRoughSupport T H τ u).Nonempty) + +lemma nonraw_support_primeFactors {T : Finset ℕ} (hT : ∀ p ∈ T, Nat.Prime p) + {H τ : ℝ} {u w : ℕ} (hw : w ∈ nonrawRoughSupport T H τ u) : + w.primeFactors ⊆ T := + retainedPrimeDivisor_factors T hT (mem_filter.mp hw).1 + +lemma nonraw_support_rough {T : Finset ℕ} (hT : ∀ p ∈ T, Nat.Prime p) + {H τ P₀ : ℝ} (hlarge : ∀ p ∈ T, P₀ ≤ (p : ℝ)) {u w : ℕ} + (hw : w ∈ nonrawRoughSupport T H τ u) : HasNoPrimeFactorBelow P₀ w := by + intro p hp hp₀ hdiv + have hwpos : 0 < w := lt_trans Nat.zero_lt_one (mem_filter.mp hw).2.1 + have hpw : p ∈ w.primeFactors := hp.mem_primeFactors hdiv hwpos.ne' + have hplarge := hlarge p (nonraw_support_primeFactors hT hw hpw) + exact (not_lt_of_ge hplarge) hp₀ + +lemma nonraw_support_bin {T : Finset ℕ} {H τ : ℝ} {u w : ℕ} (hu : 0 < u) + (hw : w ∈ nonrawRoughSupport T H τ u) : + H / (u : ℝ) < (w : ℝ) ∧ (w : ℝ) ≤ τ * (H / (u : ℝ)) := by + have hu' : (0 : ℝ) < u := by exact_mod_cast hu + have hlo : H < (u : ℝ) * w := by simpa only [Nat.cast_mul] using (mem_filter.mp hw).2.2.1 + have hhi : (u : ℝ) * w ≤ τ * H := by simpa only [Nat.cast_mul] using (mem_filter.mp hw).2.2.2.1 + constructor + · apply (div_lt_iff₀ hu').mpr + nlinarith only [hlo] + · calc + _ ≤ (τ * H) / (u : ℝ) := (le_div_iff₀ hu').mpr (by nlinarith only [hhi]) + _ = _ := by ring + +lemma nonrawRoughData_inBin {T : Finset ℕ} (hT : ∀ p ∈ T, Nat.Prime p) + (H τ P₀ : ℝ) (hlarge : ∀ p ∈ T, P₀ ≤ (p : ℝ)) + (a : ℕ → ℂ) (ha : OneBounded a) (θ : ℂ) (hθ : ‖θ‖ ≤ 1) + (u : ℕ) (hu : 0 < u) : + (nonrawRoughData T H τ a θ u).InBin (H / (u : ℝ)) τ P₀ := by + constructor + · intro w hw + exact ⟨(nonraw_support_bin hu hw).1, (nonraw_support_bin hu hw).2, + nonraw_support_rough hT hlarge hw⟩ + · intro w hw + have hwpos : 0 < w := lt_trans Nat.zero_lt_one (mem_filter.mp hw).2.1 + change ‖a (u * w) * (-θ) ^ w.primeFactors.card‖ ≤ 1 + rw [norm_mul, norm_pow, norm_neg] + exact (mul_le_mul (ha _ (Nat.mul_pos hu hwpos)) + (pow_le_one₀ (norm_nonneg θ) hθ) (by positivity) zero_le_one).trans_eq (one_mul 1) + +lemma activeNonrawDivisor_pos {S T : Finset ℕ} (hS : ∀ p ∈ S, Nat.Prime p) + {H τ : ℝ} {u : ℕ} (hu : u ∈ activeNonrawDivisors S T H τ) : 0 < u := + retainedPrimeDivisor_pos S hS (mem_filter.mp hu).1 + +lemma activeNonrawDivisor_lower {S T : Finset ℕ} + (hS : ∀ p ∈ S, Nat.Prime p) (hT : ∀ p ∈ T, Nat.Prime p) + {H τ P₀ : ℝ} (hτ : 0 < τ) (hlarge : ∀ p ∈ T, P₀ ≤ (p : ℝ)) + {u : ℕ} (hu : u ∈ activeNonrawDivisors S T H τ) : + P₀ / τ ≤ H / (u : ℝ) := by + obtain ⟨w, hw⟩ := (mem_filter.mp hu).2 + have hw₁ : 1 < w := (mem_filter.mp hw).2.1 + obtain ⟨p, hp, hpw⟩ := Nat.exists_prime_and_dvd hw₁.ne' + have hwpos : 0 < w := lt_trans Nat.zero_lt_one hw₁ + have hpT := nonraw_support_primeFactors hT hw (hp.mem_primeFactors hpw hwpos.ne') + have hpw' : (p : ℝ) ≤ w := by exact_mod_cast Nat.le_of_dvd hwpos hpw + have hPw : P₀ ≤ (w : ℝ) := (hlarge p hpT).trans hpw' + have hub : (0 : ℝ) < u := by exact_mod_cast activeNonrawDivisor_pos hS hu + have hhi : (u : ℝ) * w ≤ τ * H := by simpa only [Nat.cast_mul] using (mem_filter.mp hw).2.2.2.1 + apply (div_le_div_iff₀ hτ hub).mpr + have hmul := mul_le_mul_of_nonneg_left hPw hub.le + nlinarith only [hhi, hmul] + +lemma nonraw_support_same_core {C T : Finset ℕ} + (hC : ∀ p ∈ C, Nat.Prime p) (hT : ∀ p ∈ T, Nat.Prime p) + (hdisj : Disjoint C T) {H τ : ℝ} {u w : ℕ} + (hw : w ∈ nonrawRoughSupport T H τ u) : + ∀ p ∈ C, p ∣ u * w ↔ p ∣ u := by + intro p hp + have hnot : ¬p ∣ w := by + intro hpw + have hwpos : 0 < w := lt_trans Nat.zero_lt_one (mem_filter.mp hw).2.1 + have hpT := nonraw_support_primeFactors hT hw ((hC p hp).mem_primeFactors hpw hwpos.ne') + exact disjoint_left.mp hdisj hp hpT + simp only [(hC p hp).dvd_mul, hnot, or_false] + +lemma nonraw_cutoff_dilation {C T : Finset ℕ} + (hC : ∀ p ∈ C, Nat.Prime p) (hT : ∀ p ∈ T, Nat.Prime p) + (hdisj : Disjoint C T) {H τ : ℝ} {u w : ℕ} + (hw : w ∈ nonrawRoughSupport T H τ u) (μ σ : ℝ) (F : ℝ → ℂ) (n : ℕ) : + primeCountCutoff (C.filter (fun p => ¬p ∣ u * w)) μ σ F (u * n) = + primeCountCutoff (C.filter (fun p => ¬p ∣ u)) μ σ F n := + primeCountCutoff_same_core_factors C hC (u * w) u n + (nonraw_support_same_core hC hT hdisj hw) μ σ F + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalBins.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..774965d9e7b522816473c62b09da6ff94ecde1bd --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalBins.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingBinMassTotal +import OAI.NumberTheory.TwoPoint.Bounds.BinCutoffGeometry +import OAI.NumberTheory.TwoPoint.Bounds.PrimeTuplePool + +namespace OAI + +/-! One common eligibility predicate for the literal manuscript bins. +Positivity makes the log-product identity valid even outside the prime pools. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def numericalBinEligible (L η : ℝ) (j : ℤ) (d q : ℕ) : Prop := + 0 < d ∧ 0 < q ∧ (q.primeFactors.card : ℝ) ≤ 100 * Real.log L ∧ + actualPaddingBin η (Real.log d) j q + +lemma numericalBinEligible_bin (L η : ℝ) (j : ℤ) (d q : ℕ) + (he : numericalBinEligible L η j d q) : actualPaddingBin η (Real.log d) j q := he.2.2.2 + +lemma numericalBinEligible_pair (L η : ℝ) (hη : 0 < η) (j : ℤ) + (hj : j ∈ paddingBinIndices L η) (d q : ℕ) (he : numericalBinEligible L η j d q) : + PaddingPairEligible L η d q := by + refine ⟨he.2.2.1, ?_⟩ + have hd : (d : ℝ) ≠ 0 := by exact_mod_cast he.1.ne' + have hq : (q : ℝ) ≠ 0 := by exact_mod_cast he.2.1.ne' + have hlog : Real.log (d * q : ℕ) = Real.log q + Real.log d := by + rw [Nat.cast_mul, Real.log_mul hd hq] + ring + have hb : paddingBin η 0 (Real.log (d * q : ℕ)) = j := by + apply (paddingBin_eq_iff η 0 (Real.log (d * q : ℕ)) j hη).mpr + simpa only [actualPaddingBin, hlog, add_zero] using he.2.2.2 + rw [hb] + exact hj + +lemma numericalBin_mass (D Q : Finset ℕ) (hD : ∀ d ∈ D, 0 < d) + (hQ : ∀ p ∈ Q, p.Prime) (L η : ℝ) (hL : 1 ≤ L) : + (∑ j ∈ paddingBinIndices L η, ∑ d ∈ D, + ∑ q ∈ boundedPaddingDivisors Q ⌊100 * Real.log L⌋₊, + if numericalBinEligible L η j d q then + actualPaddingCoefficient q / (d * q : ℕ) else 0) = + totalPaddingBinMass D Q L η := by + unfold totalPaddingBinMass boundedPaddingDivisors + apply sum_congr rfl + intro j _ + apply sum_congr rfl + intro d hd + rw [sum_filter] + apply sum_congr rfl + intro q hq + have hqp := retainedPrimeDivisor_pos Q hQ hq + have hr : q.primeFactors.card ≤ ⌊100 * Real.log L⌋₊ ↔ + (q.primeFactors.card : ℝ) ≤ 100 * Real.log L := + Nat.le_floor_iff (mul_nonneg (by norm_num) (Real.log_nonneg hL)) + have hd0 : (d : ℝ) ≠ 0 := by exact_mod_cast (hD d hd).ne' + have hq0 : (q : ℝ) ≠ 0 := by exact_mod_cast hqp.ne' + have hlog : Real.log (d * q : ℕ) = Real.log q + Real.log d := by + rw [Nat.cast_mul, Real.log_mul hd0 hq0] + ring + simp only [hr, numericalBinEligible, hD d hd, hqp, true_and, actualPaddingBin, + actualPaddingCoefficient, hlog] + split_ifs <;> simp_all + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalColumnCover.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalColumnCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce45f8d852128300db9a0cb68e59661de4e67315 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalColumnCover.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MidpointCut +import OAI.NumberTheory.TwoPoint.Bounds.LowRankColumnCover + +namespace OAI + +/-! A surviving numerical trace word belongs to the universal column code set. -/ + +namespace TwoPointCorrelations.ColumnWordPattern + +open Finset + +variable {α : Type*} [Fintype α] [DecidableEq α] + +/-- The complete column-covering implication. Only the two halves are +assumed nonbacktracking. All positivity premises are actual divisibilities +at the original perfect positions; one midpoint reference is charged to +the imperfect budget. The finite code universe is independent of `value`, +the signs, the padding, and the fixed other-column coefficients. -/ +theorem numerical_column_in_universe (w : ColumnWordPattern α) (hn : 0 < w.length) + (value : α → ℕ) (hvalue : Function.Injective value) (hprime : ∀ z, (value z).Prime) + (hother : ∀ z t, t < w.length → ¬value z ∣ w.otherColumns t) + {h s J r : ℕ} {supply : ℕ → ℕ → Prop} {x : ℤ} (hh : 0 < h) (hs : 0 < s) + (perfect : Finset (Fin w.length)) (cut : Fin w.length) + (hlit : ∀ i ∈ perfect, (w.step value i.val).divisor ∣ + x + wordDisplacement h ((w.word value).take i.val)) + (heligible : ∀ a ∈ w.word value, supply a.tuple a.padding) + (hq : ∀ a ∈ w.word value, 0 < a.padding) + (hsq : ∀ a ∈ w.word value, Squarefree a.tuple) + (hcard : ∀ a ∈ w.word value, a.tuple.primeFactors.card = J) + (hleft : ((w.word value).take cut.val).IsChain (fun a b => a.tuple ≠ b.tuple)) + (hright : ((w.word value).drop cut.val).IsChain (fun a b => a.tuple ≠ b.tuple)) + (hsupport : ∀ p j, TuplePrimeAt (w.word value) p j → + ¬p ∣ h ∧ ∀ a ∈ w.word value, ¬p ∣ a.padding) + (hsurvive : ∀ y, WordVertex h x (w.word value) y → ¬ProhibitedSite h s supply y) + (L : ℝ) (hL : 1 ≤ L) (hnL : (w.length : ℝ) ≤ 2 * L) + (hsL : L ^ (1 / 10 : ℝ) / 2 ≤ (s : ℝ)) + (hrL : (r : ℝ) ≤ L ^ (1 / 50 : ℝ)) + (hI : (imperfectColumnCount (perfect.erase cut) : ℝ) ≤ 2 * L ^ (1 / 4 : ℝ)) + (hno : ∀ S : Finset (EqualLabelPairs + (fun i : perfect.erase cut => w.label i.val.val)), S.card = r → + ¬LinearIndependent ℝ (pairFamily (labelPairVectors + (fun i : perfect.erase cut => w.label i.val.val) + (fun i => formalDeparture (columnNatLabel (fun i : Fin w.length => w.label i.val) hn) + (fun t => (w.coefficient h t : ℝ)) i.val.val)) S)) : + ∃ code : BudgetColumnCode (2 * w.length) L, + decodeBudgetColumnPattern (show w.length ≤ 2 * w.length by omega) code = + fun i j => decide (w.label i.val = w.label j.val) := by + have hg := w.short_geometry_of_lit hn value hvalue hprime hother hh (perfect.erase cut) + (fun i hi => hlit i (mem_of_mem_erase hi)) heligible hq hsq hcard + (fun start len hend _ hp => trace_perfect_block_chain perfect cut (w.word value) + hleft hright start len hend hp) hsupport hsurvive + exact low_rank_column_in_budget_universe (fun i : Fin w.length => w.label i.val) hn + (fun t => (w.coefficient h t : ℝ)) (perfect.erase cut) s r hs L hL hnL hsL hrL hI hno hg + +end TwoPointCorrelations.ColumnWordPattern + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalTupleLabels.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalTupleLabels.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f10c6682746f01115614e9e6457505c62120c31 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalTupleLabels.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SuppliedTupleWords + +namespace OAI + +/-! Prime-slot coverage for the numerical words in the trace catalog. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma ofFn_step_get {R : ℕ} (step : Fin R → SignedStep) (k : Fin (List.ofFn step).length) : + (List.ofFn step).get k = step ⟨k.val, by simpa only [List.length_ofFn] using k.isLt⟩ := by + change (List.ofFn step)[k.val] = _ + simp only [List.getElem_ofFn] + +lemma numerical_label_cover {h J M R : ℕ} (data : ProhibitedPrimeFamily h J M) + (step : Fin R → SignedStep) (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (hlabel : ∀ i, (step i).tuple.primeFactors = univ.image (fun j => (label (i, j)).val)) : + ∀ k : Fin (List.ofFn step).length, ∀ p : ↥(data.P ∪ data.Q), + p.val ∈ ((List.ofFn step).get k).tuple.primeFactors → p ∈ univ.image label := by + intro k p hp + rw [ofFn_step_get, hlabel] at hp + obtain ⟨j, _, hj⟩ := mem_image.mp hp + exact mem_image.mpr ⟨(_, j), mem_univ _, Subtype.ext hj⟩ + +lemma numerical_label_pool {h J M R : ℕ} (data : ProhibitedPrimeFamily h J M) + (step : Fin R → SignedStep) (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (hpairs : ∀ i, ((step i).tuple, (step i).padding) ∈ data.pairs) + (hlabel : ∀ i, (step i).tuple.primeFactors = univ.image (fun j => (label (i, j)).val)) : + ∀ p ∈ univ.image label, p.val ∈ data.P := by + intro p hp + obtain ⟨⟨i, j⟩, _, rfl⟩ := mem_image.mp hp + apply data.tuple_pool _ (hpairs i) + rw [hlabel] + exact mem_image.mpr ⟨j, mem_univ _, rfl⟩ + +lemma numerical_word_pairs {h J M R : ℕ} (data : ProhibitedPrimeFamily h J M) + (step : Fin R → SignedStep) + (hpairs : ∀ i, ((step i).tuple, (step i).padding) ∈ data.pairs) : + ∀ a ∈ List.ofFn step, (a.tuple, a.padding) ∈ data.pairs := by + intro a ha + obtain ⟨i, rfl⟩ := List.mem_ofFn.mp ha + exact hpairs i + +lemma numerical_label_seen {h J M R : ℕ} (data : ProhibitedPrimeFamily h J M) + (step : Fin R → SignedStep) (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (hpairs : ∀ i, ((step i).tuple, (step i).padding) ∈ data.pairs) + (hlabel : ∀ i, (step i).tuple.primeFactors = univ.image (fun j => (label (i, j)).val)) : + ∀ p ∈ univ.image label, p.val ∈ wordDivisorPrimeSupport (List.ofFn step) := by + intro p hp + obtain ⟨⟨i, j⟩, _, rfl⟩ := mem_image.mp hp + apply mem_biUnion.mpr + refine ⟨step i, List.mem_toFinset.mpr (List.mem_ofFn.mpr ⟨i, rfl⟩), ?_⟩ + rw [Nat.primeFactors_mul (data.padding_squarefree _ (hpairs i)).ne_zero + (data.tuple_squarefree _ (hpairs i)).ne_zero] + apply mem_union_right + rw [hlabel] + exact mem_image.mpr ⟨j, mem_univ _, rfl⟩ + +lemma numerical_padding_retained {h J M R B : ℕ} (data : ProhibitedPrimeFamily h J M) + (step : Fin R → SignedStep) (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (hpairs : ∀ i, ((step i).tuple, (step i).padding) ∈ data.pairs) + (hlabel : ∀ i, (step i).tuple.primeFactors = univ.image (fun j => (label (i, j)).val)) + (x : ↥(data.P ∪ data.Q) → Fin B) + (hx : MainPaddingTests Subtype.val h B (List.ofFn step) x) : + RetainedMainTests Subtype.val (univ.image label) h B (List.ofFn step) x := by + apply mainPaddingTests_retained Subtype.val _ h B (List.ofFn step) x + (fun a ha => (data.padding_squarefree _ (numerical_word_pairs data step hpairs a ha)).ne_zero) + (fun a ha => (data.tuple_squarefree _ (numerical_word_pairs data step hpairs a ha)).ne_zero) + (numerical_label_cover data step label hlabel) hx + +lemma numerical_singleton_position {h J M R : ℕ} (data : ProhibitedPrimeFamily h J M) + (step : Fin R → SignedStep) (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (hpairs : ∀ i, ((step i).tuple, (step i).padding) ∈ data.pairs) + (hlabel : ∀ i, (step i).tuple.primeFactors = univ.image (fun j => (label (i, j)).val)) + (c : singletonLabels label) (v : ℕ) + (hv : TuplePrimeAt (List.ofFn step) c.val.val v) : + v = (singletonRepresentative label c).1.val := by + have hvR : v < R := by simpa only [List.length_ofFn] using hv.index_lt + let i : Fin R := ⟨v, hvR⟩ + have hd := ((tuplePrimeAt_iff_getElem _ _ _ hv.index_lt).mp hv).2 + have hd' : c.val.val ∣ (step i).tuple := by + simpa only [List.getElem_ofFn] using hd + have hm : c.val.val ∈ (step i).tuple.primeFactors := + Nat.mem_primeFactors.mpr ⟨hv.1, hd', (data.tuple_squarefree _ (hpairs i)).ne_zero⟩ + rw [hlabel] at hm + obtain ⟨j, _, hj⟩ := mem_image.mp hm + have he : label (i, j) = c.val := Subtype.ext hj + exact congrArg (fun t : Fin R × Fin J => t.1.val) + (singleton_occurrence_unique label c (i, j) he) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalWitnessEncoding.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalWitnessEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..74aa2f5bb1f216e748ed520132debf6f3398f8ca --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalWitnessEncoding.lean @@ -0,0 +1,114 @@ +import OAI.NumberTheory.TwoPoint.Walks.WitnessRelabel +import OAI.NumberTheory.TwoPoint.Bounds.EncodedWitnessSum + +namespace OAI + +/-! Actual numerical witness families are covered by the prime-slot catalog. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma LabeledPrimeWord.realizes_support_covered {ι : Type*} [DecidableEq ι] + (w : LabeledPrimeWord ι) (value : ι → ℕ) (hw : w.Realizes value) + (hprime : ∀ i, (value i).Prime) (r : ℕ) (hr : r ∈ wordPrimeSupport w.word) : + ∃ i, value i = r := by + obtain ⟨t, ht, hr⟩ := (mem_wordPrimeSupport r w.word).mp hr + obtain ⟨k, hk⟩ := List.get_of_mem ht + have hpr := (Nat.mem_primeFactors.mp hr).1 + have hdvd := (Nat.mem_primeFactors.mp hr).2.1 + have htup : (∏ i ∈ w.labels k, value i) = t.tuple := (hw k).trans (congrArg SignedStep.tuple hk) + rw [← htup] at hdvd + obtain ⟨i, _, hi⟩ := (hpr.prime.dvd_finsetProd_iff value).mp hdvd + exact ⟨i, ((Nat.prime_dvd_prime_iff_eq hpr (hprime i)).mp hi).symm⟩ + +lemma wordPrimeSupport_mono {v w : List SignedStep} + (hvw : ∀ t ∈ v, t ∈ w) : wordPrimeSupport v ⊆ wordPrimeSupport w := by + intro p hp + obtain ⟨t, ht, hpt⟩ := (mem_wordPrimeSupport p v).mp hp + exact (mem_wordPrimeSupport p w).mpr ⟨t, hvw t ht, hpt⟩ + +lemma PrimeWordEncoding.tuple_support_covered {R T : ℕ} {P Q : Finset ℕ} + (e : PrimeWordEncoding R T P Q) (hc : e.2.1.KindConsistent) + (hi : e.2.1.RowInjective) (hP : ∀ p ∈ P, p.Prime) + (r : ℕ) (hr : r ∈ wordPrimeSupport e.decode) : + ∃ z, (e.2.2.1 z).val = r := by + let a := fun z => (e.2.2.1 z).val + let b := fun z => (e.2.2.2 z).val + have he := e.2.1.labeledWord_resample hc hi a b + apply ((e.2.1.labeledWord b).resample a).realizes_support_covered a + ((e.2.1.labeledWord b).resample_realizes a) (fun z => hP _ (e.2.2.1 z).property) r + rw [he] + exact hr + +theorem PrimeWordEncoding.covers_witnesses {R T n : ℕ} {P Q : Finset ℕ} + (w : Fin R → SignedStep) + (hT : Fintype.card (ActualPrimeSlot w) ≤ T) + (ht : ∀ i, Squarefree (w i).tuple) (hq : ∀ i, Squarefree (w i).padding) + (hP : ∀ i, (w i).tuple.primeFactors ⊆ P) + (hQ : ∀ i, (w i).padding.primeFactors ⊆ Q) + (hd : ∀ i j, Disjoint (w i).tuple.primeFactors (w j).padding.primeFactors) + (hprime : ∀ p ∈ P, p.Prime) + (mainLength : ℕ) (start len : Fin n → ℕ) (h s J : ℕ) (supply : ℕ → ℕ → Prop) + {ι : Type*} (p : ι → ℕ) + (hnum : NumericalWitnessEvent ((List.ofFn w).take mainLength) + (fun i => ((List.ofFn w).drop (start i)).take (len i)) p h s J supply) : + ∃ e : PrimeWordEncoding R T P Q, e.Witnesses n mainLength start len h s J supply ∧ + e.decode = List.ofFn w ∧ + e.weight = ∏ q ∈ wordDivisorPrimeSupport (List.ofFn w), (q : ℝ)⁻¹ := by + obtain ⟨e, he, hc, hi, hinj, hweight⟩ := covers w hT ht hq hP hQ hd + have hnum' : NumericalWitnessEvent (e.decode.take mainLength) + (fun i => (e.decode.drop (start i)).take (len i)) p h s J supply := by + simpa only [he] using hnum + have hcover (i : Fin n) (r : ℕ) + (hr : r ∈ wordPrimeSupport ((e.decode.drop (start i)).take (len i))) : + ∃ z, (e.2.2.1 z).val = r := by + apply e.tuple_support_covered hc hi hprime r + apply wordPrimeSupport_mono (fun t ht => List.mem_of_mem_drop (List.mem_of_mem_take ht)) hr + exact ⟨e, ⟨hc, hi, hnum'.relabel _ hinj (fun z => hprime _ (e.2.2.1 z).property) hcover⟩, + he, hweight⟩ + +theorem numerical_witness_sum_le_encoding {R T n : ℕ} (P Q : Finset ℕ) + (F : Finset (Fin R → SignedStep)) (mainLength : ℕ) (start len : Fin n → ℕ) + (h s J : ℕ) (supply : ℕ → ℕ → Prop) {ι : Type*} (p : ι → ℕ) + (hT : ∀ w ∈ F, Fintype.card (ActualPrimeSlot w) ≤ T) + (ht : ∀ w ∈ F, ∀ i, Squarefree (w i).tuple) + (hq : ∀ w ∈ F, ∀ i, Squarefree (w i).padding) + (hP : ∀ w ∈ F, ∀ i, (w i).tuple.primeFactors ⊆ P) + (hQ : ∀ w ∈ F, ∀ i, (w i).padding.primeFactors ⊆ Q) + (hd : ∀ w ∈ F, ∀ i j, Disjoint (w i).tuple.primeFactors (w j).padding.primeFactors) + (hprime : ∀ p ∈ P, p.Prime) + (hnum : ∀ w ∈ F, NumericalWitnessEvent ((List.ofFn w).take mainLength) + (fun i => ((List.ofFn w).drop (start i)).take (len i)) p h s J supply) : + (∑ w ∈ F, ∏ q ∈ wordDivisorPrimeSupport (List.ofFn w), (q : ℝ)⁻¹) ≤ + ∑ e : PrimeWordEncoding R T P Q, + if e.Witnesses n mainLength start len h s J supply then e.weight else 0 := by + let V := F.image List.ofFn + let weight (v : List SignedStep) : ℝ := ∏ q ∈ wordDivisorPrimeSupport v, (q : ℝ)⁻¹ + let cost (e : PrimeWordEncoding R T P Q) : ℝ := + if e.Witnesses n mainLength start len h s J supply then e.weight else 0 + have hsum : (∑ w ∈ F, weight (List.ofFn w)) = ∑ v ∈ V, weight v := by + symm + exact sum_image (fun _ _ _ _ he => List.ofFn_injective he) + have hcost (e : PrimeWordEncoding R T P Q) : 0 ≤ cost e := by + dsimp only [cost] + split_ifs + · exact e.weight_nonneg + · exact le_rfl + have hcover (v : List SignedStep) (hv : v ∈ V) : + ∃ e : PrimeWordEncoding R T P Q, e.decode = v ∧ weight v ≤ cost e := by + obtain ⟨w, hw, rfl⟩ := mem_image.mp hv + obtain ⟨e, he, hdecode, hweight⟩ := PrimeWordEncoding.covers_witnesses w (hT w hw) + (ht w hw) (hq w hw) (hP w hw) (hQ w hw) (hd w hw) hprime + mainLength start len h s J supply p (hnum w hw) + refine ⟨e, hdecode, ?_⟩ + dsimp only [cost, weight] + rw [ite_eq_left he, hweight] + rw [show (∑ w ∈ F, ∏ q ∈ wordDivisorPrimeSupport (List.ofFn w), (q : ℝ)⁻¹) = + ∑ v ∈ V, weight v from hsum] + exact finite_decoding_weight_bound V PrimeWordEncoding.decode weight cost hcost hcover + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalWitnessEvent.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalWitnessEvent.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8876809b0550713df70d20064ffeb364771e280 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/NumericalWitnessEvent.lean @@ -0,0 +1,47 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ExistentialWitnesses +import OAI.NumberTheory.TwoPoint.Bounds.LabeledWordSegments +import OAI.NumberTheory.TwoPoint.Bounds.PrimeSlotClasses + +namespace OAI + +/-! A numerical formulation of the witness event and its exact coded segments. -/ + +namespace TwoPointCorrelations + +/-- All conditions involve the original numerical main and witness words. -/ +def NumericalWitnessEvent {n : ℕ} {ι : Type*} + (main : List SignedStep) (word : Fin n → List SignedStep) (value : ι → ℕ) + (h s J : ℕ) (supply : ℕ → ℕ → Prop) : Prop := + ∃ (mark : Fin n → ι) (attachment position : Fin n → ℕ), + Monotone attachment ∧ (∀ i, attachment i ≤ main.length) ∧ + Function.Injective value ∧ (∀ j, (value j).Prime) ∧ + (∀ i, MinimalWord (ForwardProhibited h s supply) (word i)) ∧ + (∀ i t, t ∈ word i → Squarefree t.tuple) ∧ + (∀ i t, t ∈ word i → t.tuple.primeFactors.card = J) ∧ + (∀ i p j, TuplePrimeAt (word i) p j → ¬p ∣ h ∧ ∀ t ∈ word i, ¬p ∣ t.padding) ∧ + (∀ i, value (mark i) ∈ wordPrimeSupport (word i)) ∧ + (∀ i j, j ≠ i → value (mark i) ∉ wordPrimeSupport (word j)) ∧ + (∀ i v, TuplePrimeAt main (value (mark i)) v → v = position i) ∧ + ∃ x : ℤ, ∀ i, PositiveWord h + (x + wordDisplacement h (main.take (attachment i))) (word i) + +lemma has_resampled_witnesses_iff {n : ℕ} {ι : Type*} [DecidableEq ι] + (main : LabeledPrimeWord ι) (word : Fin n → LabeledPrimeWord ι) + (h s J : ℕ) (supply : ℕ → ℕ → Prop) (value : ι → ℕ) : + HasResampledWitnesses main word h s J supply value ↔ + NumericalWitnessEvent (main.resample value).word + (fun i => ((word i).resample value).word) value h s J supply := by + simp only [HasResampledWitnesses, NumericalWitnessEvent, ResampledWitnessEvent, + LabeledPrimeWord.resample_length] + +lemma CrudeWordCode.segment_resample_word {R N : ℕ} (c : CrudeWordCode R N R) + (hc : c.KindConsistent) (hi : c.RowInjective) + (a : c.tupleClasses → ℕ) (b : {z : c.usedClasses // z ∉ c.tupleClasses} → ℕ) + (start len : ℕ) : + (((c.labeledWord b).segment start len).resample a).word = + ((c.numericalWord (joinCoordinates c.tupleClasses a b)).drop start).take len := by + rw [LabeledPrimeWord.segment_resample_word, c.labeledWord_resample hc hi] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ObservedColumnNames.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ObservedColumnNames.lean new file mode 100644 index 0000000000000000000000000000000000000000..fba51d3112c8335bbb1f61768ac5382d6e0dc2ac --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ObservedColumnNames.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RegularColumnNames + +namespace OAI + +/-! Factor canonical occurrence names through the original observed labels. -/ + +namespace TwoPointCorrelations + +variable {α : Type*} [DecidableEq α] {n : ℕ} + +noncomputable def observedColumnName (label : Fin n → α) (perfect : Finset (Fin n)) + (name : Fin n → ℕ ⊕ ℕ) (a : α) : CanonicalColumnLabel := by + classical + exact if h : ∃ i, label i = a then canonicalColumnName label perfect name h.choose + else .freshImperfect 0 + +theorem observedColumnName_at (label : Fin n → α) (perfect : Finset (Fin n)) + (name : Fin n → ℕ ⊕ ℕ) (i : Fin n) : + observedColumnName label perfect name (label i) = canonicalColumnName label perfect name i := by + classical + have h : ∃ j, label j = label i := ⟨i, rfl⟩ + simp only [observedColumnName, dite_eq_left h] + exact canonicalColumnName_of_label_eq label perfect name h.choose_spec + +theorem canonical_forest_name_at_perfect (label : Fin n → α) (perfect : Finset (Fin n)) + (regular : Finset α) (number : regular → ℕ) (i : Fin n) (hi : i ∈ perfect) : + canonicalColumnName label perfect (forestPerfectName label perfect regular number) i = + perfectColumnName (forestPerfectName label perfect regular number i) := by + have hp := columnRepresentative_perfect label perfect i ⟨i, hi, rfl⟩ + rw [canonicalColumnName, ite_eq_left hp] + exact congrArg perfectColumnName (forestPerfectName_of_label_eq label perfect regular number + _ i (columnRepresentative_label label perfect i)) + +/-- On actual perfect regular positions, the canonical class name is the +line number produced by the shared forest. -/ +theorem observed_forest_name_regular (label : Fin n → α) (perfect : Finset (Fin n)) + (regular : Finset α) (number : regular → ℕ) (i : Fin n) + (hi : i ∈ perfect) (hr : label i ∈ regular) : + observedColumnName label perfect (forestPerfectName label perfect regular number) (label i) = + .regular (number ⟨label i, hr⟩) := by + rw [observedColumnName_at, canonical_forest_name_at_perfect label perfect regular number i hi] + simp only [forestPerfectName, dite_eq_left hr, perfectColumnName] + +/-- Omitted perfect classes carry an occurrence index strictly below the +original column length, independent of any numerical prime value. -/ +theorem observed_forest_name_omitted (label : Fin n → α) (perfect : Finset (Fin n)) + (regular : Finset α) (number : regular → ℕ) (i : Fin n) + (hi : i ∈ perfect) (hr : label i ∉ regular) : + observedColumnName label perfect (forestPerfectName label perfect regular number) (label i) = + .omitted (columnRepresentative label perfect i).val := by + rw [observedColumnName_at, canonical_forest_name_at_perfect label perfect regular number i hi] + simp only [forestPerfectName, dite_eq_right hr, perfectColumnName] + +theorem observed_forest_name_eq_iff (label : Fin n → α) (perfect : Finset (Fin n)) + (regular : Finset α) (number : regular → ℕ) + (hinj : ∀ i ∈ perfect, ∀ j ∈ perfect, ∀ (hi : label i ∈ regular) (hj : label j ∈ regular), + number ⟨label i, hi⟩ = number ⟨label j, hj⟩ → label i = label j) + (i j : Fin n) : + observedColumnName label perfect (forestPerfectName label perfect regular number) (label i) = + observedColumnName label perfect (forestPerfectName label perfect regular number) (label j) ↔ + label i = label j := by + rw [observedColumnName_at, observedColumnName_at] + exact canonical_forest_name_eq_iff label perfect regular number hinj i j + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ObservedColumnRank.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ObservedColumnRank.lean new file mode 100644 index 0000000000000000000000000000000000000000..a46f31521c6792fbb18ed5ae85b3fec04b371f06 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ObservedColumnRank.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CoordinateEmbedding +import OAI.NumberTheory.TwoPoint.Walks.TupleColumnResampling + +namespace OAI + +/-! The ambient column rank is exactly the rank on its observed prime classes. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +lemma resampledTupleColumnPattern_label_map {J R : ℕ} {P : Fin J → Finset ℕ} + (w : ColumnPrimeAssignment J R P) (hR : 0 < R) + (forward : Fin R → Bool) (padding : Fin R → ℕ) (j : Fin J) : + Subtype.val ∘ (resampledTupleColumnPattern w hR forward padding j).label = + (tupleColumnPattern w hR forward padding j).label := rfl + +lemma resampledTupleColumnPattern_coefficient {J R : ℕ} {P : Fin J → Finset ℕ} + (w : ColumnPrimeAssignment J R P) (hR : 0 < R) + (forward : Fin R → Bool) (padding : Fin R → ℕ) (j : Fin J) (h : ℕ) : + (resampledTupleColumnPattern w hR forward padding j).coefficient h = + (tupleColumnPattern w hR forward padding j).coefficient h := rfl + +/-- The selected rank witness is unchanged by restriction to the smaller +resampling space. -/ +theorem tuple_column_observed_rank_iff {J R : ℕ} {P : Fin J → Finset ℕ} + {ρ : Type*} (w : ColumnPrimeAssignment J R P) (hR : 0 < R) + (forward : Fin R → Bool) (padding : Fin R → ℕ) (j : Fin J) (h : ℕ) + (left right : ρ → ℕ) (control : ρ → patternClasses (w j)) : + LinearIndependent ℝ (Sum.elim + (fun i => formalDeparture (resampledTupleColumnPattern w hR forward padding j).label + (fun t => ((resampledTupleColumnPattern w hR forward padding j).coefficient h t : ℝ)) (left i) - + formalDeparture (resampledTupleColumnPattern w hR forward padding j).label + (fun t => ((resampledTupleColumnPattern w hR forward padding j).coefficient h t : ℝ)) (right i)) + (fun i => Pi.basisFun ℝ (patternClasses (w j)) (control i))) ↔ + LinearIndependent ℝ (Sum.elim + (fun i => formalDeparture (tupleColumnPattern w hR forward padding j).label + (fun t => ((tupleColumnPattern w hR forward padding j).coefficient h t : ℝ)) (left i) - + formalDeparture (tupleColumnPattern w hR forward padding j).label + (fun t => ((tupleColumnPattern w hR forward padding j).coefficient h t : ℝ)) (right i)) + (fun i => Pi.basisFun ℝ (P j) (control i).val)) := by + have he := selected_rank_rename_iff + (Subtype.val : patternClasses (w j) → P j) Subtype.val_injective + (resampledTupleColumnPattern w hR forward padding j).label + (fun t => ((resampledTupleColumnPattern w hR forward padding j).coefficient h t : ℝ)) + left right control + simpa only [resampledTupleColumnPattern_label_map, + resampledTupleColumnPattern_coefficient] using he + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ObservedDesignationWeights.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ObservedDesignationWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..e2a0849a01d139e12bdcbcec4c45a603c9270201 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ObservedDesignationWeights.lean @@ -0,0 +1,135 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CenteredWordMajorant + +namespace OAI + +/-! Exact designation weights when the ambient prime pool contains unused primes. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {ι τ : Type*} [Fintype ι] [Fintype τ] [DecidableEq ι] + +lemma filtered_power_product (S : Finset ι) (θ : ι → ℝ) (e : ι → ℕ) : + (∏ i ∈ S, θ i ^ e i) = ∏ i, θ i ^ (if i ∈ S then e i else 0) := by + calc + _ = ∏ i, if i ∈ S then θ i ^ e i else 1 := by + rw [← prod_filter] + simp + _ = _ := by + apply prod_congr rfl + intro i _ + split_ifs <;> simp + +/-- Each observed prime contributes one baseline reciprocal, including +singletons. Only repeated labels contribute additional exponents. -/ +theorem observed_designation_reciprocal_factor (label : τ → ι) (lit : τ → Bool) + (p : ι → ℝ) : + (∏ t ∈ nonsingletonUnlitSlots label lit, (p (label t))⁻¹) * + (∏ i ∈ (nonsingletonLitSlots label lit).image label, (p i)⁻¹) * + (∏ i ∈ singletonLabels label, (p i)⁻¹) = + (∏ i ∈ univ.image label, (p i)⁻¹) * + ∏ i ∈ nonsingletonLabels label, (p i)⁻¹ ^ + extraReciprocalExponent (litOccurrences label lit i).card + (unlitOccurrences label lit i).card := by + rw [designated_weight_exponents (nonsingletonLitSlots label lit) + (nonsingletonUnlitSlots label lit) label (fun i => (p i)⁻¹)] + have hs : (∏ i ∈ singletonLabels label, (p i)⁻¹) = + ∏ i, (p i)⁻¹ ^ (if i ∈ singletonLabels label then 1 else 0) := by + simpa only [pow_one] using + filtered_power_product (singletonLabels label) (fun i => (p i)⁻¹) (fun _ => 1) + rw [hs, label_image_product univ label (fun i => (p i)⁻¹), + filtered_power_product (nonsingletonLabels label) (fun i => (p i)⁻¹) + (fun i => extraReciprocalExponent (litOccurrences label lit i).card + (unlitOccurrences label lit i).card), ← prod_mul_distrib, ← prod_mul_distrib] + apply prod_congr rfl + intro i _ + rw [← pow_add, ← pow_add] + congr 1 + rw [nonsingleton_lit_fiber, nonsingleton_unlit_fiber] + by_cases hn : i ∈ nonsingletonLabels label + · have hc := (mem_filter.mp hn).2 + have hm := lit_unlit_count label lit i + have hp := litReciprocalExponent_pos (litOccurrences label lit i).card + (unlitOccurrences label lit i).card (by omega) + have hns : i ∉ singletonLabels label := by + simp only [singletonLabels, mem_filter, mem_univ, true_and] + omega + simp only [ite_eq_left hn, ite_eq_right hns, add_zero, + extraReciprocalExponent] + have hz : (univ.filter (fun t => label t = i)).card ≠ 0 := by + change (labelOccurrences label i).card ≠ 0 + omega + simp only [ite_eq_right hz] + omega + · have hc : (labelOccurrences label i).card < 2 := by + simpa only [nonsingletonLabels, mem_filter, mem_univ, true_and, not_le] using hn + simp only [ite_eq_right hn, card_empty, litReciprocalExponent, ↓reduceIte, + add_zero, zero_add] + by_cases hzero : (labelOccurrences label i).card = 0 + · have hns : i ∉ singletonLabels label := by + simp [singletonLabels, hzero] + simp only [ite_eq_right hns] + change 0 = if (labelOccurrences label i).card = 0 then 0 else 1 + rw [ite_eq_left hzero] + · have hone : (labelOccurrences label i).card = 1 := by omega + have hss : i ∈ singletonLabels label := by simp [singletonLabels, hone] + simp only [ite_eq_left hss] + change 1 = if (labelOccurrences label i).card = 0 then 0 else 1 + rw [ite_eq_right hzero] + +theorem observed_designation_reciprocal_bound (label : τ → ι) (lit : τ → Bool) + (p : ι → ℝ) (H : ℝ) (hH : 0 < H) (hp : ∀ i, H ≤ p i) : + (∏ t ∈ nonsingletonUnlitSlots label lit, (p (label t))⁻¹) * + (∏ i ∈ (nonsingletonLitSlots label lit).image label, (p i)⁻¹) * + (∏ i ∈ singletonLabels label, (p i)⁻¹) ≤ + (∏ i ∈ univ.image label, (p i)⁻¹) * H⁻¹ ^ + (∑ i ∈ nonsingletonLabels label, + extraReciprocalExponent (litOccurrences label lit i).card + (unlitOccurrences label lit i).card) := by + rw [observed_designation_reciprocal_factor, ← prod_pow_eq_pow_sum] + apply mul_le_mul_of_nonneg_left + · apply prod_le_prod₀ + · intro i _ + exact pow_nonneg (inv_nonneg.mpr (hH.trans_le (hp i)).le) _ + · intro i _ + exact pow_le_pow_left₀ (inv_nonneg.mpr (hH.trans_le (hp i)).le) + (inv_anti₀ hH (hp i)) _ + · exact prod_nonneg (fun i _ => inv_nonneg.mpr (hH.trans_le (hp i)).le) + +noncomputable def designationLit (U : Finset τ) (t : τ) : Bool := decide (t ∉ U) + +lemma designationLit_unlit (label : τ → ι) (U : Finset τ) + (hU : U ⊆ nonsingletonSlots label) : + nonsingletonUnlitSlots label (designationLit U) = U := by + ext t + simp only [nonsingletonUnlitSlots, mem_filter, mem_univ, true_and, designationLit, + decide_eq_false_iff_not, not_not] + constructor + · exact And.right + · intro ht + exact ⟨(mem_filter.mp (hU ht)).2, ht⟩ + +lemma designationLit_lit (label : τ → ι) (U : Finset τ) : + nonsingletonLitSlots label (designationLit U) = nonsingletonSlots label \ U := by + ext t + simp [nonsingletonLitSlots, nonsingletonSlots, designationLit, and_comm] + +/-- The coefficient in the full signed expansion retains the actual +extra-exponent saving even when unused primes occur in the ambient pool. -/ +theorem full_word_designated_reciprocal_bound (label : τ → ι) (U : Finset τ) + (hU : U ⊆ nonsingletonSlots label) (p : ι → ℕ) (H : ℝ) + (hH : 0 < H) (hp : ∀ i, H ≤ p i) : + designatedReciprocal p (singletonLabels label) (nonsingletonSlots label \ U) U label ≤ + (∏ i ∈ univ.image label, (p i : ℝ)⁻¹) * H⁻¹ ^ + (∑ i ∈ nonsingletonLabels label, + extraReciprocalExponent (litOccurrences label (designationLit U) i).card + (unlitOccurrences label (designationLit U) i).card) := by + simpa only [designationLit_unlit label U hU, designationLit_lit, designatedReciprocal] + using observed_designation_reciprocal_bound label (designationLit U) + (fun i => (p i : ℝ)) H hH hp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ObservedReciprocalBound.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ObservedReciprocalBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..317390b8e6f90bffaa320ad7a0bbc9b41c8bce9f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ObservedReciprocalBound.lean @@ -0,0 +1,46 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ObservedDesignationWeights + +namespace OAI + +/-! Extra-reciprocal estimates require the lower prime bound only on used tuple coordinates. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma designation_sdiff_decidable {τ : Type*} (d₁ d₂ : DecidableEq τ) (S U : Finset τ) : + @SDiff.sdiff (Finset τ) (@Finset.instSDiff τ d₁) S U = + @SDiff.sdiff (Finset τ) (@Finset.instSDiff τ d₂) S U := by + have hd : d₁ = d₂ := Subsingleton.elim _ _ + cases hd + rfl + +theorem full_word_designated_reciprocal_bound_on_support {ι τ : Type*} + [Fintype ι] [Fintype τ] [DecidableEq ι] + (label : τ → ι) (U : Finset τ) (hU : U ⊆ nonsingletonSlots label) + (p : ι → ℕ) (H : ℝ) (hH : 0 < H) + (hp : ∀ i ∈ nonsingletonLabels label, H ≤ p i) : + designatedReciprocal p (singletonLabels label) (nonsingletonSlots label \ U) U label ≤ + (∏ i ∈ univ.image label, (p i : ℝ)⁻¹) * H⁻¹ ^ + (∑ i ∈ nonsingletonLabels label, + extraReciprocalExponent (litOccurrences label (designationLit U) i).card + (unlitOccurrences label (designationLit U) i).card) := by + have he : designatedReciprocal p (singletonLabels label) (nonsingletonSlots label \ U) U label = + (∏ i ∈ univ.image label, (p i : ℝ)⁻¹) * + ∏ i ∈ nonsingletonLabels label, (p i : ℝ)⁻¹ ^ + extraReciprocalExponent (litOccurrences label (designationLit U) i).card + (unlitOccurrences label (designationLit U) i).card := by + simpa only [designationLit_unlit label U hU, designationLit_lit, designatedReciprocal] using + observed_designation_reciprocal_factor label (designationLit U) (fun i => (p i : ℝ)) + rw [he, ← prod_pow_eq_pow_sum] + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply prod_le_prod₀ + · intro i _ + positivity + · intro i hi + exact pow_le_pow_left₀ (by positivity) (inv_anti₀ hH (hp i hi)) _ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/OccurrenceCounts.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/OccurrenceCounts.lean new file mode 100644 index 0000000000000000000000000000000000000000..64c5c0083f3339c3c4bb133f53670a080235bde0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/OccurrenceCounts.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.TwoPoint.Bounds.LitOccurrenceWeights + +namespace OAI + +/-! Counts of the actual slots belonging to each prime label. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι τ : Type*} [Fintype ι] [Fintype τ] [DecidableEq ι] + +def labelOccurrences (label : τ → ι) (i : ι) : Finset τ := + univ.filter (fun t => label t = i) + +def litOccurrences (label : τ → ι) (lit : τ → Bool) (i : ι) : Finset τ := + (labelOccurrences label i).filter (fun t => lit t = true) + +def unlitOccurrences (label : τ → ι) (lit : τ → Bool) (i : ι) : Finset τ := + (labelOccurrences label i).filter (fun t => lit t = false) + +omit [Fintype ι] in +lemma lit_unlit_count (label : τ → ι) (lit : τ → Bool) (i : ι) : + (litOccurrences label lit i).card + (unlitOccurrences label lit i).card = + (labelOccurrences label i).card := by + have he : unlitOccurrences label lit i = + (labelOccurrences label i).filter (fun t => ¬lit t = true) := by + ext t + simp [unlitOccurrences] + rw [litOccurrences, he] + exact card_filter_add_card_filter_not (s := labelOccurrences label i) (fun t => lit t = true) + +lemma total_label_occurrences (label : τ → ι) : + ∑ i, (labelOccurrences label i).card = Fintype.card τ := by + simpa only [labelOccurrences, mem_univ, filter_true, card_univ] using + sum_card_fiberwise_eq_card_filter (univ : Finset τ) (univ : Finset ι) label + +def singletonLabels (label : τ → ι) : Finset ι := + univ.filter (fun i => (labelOccurrences label i).card = 1) + +def nonsingletonLabels (label : τ → ι) : Finset ι := + univ.filter (fun i => 2 ≤ (labelOccurrences label i).card) + +/-- The number of labels is at most half the slot count plus half the +singleton count. All labels here are observed in the word. -/ +lemma twice_labels_le_slots_add_singletons (label : τ → ι) + (hused : ∀ i, 0 < (labelOccurrences label i).card) : + 2 * Fintype.card ι ≤ Fintype.card τ + (singletonLabels label).card := by + have hlocal (i : ι) : 2 ≤ (labelOccurrences label i).card + + (if (labelOccurrences label i).card = 1 then 1 else 0) := by + have hi := hused i + split_ifs <;> omega + have hs := sum_le_sum (fun i (_ : i ∈ (univ : Finset ι)) => hlocal i) + rw [sum_add_distrib, total_label_occurrences] at hs + have hc : (∑ i : ι, if (labelOccurrences label i).card = 1 then (1 : ℕ) else 0) = + (singletonLabels label).card := by simp [singletonLabels, sum_boole] + rw [hc] at hs + simpa [mul_comm] using hs + +/-- The extra-exponent bound applies to the literal occurrence counts of +every nonsingleton in the given designation. -/ +lemma actual_unlit_le_twice_extra (label : τ → ι) (lit : τ → Bool) : + (∑ i : nonsingletonLabels label, (unlitOccurrences label lit i.val).card) ≤ + 2 * ∑ i : nonsingletonLabels label, + extraReciprocalExponent (litOccurrences label lit i.val).card + (unlitOccurrences label lit i.val).card := by + apply total_unlit_le_twice_extra + intro i + rw [lit_unlit_count] + exact (mem_filter.mp i.property).2 + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/OrderedElimination.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/OrderedElimination.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e12ba118d211a0583cbe8ba2c5786c5143dd66e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/OrderedElimination.lean @@ -0,0 +1,121 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ReciprocalSampling + +namespace OAI + +/-! Eliminate labels in the order of witness records, independently of label names. -/ + +namespace TwoPointCorrelations + +open Finset + +namespace FiniteLaw + +variable {ι A : Type*} [Fintype ι] [DecidableEq ι] [Fintype A] + +/-- The order belongs to the relation records. The ambient prime labels +need no compatible order and all unselected coordinates keep their law. -/ +theorem ordered_coordinate_probability_bound {κ : Type*} [LinearOrder κ] + [Nonempty A] (coordinate : κ → ι) + (μ : ι → FiniteLaw A) (E : κ → (ι → A) → Prop) (δ : ℝ) (hδ : 0 ≤ δ) + (R : Finset κ) + (hdepends : ∀ i ∈ R, ∀ j ∈ R, i < j → ∀ x a, + E i (Function.update x (coordinate j) a) ↔ E i x) + (hconditional : ∀ i ∈ R, ∀ x, + (μ (coordinate i)).probability (fun a => E i (Function.update x (coordinate i) a)) ≤ δ) : + (independent μ).probability (fun x => ∀ i ∈ R, E i x) ≤ δ ^ R.card := by + classical + revert hdepends hconditional + induction R using Finset.strongInductionOn with + | _ R ih => + intro hdepends hconditional + by_cases hR : R.Nonempty + · let i := R.max' hR + have hi : i ∈ R := max'_mem R hR + have hjlt (j : κ) (hj : j ∈ R.erase i) : j < i := by + have hjR := (mem_erase.mp hj).2 + have hji := (mem_erase.mp hj).1 + exact lt_of_le_of_ne (le_max' R j hjR) hji + have hretained : ∀ x a, + (∀ j ∈ R.erase i, E j (Function.update x (coordinate i) a)) ↔ ∀ j ∈ R.erase i, E j x := by + intro x a + constructor <;> intro hx j hj + · exact (hdepends j (mem_erase.mp hj).2 i hi (hjlt j hj) x a).mp (hx j hj) + · exact (hdepends j (mem_erase.mp hj).2 i hi (hjlt j hj) x a).mpr (hx j hj) + have hstep := eliminate_coordinate μ (coordinate i) (fun x => ∀ j ∈ R.erase i, E j x) + (E i) δ hretained (hconditional i hi) + have hevent : (fun x => ∀ j ∈ R, E j x) = + (fun x => (∀ j ∈ R.erase i, E j x) ∧ E i x) := by + funext x + apply propext + constructor + · intro hx + exact ⟨fun j hj => hx j (mem_erase.mp hj).2, hx i hi⟩ + · rintro ⟨hx, hxi⟩ j hj + by_cases hji : j = i + · simpa only [hji] using hxi + · exact hx j (mem_erase.mpr ⟨hji, hj⟩) + rw [hevent] + apply hstep.trans + have hrest := ih (R.erase i) (Finset.erase_ssubset hi) + (fun j hj k hk hjk x a => hdepends j (mem_erase.mp hj).2 k (mem_erase.mp hk).2 hjk x a) + (fun j hj => hconditional j (mem_erase.mp hj).2) + have hmul := mul_le_mul_of_nonneg_left hrest hδ + have hcard : R.card = (R.erase i).card + 1 := by + rw [card_erase_of_mem hi] + have hpos := card_pos.mpr hR + omega + simpa only [hcard, pow_succ, mul_comm] using hmul + · have hzero : R = ∅ := not_nonempty_iff_eq_empty.mp hR + rw [hzero, card_empty, pow_zero] + exact probability_le_one _ _ + + +/-- Ordered nondegenerate prime relations: selected coordinates can be +any labels in the ambient assignment, not necessarily an initial segment. -/ +theorem ordered_prime_relation_probability {κ : Type*} [LinearOrder κ] + (τ : κ → Type*) [∀ i, Fintype (τ i)] + [Nonempty A] (μ : ι → FiniteLaw A) (value : A → ℕ) + (hinj : Function.Injective value) (H N : ℕ) (hH : 0 < H) (hN : 1 ≤ N) + (hprime : ∀ a, (value a).Prime) (hlo : ∀ a, H ≤ value a) + (hhi : ∀ a, value a ≤ N) (hweight : ∀ i a, (μ i).weight a ≤ (value a : ℝ)⁻¹) + (m : (i : κ) → τ i → PrimeMonomial ι) (selected control : κ → ι) (R : Finset κ) + (hcontrol : ∀ i ∈ R, control i ≠ selected i) + (htriangular : ∀ i ∈ R, ∀ j ∈ R, i < j → + selected j ∉ primeRelationSupport (m i) ∧ control i ≠ selected j) : + (independent μ).probability (fun x => ∀ i ∈ R, + primeRelationEvent (m i) (selected i) (control i) (integerPrimeAssignment value x)) ≤ + ((H : ℝ)⁻¹ + (1 + Real.log N) / H) ^ R.card := by + classical + let E : κ → (ι → A) → Prop := fun i x => + primeRelationEvent (m i) (selected i) (control i) (integerPrimeAssignment value x) + have hlog : 0 ≤ Real.log (N : ℝ) := Real.log_nonneg (by exact_mod_cast hN) + apply ordered_coordinate_probability_bound selected μ E _ (by positivity) R ?_ ?_ + · intro i hi j hj hij x a + exact primeRelationEvent_update_irrelevant (m i) (selected i) (control i) (selected j) + value x a (htriangular i hi j hj hij).1 (htriangular i hi j hj hij).2 + · intro i hi x + have hlinear := nondegenerate_reciprocal_probability_bound (μ (selected i)) value hinj + H N (value (x (control i))) + (primeRelationCoefficient (m i) (selected i) (integerPrimeAssignment value x)) + (primeRelationConstant (m i) (selected i) (integerPrimeAssignment value x)) + hH hN (hprime _) hlo hhi (hweight (selected i)) + have hevent : (fun a => E i (Function.update x (selected i) a)) = + (fun a => (value (x (control i)) : ℤ) ∣ + primeRelationCoefficient (m i) (selected i) (integerPrimeAssignment value x) * value a + + primeRelationConstant (m i) (selected i) (integerPrimeAssignment value x) ∧ + ¬(value (x (control i)) : ℤ) ∣ + primeRelationCoefficient (m i) (selected i) (integerPrimeAssignment value x)) := by + funext a + exact propext (primeRelationEvent_update_selected (m i) (selected i) (control i) + (hcontrol i hi) value x a) + rw [hevent] + apply hlinear.trans + apply add_le_add le_rfl + exact div_le_div_of_nonneg_left (by linarith) (by exact_mod_cast hH) + (by exact_mod_cast hlo (x (control i))) + +end FiniteLaw + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/OrderedPrimeSystems.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/OrderedPrimeSystems.lean new file mode 100644 index 0000000000000000000000000000000000000000..2e7a1cb2ceb8831a015ba8830377c7c40e92c9ba --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/OrderedPrimeSystems.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.TwoPoint.Bounds.OrderedElimination +import OAI.NumberTheory.TwoPoint.Bounds.PrimeReciprocalLaw + +namespace OAI + +/-! A finite ordered family packages the precise output of witness selection. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +/-- The index order records elimination order; it is unrelated to the +names or numerical values of the ambient prime labels. -/ +structure OrderedPrimeSystem (ι : Type*) [DecidableEq ι] where + Index : Type + [indexFintype : Fintype Index] + [indexOrder : LinearOrder Index] + Term : Index → Type + [termFintype : ∀ i, Fintype (Term i)] + relation : (i : Index) → Term i → PrimeMonomial ι + selected : Index → ι + control : Index → ι + control_ne : ∀ i, control i ≠ selected i + triangular : ∀ i j, i < j → + selected j ∉ primeRelationSupport (relation i) ∧ control i ≠ selected j + +attribute [instance] OrderedPrimeSystem.indexFintype OrderedPrimeSystem.indexOrder + OrderedPrimeSystem.termFintype + +namespace OrderedPrimeSystem + +variable {ι : Type*} [DecidableEq ι] + +def size (S : OrderedPrimeSystem ι) : ℕ := Fintype.card S.Index + +def Holds (S : OrderedPrimeSystem ι) (x : ι → ℤ) : Prop := + ∀ i, primeRelationEvent (S.relation i) (S.selected i) (S.control i) x + +/-- Each selected interval or comparison earns its own factor; every +unselected prime variable is averaged with its original product law. -/ +theorem probability_bound [Fintype ι] {A : Type*} [Fintype A] [Nonempty A] + (S : OrderedPrimeSystem ι) (μ : ι → FiniteLaw A) (value : A → ℕ) + (hinj : Function.Injective value) (H N : ℕ) (hH : 0 < H) (hN : 1 ≤ N) + (hprime : ∀ a, (value a).Prime) (hlo : ∀ a, H ≤ value a) + (hhi : ∀ a, value a ≤ N) (hweight : ∀ i a, (μ i).weight a ≤ (value a : ℝ)⁻¹) : + (FiniteLaw.independent μ).probability (fun x => S.Holds (integerPrimeAssignment value x)) ≤ + ((H : ℝ)⁻¹ + (1 + Real.log N) / H) ^ S.size := by + simpa only [Holds, Finset.mem_univ, forall_true_left, card_univ, size] using + FiniteLaw.ordered_prime_relation_probability S.Term μ value hinj H N hH hN hprime + hlo hhi hweight S.relation S.selected S.control univ + (fun i _ => S.control_ne i) (fun i _ j _ hij => S.triangular i j hij) + +/-- The actual reciprocal sum for a fixed recorded system. Keeping the +nonzero coefficient tests in `Holds` makes every elimination valid after +resampling, including samples with coincident numerical primes. -/ +theorem reciprocal_sum_bound [Fintype ι] (S : OrderedPrimeSystem ι) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hV : 1 ≤ primeHarmonicMass P) + (H N : ℕ) (hH : 0 < H) (hN : 1 ≤ N) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ N) : + (∑ x : ι → P, if S.Holds (integerPrimeAssignment Subtype.val x) + then ∏ z, ((x z).val : ℝ)⁻¹ else 0) ≤ + primeHarmonicMass P ^ Fintype.card ι * + ((H : ℝ)⁻¹ + (1 + Real.log N) / H) ^ S.size := by + classical + have hVp : 0 < primeHarmonicMass P := lt_of_lt_of_le zero_lt_one hV + have hPnonempty : Nonempty P := by + have hPn : P.Nonempty := by + by_contra hn + have hpempty : P = ∅ := not_nonempty_iff_eq_empty.mp hn + have hz : primeHarmonicMass P = 0 := by + subst P + simp [primeHarmonicMass] + linarith + obtain ⟨p, hp⟩ := hPn + exact ⟨⟨p, hp⟩⟩ + have : Nonempty P := hPnonempty + apply primeReciprocalLaw_restore_bound P hVp _ _ + apply S.probability_bound (fun _ => primeReciprocalLaw P hVp) Subtype.val + Subtype.val_injective H N hH hN (fun p => hP p.val p.property) + (fun p => hlo p.val p.property) (fun p => hhi p.val p.property) + intro i p + change (p.val : ℝ)⁻¹ / primeHarmonicMass P ≤ (p.val : ℝ)⁻¹ + exact div_le_self (by positivity) hV + +end OrderedPrimeSystem + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/OscillatoryThetaError.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/OscillatoryThetaError.lean new file mode 100644 index 0000000000000000000000000000000000000000..220e3681581b1d2dea6031e504d20999e0461489 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/OscillatoryThetaError.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.TwoPoint.Bounds.WeightedThetaError +import OAI.NumberTheory.TwoPoint.Bounds.PaddingCharacteristic +import Mathlib.Analysis.Calculus.ContDiff.Deriv + +namespace OAI + +/-! Uniform partial summation for `(1-cos(t log p))/p`, with `|t|≤2`. +The oscillatory prime estimate is deduced from the theta error. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +noncomputable def oscillatoryReciprocalLog (t x : ℝ) : ℝ := + (1 - Real.cos (t * Real.log x)) * reciprocalLog x + +lemma reciprocalLog_size {x : ℝ} (hx : 1 < x) (hl : 1 ≤ Real.log x) : + |reciprocalLog x| ≤ 1 / x := by + have hx0 : 0 < x := zero_lt_one.trans hx + have hl0 : 0 < Real.log x := zero_lt_one.trans_le hl + unfold reciprocalLog + rw [abs_of_nonneg (by positivity)] + apply (div_le_iff₀ hl0).mpr + have hh := mul_le_mul_of_nonneg_left hl (inv_nonneg.mpr hx0.le) + simpa only [mul_one, one_div] using hh + +lemma reciprocalLog_deriv_size {x : ℝ} (hx : 1 < x) (hl : 1 ≤ Real.log x) : + |deriv reciprocalLog x| ≤ 2 / x ^ 2 := by + have hx0 : 0 < x := zero_lt_one.trans hx + have hl0 : 0 < Real.log x := zero_lt_one.trans_le hl + rw [(reciprocalLog_hasDerivAt hx).deriv, abs_div, abs_neg, + abs_of_pos (by positivity : 0 < Real.log x + 1), + abs_of_pos (by positivity : 0 < x ^ 2 * Real.log x ^ 2)] + calc + _ ≤ (2 * Real.log x ^ 2) / (x ^ 2 * Real.log x ^ 2) := by + apply div_le_div_of_nonneg_right _ (by positivity) + nlinarith [sq_nonneg (Real.log x - 1)] + _ = _ := by field_simp + +lemma oscillatoryReciprocalLog_hasDerivAt (t x : ℝ) (hx : 1 < x) : + HasDerivAt (oscillatoryReciprocalLog t) + ((t * Real.sin (t * Real.log x) / x) * reciprocalLog x + + (1 - Real.cos (t * Real.log x)) * deriv reciprocalLog x) x := by + have hx0 : x ≠ 0 := (zero_lt_one.trans hx).ne' + have hg := ((Real.hasDerivAt_cos (t * Real.log x)).comp x + ((Real.hasDerivAt_log hx0).const_mul t)).const_sub 1 + have hh := hg.mul (reciprocalLog_hasDerivAt hx) + convert hh using 1 + · rfl + · rw [(reciprocalLog_hasDerivAt hx).deriv] + simp only [div_eq_mul_inv, Function.comp_def] + ring + +lemma oscillatoryReciprocalLog_bounds (t x : ℝ) (ht : |t| ≤ 2) + (hx : 1 < x) (hl : 1 ≤ Real.log x) : + |oscillatoryReciprocalLog t x| ≤ 2 / x ∧ + |deriv (oscillatoryReciprocalLog t) x| ≤ 6 / x ^ 2 := by + have hx0 : 0 < x := zero_lt_one.trans hx + have hg : |1 - Real.cos (t * Real.log x)| ≤ 2 := + (abs_of_nonneg (one_sub_cos_bounds _).1).trans_le (one_sub_cos_bounds _).2 + have hs : |t * Real.sin (t * Real.log x) / x| ≤ 2 / x := by + rw [abs_div, abs_mul, abs_of_pos hx0] + apply div_le_div_of_nonneg_right _ hx0.le + exact (mul_le_mul ht (Real.abs_sin_le_one _) (abs_nonneg _) (by norm_num)).trans_eq (mul_one 2) + have hrec := reciprocalLog_size hx hl + have hdrec := reciprocalLog_deriv_size hx hl + constructor + · unfold oscillatoryReciprocalLog + rw [abs_mul] + calc + _ ≤ 2 * (1 / x) := mul_le_mul hg hrec (abs_nonneg _) (by norm_num) + _ = _ := by ring + · rw [(oscillatoryReciprocalLog_hasDerivAt t x hx).deriv] + apply (abs_add_le _ _).trans + rw [abs_mul, abs_mul] + calc + _ ≤ (2 / x) * (1 / x) + 2 * (2 / x ^ 2) := + add_le_add (mul_le_mul hs hrec (abs_nonneg _) (by positivity)) + (mul_le_mul hg hdrec (abs_nonneg _) (by norm_num)) + _ = _ := by field_simp; ring + +theorem oscillatory_theta_error (c : ℕ → ℝ) (α K a b t : ℝ) + (hK : 0 ≤ K) (ha : Real.exp 1 ≤ a) (hab : a ≤ b) (ht : |t| ≤ 2) + (hE : ∀ x ∈ Set.Icc a b, + |partialCoefficientSum c x - α * x| ≤ K * x / Real.log x ^ 2) : + |(∑ n ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, oscillatoryReciprocalLog t n * c n) - + α * (∫ x in a..b, oscillatoryReciprocalLog t x)| ≤ 10 * K / Real.log a := by + have ha1 : 1 < a := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le ha + have hx1 (x : ℝ) (hx : x ∈ Set.Icc a b) : 1 < x := ha1.trans_le hx.1 + have hl (x : ℝ) (hx : x ∈ Set.Icc a b) : 1 ≤ Real.log x := by + calc + 1 = Real.log (Real.exp 1) := (Real.log_exp 1).symm + _ ≤ _ := Real.log_le_log (Real.exp_pos _) (ha.trans hx.1) + suffices hh : |(∑ n ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, oscillatoryReciprocalLog t n * c n) - + α * (∫ x in a..b, oscillatoryReciprocalLog t x)| ≤ (2 * 2 + 6) * K / Real.log a by + norm_num at hh + exact hh + apply weighted_theta_error c α K 2 6 a b hK (by norm_num) (by norm_num) ha hab + · intro x hx + exact (oscillatoryReciprocalLog_hasDerivAt t x (hx1 x hx)).differentiableAt + · intro x hx + have hxn : x ≠ 0 := (zero_lt_one.trans (hx1 x hx)).ne' + have hln : Real.log x ≠ 0 := (Real.log_pos (hx1 x hx)).ne' + have hc : ContDiffAt ℝ 2 (oscillatoryReciprocalLog t) x := by + unfold oscillatoryReciprocalLog reciprocalLog + fun_prop (disch := assumption) + exact (hc.derivWithin (m := 0) (by norm_num)).continuousAt.continuousWithinAt + · exact fun x hx => (oscillatoryReciprocalLog_bounds t x ht (hx1 x hx) (hl x hx)).1 + · exact fun x hx => (oscillatoryReciprocalLog_bounds t x ht (hx1 x hx) (hl x hx)).2 + · exact hE + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/OverlapPrefix.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/OverlapPrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..091ad357acc7799ca63efac7d1451fb6962fa77d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/OverlapPrefix.lean @@ -0,0 +1,123 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftBoundary + +namespace OAI + +/-! Overlapping blocks recover a positive prefix. The missing terminal +edges cost displacement/block length, and translation costs block/prefix length. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def edgeBlockSum {E : Type*} (edges : Finset E) (r : E → ℕ) + (c : E → ℕ → ℂ) (M t : ℕ) : ℂ := + ∑ i ∈ range M, ∑ e ∈ edges, if i + 1 + r e ≤ M then c e (t + i + 2) else 0 + +noncomputable def fullBlockSum {E : Type*} (edges : Finset E) + (c : E → ℕ → ℂ) (M t : ℕ) : ℂ := + ∑ i ∈ range M, ∑ e ∈ edges, c e (t + i + 2) + +lemma edgeBlockSum_error {E : Type*} (edges : Finset E) (r : E → ℕ) + (c : E → ℕ → ℂ) (M R t : ℕ) (D : ℝ) (hD : 0 ≤ D) + (hr : ∀ e ∈ edges, r e ≤ R) + (hc : ∀ n, 0 < n → (∑ e ∈ edges, ‖c e n‖) ≤ D) : + ‖edgeBlockSum edges r c M t - fullBlockSum edges c M t‖ ≤ R * D := by + have hterm (i : ℕ) : + ‖(∑ e ∈ edges, if i + 1 + r e ≤ M then c e (t + i + 2) else 0) - + ∑ e ∈ edges, c e (t + i + 2)‖ ≤ if M - R ≤ i then D else 0 := by + by_cases hi : M - R ≤ i + · rw [ite_eq_left hi, ← sum_sub_distrib] + apply (norm_sum_le _ _).trans + apply le_trans _ (hc (t + i + 2) (by omega)) + apply sum_le_sum + intro e _ + split_ifs <;> simp + · rw [ite_eq_right hi] + have he (e : E) (he : e ∈ edges) : i + 1 + r e ≤ M := by + have := hr e he + omega + have hz : (∑ e ∈ edges, if i + 1 + r e ≤ M then c e (t + i + 2) else 0) = + ∑ e ∈ edges, c e (t + i + 2) := by + apply sum_congr rfl + intro e he' + rw [ite_eq_left (he e he')] + simp only [hz, sub_self, norm_zero, le_refl] + have hfilter : (range M).filter (fun i => M - R ≤ i) = Ico (M - R) M := by + ext i + simp only [mem_filter, mem_range, mem_Ico] + omega + calc + _ = ‖∑ i ∈ range M, + ((∑ e ∈ edges, if i + 1 + r e ≤ M then c e (t + i + 2) else 0) - + ∑ e ∈ edges, c e (t + i + 2))‖ := by rw [sum_sub_distrib]; rfl + _ ≤ ∑ i ∈ range M, ‖(∑ e ∈ edges, + if i + 1 + r e ≤ M then c e (t + i + 2) else 0) - + ∑ e ∈ edges, c e (t + i + 2)‖ := norm_sum_le _ _ + _ ≤ ∑ i ∈ range M, if M - R ≤ i then D else 0 := sum_le_sum (fun i _ => hterm i) + _ = (M - (M - R) : ℕ) * D := by + rw [← sum_filter, hfilter] + simp + _ ≤ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast (show M - (M - R) ≤ R by omega)) hD + +lemma fullBlockSum_prefix_identity {E : Type*} (edges : Finset E) + (c : E → ℕ → ℂ) (M N : ℕ) : + (M : ℂ)⁻¹ * ∑ t ∈ range N, fullBlockSum edges c M t = + translatedPrefixAverage (fun n => ∑ e ∈ edges, c e n) N M := by + unfold fullBlockSum translatedPrefixAverage positivePrefix + rw [sum_comm] + congr 1 + apply sum_congr rfl + intro i _ + apply sum_congr rfl + intro t _ + rw [show t + i + 2 = t + 1 + (i + 1) by omega] + +lemma edgeBlockSum_prefix_error {E : Type*} (edges : Finset E) (r : E → ℕ) + (c : E → ℕ → ℂ) (M R N : ℕ) (hM : 0 < M) (hN : 0 < N) + (D : ℝ) (hD : 0 ≤ D) (hr : ∀ e ∈ edges, r e ≤ R) + (hc : ∀ n, 0 < n → (∑ e ∈ edges, ‖c e n‖) ≤ D) : + ‖((∑ t ∈ range N, edgeBlockSum edges r c M t) / (M : ℂ)) / (N : ℂ) - + positivePrefix (fun n => ∑ e ∈ edges, c e n) N / (N : ℂ)‖ ≤ + (R : ℝ) / M * D + 2 * (M : ℝ) / N * D := by + let F := fun n => ∑ e ∈ edges, c e n + let T := translatedPrefixAverage F N M + have htranslate := norm_normalized_translation_error F N M hN hM D hD + (fun n hn => (norm_sum_le _ _).trans (hc n hn)) + have hblock : ‖((∑ t ∈ range N, edgeBlockSum edges r c M t) / (M : ℂ)) / + (N : ℂ) - T / (N : ℂ)‖ ≤ (R : ℝ) / M * D := by + have heq : ((∑ t ∈ range N, edgeBlockSum edges r c M t) / (M : ℂ)) / + (N : ℂ) - T / (N : ℂ) = + ((∑ t ∈ range N, (edgeBlockSum edges r c M t - fullBlockSum edges c M t)) / + (M : ℂ)) / (N : ℂ) := by + dsimp [T, F] + rw [← fullBlockSum_prefix_identity edges c M N, sum_sub_distrib] + ring + rw [heq, norm_div, norm_div, Complex.norm_natCast, Complex.norm_natCast] + have hs : ‖∑ t ∈ range N, (edgeBlockSum edges r c M t - fullBlockSum edges c M t)‖ ≤ + (N : ℝ) * ((R : ℝ) * D) := by + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ _t ∈ range N, (R : ℝ) * D := + sum_le_sum (fun t _ => edgeBlockSum_error edges r c M R t D hD hr hc) + _ = _ := by simp + have hMr : 0 < (M : ℝ) := by exact_mod_cast hM + have hNr : 0 < (N : ℝ) := by exact_mod_cast hN + calc + _ ≤ ((N : ℝ) * ((R : ℝ) * D) / M) / N := + div_le_div_of_nonneg_right (div_le_div_of_nonneg_right hs hMr.le) hNr.le + _ = _ := by field_simp + calc + _ ≤ ‖((∑ t ∈ range N, edgeBlockSum edges r c M t) / (M : ℂ)) / + (N : ℂ) - T / (N : ℂ)‖ + ‖(T - positivePrefix F N) / (N : ℂ)‖ := by + have heq : ((∑ t ∈ range N, edgeBlockSum edges r c M t) / (M : ℂ)) / + (N : ℂ) - positivePrefix F N / (N : ℂ) = + (((∑ t ∈ range N, edgeBlockSum edges r c M t) / (M : ℂ)) / + (N : ℂ) - T / (N : ℂ)) + (T - positivePrefix F N) / (N : ℂ) := by ring + rw [heq] + exact norm_add_le _ _ + _ ≤ _ := add_le_add hblock htranslate + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddedListCode.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddedListCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b5c0aafa4186059108f6453e227df9f6b1a5400 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddedListCode.lean @@ -0,0 +1,27 @@ +import Mathlib.Data.List.OfFn +import Mathlib.Tactic + +namespace OAI + +/-! Fixed-length code slots for finite lists with a bounded length. -/ + +namespace TwoPointCorrelations + +variable {α : Type*} {N : ℕ} + +def paddedListCode (l : List α) (h : l.length ≤ N) (default : α) : Fin N → α := + fun i => (l ++ List.replicate (N - l.length) default)[i.val]'(by + simp only [List.length_append, List.length_replicate] + omega) + +@[simp] theorem paddedListCode_ofFn (l : List α) (h : l.length ≤ N) (default : α) : + List.ofFn (paddedListCode l h default) = l ++ List.replicate (N - l.length) default := by + apply List.ext_getElem + · simp only [List.length_ofFn, List.length_append, List.length_replicate] + omega + · intro i hi hj + simp only [List.getElem_ofFn, paddedListCode] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingActiveState.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingActiveState.lean new file mode 100644 index 0000000000000000000000000000000000000000..13f1420fa0975ce3799a8c34d5dac02b99c20ea3 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingActiveState.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActiveStateExpansion +import OAI.NumberTheory.TwoPoint.Bounds.ActualPaddingResidues + +namespace OAI + +/-! Exact finite-index active states for the literal padding primes. +The same state determines the vertex normalization and every retained +squarefree padding-divisor test. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def paddingActiveState {m : ℕ} (Q : Finset ℕ) (e : Fin m ≃ Q) + (n : ℤ) : Finset (Fin m) := + activeState (fun i => decide (((e i).val : ℤ) ∣ n)) + +lemma paddingActiveState_image {m : ℕ} (Q : Finset ℕ) (e : Fin m ≃ Q) (n : ℤ) : + (paddingActiveState Q e n).image (fun i => (e i).val) = + Q.filter (fun p : ℕ => (p : ℤ) ∣ n) := by + ext p + constructor + · intro hp + obtain ⟨i, hi, rfl⟩ := mem_image.mp hp + exact mem_filter.mpr ⟨(e i).property, by simpa [paddingActiveState, activeState] using hi⟩ + · intro hp + obtain ⟨hpQ, hd⟩ := mem_filter.mp hp + obtain ⟨i, hi⟩ := e.surjective ⟨p, hpQ⟩ + apply mem_image.mpr + refine ⟨i, ?_, congrArg Subtype.val hi⟩ + simp only [paddingActiveState, activeState, mem_filter, mem_univ, true_and, + decide_eq_true_eq] + simpa only [hi] using hd + +lemma paddingActiveState_card {m : ℕ} (Q : Finset ℕ) (e : Fin m ≃ Q) (n : ℤ) : + (paddingActiveState Q e n).card = actualPaddingDegree Q n := by + have hi : Function.Injective (fun i => (e i).val) := + Subtype.val_injective.comp e.injective + have hh := congrArg Finset.card (paddingActiveState_image Q e n) + rw [card_image_of_injective _ hi] at hh + exact hh + +lemma actualPaddingVertex_sq_activeState {m : ℕ} (Q : Finset ℕ) (e : Fin m ≃ Q) (n : ℤ) : + (actualPaddingVertex Q n) ^ 2 = (5 : ℝ) ^ (paddingActiveState Q e n).card := by + rw [actualPaddingVertex_sq, actualPaddingWeight, paddingActiveState_card] + +lemma retainedPadding_dvd_iff_activeState {m : ℕ} (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) (e : Fin m ≃ Q) (q : ℕ) + (hq : q ∈ retainedPrimeDivisors Q) (n : ℤ) : + (q : ℤ) ∣ n ↔ q.primeFactors ⊆ + (paddingActiveState Q e n).image (fun i => (e i).val) := by + rw [paddingActiveState_image, ← paddingAvailablePrimes_integer] + exact (padding_literal_support_iff_dvd Q hQ n q hq).symm + +lemma paddingActiveState_residue {m : ℕ} (Q : Finset ℕ) (e : Fin m ≃ Q) + (z : ∀ i, ZMod (e i).val) (n : ℤ) + (hn : ∀ i, (n : ZMod (e i).val) = z i) : + paddingActiveState Q e n = activeState (fun i => decide (z i = 0)) := by + ext i + simp only [paddingActiveState, activeState, mem_filter, mem_univ, true_and, + decide_eq_true_eq] + rw [← ZMod.intCast_zmod_eq_zero_iff_dvd, hn i] + +lemma actualPaddingVertex_sq_residue_state {m : ℕ} (Q : Finset ℕ) (e : Fin m ≃ Q) + (z : ∀ i, ZMod (e i).val) (n : ℤ) + (hn : ∀ i, (n : ZMod (e i).val) = z i) : + (actualPaddingVertex Q n) ^ 2 = + (5 : ℝ) ^ (activeState (fun i => decide (z i = 0))).card := by + rw [actualPaddingVertex_sq_activeState Q e n, paddingActiveState_residue Q e z n hn] + +lemma retainedPadding_dvd_iff_residue_state {m : ℕ} (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) (e : Fin m ≃ Q) (q : ℕ) + (hq : q ∈ retainedPrimeDivisors Q) (z : ∀ i, ZMod (e i).val) (n : ℤ) + (hn : ∀ i, (n : ZMod (e i).val) = z i) : + (q : ℤ) ∣ n ↔ q.primeFactors ⊆ + (activeState (fun i => decide (z i = 0))).image (fun i => (e i).val) := by + rw [← paddingActiveState_residue Q e z n hn] + exact retainedPadding_dvd_iff_activeState Q hQ e q hq n + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingBinCount.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingBinCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..431bde0f86ae089f3dece84b22c898aaf6b5fe8f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingBinCount.lean @@ -0,0 +1,46 @@ +import OAI.NumberTheory.TwoPoint.Walks.RetainedRowScale +import OAI.NumberTheory.TwoPoint.Bounds.PaddingBinCoverage + +namespace OAI + +/-! Bounds for the actual finite bin set at eta = exp(-J). -/ + +namespace TwoPointCorrelations + +open Filter + +lemma paddingBinIndices_card_linear (L η : ℝ) (hL : 1 ≤ L) + (hη : 0 < η) (hηone : η ≤ 1) : + ((paddingBinIndices L η).card : ℝ) ≤ 101 * L / η := by + have hb := paddingBinIndices_card L η (by linarith) hη + have hratio : 1 ≤ L / η := (one_le_div hη).mpr (by linarith) + have he : 101 * L / η = 100 * L / η + L / η := by ring + rw [he] + linarith + +lemma paddingBinIndices_card_polynomial (L W : ℝ) (hL : 101 ≤ L) (hW : 1 ≤ W) : + ((paddingBinIndices L (Real.exp (-(primeSupplyCount W L : ℝ)))).card : ℝ) ≤ + Real.exp (3 * Real.log L) := by + have hLp : 0 < L := by linarith + have hLone : 1 ≤ L := by linarith + have hJ := primeSupplyCount_le_log W L hW hLone + have he : Real.exp (primeSupplyCount W L) ≤ L := by + simpa only [Real.exp_log hLp] using Real.exp_le_exp.mpr hJ + have hη : Real.exp (-(primeSupplyCount W L : ℝ)) ≤ 1 := + Real.exp_le_one_iff.mpr (neg_nonpos.mpr (Nat.cast_nonneg _)) + have hb := paddingBinIndices_card_linear L (Real.exp (-(primeSupplyCount W L : ℝ))) + hLone (Real.exp_pos _) hη + calc + _ ≤ 101 * L / Real.exp (-(primeSupplyCount W L : ℝ)) := hb + _ = 101 * L * Real.exp (primeSupplyCount W L) := by rw [Real.exp_neg]; field_simp + _ ≤ 101 * L * L := mul_le_mul_of_nonneg_left he (by positivity) + _ ≤ L ^ 3 := by + have hx := mul_le_mul_of_nonneg_right hL (sq_nonneg L) + nlinarith + _ = _ := by + rw [show 3 * Real.log L = (3 : ℕ) * Real.log L by norm_num, + Real.exp_nat_mul, Real.exp_log hLp] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingBinCoverage.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingBinCoverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..340bf9f20e96bde91577a06e451131d8259af04c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingBinCoverage.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingRetainedProbability +import OAI.NumberTheory.TwoPoint.Bounds.PaddingIntegerBins +import Mathlib.Data.Int.Interval + +namespace OAI + +/-! The literal finite bin family covers every padding divisor surviving +the degree and logarithmic-size cuts. This includes the last bin whose +left endpoint, rather than its right endpoint, is at most `100 L`. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def paddingBinIndices (L η : ℝ) : Finset ℤ := + Icc 0 ⌊100 * L / η⌋ + +lemma mem_paddingBinIndices_iff (L η : ℝ) (j : ℤ) (hη : 0 < η) : + j ∈ paddingBinIndices L η ↔ 0 ≤ j ∧ (j : ℝ) * η ≤ 100 * L := by + rw [paddingBinIndices, mem_Icc, Int.le_floor, le_div_iff₀ hη] + +lemma paddingBin_mem_indices {L η x : ℝ} (hη : 0 < η) + (hx : 0 ≤ x) (hxL : x ≤ 100 * L) : + paddingBin η 0 x ∈ paddingBinIndices L η := by + change ⌊(x + 0) / η⌋ ∈ Icc 0 ⌊100 * L / η⌋ + rw [add_zero, mem_Icc] + exact ⟨Int.floor_nonneg.mpr (div_nonneg hx hη.le), + Int.floor_mono (div_le_div_of_nonneg_right hxL hη.le)⟩ + +lemma paddingBinIndices_card (L η : ℝ) (hL : 0 ≤ L) (hη : 0 < η) : + ((paddingBinIndices L η).card : ℝ) ≤ 100 * L / η + 1 := by + have hf : 0 ≤ ⌊100 * L / η⌋ := Int.floor_nonneg.mpr (by positivity) + have hc : ((paddingBinIndices L η).card : ℝ) = (⌊100 * L / η⌋ : ℝ) + 1 := by + have hh := Int.card_Icc_of_le 0 ⌊100 * L / η⌋ + (show (0 : ℤ) ≤ ⌊100 * L / η⌋ + 1 by omega) + simp only [sub_zero] at hh + change ((Icc (0 : ℤ) ⌊100 * L / η⌋).card : ℝ) = _ + exact_mod_cast hh + rw [hc] + linarith [Int.floor_le (100 * L / η)] + +def PaddingPairEligible (L η : ℝ) (d q : ℕ) : Prop := + (q.primeFactors.card : ℝ) ≤ 100 * Real.log L ∧ + paddingBin η 0 (Real.log (d * q : ℕ)) ∈ paddingBinIndices L η + +lemma paddingSelectedDivisor_count (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (b : Q → Bool) : + ((paddingSelectedDivisor Q b).primeFactors.card : ℝ) = booleanCount b := by + rw [paddingSelectedDivisor_primeFactors Q hQ b, paddingAvailablePrimes_card, + booleanCount_eq_card] + rfl + +lemma padding_pair_eligible_of_retained (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + {L η : ℝ} (hη : 0 < η) (d : ℕ) (hd : 0 < d) + (hdL : Real.log d ≤ 2 * L) (b : Q → Bool) + (hb : booleanCount b ≤ 100 * Real.log L ∧ paddingLog Q b ≤ 98 * L) : + PaddingPairEligible L η d (paddingSelectedDivisor Q b) := by + refine ⟨?_, ?_⟩ + · rw [paddingSelectedDivisor_count Q hQ b] + exact hb.1 + · apply paddingBin_mem_indices hη (log_nat_nonneg _) + have hq : 0 < paddingSelectedDivisor Q b := + retainedPrimeDivisor_pos Q hQ (paddingSelectedDivisor_mem Q b) + have hd0 : (d : ℝ) ≠ 0 := by exact_mod_cast hd.ne' + have hq0 : (paddingSelectedDivisor Q b : ℝ) ≠ 0 := by exact_mod_cast hq.ne' + rw [Nat.cast_mul, Real.log_mul hd0 hq0, paddingSelectedDivisor_log Q hQ b] + linarith [hb.2] + +lemma reciprocal_padding_eligible_probability (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) {L η : ℝ} (hη : 0 < η) + (hhalf : (1 / 2 : ℝ) ≤ (reciprocalPaddingLaw Q).probability + (fun b => booleanCount b ≤ 100 * Real.log L ∧ paddingLog Q b ≤ 98 * L)) + (d : ℕ) (hd : 0 < d) (hdL : Real.log d ≤ 2 * L) : + (1 / 2 : ℝ) ≤ (reciprocalPaddingLaw Q).probability + (fun b => PaddingPairEligible L η d (paddingSelectedDivisor Q b)) := by + apply hhalf.trans + apply FiniteLaw.average_mono + intro b + by_cases hb : booleanCount b ≤ 100 * Real.log L ∧ paddingLog Q b ≤ 98 * L + · have he := padding_pair_eligible_of_retained Q hQ hη d hd hdL b hb + simp only [ite_eq_left hb, ite_eq_left he, le_refl] + · simp only [ite_eq_right hb] + split_ifs <;> norm_num + +theorem ModFiveThetaInput.eventually_padding_bin_probability (hP : ModFiveThetaInput) + (E : Finset ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ η : ℝ, 0 < η → ∀ d : ℕ, + 0 < d → Real.log d ≤ 2 * L → + (1 / 2 : ℝ) ≤ (reciprocalPaddingLaw (paddingPrimeSupply E L)).probability + (fun b => PaddingPairEligible L η d + (paddingSelectedDivisor (paddingPrimeSupply E L) b)) := by + filter_upwards [hP.eventually_retained_padding_probability E] with L hL + intro η hη d hd hdL + exact reciprocal_padding_eligible_probability _ (fun _ hp => paddingPrimeSupply_prime hp) + hη hL d hd hdL + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingBinMassTotal.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingBinMassTotal.lean new file mode 100644 index 0000000000000000000000000000000000000000..394157c9709028a438cfa95d8109cc50e55b28c4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingBinMassTotal.lean @@ -0,0 +1,151 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingBinCoverage + +namespace OAI + +/-! The actual finite harmonic mass in the manuscript's half-open bins. +Its lower bound follows from the proved reciprocal padding law and its +upper bound simply removes the two restrictions. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def paddingPairHarmonicMass (Q : Finset ℕ) (L η : ℝ) (d : ℕ) : ℝ := + ∑ q ∈ retainedPrimeDivisors Q, + if PaddingPairEligible L η d q then + (4 : ℝ) ^ q.primeFactors.card / (d * q : ℕ) else 0 + +/-- This is the literal `S₀`: the index restriction is on the left endpoint +of each bin, exactly as in `q:bins`. -/ +noncomputable def totalPaddingBinMass (D Q : Finset ℕ) (L η : ℝ) : ℝ := + ∑ j ∈ paddingBinIndices L η, ∑ d ∈ D, ∑ q ∈ retainedPrimeDivisors Q, + if (q.primeFactors.card : ℝ) ≤ 100 * Real.log L ∧ + (j : ℝ) * η ≤ Real.log (d * q : ℕ) ∧ + Real.log (d * q : ℕ) < ((j : ℝ) + 1) * η + then (4 : ℝ) ^ q.primeFactors.card / (d * q : ℕ) else 0 + +lemma padding_bin_weight_sum (L η : ℝ) (d q : ℕ) (hη : 0 < η) : + (∑ j ∈ paddingBinIndices L η, + if (q.primeFactors.card : ℝ) ≤ 100 * Real.log L ∧ + (j : ℝ) * η ≤ Real.log (d * q : ℕ) ∧ + Real.log (d * q : ℕ) < ((j : ℝ) + 1) * η + then (4 : ℝ) ^ q.primeFactors.card / (d * q : ℕ) else 0) = + if PaddingPairEligible L η d q then + (4 : ℝ) ^ q.primeFactors.card / (d * q : ℕ) else 0 := by + have hi (j : ℤ) : + ((j : ℝ) * η ≤ Real.log (d * q : ℕ) ∧ + Real.log (d * q : ℕ) < ((j : ℝ) + 1) * η) ↔ + paddingBin η 0 (Real.log (d * q : ℕ)) = j := by + simpa only [add_zero] using + (paddingBin_eq_iff η 0 (Real.log (d * q : ℕ)) j hη).symm + simp only [hi, PaddingPairEligible] + by_cases hc : (q.primeFactors.card : ℝ) ≤ 100 * Real.log L + · simp [hc] + · simp [hc] + +lemma totalPaddingBinMass_eq (D Q : Finset ℕ) (L η : ℝ) (hη : 0 < η) : + totalPaddingBinMass D Q L η = ∑ d ∈ D, paddingPairHarmonicMass Q L η d := by + unfold totalPaddingBinMass paddingPairHarmonicMass + rw [sum_comm] + apply sum_congr rfl + intro d _ + rw [sum_comm] + apply sum_congr rfl + intro q _ + exact padding_bin_weight_sum L η d q hη + +lemma paddingPairHarmonicMass_probability (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) (L η : ℝ) (d : ℕ) : + paddingPairHarmonicMass Q L η d = + (paddingTiltNormalizer Q / d) * (reciprocalPaddingLaw Q).probability + (fun b => PaddingPairEligible L η d (paddingSelectedDivisor Q b)) := by + let T : ℝ := ∑ q ∈ retainedPrimeDivisors Q, + ((4 : ℝ) ^ q.primeFactors.card / (q : ℝ)) * + (if PaddingPairEligible L η d q then 1 else 0) + have hP := reciprocal_padding_average Q hQ + (fun q => if PaddingPairEligible L η d q then 1 else 0) + change (reciprocalPaddingLaw Q).probability + (fun b => PaddingPairEligible L η d (paddingSelectedDivisor Q b)) = + (paddingTiltNormalizer Q)⁻¹ * T at hP + have he : paddingPairHarmonicMass Q L η d = (1 / (d : ℝ)) * T := by + unfold paddingPairHarmonicMass T + rw [mul_sum] + apply sum_congr rfl + intro q _ + by_cases h : PaddingPairEligible L η d q + · simp only [ite_eq_left h, mul_one, Nat.cast_mul] + simp only [div_eq_mul_inv, mul_inv_rev] + ring + · simp only [ite_eq_right h, mul_zero] + rw [he, hP] + have hS := paddingTiltNormalizer_pos Q + simp only [div_eq_mul_inv, one_mul] + symm + calc + _ = (paddingTiltNormalizer Q * (paddingTiltNormalizer Q)⁻¹) * + ((d : ℝ)⁻¹ * T) := by ring + _ = _ := by rw [mul_inv_cancel₀ hS.ne', one_mul] + +lemma paddingPairHarmonicMass_bounds (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) {L η : ℝ} (hη : 0 < η) + (hhalf : (1 / 2 : ℝ) ≤ (reciprocalPaddingLaw Q).probability + (fun b => booleanCount b ≤ 100 * Real.log L ∧ paddingLog Q b ≤ 98 * L)) + (d : ℕ) (hd : 0 < d) (hdL : Real.log d ≤ 2 * L) : + (paddingTiltNormalizer Q / d) * (1 / 2) ≤ paddingPairHarmonicMass Q L η d ∧ + paddingPairHarmonicMass Q L η d ≤ paddingTiltNormalizer Q / d := by + rw [paddingPairHarmonicMass_probability Q hQ] + have hfactor : 0 ≤ paddingTiltNormalizer Q / (d : ℝ) := + div_nonneg (paddingTiltNormalizer_pos Q).le (Nat.cast_nonneg d) + constructor + · exact mul_le_mul_of_nonneg_left + (reciprocal_padding_eligible_probability Q hQ hη hhalf d hd hdL) hfactor + · exact (mul_le_mul_of_nonneg_left + ((reciprocalPaddingLaw Q).probability_le_one _) hfactor).trans_eq (mul_one _) + +theorem totalPaddingBinMass_bounds (D Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) {L η : ℝ} (hη : 0 < η) + (hhalf : (1 / 2 : ℝ) ≤ (reciprocalPaddingLaw Q).probability + (fun b => booleanCount b ≤ 100 * Real.log L ∧ paddingLog Q b ≤ 98 * L)) + (hD : ∀ d ∈ D, 0 < d ∧ Real.log d ≤ 2 * L) : + (1 / 2 : ℝ) * paddingTiltNormalizer Q * (∑ d ∈ D, 1 / (d : ℝ)) ≤ + totalPaddingBinMass D Q L η ∧ + totalPaddingBinMass D Q L η ≤ + paddingTiltNormalizer Q * (∑ d ∈ D, 1 / (d : ℝ)) := by + rw [totalPaddingBinMass_eq D Q L η hη] + have hl : (1 / 2 : ℝ) * paddingTiltNormalizer Q * (∑ d ∈ D, 1 / (d : ℝ)) = + ∑ d ∈ D, (paddingTiltNormalizer Q / d) * (1 / 2) := by + rw [mul_sum] + apply sum_congr rfl + intro d _ + ring + have hu : paddingTiltNormalizer Q * (∑ d ∈ D, 1 / (d : ℝ)) = + ∑ d ∈ D, paddingTiltNormalizer Q / d := by + rw [mul_sum] + apply sum_congr rfl + intro d _ + ring + rw [hl, hu] + constructor + · exact sum_le_sum fun d hd => + (paddingPairHarmonicMass_bounds Q hQ hη hhalf d (hD d hd).1 (hD d hd).2).1 + · exact sum_le_sum fun d hd => + (paddingPairHarmonicMass_bounds Q hQ hη hhalf d (hD d hd).1 (hD d hd).2).2 + +/-- The manuscript's retained bin mass bound, uniform over every finite +centered divisor family with the proved logarithmic size restriction. -/ +theorem ModFiveThetaInput.eventually_totalPaddingBinMass (hP : ModFiveThetaInput) + (E : Finset ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (D : Finset ℕ) (η : ℝ), 0 < η → + (∀ d ∈ D, 0 < d ∧ Real.log d ≤ 2 * L) → + (1 / 2 : ℝ) * paddingTiltNormalizer (paddingPrimeSupply E L) * + (∑ d ∈ D, 1 / (d : ℝ)) ≤ totalPaddingBinMass D (paddingPrimeSupply E L) L η ∧ + totalPaddingBinMass D (paddingPrimeSupply E L) L η ≤ + paddingTiltNormalizer (paddingPrimeSupply E L) * (∑ d ∈ D, 1 / (d : ℝ)) := by + filter_upwards [hP.eventually_retained_padding_probability E] with L hL + intro D η hη hD + exact totalPaddingBinMass_bounds D _ (fun _ hp => paddingPrimeSupply_prime hp) hη hL hD + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingBinSquare.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingBinSquare.lean new file mode 100644 index 0000000000000000000000000000000000000000..0909e356e1211476d3b0b21ad1b5b79494af872e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingBinSquare.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingPairSampling +import OAI.NumberTheory.TwoPoint.Bounds.PaddingPrimeOscillation +import Mathlib.Algebra.Order.Floor.Ring + +namespace OAI + +/-! The actual bin-square padding average is bounded by the exact difference +small-ball probability, uniformly in a common translation of all bins. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace FiniteLaw + +variable {α β : Type*} [Fintype α] + +lemma average_finset_sum (μ : FiniteLaw α) (s : Finset β) (F : β → α → ℝ) : + μ.average (fun x => ∑ b ∈ s, F b x) = ∑ b ∈ s, μ.average (F b) := by + simp only [average, mul_sum] + exact sum_comm + +lemma partial_collision_bound (μ : FiniteLaw α) (bin : α → β) (B : Finset β) : + (∑ b ∈ B, (μ.probability (fun x => bin x = b)) ^ 2) ≤ + μ.average (fun x => μ.probability (fun y => bin x = bin y)) := by + calc + _ = μ.average (fun x => μ.average (fun y => + ∑ b ∈ B, (if bin x = b then 1 else 0) * (if bin y = b then 1 else 0))) := by + simp only [average_finset_sum] + apply sum_congr rfl + intro b _ + simpa only [probability] using square_average_eq μ (fun x => if bin x = b then 1 else 0) + _ ≤ _ := by + apply μ.average_mono + intro x + apply μ.average_mono + intro y + change (∑ b ∈ B, (if bin x = b then (1 : ℝ) else 0) * + (if bin y = b then 1 else 0)) ≤ if bin x = bin y then 1 else 0 + by_cases h : bin x = bin y + · have he (b : β) : + (if bin x = b then (1 : ℝ) else 0) * (if bin y = b then 1 else 0) = + (if bin x = b then 1 else 0) := by + by_cases hx : bin x = b <;> simp [hx, ← h] + simp_rw [he] + rw [ite_eq_left h] + by_cases hx : bin x ∈ B <;> simp [hx] + · rw [ite_eq_right h] + apply le_of_eq + apply sum_eq_zero + intro b _ + by_cases hx : bin x = b + · have hy : bin y ≠ b := fun hy => h (hx.trans hy.symm) + simp [hx, hy] + · simp [hx] + +end FiniteLaw + +noncomputable def paddingBin (η c x : ℝ) : ℤ := ⌊(x + c) / η⌋ + +lemma paddingBin_difference {η c x y : ℝ} (hη : 0 < η) + (h : paddingBin η c x = paddingBin η c y) : |x - y| < η := by + have hh := Int.abs_sub_lt_one_of_floor_eq_floor h + have he : (x + c) / η - (y + c) / η = (x - y) / η := by ring + rw [he, abs_div, abs_of_pos hη] at hh + exact (div_lt_one hη).mp hh + +noncomputable def paddingBinMass (Q : Finset ℕ) (a : Q → Bool) (η c : ℝ) (j : ℤ) : ℝ := + (paddingDivisorLaw Q a).probability (fun b => paddingBin η c (paddingLog Q b) = j) + +lemma padding_bin_square_small_ball (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) + (η c : ℝ) (hη : 0 < η) (hη1 : η ≤ 1) (B : Finset ℤ) : + (paddingAvailableLaw Q hQ).average (fun a => + ∑ j ∈ B, (paddingBinMass Q a η c j) ^ 2) ≤ + (paddingDifferenceLaw Q hQ).probability + (fun x => |paddingDifferenceValue Q x| ≤ 1) := by + calc + _ ≤ (paddingAvailableLaw Q hQ).average (fun a => + (paddingDivisorLaw Q a).average (fun b => + (paddingDivisorLaw Q a).probability (fun d => + paddingBin η c (paddingLog Q b) = paddingBin η c (paddingLog Q d)))) := by + apply FiniteLaw.average_mono + intro a + exact FiniteLaw.partial_collision_bound _ _ _ + _ ≤ (paddingAvailableLaw Q hQ).average (fun a => + (paddingDivisorLaw Q a).average (fun b => + (paddingDivisorLaw Q a).probability (fun d => |paddingLog Q b - paddingLog Q d| ≤ 1))) := by + apply FiniteLaw.average_mono + intro a + apply FiniteLaw.average_mono + intro b + apply FiniteLaw.average_mono + intro d + by_cases h : paddingBin η c (paddingLog Q b) = paddingBin η c (paddingLog Q d) + · have hd := (paddingBin_difference hη h).le.trans hη1 + simp [h, hd] + · simp [h] + split_ifs <;> norm_num + _ = _ := padding_pair_difference_average Q hQ (fun z => if |z| ≤ 1 then 1 else 0) + +/-- The manuscript's squared bin mass, with tilted prime availability and +actual independent divisor selections, is `O(1/L)` uniformly in bin location. -/ +theorem ModFiveThetaInput.padding_bin_square (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ C : ℝ, 0 < C ∧ ∀ (L η c : ℝ) (B : Finset ℤ), 1 ≤ L → 0 < η → η ≤ 1 → + (paddingAvailableLaw (paddingPrimeSupply E L) + (fun _ hp => (paddingPrimeSupply_prime hp).two_le)).average (fun a => + ∑ j ∈ B, (paddingBinMass (paddingPrimeSupply E L) a η c j) ^ 2) ≤ C / L := by + obtain ⟨C, hC, hbound⟩ := hP.padding_small_ball E + exact ⟨C, hC, fun L η c B hL hη hη1 => + (padding_bin_square_small_ball _ _ η c hη hη1 B).trans (hbound L hL)⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingCatalog.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingCatalog.lean new file mode 100644 index 0000000000000000000000000000000000000000..12b94479e3b43511ddebece9042fb655c51493c3 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingCatalog.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CrudeNumericalWordSum +import OAI.NumberTheory.TwoPoint.Bounds.PaddingResidueEvent + +namespace OAI + +/-! The padding catalog also pays only one reciprocal per distinct prime. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def paddingOnlyWord {R : ℕ} (q : Fin R → ℕ) : Fin R → SignedStep := + fun i => ⟨false, 1, q i⟩ + +lemma paddingOnlyWord_injective (R : ℕ) : + Function.Injective (paddingOnlyWord (R := R)) := by + intro q r h + funext i + exact congrArg SignedStep.padding (congrFun h i) + +lemma paddingOnlyWord_support {R : ℕ} (q : Fin R → ℕ) : + wordDivisorPrimeSupport (List.ofFn (paddingOnlyWord q)) = paddingPrimeSupport q := by + ext p + simp only [wordDivisorPrimeSupport, List.mem_toFinset, List.mem_ofFn, mem_biUnion, + paddingPrimeSupport, mem_univ, true_and, paddingOnlyWord] + constructor + · rintro ⟨a, ⟨i, rfl⟩, hp⟩ + refine ⟨i, ?_⟩ + change p ∈ (q i * 1).primeFactors at hp + simpa only [mul_one] using hp + · rintro ⟨i, hp⟩ + refine ⟨⟨false, 1, q i⟩, ⟨i, rfl⟩, ?_⟩ + change p ∈ (q i * 1).primeFactors + simpa only [mul_one] using hp + +theorem padding_catalog_reciprocal_sum (R M : ℕ) (Q : Finset ℕ) + (F : Finset (Fin R → ℕ)) (U : ℝ) (hU : 1 ≤ U) + (hQ : primeHarmonicMass Q ≤ U) + (hsq : ∀ q ∈ F, ∀ i, Squarefree (q i)) + (hpool : ∀ q ∈ F, ∀ i, (q i).primeFactors ⊆ Q) + (hcount : ∀ q ∈ F, ∀ i, (q i).primeFactors.card ≤ M) : + (∑ q ∈ F, ∏ p ∈ paddingPrimeSupport q, (p : ℝ)⁻¹) ≤ + (∑ n : Fin (R * M + 1), (Fintype.card (CrudeWordCode R n.val R) : ℝ)) * U ^ (R * M) := by + have hc : ∀ v ∈ F.image paddingOnlyWord, + Fintype.card (ActualPrimeSlot v) ≤ R * M := by + intro v hv + obtain ⟨q, hq, rfl⟩ := mem_image.mp hv + simpa only [zero_add] using actualPrimeSlot_card_le (paddingOnlyWord q) 0 M + (by intro i; simp [paddingOnlyWord]) (hcount q hq) + have hb := numerical_word_reciprocal_sum_le R (R * M) ∅ Q + (F.image paddingOnlyWord) (fun _ => 1) 1 U (by norm_num) hU + (by simpa [primeHarmonicMass] using zero_le_one.trans hU) hQ + (by intros; exact le_rfl) hc + (by intro v hv i; obtain ⟨q, _, rfl⟩ := mem_image.mp hv; simp [paddingOnlyWord]) + (by intro v hv i; obtain ⟨q, hq, rfl⟩ := mem_image.mp hv; exact hsq q hq i) + (by intro v hv i; obtain ⟨q, _, rfl⟩ := mem_image.mp hv; simp [paddingOnlyWord]) + (by intro v hv i; obtain ⟨q, hq, rfl⟩ := mem_image.mp hv; exact hpool q hq i) + (by intro v hv i j; obtain ⟨q, _, rfl⟩ := mem_image.mp hv; simp [paddingOnlyWord]) + rw [sum_image (fun q _ r _ he => paddingOnlyWord_injective R he)] at hb + simpa only [one_mul, paddingOnlyWord_support] using hb + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingCharacteristic.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingCharacteristic.lean new file mode 100644 index 0000000000000000000000000000000000000000..f33cae0af944b818c0dd11e95fb64f7651150be0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingCharacteristic.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveProducts +import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic + +namespace OAI + +/-! The finite characteristic product in the padding argument. The loss +from replacing `p+4` by `p` is bounded explicitly by a convergent square +sum, using only elementary estimates. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def paddingCharacteristicFactor (p : ℕ) (t : ℝ) : ℝ := + 1 - 8 * (1 - Real.cos (t * Real.log p)) / (5 * ((p : ℝ) + 4)) + +noncomputable def paddingCharacteristic (Q : Finset ℕ) (t : ℝ) : ℝ := + ∏ p ∈ Q, paddingCharacteristicFactor p t + +noncomputable def paddingOscillation (Q : Finset ℕ) (t : ℝ) : ℝ := + ∑ p ∈ Q, (1 - Real.cos (t * Real.log p)) / p + +lemma one_sub_cos_bounds (x : ℝ) : 0 ≤ 1 - Real.cos x ∧ 1 - Real.cos x ≤ 2 := by + constructor <;> linarith [Real.cos_le_one x, Real.neg_one_le_cos x] + +lemma paddingCharacteristicFactor_bounds (p : ℕ) (hp : 2 ≤ p) (t : ℝ) : + 7 / 15 ≤ paddingCharacteristicFactor p t ∧ paddingCharacteristicFactor p t ≤ 1 := by + have hpr : (2 : ℝ) ≤ p := by exact_mod_cast hp + have hd : 0 < 5 * ((p : ℝ) + 4) := by positivity + have hb := one_sub_cos_bounds (t * Real.log p) + unfold paddingCharacteristicFactor + constructor + · have hh : 8 * (1 - Real.cos (t * Real.log p)) / (5 * ((p : ℝ) + 4)) ≤ 8 / 15 := by + apply (div_le_iff₀ hd).mpr + nlinarith + linarith + · have hh : 0 ≤ 8 * (1 - Real.cos (t * Real.log p)) / (5 * ((p : ℝ) + 4)) := + div_nonneg (mul_nonneg (by norm_num) hb.1) hd.le + linarith + +lemma padding_reciprocal_shift (p : ℕ) (hp : 2 ≤ p) (u : ℝ) (hu2 : u ≤ 2) : + u / p - u / ((p : ℝ) + 4) ≤ 8 / (p : ℝ) ^ 2 := by + have hpr : (0 : ℝ) < p := by exact_mod_cast (by omega : 0 < p) + apply (mul_le_mul_iff_of_pos_right (by positivity : 0 < (p : ℝ) ^ 2 * ((p : ℝ) + 4))).mp + field_simp + nlinarith [mul_le_mul_of_nonneg_left hu2 hpr.le] + +theorem paddingCharacteristic_nonneg (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) (t : ℝ) : + 0 ≤ paddingCharacteristic Q t := + prod_nonneg (fun p hp => (by linarith [(paddingCharacteristicFactor_bounds p (hQ p hp) t).1])) + +theorem paddingCharacteristic_exp_bound (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) (t : ℝ) : + paddingCharacteristic Q t ≤ Real.exp (64 / 5) * + Real.exp (-(8 / 5 : ℝ) * paddingOscillation Q t) := by + have hfirst : paddingCharacteristic Q t ≤ + Real.exp (-(8 / 5 : ℝ) * ∑ p ∈ Q, (1 - Real.cos (t * Real.log p)) / ((p : ℝ) + 4)) := by + calc + _ ≤ ∏ p ∈ Q, Real.exp (-(8 / 5 : ℝ) * + ((1 - Real.cos (t * Real.log p)) / ((p : ℝ) + 4))) := by + apply prod_le_prod₀ + · intro p hp + linarith [(paddingCharacteristicFactor_bounds p (hQ p hp) t).1] + · intro p hp + have hh := Real.add_one_le_exp (-(8 / 5 : ℝ) * + ((1 - Real.cos (t * Real.log p)) / ((p : ℝ) + 4))) + unfold paddingCharacteristicFactor + convert hh using 1 + field_simp + ring + _ = _ := by rw [← Real.exp_sum]; congr 1; rw [mul_sum] + have hdiff : paddingOscillation Q t - + (∑ p ∈ Q, (1 - Real.cos (t * Real.log p)) / ((p : ℝ) + 4)) ≤ 8 := by + unfold paddingOscillation + rw [← sum_sub_distrib] + calc + _ ≤ ∑ p ∈ Q, 8 / (p : ℝ) ^ 2 := sum_le_sum (fun p hp => + padding_reciprocal_shift p (hQ p hp) _ + (one_sub_cos_bounds _).2) + _ = 8 * ∑ p ∈ Q, 1 / (p : ℝ) ^ 2 := by rw [mul_sum]; apply sum_congr rfl; intros; ring + _ ≤ 8 := by linarith [reciprocal_square_sum_le_one Q hQ] + apply hfirst.trans + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + linarith + +/-- Once the internally derived oscillatory prime estimate is supplied, +the padding Fourier decay has the exponent `6/5` required for integrability. -/ +theorem paddingCharacteristic_power_bound (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) + (L C t : ℝ) (hL : 0 ≤ L) + (hprime : (3 / 4 : ℝ) * Real.log (1 + L * |t|) - C ≤ paddingOscillation Q t) : + paddingCharacteristic Q t ≤ Real.exp ((8 / 5 : ℝ) * C + 64 / 5) * + (1 + L * |t|) ^ (-6 / 5 : ℝ) := by + apply (paddingCharacteristic_exp_bound Q hQ t).trans + have hx : 0 < 1 + L * |t| := by positivity + rw [Real.rpow_def_of_pos hx, ← Real.exp_add, ← Real.exp_add] + apply Real.exp_le_exp.mpr + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingCutCircuit.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingCutCircuit.lean new file mode 100644 index 0000000000000000000000000000000000000000..4cd545b110843fb146282bd77f565ead865664f2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingCutCircuit.lean @@ -0,0 +1,155 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeDegreeCircuit +import OAI.NumberTheory.TwoPoint.Bounds.PaddingStateWeights + +namespace OAI + +/-! Arbitrary predicates of a bounded padding-prime state have a +literal depth-two DNF. Conjoining a fixed divisor costs one layer. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def activePredicateCircuit (n M : ℕ) (E : Finset (Fin n) → Prop) : + AC0Circuit n := + AC0Circuit.disjunction (fun S : (boundedActiveStates n M).filter E => + activeStateCircuit S.val) + +lemma activePredicateCircuit_eval (n M : ℕ) (E : Finset (Fin n) → Prop) + (x : BooleanCube n) : + (activePredicateCircuit n M E).eval x = true ↔ + (activeState x).card ≤ M ∧ E (activeState x) := by + rw [activePredicateCircuit, AC0Circuit.disjunction_eval] + constructor + · rintro ⟨S, hS⟩ + have he := (activeStateCircuit_eval S.val x).mp hS + have hm := mem_filter.mp S.property + simpa only [he] using (And.intro (mem_boundedActiveStates.mp hm.1) hm.2) + · intro hx + refine ⟨⟨activeState x, mem_filter.mpr ⟨mem_boundedActiveStates.mpr hx.1, hx.2⟩⟩, ?_⟩ + exact (activeStateCircuit_eval _ _).mpr rfl + +lemma activePredicateCircuit_depth (n M : ℕ) (E : Finset (Fin n) → Prop) : + (activePredicateCircuit n M E).depth ≤ 2 := + AC0Circuit.disjunction_depth _ (fun S => activeStateCircuit_depth S.val) + +lemma activePredicateCircuit_size (n M : ℕ) (E : Finset (Fin n) → Prop) : + (activePredicateCircuit n M E).size ≤ 1 + (M + 1) * (n + 1) ^ (M + 1) := by + rw [activePredicateCircuit, AC0Circuit.disjunction_size] + simp only [activeStateCircuit_size, sum_const, card_univ, Fintype.card_coe, nsmul_eq_mul] + have hcard := (card_filter_le (boundedActiveStates n M) E).trans (boundedActiveStates_card n M) + calc + _ ≤ 1 + ((M + 1) * (n + 1) ^ M) * (1 + n) := by + gcongr + exact_mod_cast hcard + _ = _ := by rw [pow_succ]; ring + +noncomputable def stateDivisorCircuit {m n t : ℕ} + (qindex : Fin n → Fin m) (dindex : Fin t → Fin m) (M : ℕ) + (E : Finset (Fin n) → Prop) : AC0Circuit m := + AC0Circuit.conjunction (fun b : Bool => if b then + AC0Circuit.relabel qindex (activePredicateCircuit n M E) else + AC0Circuit.relabel dindex (degreeSubsetCircuit univ)) + +lemma stateDivisorCircuit_eval {m n t : ℕ} + (qindex : Fin n → Fin m) (dindex : Fin t → Fin m) (M : ℕ) + (E : Finset (Fin n) → Prop) (x : BooleanCube m) : + (stateDivisorCircuit qindex dindex M E).eval x = true ↔ + (∀ i, x (dindex i) = true) ∧ + (activeState (fun i => x (qindex i))).card ≤ M ∧ + E (activeState (fun i => x (qindex i))) := by + rw [stateDivisorCircuit, AC0Circuit.conjunction_eval] + simp only [Bool.forall_bool, Bool.false_eq_true, ite_false, ite_true, + AC0Circuit.relabel_eval, activePredicateCircuit_eval, degreeSubsetCircuit_eval] + have he : (univ : Finset (Fin t)) ⊆ activeState (fun i => x (dindex i)) ↔ + ∀ i, x (dindex i) = true := by + simp only [subset_iff, mem_univ, activeState, mem_filter, true_and, forall_const] + rw [he] + +lemma stateDivisorCircuit_depth {m n t : ℕ} + (qindex : Fin n → Fin m) (dindex : Fin t → Fin m) (M : ℕ) + (E : Finset (Fin n) → Prop) : + (stateDivisorCircuit qindex dindex M E).depth ≤ 3 := by + apply AC0Circuit.conjunction_depth + intro b + cases b + · exact (AC0Circuit.relabel_depth _ _).trans ((degreeSubsetCircuit_depth _).trans (by omega)) + · exact (AC0Circuit.relabel_depth _ _).trans (activePredicateCircuit_depth _ _ _) + +lemma stateDivisorCircuit_size {m n t : ℕ} + (qindex : Fin n → Fin m) (dindex : Fin t → Fin m) (M : ℕ) + (E : Finset (Fin n) → Prop) : + (stateDivisorCircuit qindex dindex M E).size ≤ + 3 + t + (M + 1) * (n + 1) ^ (M + 1) := by + rw [stateDivisorCircuit, AC0Circuit.conjunction_size] + simp only [Fintype.sum_bool, Bool.false_eq_true, ite_false, ite_true] + have hq := AC0Circuit.relabel_size qindex (activePredicateCircuit n M E) + have hd := AC0Circuit.relabel_size dindex (degreeSubsetCircuit (univ : Finset (Fin t))) + have hs := activePredicateCircuit_size n M E + simp only [degreeSubsetCircuit_size, card_univ, Fintype.card_fin] at hd + omega + +lemma stateDivisorCircuit_size_exp {m n t : ℕ} + (qindex : Fin n → Fin m) (dindex : Fin t → Fin m) (M : ℕ) + (E : Finset (Fin n) → Prop) (L : ℝ) (hL : 4800 ≤ L) + (hn : (n : ℝ) ≤ Real.exp L) (ht : (t : ℝ) ≤ 100 * Real.log L) + (hM : (M : ℝ) ≤ 400 * Real.log L) : + ((stateDivisorCircuit qindex dindex M E).size : ℝ) ≤ Real.exp (L ^ 3) := by + have hL0 : 0 ≤ L := by linarith + have hlog : Real.log L ≤ L := + (Real.log_le_sub_one_of_pos (by linarith)).trans (by linarith) + have hML : (M : ℝ) + 1 ≤ 401 * L := by nlinarith + have htwo : (2 : ℝ) ≤ Real.exp L := by linarith [Real.add_one_le_exp L] + have hn' : (n : ℝ) + 1 ≤ Real.exp (2 * L) := by + rw [show 2 * L = L + L by ring, Real.exp_add] + nlinarith + have hprod : ((M : ℝ) + 1) * ((n : ℝ) + 1) ^ (M + 1) ≤ + Real.exp (1203 * L ^ 2) := by + have heM : (M : ℝ) + 1 ≤ Real.exp ((M : ℝ) + 1) := by + linarith [Real.add_one_le_exp ((M : ℝ) + 1)] + calc + _ ≤ Real.exp ((M : ℝ) + 1) * (Real.exp (2 * L)) ^ (M + 1) := + mul_le_mul heM + (pow_le_pow_left₀ (by positivity) hn' _) (by positivity) (by positivity) + _ = Real.exp (((M : ℝ) + 1) * (1 + 2 * L)) := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + push_cast + congr 1 + ring + _ ≤ _ := Real.exp_le_exp.mpr (by + have hm := mul_le_mul_of_nonneg_right hML (show 0 ≤ 1 + 2 * L by positivity) + have hs := mul_nonneg hL0 (show 0 ≤ L - 1 by linarith) + nlinarith) + have hsmall : 3 + (t : ℝ) ≤ Real.exp (1203 * L ^ 2) := by + have he := Real.add_one_le_exp (1203 * L ^ 2) + nlinarith [sq_nonneg (L - 1)] + have hc : ((stateDivisorCircuit qindex dindex M E).size : ℝ) ≤ + 3 + t + ((M : ℝ) + 1) * ((n : ℝ) + 1) ^ (M + 1) := by + exact_mod_cast stateDivisorCircuit_size qindex dindex M E + calc + _ ≤ 2 * Real.exp (1203 * L ^ 2) := by linarith + _ ≤ Real.exp (1 + 1203 * L ^ 2) := by + rw [Real.exp_add] + exact mul_le_mul_of_nonneg_right + (by linarith [Real.add_one_le_exp (1 : ℝ)]) (Real.exp_pos _).le + _ ≤ _ := Real.exp_le_exp.mpr (by + have hsq : (1 : ℝ) ≤ L ^ 2 := by nlinarith + have hh := mul_nonneg (sq_nonneg L) (show 0 ≤ L - 1204 by linarith) + nlinarith) + +lemma stateDivisorCircuit_integer (U Q : Finset ℕ) (hQU : Q ⊆ U) + (hQ : ∀ p ∈ Q, p.Prime) (q : ℕ) (hq : q ∈ retainedPrimeDivisors Q) + (M : ℕ) (E : Finset (Fin (Fintype.card Q)) → Prop) (n : ℤ) : + (stateDivisorCircuit (primeSubsetIndex U Q hQU) + (primeSubsetIndex U q.primeFactors ((retainedPrimeDivisor_factors Q hQ hq).trans hQU)) + M E).eval (primeSiteBits U n) = true ↔ + (q : ℤ) ∣ n ∧ actualPaddingDegree Q n ≤ M ∧ + E (paddingActiveState Q (Fintype.equivFin Q).symm n) := by + rw [stateDivisorCircuit_eval, prime_divisor_all_bits U Q hQU hQ q hq n, + primeSubsetIndex_bits, primeSiteBits_card] + rfl + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingCutCost.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingCutCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad47b72780d1f1d5270db81cd3b4447be14b31fa --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingCutCost.lean @@ -0,0 +1,113 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualPaddingCuts +import OAI.NumberTheory.TwoPoint.Bounds.PrimePaddingFactorization + +namespace OAI + +/-! The two padding deletions with the positive tuple weight retained. +The literal rejection function depends only on Q residues. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def paddingRejectedMass (Q D : Finset ℕ) (bins : Finset ℤ) + (η c L K : ℝ) (n : ℤ) : ℝ := + (actualPaddingVertex Q n) ^ 2 * + ∑ j ∈ bins, if ¬integerEdgeKeep D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex Q) L K (actualPaddingDegreeCut Q L) n then + paddingDensity D actualPaddingCoefficient (actualPaddingBin η c j) + (actualPaddingVertex Q) n else 0 + +lemma paddingRejectedMass_nonneg (Q D : Finset ℕ) (bins : Finset ℤ) + (η c L K : ℝ) (n : ℤ) : 0 ≤ paddingRejectedMass Q D bins η c L K n := by + apply mul_nonneg (sq_nonneg _) + apply sum_nonneg + intro j _ + have hd := actualPaddingDensity_nonneg Q D (actualPaddingBin η c j) n + split_ifs <;> linarith + +lemma paddingRejectedMass_residue_congr (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) (D : Finset ℕ) (hD : D ⊆ retainedPrimeDivisors Q) + (bins : Finset ℤ) (η c L K : ℝ) (n m : ℤ) + (hnm : ∀ p ∈ Q, (n : ZMod p) = (m : ZMod p)) : + paddingRejectedMass Q D bins η c L K n = paddingRejectedMass Q D bins η c L K m := by + unfold paddingRejectedMass + rw [actualPaddingVertex_residue_congr Q n m hnm] + congr 1 + apply sum_congr rfl + intro j _ + simp only [actualPaddingKeep_residue_congr Q hQ D hD (actualPaddingBin η c j) L K n m hnm, + actualPaddingDensity_residue_congr Q hQ D hD (actualPaddingBin η c j) n m hnm] + +namespace ProhibitedPrimeFamily + +variable {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + +lemma positive_prime_padding_factor (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (S : Finset ℕ) (hSP : S ⊆ data.P) (site : ℤ) (g : ℤ → ℝ) + (hg : ∀ n m : ℤ, (∀ q ∈ data.Q, (n : ZMod q) = (m : ZMod q)) → g n = g m) : + (data.residueLaw B hB).average (fun x => + positivePrimeWeight S (data.residueOrigin x + site) * g (data.residueOrigin x + site)) = + positivePrimeNormalizer S * + (data.residueLaw B hB).average (fun x => g (data.residueOrigin x + site)) := by + rw [data.positive_prime_padding_average hB S hSP site g hg, + data.residue_average_padding_shift hB site g hg] + +end ProhibitedPrimeFamily + +theorem ModFiveThetaInput.eventually_positive_padding_cut_cost + (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, + ∀ (η c K : ℝ) (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M), + data.Q = paddingPrimeSupply E L → + ∀ (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) (site : ℤ) (bins : Finset ℤ), + 0 < η → η ≤ 1 → 0 < K → + ∀ (D : Finset ℕ), D ⊆ retainedPrimeDivisors data.Q → + ∀ (S : Finset ℕ), S ⊆ data.P → + (data.residueLaw B hB).average (fun x => + positivePrimeWeight S (data.residueOrigin x + site) * + paddingRejectedMass data.Q D bins η c L K (data.residueOrigin x + site)) / + paddingTiltNormalizer data.Q ≤ + positivePrimeNormalizer S * (C / K + L ^ (-100 : ℝ)) := by + obtain ⟨C, hC, hb⟩ := hP.eventually_actual_padding_keep_loss E + refine ⟨C, hC, ?_⟩ + filter_upwards [hb] with L hb + intro η c K h J M B data hQ hB site bins hη hηone hK D hD S hSP + have hg := paddingRejectedMass_residue_congr data.Q data.primeQ D hD bins η c L K + have he := data.positive_prime_padding_factor hB S hSP site + (paddingRejectedMass data.Q D bins η c L K) hg + rw [he] + calc + _ = positivePrimeNormalizer S * + ((data.residueLaw B hB).average (fun x => + paddingRejectedMass data.Q D bins η c L K (data.residueOrigin x + site)) / + paddingTiltNormalizer data.Q) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left + (hb η c K h J M B data hQ site bins hη hηone hK hB D hD) + (by unfold positivePrimeNormalizer; positivity) + +theorem ModFiveThetaInput.eventually_tuple_padding_cut_cost + (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, + ∀ (η c K : ℝ) (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M), + data.Q = paddingPrimeSupply E L → + ∀ (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) (site : ℤ) (bins : Finset ℤ), + 0 < η → η ≤ 1 → 0 < K → + ∀ (D : Finset ℕ), D ⊆ retainedPrimeDivisors data.Q → + ∀ (d : ℕ), Squarefree d → d.primeFactors.card = J → d.primeFactors ⊆ data.P → + (data.residueLaw B hB).average (fun x => + positivePrimeWeight d.primeFactors (data.residueOrigin x + site) * + paddingRejectedMass data.Q D bins η c L K (data.residueOrigin x + site)) / + paddingTiltNormalizer data.Q ≤ + ((2 : ℝ) ^ J / d) * (C / K + L ^ (-100 : ℝ)) := by + obtain ⟨C, hC, hb⟩ := hP.eventually_positive_padding_cut_cost E + refine ⟨C, hC, ?_⟩ + filter_upwards [hb] with L hb + intro η c K h J M B data hQ hB site bins hη hηone hK D hD d hd hdJ hdP + simpa only [positivePrimeNormalizer_squarefree d hd, hdJ] using + hb η c K h J M B data hQ hB site bins hη hηone hK D hD d.primeFactors hdP + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDefectMass.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDefectMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ee5f4b41c55ed9138db5b00ab3b3625288759b2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDefectMass.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ReciprocalPaddingLaw + +namespace OAI + +/-! Exact first moments of additive prime costs under the actual padding law. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma padding_selected_prime_sum (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (b : Q → Bool) (c : ℕ → ℝ) : + (∑ p ∈ (paddingSelectedDivisor Q b).primeFactors, c p) = + ∑ p : Q, if b p then c p.val else 0 := by + rw [paddingSelectedDivisor_primeFactors Q hQ, paddingAvailablePrimes, sum_image] + · simp only [selectedCoordinates, sum_filter] + · intro p _ r _ he + exact Subtype.ext he + +lemma padding_prime_cost_average (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (c : ℕ → ℝ) : + (reciprocalPaddingLaw Q).average + (fun b => ∑ p ∈ (paddingSelectedDivisor Q b).primeFactors, c p) = + ∑ p ∈ Q, (4 / ((p : ℝ) + 4)) * c p := by + simp only [padding_selected_prime_sum Q hQ] + rw [FiniteLaw.average_sum, ← sum_coe_sort Q] + apply sum_congr rfl + intro p _ + rw [reciprocalPaddingLaw, FiniteLaw.independent_average_coordinate + (fun p : Q => reciprocalPaddingPrimeLaw p.val) p + (fun b : Bool => if b then c p.val else 0)] + simp [reciprocalPaddingPrimeLaw, booleanLaw, FiniteLaw.average] + +lemma padding_prime_cost_sum (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (c : ℕ → ℝ) : + (∑ q ∈ retainedPrimeDivisors Q, (4 : ℝ) ^ q.primeFactors.card / (q : ℝ) * + ∑ p ∈ q.primeFactors, c p) = + paddingTiltNormalizer Q * ∑ p ∈ Q, (4 / ((p : ℝ) + 4)) * c p := by + have he := reciprocal_padding_average Q hQ (fun q => ∑ p ∈ q.primeFactors, c p) + rw [padding_prime_cost_average Q hQ] at he + have hS := paddingTiltNormalizer_pos Q + calc + _ = paddingTiltNormalizer Q * ((paddingTiltNormalizer Q)⁻¹ * + ∑ q ∈ retainedPrimeDivisors Q, (4 : ℝ) ^ q.primeFactors.card / (q : ℝ) * + ∑ p ∈ q.primeFactors, c p) := by + rw [← mul_assoc, mul_inv_cancel₀ hS.ne', one_mul] + _ = _ := by rw [← he] + +lemma padding_reciprocal_cost_sum_le (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) : + (∑ q ∈ retainedPrimeDivisors Q, (4 : ℝ) ^ q.primeFactors.card / (q : ℝ) * + ∑ p ∈ q.primeFactors, 1 / (p : ℝ)) ≤ + paddingTiltNormalizer Q * (4 * ∑ p ∈ Q, 1 / (p : ℝ) ^ 2) := by + rw [padding_prime_cost_sum Q hQ] + apply mul_le_mul_of_nonneg_left _ (paddingTiltNormalizer_pos Q).le + rw [mul_sum] + apply sum_le_sum + intro p hp + have hpR : (0 : ℝ) < p := by exact_mod_cast (hQ p hp).pos + have he : 4 / ((p : ℝ) + 4) ≤ 4 / (p : ℝ) := + div_le_div_of_nonneg_left (by norm_num) hpR (by linarith) + calc + _ ≤ (4 / (p : ℝ)) * (1 / (p : ℝ)) := + mul_le_mul_of_nonneg_right he (by positivity) + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDegreeTail.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDegreeTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f0de3eeb9b265efd41dd06185a2f9b277fd2140 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDegreeTail.lean @@ -0,0 +1,134 @@ +import OAI.NumberTheory.TwoPoint.Bounds.BernoulliTail +import OAI.NumberTheory.TwoPoint.Bounds.PaddingResidueTilt +import Mathlib.Analysis.Complex.ExponentialBounds + +namespace OAI + +/-! The exact tilted padding law has mean at most `4 log L` eventually. +The finite exponential-moment bound gives the manuscript's `L^-100` +large-padding-degree error using the same fixed-modulus prime input. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma paddingPrimeSupply_split (E : Finset ℕ) (L : ℝ) (hL : 1 ≤ L) : + paddingPrimeSupply E L = paddingPrimeSupply E 1 ∪ + modFivePrimeBand E false (Real.exp 1) (Real.exp L) := by + have hfloor : ⌊Real.exp 1⌋₊ ≤ ⌊Real.exp L⌋₊ := + Nat.floor_mono (Real.exp_le_exp.mpr hL) + ext p + constructor + · intro hp + obtain ⟨hp, he⟩ := Finset.mem_sdiff.mp hp + obtain ⟨hp, hprime⟩ := mem_filter.mp hp + obtain ⟨hp0, hpL⟩ := mem_Icc.mp hp + apply mem_union.mpr + by_cases hsmall : p ≤ ⌊Real.exp 1⌋₊ + · exact Or.inl (Finset.mem_sdiff.mpr ⟨mem_filter.mpr ⟨mem_Icc.mpr ⟨hp0, hsmall⟩, hprime⟩, he⟩) + · exact Or.inr (mem_filter.mpr ⟨mem_Ioc.mpr ⟨by omega, hpL⟩, hprime, he⟩) + · intro hp + apply Finset.mem_sdiff.mpr + rcases mem_union.mp hp with hp | hp + · obtain ⟨hp, he⟩ := Finset.mem_sdiff.mp hp + obtain ⟨hp, hprime⟩ := mem_filter.mp hp + obtain ⟨hp0, hp1⟩ := mem_Icc.mp hp + exact ⟨mem_filter.mpr ⟨mem_Icc.mpr ⟨hp0, hp1.trans hfloor⟩, hprime⟩, he⟩ + · obtain ⟨hp, hprime, he⟩ := mem_filter.mp hp + exact ⟨mem_filter.mpr ⟨mem_Icc.mpr ⟨Nat.zero_le p, (mem_Ioc.mp hp).2⟩, hprime⟩, he⟩ + +lemma paddingPrimeSupply_split_disjoint (E : Finset ℕ) (L : ℝ) : + Disjoint (paddingPrimeSupply E 1) + (modFivePrimeBand E false (Real.exp 1) (Real.exp L)) := by + apply disjoint_left.mpr + intro p hp hb + have hp1 := (mem_Icc.mp (mem_filter.mp (Finset.mem_sdiff.mp hp).1).1).2 + have hp2 := (mem_Ioc.mp (mem_filter.mp hb).1).1 + omega + +theorem ModFiveThetaInput.padding_reciprocal_mass (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ C : ℝ, 0 ≤ C ∧ ∀ L : ℝ, 1 ≤ L → + (∑ p ∈ paddingPrimeSupply E L, 1 / (p : ℝ)) ≤ (3 / 4 : ℝ) * Real.log L + C := by + obtain ⟨K, hK, hband⟩ := hP.band_error E + refine ⟨(∑ p ∈ paddingPrimeSupply E 1, 1 / (p : ℝ)) + 4 * K, + add_nonneg (sum_nonneg (fun _ _ => by positivity)) (by positivity), fun L hL => ?_⟩ + rw [paddingPrimeSupply_split E L hL, sum_union (paddingPrimeSupply_split_disjoint E L)] + have hb := (abs_le.mp (hband false 1 L le_rfl hL)).2 + norm_num [modFiveDensity] at hb + simp only [one_div] + linarith + +lemma padding_mean_le_reciprocal (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) : + (∑ p : Q, 5 / ((p.val : ℝ) + 4)) ≤ 5 * ∑ p ∈ Q, 1 / (p : ℝ) := by + rw [← sum_coe_sort Q (fun p : ℕ => 1 / (p : ℝ)), mul_sum] + apply sum_le_sum + intro p _ + have hp : (0 : ℝ) < p.val := by exact_mod_cast (by have := hQ p p.property; omega : 0 < p.val) + calc + 5 / ((p.val : ℝ) + 4) ≤ 5 / (p.val : ℝ) := + div_le_div_of_nonneg_left (by norm_num) hp (by linarith) + _ = _ := by ring + +theorem ModFiveThetaInput.eventually_padding_mean (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∀ᶠ L : ℝ in atTop, + (∑ p : paddingPrimeSupply E L, 5 / ((p.val : ℝ) + 4)) ≤ 4 * Real.log L := by + obtain ⟨C, hC, hmass⟩ := hP.padding_reciprocal_mass E + filter_upwards [eventually_ge_atTop (Real.exp (20 * C)), eventually_ge_atTop (1 : ℝ)] + with L hLC hL + have hlog : 20 * C ≤ Real.log L := by + simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos _) hLC + have hh := padding_mean_le_reciprocal (paddingPrimeSupply E L) + (fun _ hp => (paddingPrimeSupply_prime hp).two_le) + nlinarith [hmass L hL] + +theorem ModFiveThetaInput.eventually_padding_degree_tail (hP : ModFiveThetaInput) + (E : Finset ℕ) : + ∀ᶠ L : ℝ in atTop, + (paddingAvailableLaw (paddingPrimeSupply E L) + (fun _ hp => (paddingPrimeSupply_prime hp).two_le)).probability + (fun a => 400 * Real.log L < booleanCount a) ≤ L ^ (-100 : ℝ) := by + filter_upwards [hP.eventually_padding_mean E, eventually_ge_atTop (1 : ℝ)] with L hM hL + let Q := paddingPrimeSupply E L + have hQ : ∀ p ∈ Q, 2 ≤ p := fun _ hp => (paddingPrimeSupply_prime hp).two_le + have hq0 (p : Q) : 0 ≤ 5 / ((p.val : ℝ) + 4) := by positivity + have hq1 (p : Q) : 5 / ((p.val : ℝ) + 4) ≤ 1 := by + apply (div_le_one (by positivity)).mpr + have hp : (2 : ℝ) ≤ p.val := by exact_mod_cast hQ p p.property + linarith + have hb := independent_boolean_tail (fun p : Q => 5 / ((p.val : ℝ) + 4)) hq0 hq1 + 1 (4 * Real.log L) (400 * Real.log L) (by norm_num) hM + change (paddingAvailableLaw Q hQ).probability _ ≤ _ + calc + _ ≤ Real.exp ((Real.exp 1 - 1) * (4 * Real.log L) - 1 * (400 * Real.log L)) := hb + _ ≤ Real.exp (-100 * Real.log L) := by + apply Real.exp_le_exp.mpr + have hlog : 0 ≤ Real.log L := Real.log_nonneg hL + nlinarith [Real.exp_one_lt_three] + _ = L ^ (-100 : ℝ) := by + rw [Real.rpow_def_of_pos (zero_lt_one.trans_le hL)] + congr 1 + ring + +/-- The original uniform-residue expectation, with its literal padding +weight retained, has the same `L^-100` degree-deletion bound. -/ +theorem ModFiveThetaInput.eventually_padding_residue_degree_tail (hP : ModFiveThetaInput) + (E : Finset ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (B : ℕ) (n : ℤ) + (hQB : ∀ p ∈ paddingPrimeSupply E L, p ≤ B), + (FiniteLaw.independent (fun p : paddingPrimeSupply E L => + uniformResidueLaw B p.val (paddingPrimeSupply_prime p.property).pos + (hQB p p.property))).average (fun z => + paddingTiltWeight _ (paddingResidueAvailable _ B n z) * + if 400 * Real.log L < booleanCount (paddingResidueAvailable _ B n z) + then 1 else 0) / paddingTiltNormalizer (paddingPrimeSupply E L) ≤ L ^ (-100 : ℝ) := by + filter_upwards [hP.eventually_padding_degree_tail E] with L hL + intro B n hQB + rw [padding_residue_tilt (paddingPrimeSupply E L) B + (fun _ hp => (paddingPrimeSupply_prime hp).two_le) hQB n + (fun a => if 400 * Real.log L < booleanCount a then 1 else 0)] + exact hL + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDeletionComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDeletionComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..95f24814d96f07d685f1b47cf7da88d86b7c943b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDeletionComparison.lean @@ -0,0 +1,169 @@ +import OAI.NumberTheory.TwoPoint.Bounds.StateCostComparison +import OAI.NumberTheory.TwoPoint.Bounds.DegreeCostComparison +import OAI.NumberTheory.TwoPoint.Bounds.PaddingDeletionIdentity +import OAI.NumberTheory.TwoPoint.Bounds.PrimeRowSecondMoment + +namespace OAI + +/-! Compare the two disjoint padding failures before summing pairs. +The model side is exactly the rejected padding mass. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma uniformFiniteLaw_sum_error {α β ι : Type*} + [Fintype α] [Fintype β] [Fintype ι] (μ : FiniteLaw β) + (f : ι → α → ℝ) (g : ι → β → ℝ) (ε : ι → ℝ) + (h : ∀ i, |uniformAverage (f i) - μ.average (g i)| ≤ ε i) : + |uniformAverage (fun x => ∑ i, f i x) - μ.average (fun y => ∑ i, g i y)| ≤ ∑ i, ε i := by + rw [uniformAverage_sum, μ.average_sum, ← sum_sub_distrib] + exact (abs_sum_le_sum_abs _ _).trans (sum_le_sum (fun i _ => h i)) + +theorem BravermanDepth22Input.eventually_padding_atom_comparison + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M) + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (S : Finset ℕ), S ⊆ data.P ∪ data.Q → (S.card : ℝ) ≤ L ^ 2 → + ∀ (q : ℕ), q ∈ retainedPrimeDivisors data.Q → + (q.primeFactors.card : ℝ) ≤ 100 * Real.log L → + ∀ (D : Finset ℕ), D ⊆ retainedPrimeDivisors data.Q → + ∀ (eligible : ℕ → Prop) (K : ℝ) (site : ℤ) (a N : ℕ), + Real.exp (L ^ A / 2) ≤ (N : ℝ) → + |uniformAverage (fun x : Fin N => + paddingRejectionAtom data.Q S D eligible L K q ((a + x.val : ℤ) + site)) - + (data.residueLaw B hB).average (fun x => + paddingRejectionAtom data.Q S D eligible L K q (data.residueOrigin x + site))| ≤ + 2 * Real.exp (-(L ^ 9)) := by + obtain ⟨A₁, hA₁, hd⟩ := hBr.eventually_degree_cost_comparison + obtain ⟨A₂, hA₂, hs⟩ := hBr.eventually_density_cost_comparison + refine ⟨A₁ + A₂, by omega, ?_⟩ + filter_upwards [hd, hs, eventually_ge_atTop (1 : ℝ)] with L hd hs hL + intro h J M B data hB hpool hBL S hS hSL q hq hqdegree D hD eligible K site a N hN + have hN₁ : Real.exp (L ^ A₁ / 2) ≤ (N : ℝ) := + (Real.exp_le_exp.mpr (div_le_div_of_nonneg_right + (pow_le_pow_right₀ hL (Nat.le_add_right A₁ A₂)) (by norm_num))).trans hN + have hN₂ : Real.exp (L ^ A₂ / 2) ≤ (N : ℝ) := + (Real.exp_le_exp.mpr (div_le_div_of_nonneg_right + (pow_le_pow_right₀ hL (Nat.le_add_left A₂ A₁)) (by norm_num))).trans hN + by_cases he : eligible q + · let H := fun n : ℤ => actualPaddingCoefficient q * positivePrimeWeight S n * + if (q : ℤ) ∣ n ∧ 400 * Real.log L < (actualPaddingDegree data.Q n : ℝ) then 1 else 0 + let G := fun n : ℤ => actualPaddingCoefficient q * positivePrimeWeight S n * + if (q : ℤ) ∣ n ∧ actualPaddingDegreeCut data.Q L n ∧ + K / L < paddingDensity D actualPaddingCoefficient eligible (actualPaddingVertex data.Q) n + then 1 else 0 + have hlog : 0 ≤ 400 * Real.log L := mul_nonneg (by norm_num) (Real.log_nonneg hL) + have hH := hd h J M B data hB hpool hBL S data.Q hS subset_union_right hSL + q hq hqdegree (400 * Real.log L) hlog le_rfl site a N hN₁ + have hG := hs h J M B data hB hpool hBL S hS hSL q hq hqdegree D hD eligible K site a N hN₂ + have hsplit (n : ℤ) : paddingRejectionAtom data.Q S D eligible L K q n = H n + G n := by + simp only [paddingRejectionAtom, he, ite_true, padding_rejection_failure_split, mul_add, H, G] + simp_rw [hsplit] + have hu : uniformAverage (fun x : Fin N => H ((a + x.val : ℤ) + site) + + G ((a + x.val : ℤ) + site)) = + uniformAverage (fun x : Fin N => H ((a + x.val : ℤ) + site)) + + uniformAverage (fun x : Fin N => G ((a + x.val : ℤ) + site)) := by + simp only [uniformAverage, sum_add_distrib, add_div] + rw [hu, (data.residueLaw B hB).average_add] + calc + _ = |(uniformAverage (fun x : Fin N => H ((a + x.val : ℤ) + site)) - + (data.residueLaw B hB).average (fun x => H (data.residueOrigin x + site))) + + (uniformAverage (fun x : Fin N => G ((a + x.val : ℤ) + site)) - + (data.residueLaw B hB).average (fun x => G (data.residueOrigin x + site)))| := by + congr 1 + ring + _ ≤ _ := (abs_add_le _ _).trans (show _ ≤ 2 * Real.exp (-(L ^ 9)) by linarith [hH, hG]) + · simp only [paddingRejectionAtom, he, ite_false, uniformAverage, sum_const_zero, + zero_div, (data.residueLaw B hB).average_const, sub_self, abs_zero] + positivity + +theorem BravermanDepth22Input.eventually_padding_mass_comparison + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M) + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (S : Finset ℕ), S ⊆ data.P ∪ data.Q → (S.card : ℝ) ≤ L ^ 2 → + ∀ (D : Finset ℕ), D ⊆ retainedPrimeDivisors data.Q → + (∀ q ∈ D, (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) → + ∀ (bins : Finset ℤ) (η c K : ℝ) (site : ℤ) (a N : ℕ), + Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let F := fun n : ℤ => positivePrimeWeight S n * paddingRejectedMass data.Q D bins η c L K n + |uniformAverage (fun x : Fin N => F ((a + x.val : ℤ) + site)) - + (data.residueLaw B hB).average (fun x => F (data.residueOrigin x + site))| ≤ + 2 * bins.card * D.card * Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_padding_atom_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hb] with L hb + intro h J M B data hB hpool hBL S hS hSL D hD hdegree bins η c K site a N hN + dsimp only + simp_rw [padding_rejection_bin_identity] + have he (j : bins) : + |uniformAverage (fun x : Fin N => ∑ q : D, + paddingRejectionAtom data.Q S D (actualPaddingBin η c j.val) L K q.val + ((a + x.val : ℤ) + site)) - + (data.residueLaw B hB).average (fun x => ∑ q : D, + paddingRejectionAtom data.Q S D (actualPaddingBin η c j.val) L K q.val + (data.residueOrigin x + site))| ≤ D.card * (2 * Real.exp (-(L ^ 9))) := by + simpa only [sum_const, card_univ, Fintype.card_coe, nsmul_eq_mul] using + uniformFiniteLaw_sum_error (data.residueLaw B hB) + (fun (q : D) (x : Fin N) => paddingRejectionAtom data.Q S D (actualPaddingBin η c j.val) + L K q.val ((a + x.val : ℤ) + site)) + (fun (q : D) x => paddingRejectionAtom data.Q S D (actualPaddingBin η c j.val) + L K q.val (data.residueOrigin x + site)) (fun _ => 2 * Real.exp (-(L ^ 9))) + (fun q => hb h J M B data hB hpool hBL S hS hSL q.val (hD q.property) + (hdegree q.val q.property) D hD (actualPaddingBin η c j.val) K site a N hN) + simp_rw [← sum_coe_sort D, ← sum_coe_sort bins] + have ht := uniformFiniteLaw_sum_error (data.residueLaw B hB) + (fun (j : bins) (x : Fin N) => ∑ q : D, + paddingRejectionAtom data.Q S D (actualPaddingBin η c j.val) L K q.val ((a + x.val : ℤ) + site)) + (fun (j : bins) x => ∑ q : D, + paddingRejectionAtom data.Q S D (actualPaddingBin η c j.val) L K q.val (data.residueOrigin x + site)) + (fun _ => D.card * (2 * Real.exp (-(L ^ 9)))) he + convert ht using 1 + simp only [sum_const, card_univ, Fintype.card_coe, nsmul_eq_mul] + ring + +theorem BravermanDepth22Input.eventually_integer_padding_deletion + (hBr : BravermanDepth22Input) (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ (A : ℕ) (C : ℝ), 1000 ≤ A ∧ 0 < C ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M), + data.Q = paddingPrimeSupply E L → + ∀ (_hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (S : Finset ℕ), S ⊆ data.P → (S.card : ℝ) ≤ L ^ 2 → + ∀ (D : Finset ℕ), D ⊆ retainedPrimeDivisors data.Q → + (∀ q ∈ D, (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) → + ∀ (bins : Finset ℤ) (η c K : ℝ), 0 < η → η ≤ 1 → 0 < K → + ∀ (site : ℤ) (a N : ℕ), Real.exp (L ^ A / 2) ≤ (N : ℝ) → + uniformAverage (fun x : Fin N => positivePrimeWeight S ((a + x.val : ℤ) + site) * + paddingRejectedMass data.Q D bins η c L K ((a + x.val : ℤ) + site)) / + paddingTiltNormalizer data.Q ≤ + positivePrimeNormalizer S * (C / K + L ^ (-100 : ℝ)) + + (2 * bins.card * D.card * Real.exp (-(L ^ 9))) / paddingTiltNormalizer data.Q := by + obtain ⟨A, hA, hc⟩ := hBr.eventually_padding_mass_comparison + obtain ⟨C, hC, hp⟩ := hP.eventually_positive_padding_cut_cost E + refine ⟨A, C, hA, hC, ?_⟩ + filter_upwards [hc, hp] with L hc hp + intro h J M B data hQ hB hpool hBL S hSP hSL D hD hdegree bins η c K hη hηone hK site a N hN + have hcomp := hc h J M B data hB hpool hBL S (hSP.trans subset_union_left) hSL + D hD hdegree bins η c K site a N hN + have hmodel := hp η c K h J M B data hQ hB site bins hη hηone hK D hD S hSP + have hdiff := (le_abs_self _).trans hcomp + dsimp only at hdiff + calc + _ ≤ ((data.residueLaw B hB).average (fun x => + positivePrimeWeight S (data.residueOrigin x + site) * + paddingRejectedMass data.Q D bins η c L K (data.residueOrigin x + site)) + + 2 * bins.card * D.card * Real.exp (-(L ^ 9))) / paddingTiltNormalizer data.Q := + div_le_div_of_nonneg_right (by linarith) (paddingTiltNormalizer_pos data.Q).le + _ = _ := add_div _ _ _ + _ ≤ _ := by linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDeletionIdentity.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDeletionIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..f808fa3635c024712def2edb03fe3dd7d61e89c6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDeletionIdentity.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingCutCost + +namespace OAI + +/-! Exact sum of fixed-pair deletion costs. The high-degree and +low-degree density failures are disjoint and exhaust the padding cut. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def paddingRejectionAtom (Q S D : Finset ℕ) (eligible : ℕ → Prop) + (L K : ℝ) (q : ℕ) (n : ℤ) : ℝ := + if eligible q then + actualPaddingCoefficient q * positivePrimeWeight S n * + if (q : ℤ) ∣ n ∧ ¬integerEdgeKeep D actualPaddingCoefficient eligible + (actualPaddingVertex Q) L K (actualPaddingDegreeCut Q L) n then 1 else 0 + else 0 + +lemma padding_rejection_row_identity (Q S D : Finset ℕ) (eligible : ℕ → Prop) + (L K : ℝ) (n : ℤ) : + positivePrimeWeight S n * (actualPaddingVertex Q n) ^ 2 * + (if ¬integerEdgeKeep D actualPaddingCoefficient eligible + (actualPaddingVertex Q) L K (actualPaddingDegreeCut Q L) n then + paddingDensity D actualPaddingCoefficient eligible (actualPaddingVertex Q) n else 0) = + ∑ q ∈ D, paddingRejectionAtom Q S D eligible L K q n := by + by_cases hk : integerEdgeKeep D actualPaddingCoefficient eligible + (actualPaddingVertex Q) L K (actualPaddingDegreeCut Q L) n + · simp only [paddingRejectionAtom, hk, not_true_eq_false, and_false, ite_false, + mul_zero, ite_self, sum_const_zero] + · simp only [paddingRejectionAtom, hk, not_false_eq_true, and_true, ite_true] + calc + _ = positivePrimeWeight S n * + ∑ q ∈ D, if eligible q ∧ (q : ℤ) ∣ n then actualPaddingCoefficient q else 0 := by + unfold paddingDensity + field_simp [actualPaddingVertex_ne_zero Q n] + _ = _ := by + rw [mul_sum] + apply sum_congr rfl + intro q _ + by_cases he : eligible q <;> by_cases hd : (q : ℤ) ∣ n <;> + simp only [he, hd, and_true, and_false, ite_true, ite_false, + mul_zero, mul_one] + ring + +lemma padding_rejection_failure_split (Q D : Finset ℕ) (eligible : ℕ → Prop) + (L K : ℝ) (q : ℕ) (n : ℤ) : + (if (q : ℤ) ∣ n ∧ ¬integerEdgeKeep D actualPaddingCoefficient eligible + (actualPaddingVertex Q) L K (actualPaddingDegreeCut Q L) n then (1 : ℝ) else 0) = + (if (q : ℤ) ∣ n ∧ 400 * Real.log L < (actualPaddingDegree Q n : ℝ) then 1 else 0) + + (if (q : ℤ) ∣ n ∧ actualPaddingDegreeCut Q L n ∧ + K / L < paddingDensity D actualPaddingCoefficient eligible (actualPaddingVertex Q) n + then 1 else 0) := by + by_cases hd : (q : ℤ) ∣ n + · by_cases hdegree : actualPaddingDegreeCut Q L n + · by_cases hdensity : paddingDensity D actualPaddingCoefficient eligible + (actualPaddingVertex Q) n ≤ K / L + · simp only [integerEdgeKeep, hd, hdensity, hdegree, true_and, not_true_eq_false, + ite_false, add_zero, not_lt.mpr hdensity] + have hn : ¬400 * Real.log L < (actualPaddingDegree Q n : ℝ) := + not_lt.mpr hdegree + simp only [hn, ite_false] + · have hgt := lt_of_not_ge hdensity + have hn : ¬400 * Real.log L < (actualPaddingDegree Q n : ℝ) := + not_lt.mpr hdegree + simp only [integerEdgeKeep, hd, hdensity, hdegree, false_and, and_false, + true_and, not_false_eq_true, ite_true, hgt, hn, ite_false, zero_add] + · have hgt : 400 * Real.log L < (actualPaddingDegree Q n : ℝ) := + lt_of_not_ge hdegree + simp only [integerEdgeKeep, hd, hdegree, and_false, false_and, true_and, + not_false_eq_true, ite_true, hgt, ite_false, add_zero] + · simp only [hd, false_and, ite_false, add_zero] + +lemma padding_rejection_bin_identity (Q S D : Finset ℕ) (bins : Finset ℤ) + (η c L K : ℝ) (n : ℤ) : + positivePrimeWeight S n * paddingRejectedMass Q D bins η c L K n = + ∑ j ∈ bins, ∑ q ∈ D, paddingRejectionAtom Q S D (actualPaddingBin η c j) L K q n := by + unfold paddingRejectedMass + rw [← mul_assoc, mul_sum] + apply sum_congr rfl + intro j _ + exact padding_rejection_row_identity Q S D (actualPaddingBin η c j) L K n + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDifferenceLaw.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDifferenceLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..a60c9ad4e9ba2e2439115f0e50a30554c2ef3aee --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDifferenceLaw.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingCharacteristic +import OAI.NumberTheory.TwoPoint.Bounds.FiniteProbability +import Mathlib.Analysis.Complex.Trigonometric + +namespace OAI + +/-! The actual independent three-point padding difference law and its +characteristic product. At each prime the two nonzero atoms have the +manuscript's exact probability `4/(5(p+4))`. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def paddingDifferenceAtom (p : ℕ) (e : Fin 3) : ℝ := + if e = 0 then 1 - 8 / (5 * ((p : ℝ) + 4)) else 4 / (5 * ((p : ℝ) + 4)) + +noncomputable def paddingDifferenceStep (p : ℕ) (e : Fin 3) : ℝ := + if e = 0 then 0 else if e = 1 then Real.log p else -Real.log p + +noncomputable def paddingStepLaw (p : ℕ) (hp : 2 ≤ p) : FiniteLaw (Fin 3) where + weight := paddingDifferenceAtom p + nonneg e := by + have hpr : (2 : ℝ) ≤ p := by exact_mod_cast hp + have hd : 0 < 5 * ((p : ℝ) + 4) := by positivity + unfold paddingDifferenceAtom + split_ifs + · have hh : 8 / (5 * ((p : ℝ) + 4)) ≤ 1 := (div_le_one hd).mpr (by linarith) + linarith + · positivity + total := by + rw [Fin.sum_univ_three] + norm_num [paddingDifferenceAtom] + ring + +noncomputable def paddingDifferenceLaw (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) : + FiniteLaw (Q → Fin 3) := + FiniteLaw.independent (fun p : Q => paddingStepLaw p (hQ p p.property)) + +noncomputable def paddingDifferenceValue (Q : Finset ℕ) (x : Q → Fin 3) : ℝ := + ∑ p : Q, paddingDifferenceStep p (x p) + +lemma paddingStep_characteristic (p : ℕ) (t : ℝ) : + (∑ e : Fin 3, (paddingDifferenceAtom p e : ℂ) * + Complex.exp (((t * paddingDifferenceStep p e : ℝ) : ℂ) * Complex.I)) = + (paddingCharacteristicFactor p t : ℂ) := by + rw [Fin.sum_univ_three] + norm_num only [paddingDifferenceAtom, paddingDifferenceStep, Fin.isValue, + Fin.zero_eta, ↓reduceIte, Fin.reduceEq, mul_zero, Complex.ofReal_zero, + zero_mul, Complex.exp_zero, mul_one] + rw [show t * -Real.log p = -(t * Real.log p) by ring] + rw [Complex.exp_ofReal_mul_I, Complex.exp_ofReal_mul_I] + rw [Real.cos_neg, Real.sin_neg] + unfold paddingCharacteristicFactor + push_cast + ring + +/-- The complete finite-law characteristic function is the real, +nonnegative product estimated in `PaddingCharacteristic`. -/ +theorem paddingDifference_characteristic (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) (t : ℝ) : + (∑ x : Q → Fin 3, ((paddingDifferenceLaw Q hQ).weight x : ℂ) * + Complex.exp (((t * paddingDifferenceValue Q x : ℝ) : ℂ) * Complex.I)) = + (paddingCharacteristic Q t : ℂ) := by + have hexp (x : Q → Fin 3) : + Complex.exp (((t * paddingDifferenceValue Q x : ℝ) : ℂ) * Complex.I) = + ∏ p : Q, Complex.exp (((t * paddingDifferenceStep p (x p) : ℝ) : ℂ) * Complex.I) := by + unfold paddingDifferenceValue + rw [mul_sum, Complex.ofReal_sum, sum_mul, Complex.exp_sum] + simp only [paddingDifferenceLaw, FiniteLaw.independent, paddingStepLaw, + Complex.ofReal_prod, hexp, ← prod_mul_distrib] + rw [← Fintype.prod_sum (fun (p : Q) (e : Fin 3) => + (paddingDifferenceAtom p e : ℂ) * + Complex.exp (((t * paddingDifferenceStep p e : ℝ) : ℂ) * Complex.I))] + simp only [paddingStep_characteristic] + unfold paddingCharacteristic + rw [Complex.ofReal_prod] + exact (prod_subtype (p := fun p : ℕ => p ∈ Q) Q (fun _ => Iff.rfl) + (fun p => (paddingCharacteristicFactor p t : ℂ))).symm + +lemma paddingDifference_cosine (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) (t : ℝ) : + (paddingDifferenceLaw Q hQ).average (fun x => Real.cos (t * paddingDifferenceValue Q x)) = + paddingCharacteristic Q t := by + have hh := congrArg Complex.re (paddingDifference_characteristic Q hQ t) + simpa [FiniteLaw.average, Complex.mul_re, Complex.exp_re] using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDivisorEncoding.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDivisorEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..8dd826baa6ab310705f3c85866eda22c3f8dd729 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingDivisorEncoding.lean @@ -0,0 +1,180 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingLiteralBins + +namespace OAI + +/-! Squarefree padding divisors encode prime selections without multiplicity. +This identifies the bin law with the paper's numerical divisor sum. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def paddingAvailablePrimes (Q : Finset ℕ) (a : Q → Bool) : Finset ℕ := + (selectedCoordinates Q a).image Subtype.val + +lemma paddingAvailablePrimes_subset (Q : Finset ℕ) (a : Q → Bool) : + paddingAvailablePrimes Q a ⊆ Q := by + intro p hp + obtain ⟨u, _, rfl⟩ := mem_image.mp hp + exact u.property + +lemma mem_paddingAvailablePrimes (Q : Finset ℕ) (a : Q → Bool) (p : Q) : + p.val ∈ paddingAvailablePrimes Q a ↔ a p = true := by + constructor + · intro hp + obtain ⟨u, hu, he⟩ := mem_image.mp hp + have hup : u = p := Subtype.ext he + subst u + exact (mem_filter.mp hu).2 + · intro hp + exact mem_image.mpr ⟨p, mem_filter.mpr ⟨mem_univ p, hp⟩, rfl⟩ + +lemma paddingSelectedDivisor_eq_prod (Q : Finset ℕ) (b : Q → Bool) : + paddingSelectedDivisor Q b = ∏ p ∈ paddingAvailablePrimes Q b, p := by + rw [paddingAvailablePrimes, prod_image] + · rfl + · intro p _ q _ hpq + exact Subtype.ext hpq + +lemma paddingSelectedDivisor_primeFactors (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (b : Q → Bool) : (paddingSelectedDivisor Q b).primeFactors = paddingAvailablePrimes Q b := by + rw [paddingSelectedDivisor_eq_prod, Nat.primeFactors_prod] + exact fun p hp => hQ p (paddingAvailablePrimes_subset Q b hp) + +lemma paddingAvailablePrimes_card (Q : Finset ℕ) (a : Q → Bool) : + (paddingAvailablePrimes Q a).card = (selectedCoordinates Q a).card := by + exact card_image_iff.mpr (fun _ _ _ _ h => Subtype.ext h) + +lemma padding_supported_iff_primeFactors_subset (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) (a b : Q → Bool) : + PaddingSelectionSupported Q a b ↔ + (paddingSelectedDivisor Q b).primeFactors ⊆ paddingAvailablePrimes Q a := by + rw [paddingSelectedDivisor_primeFactors Q hQ b] + constructor + · intro h p hp + have hpQ := paddingAvailablePrimes_subset Q b hp + exact (mem_paddingAvailablePrimes Q a ⟨p, hpQ⟩).mpr + (h ⟨p, hpQ⟩ ((mem_paddingAvailablePrimes Q b ⟨p, hpQ⟩).mp hp)) + · intro h p hp + exact (mem_paddingAvailablePrimes Q a p).mp + (h ((mem_paddingAvailablePrimes Q b p).mpr hp)) + +lemma paddingSelectedDivisor_injective (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) : + Function.Injective (paddingSelectedDivisor Q) := by + intro b c hbc + have hsets : paddingAvailablePrimes Q b = paddingAvailablePrimes Q c := by + simpa only [paddingSelectedDivisor_primeFactors Q hQ] using congrArg Nat.primeFactors hbc + funext p + have he : (b p = true) ↔ (c p = true) := by + rw [← mem_paddingAvailablePrimes Q b p, ← mem_paddingAvailablePrimes Q c p, hsets] + cases hb : b p <;> cases hc : c p <;> simp_all + +lemma paddingSelectedDivisor_mem (Q : Finset ℕ) (b : Q → Bool) : + paddingSelectedDivisor Q b ∈ retainedPrimeDivisors Q := by + rw [retainedPrimeDivisors, paddingSelectedDivisor_eq_prod] + exact mem_image.mpr ⟨paddingAvailablePrimes Q b, + mem_powerset.mpr (paddingAvailablePrimes_subset Q b), rfl⟩ + +lemma exists_paddingSelection (Q : Finset ℕ) (q : ℕ) (hq : q ∈ retainedPrimeDivisors Q) : + ∃ b : Q → Bool, paddingSelectedDivisor Q b = q := by + obtain ⟨S, hS, rfl⟩ := mem_image.mp hq + have hSQ := mem_powerset.mp hS + let b : Q → Bool := fun p => decide (p.val ∈ S) + have hb : paddingAvailablePrimes Q b = S := by + ext p + constructor + · intro hp + obtain ⟨u, hu, rfl⟩ := mem_image.mp hp + simpa only [selectedCoordinates, mem_filter, mem_univ, true_and, b, + decide_eq_true_eq] using hu + · intro hp + exact (mem_paddingAvailablePrimes Q b ⟨p, hSQ hp⟩).mpr (by simp [b, hp]) + exact ⟨b, by rw [paddingSelectedDivisor_eq_prod, hb]⟩ + +noncomputable def paddingDivisorEquiv (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) : + (Q → Bool) ≃ retainedPrimeDivisors Q := + Equiv.ofBijective (fun b => ⟨paddingSelectedDivisor Q b, paddingSelectedDivisor_mem Q b⟩) + ⟨fun _ _ h => paddingSelectedDivisor_injective Q hQ (congrArg Subtype.val h), by + intro q + obtain ⟨b, hb⟩ := exists_paddingSelection Q q q.property + exact ⟨b, Subtype.ext hb⟩⟩ + +/-- `rho_j` as a sum over actual numerical squarefree divisors. -/ +noncomputable def literalPaddingBinMass (Q : Finset ℕ) (a : Q → Bool) + (η c : ℝ) (j : ℤ) : ℝ := + (5 : ℝ) ^ (-(paddingAvailablePrimes Q a).card : ℤ) * + ∑ q ∈ retainedPrimeDivisors Q, + if q.primeFactors ⊆ paddingAvailablePrimes Q a ∧ + paddingBin η c (Real.log q) = j + then (4 : ℝ) ^ q.primeFactors.card else 0 + +lemma paddingBinMass_eq_literal (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (a : Q → Bool) (η c : ℝ) (j : ℤ) : + paddingBinMass Q a η c j = literalPaddingBinMass Q a η c j := by + rw [paddingBinMass_normalized_sum, paddingTiltWeight_eq_five_pow] + unfold literalPaddingBinMass + rw [paddingAvailablePrimes_card, zpow_neg, zpow_natCast] + congr 1 + let F (q : retainedPrimeDivisors Q) : ℝ := + if q.val.primeFactors ⊆ paddingAvailablePrimes Q a ∧ + paddingBin η c (Real.log q.val) = j + then (4 : ℝ) ^ q.val.primeFactors.card else 0 + calc + _ = ∑ b : Q → Bool, F (paddingDivisorEquiv Q hQ b) := by + apply sum_congr rfl + intro b _ + change _ = if (paddingSelectedDivisor Q b).primeFactors ⊆ paddingAvailablePrimes Q a ∧ + paddingBin η c (Real.log (paddingSelectedDivisor Q b)) = j + then (4 : ℝ) ^ (paddingSelectedDivisor Q b).primeFactors.card else 0 + have hs := padding_supported_iff_primeFactors_subset Q hQ a b + rw [paddingSelectedDivisor_primeFactors Q hQ b] at hs + simp only [← hs, + paddingSelectedDivisor_log Q hQ b, paddingSelectedDivisor_primeFactors Q hQ b, + paddingAvailablePrimes_card, paddingDivisorCoefficient_eq_four_pow] + _ = ∑ q : retainedPrimeDivisors Q, F q := (paddingDivisorEquiv Q hQ).sum_comp F + _ = _ := by + unfold F + exact sum_coe_sort (retainedPrimeDivisors Q) (fun q : ℕ => + if q.primeFactors ⊆ paddingAvailablePrimes Q a ∧ paddingBin η c (Real.log q) = j + then (4 : ℝ) ^ q.primeFactors.card else 0) + +lemma paddingTiltNormalizer_eq_divisor_sum (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) : + paddingTiltNormalizer Q = + ∑ q ∈ retainedPrimeDivisors Q, (4 : ℝ) ^ q.primeFactors.card / (q : ℝ) := by + unfold paddingTiltNormalizer + rw [prod_coe_sort Q (fun p : ℕ => 1 + 4 / (p : ℝ))] + simpa only [prod_const] using + (retainedPrimeDivisors_weighted_mass Q hQ (fun _ => (4 : ℝ))).symm + +lemma padding_divisor_weight_total (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (a : Q → Bool) : + (∑ q ∈ retainedPrimeDivisors Q, + if q.primeFactors ⊆ paddingAvailablePrimes Q a then (4 : ℝ) ^ q.primeFactors.card else 0) = + paddingTiltWeight Q a := by + let F (q : retainedPrimeDivisors Q) : ℝ := + if q.val.primeFactors ⊆ paddingAvailablePrimes Q a then (4 : ℝ) ^ q.val.primeFactors.card else 0 + have he (b : Q → Bool) : F (paddingDivisorEquiv Q hQ b) = + (paddingDivisorLaw Q a).weight b * paddingTiltWeight Q a := by + rw [padding_divisor_weight] + change (if (paddingSelectedDivisor Q b).primeFactors ⊆ paddingAvailablePrimes Q a + then (4 : ℝ) ^ (paddingSelectedDivisor Q b).primeFactors.card else 0) = _ + have hs := padding_supported_iff_primeFactors_subset Q hQ a b + rw [paddingSelectedDivisor_primeFactors Q hQ b] at hs + simp only [← hs, + paddingSelectedDivisor_primeFactors Q hQ b, paddingAvailablePrimes_card, + paddingDivisorCoefficient_eq_four_pow] + calc + _ = ∑ q : retainedPrimeDivisors Q, F q := (sum_coe_sort _ (fun q : ℕ => + if q.primeFactors ⊆ paddingAvailablePrimes Q a then (4 : ℝ) ^ q.primeFactors.card else 0)).symm + _ = ∑ b : Q → Bool, F (paddingDivisorEquiv Q hQ b) := + ((paddingDivisorEquiv Q hQ).sum_comp F).symm + _ = ∑ b : Q → Bool, (paddingDivisorLaw Q a).weight b * paddingTiltWeight Q a := + sum_congr rfl (fun b _ => he b) + _ = paddingTiltWeight Q a := by + rw [← sum_mul, (paddingDivisorLaw Q a).total, one_mul] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingIntegerBins.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingIntegerBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..515192cb88f9efd584df3c047211800188e97cdc --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingIntegerBins.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingDivisorEncoding +import OAI.NumberTheory.TwoPoint.Bounds.CommonResidueLift + +namespace OAI + +/-! The squarefree divisor formula uses literal divisibility by the site, +including the site zero. Bin membership is exactly the half-open interval +condition in the manuscript. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma paddingSelectedDivisor_dvd_iff (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (b : Q → Bool) (n : ℤ) : + (paddingSelectedDivisor Q b : ℤ) ∣ n ↔ + ∀ p : Q, b p = true → (p.val : ℤ) ∣ n := by + rw [paddingSelectedDivisor, Nat.cast_prod] + constructor + · intro h p hp + exact (dvd_prod_of_mem (fun q : Q => (q.val : ℤ)) + (mem_filter.mpr ⟨mem_univ p, hp⟩)).trans h + · intro h + apply prod_dvd_of_coprime + · intro p _ q _ hpq + apply Nat.Coprime.cast + apply (Nat.coprime_primes (hQ p p.property) (hQ q q.property)).mpr + exact fun he => hpq (Subtype.ext he) + · intro p hp + exact h p (mem_filter.mp hp).2 + +lemma padding_literal_support_iff_dvd (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (n : ℤ) (q : ℕ) (hq : q ∈ retainedPrimeDivisors Q) : + q.primeFactors ⊆ paddingAvailablePrimes Q (fun p => decide ((p.val : ℤ) ∣ n)) ↔ + (q : ℤ) ∣ n := by + obtain ⟨b, rfl⟩ := exists_paddingSelection Q q hq + rw [← padding_supported_iff_primeFactors_subset Q hQ, + paddingSelectedDivisor_dvd_iff Q hQ b n] + simp only [PaddingSelectionSupported, decide_eq_true_eq] + +lemma paddingBin_eq_iff (η c x : ℝ) (j : ℤ) (hη : 0 < η) : + paddingBin η c x = j ↔ (j : ℝ) * η ≤ x + c ∧ x + c < ((j : ℝ) + 1) * η := by + rw [paddingBin, Int.floor_eq_iff, le_div_iff₀ hη, div_lt_iff₀ hη] + +lemma paddingAvailablePrimes_integer (Q : Finset ℕ) (n : ℤ) : + paddingAvailablePrimes Q (fun p => decide ((p.val : ℤ) ∣ n)) = + Q.filter (fun (p : ℕ) => (p : ℤ) ∣ n) := by + ext p + constructor + · intro hp + have hpQ := paddingAvailablePrimes_subset Q _ hp + exact mem_filter.mpr ⟨hpQ, by + simpa using (mem_paddingAvailablePrimes Q _ ⟨p, hpQ⟩).mp hp⟩ + · intro hp + exact (mem_paddingAvailablePrimes Q _ ⟨p, (mem_filter.mp hp).1⟩).mpr + (by simpa using (mem_filter.mp hp).2) + +noncomputable def integerPaddingBinMass (Q : Finset ℕ) (n : ℤ) (η c : ℝ) (j : ℤ) : ℝ := + (5 : ℝ) ^ (-((Q.filter (fun (p : ℕ) => (p : ℤ) ∣ n)).card : ℤ)) * + ∑ q ∈ retainedPrimeDivisors Q, + if (q : ℤ) ∣ n ∧ (j : ℝ) * η ≤ Real.log q + c ∧ + Real.log q + c < ((j : ℝ) + 1) * η + then (4 : ℝ) ^ q.primeFactors.card else 0 + +lemma literalPaddingBinMass_integer (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (n : ℤ) (η c : ℝ) (j : ℤ) (hη : 0 < η) : + literalPaddingBinMass Q (fun p => decide ((p.val : ℤ) ∣ n)) η c j = + integerPaddingBinMass Q n η c j := by + unfold literalPaddingBinMass integerPaddingBinMass + rw [paddingAvailablePrimes_integer] + congr 1 + apply sum_congr rfl + intro q hq + rw [← paddingAvailablePrimes_integer Q n] + simp only [padding_literal_support_iff_dvd Q hQ n q hq, + paddingBin_eq_iff η c (Real.log q) j hη] + +lemma padding_integer_weight_total (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) (n : ℤ) : + (∑ q ∈ retainedPrimeDivisors Q, if (q : ℤ) ∣ n then (4 : ℝ) ^ q.primeFactors.card else 0) = + (5 : ℝ) ^ (Q.filter (fun (p : ℕ) => (p : ℤ) ∣ n)).card := by + have hh := padding_divisor_weight_total Q hQ (fun p => decide ((p.val : ℤ) ∣ n)) + rw [paddingTiltWeight_eq_five_pow, ← paddingAvailablePrimes_card, + paddingAvailablePrimes_integer] at hh + convert hh using 1 + apply sum_congr rfl + intro q hq + have hd := padding_literal_support_iff_dvd Q hQ n q hq + rw [paddingAvailablePrimes_integer] at hd + simp only [hd] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingLargeBinCut.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingLargeBinCut.lean new file mode 100644 index 0000000000000000000000000000000000000000..8086491d14983278f0122abf59516d50ee1f780c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingLargeBinCut.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingResidueTilt + +namespace OAI + +/-! The squared-bin estimate gives the exact `O(1/K)` cost of deleting +bins whose padding density exceeds `K/L`. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma large_nonnegative_value (r K L : ℝ) (hr : 0 ≤ r) (hK : 0 < K) (hL : 0 < L) : + (if K / L < r then r else 0) ≤ (L / K) * r ^ 2 := by + by_cases h : K / L < r + · rw [ite_eq_left h, div_mul_eq_mul_div] + apply (le_div_iff₀ hK).mpr + have hh := (div_lt_iff₀ hL).mp h + nlinarith [mul_nonneg hr (sub_nonneg.mpr hh.le)] + · rw [ite_eq_right h] + positivity + +lemma FiniteLaw.large_bin_cut {A I : Type*} [Fintype A] + (μ : FiniteLaw A) (bins : Finset I) (ρ : A → I → ℝ) + (hρ : ∀ a j, 0 ≤ ρ a j) (K L : ℝ) (hK : 0 < K) (hL : 0 < L) : + μ.average (fun a => ∑ j ∈ bins, if K / L < ρ a j then ρ a j else 0) ≤ + (L / K) * μ.average (fun a => ∑ j ∈ bins, (ρ a j) ^ 2) := by + calc + _ ≤ μ.average (fun a => ∑ j ∈ bins, (L / K) * (ρ a j) ^ 2) := by + apply μ.average_mono + intro a + exact sum_le_sum (fun j _ => large_nonnegative_value (ρ a j) K L (hρ a j) hK hL) + _ = _ := by + simp only [← mul_sum, FiniteLaw.average] + conv_rhs => rw [mul_sum] + apply sum_congr rfl + intro a _ + ring + +lemma paddingBinMass_nonneg (Q : Finset ℕ) (a : Q → Bool) (η c : ℝ) (j : ℤ) : + 0 ≤ paddingBinMass Q a η c j := FiniteLaw.probability_nonneg _ _ + +/-- Uniform over bin translations and every finite collection of bins. -/ +theorem ModFiveThetaInput.padding_large_bin_cut (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ C : ℝ, 0 < C ∧ ∀ (L η c K : ℝ) (bins : Finset ℤ), + 1 ≤ L → 0 < η → η ≤ 1 → 0 < K → + (paddingAvailableLaw (paddingPrimeSupply E L) + (fun _ hp => (paddingPrimeSupply_prime hp).two_le)).average (fun a => + ∑ j ∈ bins, if K / L < paddingBinMass (paddingPrimeSupply E L) a η c j + then paddingBinMass (paddingPrimeSupply E L) a η c j else 0) ≤ C / K := by + obtain ⟨C, hC, hbound⟩ := hP.padding_bin_square E + refine ⟨C, hC, fun L η c K bins hL hη hη1 hK => ?_⟩ + have hLp : 0 < L := zero_lt_one.trans_le hL + calc + _ ≤ (L / K) * (paddingAvailableLaw (paddingPrimeSupply E L) + (fun _ hp => (paddingPrimeSupply_prime hp).two_le)).average + (fun a => ∑ j ∈ bins, (paddingBinMass (paddingPrimeSupply E L) a η c j) ^ 2) := + FiniteLaw.large_bin_cut _ bins _ (fun a j => paddingBinMass_nonneg _ a η c j) K L hK hLp + _ ≤ (L / K) * (C / L) := + mul_le_mul_of_nonneg_left (hbound L η c bins hL hη hη1) (div_nonneg hLp.le hK.le) + _ = C / K := by field_simp + +/-- The same bound in the original weighted uniform-residue expectation. -/ +theorem ModFiveThetaInput.padding_residue_large_bin_cut (hP : ModFiveThetaInput) + (E : Finset ℕ) : + ∃ C : ℝ, 0 < C ∧ ∀ (L η c K : ℝ) (B : ℕ) (n : ℤ) (bins : Finset ℤ), + 1 ≤ L → 0 < η → η ≤ 1 → 0 < K → + ∀ hQB : ∀ p ∈ paddingPrimeSupply E L, p ≤ B, + (FiniteLaw.independent (fun p : paddingPrimeSupply E L => + uniformResidueLaw B p.val (paddingPrimeSupply_prime p.property).pos + (hQB p p.property))).average (fun z => + paddingTiltWeight _ (paddingResidueAvailable _ B n z) * + ∑ j ∈ bins, + if K / L < literalPaddingBinMass _ (paddingResidueAvailable _ B n z) η c j + then literalPaddingBinMass _ (paddingResidueAvailable _ B n z) η c j else 0) / + paddingTiltNormalizer (paddingPrimeSupply E L) ≤ C / K := by + obtain ⟨C, hC, hbound⟩ := hP.padding_large_bin_cut E + refine ⟨C, hC, fun L η c K B n bins hL hη hη1 hK hQB => ?_⟩ + simp_rw [← paddingBinMass_eq_literal _ (fun p hp => paddingPrimeSupply_prime hp)] + rw [padding_residue_tilt (paddingPrimeSupply E L) B + (fun _ hp => (paddingPrimeSupply_prime hp).two_le) hQB n + (fun a => ∑ j ∈ bins, if K / L < paddingBinMass _ a η c j then paddingBinMass _ a η c j else 0)] + exact hbound L η c K bins hL hη hη1 hK + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingLiteralBins.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingLiteralBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..7643b60c7b871f04a1eb0d5b1ffc824d713e6dfb --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingLiteralBins.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingBinSquare +import OAI.NumberTheory.TwoPoint.Bounds.PaddingTilt +import OAI.NumberTheory.TwoPoint.Walks.RetainedDivisorMass +import Mathlib.Data.Fintype.Powerset + +namespace OAI + +/-! The bin mass is the literal normalized sum of padding-divisor weights. +Boolean selections are finite subsets, so no extra multiplicity is present. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def selectedCoordinates (Q : Finset ℕ) (b : Q → Bool) : Finset Q := + univ.filter (fun p => b p = true) + +noncomputable def selectionFinsetEquiv (Q : Finset ℕ) : (Q → Bool) ≃ Finset Q where + toFun := selectedCoordinates Q + invFun S p := decide (p ∈ S) + left_inv b := by + funext p + cases hp : b p <;> simp [selectedCoordinates, hp] + right_inv S := by ext p; simp [selectedCoordinates] + +lemma selection_supported_iff (Q : Finset ℕ) (a b : Q → Bool) : + PaddingSelectionSupported Q a b ↔ selectedCoordinates Q b ⊆ selectedCoordinates Q a := by + simp only [PaddingSelectionSupported, subset_iff, selectedCoordinates, + mem_filter, mem_univ, true_and] + +lemma paddingTiltWeight_eq_five_pow (Q : Finset ℕ) (a : Q → Bool) : + paddingTiltWeight Q a = (5 : ℝ) ^ (selectedCoordinates Q a).card := by + rw [← prod_const] + simp only [selectedCoordinates, prod_filter, paddingTiltWeight] + +lemma paddingDivisorCoefficient_eq_four_pow (Q : Finset ℕ) (b : Q → Bool) : + paddingDivisorCoefficient Q b = (4 : ℝ) ^ (selectedCoordinates Q b).card := by + rw [← prod_const] + simp only [selectedCoordinates, prod_filter, paddingDivisorCoefficient] + +noncomputable def paddingSelectedDivisor (Q : Finset ℕ) (b : Q → Bool) : ℕ := + ∏ p ∈ selectedCoordinates Q b, p.val + +lemma paddingSelectedDivisor_log (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (b : Q → Bool) : Real.log (paddingSelectedDivisor Q b) = paddingLog Q b := by + rw [paddingSelectedDivisor, Nat.cast_prod, Real.log_prod] + · simp only [selectedCoordinates, sum_filter, paddingLog] + · intro p _ + exact_mod_cast (hQ p p.property).ne_zero + +lemma paddingBinMass_normalized_sum (Q : Finset ℕ) (a : Q → Bool) + (η c : ℝ) (j : ℤ) : + paddingBinMass Q a η c j = (paddingTiltWeight Q a)⁻¹ * + ∑ b : Q → Bool, + if PaddingSelectionSupported Q a b ∧ paddingBin η c (paddingLog Q b) = j + then paddingDivisorCoefficient Q b else 0 := by + simp only [paddingBinMass, FiniteLaw.probability, FiniteLaw.average, + paddingDivisorLaw_weight_eq, mul_sum] + apply sum_congr rfl + intro b _ + by_cases hs : PaddingSelectionSupported Q a b <;> + by_cases hb : paddingBin η c (paddingLog Q b) = j <;> + simp [hs, hb, div_eq_mul_inv, mul_comm] + +/-- The finite subset formula exactly matches `rho`: sum the weight +`4^omega(q)` over available squarefree padding divisors in the bin and +normalize by `5^omega_Q`. -/ +lemma paddingBinMass_subset_formula (Q : Finset ℕ) (a : Q → Bool) + (η c : ℝ) (j : ℤ) : + paddingBinMass Q a η c j = (5 : ℝ) ^ (-(selectedCoordinates Q a).card : ℤ) * + ∑ S : Finset Q, + if S ⊆ selectedCoordinates Q a ∧ + paddingBin η c (∑ p ∈ S, Real.log p.val) = j + then (4 : ℝ) ^ S.card else 0 := by + rw [paddingBinMass_normalized_sum, paddingTiltWeight_eq_five_pow] + rw [zpow_neg, zpow_natCast] + congr 1 + calc + _ = ∑ S : Finset Q, + if PaddingSelectionSupported Q a ((selectionFinsetEquiv Q).symm S) ∧ + paddingBin η c (paddingLog Q ((selectionFinsetEquiv Q).symm S)) = j + then paddingDivisorCoefficient Q ((selectionFinsetEquiv Q).symm S) else 0 := + ((selectionFinsetEquiv Q).symm.sum_comp _).symm + _ = _ := by + apply sum_congr rfl + intro S _ + rw [selection_supported_iff, paddingDivisorCoefficient_eq_four_pow] + have hs : selectedCoordinates Q ((selectionFinsetEquiv Q).symm S) = S := + (selectionFinsetEquiv Q).apply_symm_apply S + rw [hs] + have hl : paddingLog Q ((selectionFinsetEquiv Q).symm S) = + ∑ p ∈ S, Real.log p.val := by + change (∑ p : Q, if decide (p ∈ S) then Real.log p.val else 0) = _ + simp only [decide_eq_true_eq] + rw [← sum_filter, filter_mem_eq_inter, univ_inter] + rw [hl] + split_ifs <;> rfl + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingLogMoment.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingLogMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..fad57fe813c9df1495430c1aae1e94f6cdf94ca5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingLogMoment.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingDegreeTail +import OAI.NumberTheory.TwoPoint.Bounds.WeightedThetaError + +namespace OAI + +/-! The same fixed-modulus input bounds the logarithmic moment of the +reciprocal padding-divisor law, as needed for mass retained in bins. -/ + +namespace TwoPointCorrelations + +open Finset Filter MeasureTheory +open scoped Classical + +lemma modFivePrimeBand_log_mass (E : Finset ℕ) (one : Bool) (a b : ℝ) : + (∑ p ∈ modFivePrimeBand E one a b, Real.log p / p) = + ∑ p ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, (p : ℝ)⁻¹ * deletedModFiveLogWeight E one p := by + rw [modFivePrimeBand, sum_filter] + apply sum_congr rfl + intro p _ + by_cases hs : ModFivePrime one p ∧ p ∉ E + · simp only [ite_eq_left hs, deletedModFiveLogWeight] + ring + · simp [deletedModFiveLogWeight, hs] + +theorem ModFiveThetaInput.padding_log_mass (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ C : ℝ, 0 ≤ C ∧ ∀ L : ℝ, 1 ≤ L → + (∑ p ∈ paddingPrimeSupply E L, Real.log p / p) ≤ (3 / 4 : ℝ) * L + C := by + obtain ⟨K, hK, herror⟩ := hP.deleted_log_error E + let C₀ := ∑ p ∈ paddingPrimeSupply E 1, Real.log p / p + have hC₀ : 0 ≤ C₀ := sum_nonneg (fun p _ => div_nonneg (log_nat_nonneg p) (Nat.cast_nonneg p)) + refine ⟨C₀ + 3 * K, by positivity, fun L hL => ?_⟩ + have hab : Real.exp 1 ≤ Real.exp L := Real.exp_le_exp.mpr hL + have hxp (x : ℝ) (hx : x ∈ Set.Icc (Real.exp 1) (Real.exp L)) : 0 < x := + (Real.exp_pos 1).trans_le hx.1 + have hh := weighted_theta_error (deletedModFiveLogWeight E false) (modFiveDensity false) + K 1 1 (Real.exp 1) (Real.exp L) hK (by norm_num) (by norm_num) le_rfl hab + (fun x : ℝ => x⁻¹) + (fun x hx => (hasDerivAt_inv (hxp x hx).ne').differentiableAt) + (fun x hx => by + have hxn : x ≠ 0 := (hxp x hx).ne' + have hc : ContDiffAt ℝ 2 (fun y : ℝ => y⁻¹) x := by fun_prop (disch := assumption) + exact (hc.derivWithin (m := 0) (by norm_num)).continuousAt.continuousWithinAt) + (fun x hx => by rw [abs_of_pos (inv_pos.mpr (hxp x hx))]; simp) + (fun x hx => by + rw [(hasDerivAt_inv (hxp x hx).ne').deriv] + simp [abs_of_pos (hxp x hx), one_div]) + (fun x hx => by + rw [partialSum_deletedModFive] + apply herror false x + have he : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + exact he.trans hx.1) + rw [← modFivePrimeBand_log_mass] at hh + have hi : (∫ x in Real.exp 1..Real.exp L, x⁻¹) = L - 1 := by + rw [integral_inv_of_pos (Real.exp_pos _) (Real.exp_pos _), + Real.log_div (Real.exp_pos _).ne' (Real.exp_pos _).ne', Real.log_exp, Real.log_exp] + rw [hi, Real.log_exp] at hh + norm_num [modFiveDensity] at hh + rw [paddingPrimeSupply_split E L hL, sum_union (paddingPrimeSupply_split_disjoint E L)] + have hu := (abs_le.mp hh).2 + change C₀ + _ ≤ _ + linarith + +theorem ModFiveThetaInput.eventually_reciprocal_padding_log_mean (hP : ModFiveThetaInput) + (E : Finset ℕ) : + ∀ᶠ L : ℝ in atTop, + (∑ p : paddingPrimeSupply E L, (4 / ((p.val : ℝ) + 4)) * Real.log p.val) ≤ 4 * L := by + obtain ⟨C, hC, hbound⟩ := hP.padding_log_mass E + filter_upwards [eventually_ge_atTop (4 * C), eventually_ge_atTop (1 : ℝ)] with L hLC hL + have hh : (∑ p : paddingPrimeSupply E L, (4 / ((p.val : ℝ) + 4)) * Real.log p.val) ≤ + 4 * ∑ p ∈ paddingPrimeSupply E L, Real.log p / p := by + rw [← sum_coe_sort _ (fun p : ℕ => Real.log p / p), mul_sum] + apply sum_le_sum + intro p _ + have hp : (0 : ℝ) < p.val := by exact_mod_cast (paddingPrimeSupply_prime p.property).pos + calc + (4 / ((p.val : ℝ) + 4)) * Real.log p.val ≤ (4 / p.val) * Real.log p.val := + mul_le_mul_of_nonneg_right + (div_le_div_of_nonneg_left (by norm_num) hp (by linarith)) (log_nat_nonneg p.val) + _ = _ := by ring + nlinarith [hbound L hL] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingPairSampling.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingPairSampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..afd2d84a1739bf8d7c64b8f8b47437e74a5c4ceb --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingPairSampling.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingSelectionLaw + +namespace OAI + +/-! The local three-boolean experiment agrees with first choosing all +available primes and then independently choosing two padding divisors. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def paddingAvailableLaw (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) : + FiniteLaw (Q → Bool) := + FiniteLaw.independent (fun p : Q => paddingAvailabilityLaw p (hQ p p.property)) + +noncomputable def paddingDivisorLaw (Q : Finset ℕ) (a : Q → Bool) : + FiniteLaw (Q → Bool) := FiniteLaw.independent (fun p => paddingSelectionLaw (a p)) + +noncomputable def paddingLog (Q : Finset ℕ) (b : Q → Bool) : ℝ := + ∑ p : Q, if b p then Real.log p else 0 + +def paddingTripleEquiv (Q : Finset ℕ) : + (Q → Bool × (Bool × Bool)) ≃ ((Q → Bool) × ((Q → Bool) × (Q → Bool))) where + toFun x := (fun p => (x p).1, fun p => (x p).2.1, fun p => (x p).2.2) + invFun y p := (y.1 p, y.2.1 p, y.2.2 p) + left_inv x := by funext p; rfl + right_inv y := by rfl + +lemma paddingPairLaw_weight (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) + (a b c : Q → Bool) : + (paddingPairLaw Q hQ).weight (fun p => (a p, b p, c p)) = + (paddingAvailableLaw Q hQ).weight a * + (paddingDivisorLaw Q a).weight b * (paddingDivisorLaw Q a).weight c := by + simp only [paddingPairLaw, paddingPairLocal, paddingAvailableLaw, paddingDivisorLaw, + FiniteLaw.independent, FiniteLaw.dependentProduct, FiniteLaw.product] + rw [prod_mul_distrib, prod_mul_distrib] + ring + +lemma paddingPairLaw_average_nested (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) + (F : (Q → Bool) → (Q → Bool) → (Q → Bool) → ℝ) : + (paddingPairLaw Q hQ).average + (fun x => F (fun p => (x p).1) (fun p => (x p).2.1) (fun p => (x p).2.2)) = + (paddingAvailableLaw Q hQ).average (fun a => + (paddingDivisorLaw Q a).average (fun b => + (paddingDivisorLaw Q a).average (fun c => F a b c))) := by + calc + _ = ∑ y : (Q → Bool) × ((Q → Bool) × (Q → Bool)), + (paddingPairLaw Q hQ).weight (fun p => (y.1 p, y.2.1 p, y.2.2 p)) * + F y.1 y.2.1 y.2.2 := by + exact ((paddingTripleEquiv Q).symm.sum_comp + (fun x => (paddingPairLaw Q hQ).weight x * + F (fun p => (x p).1) (fun p => (x p).2.1) (fun p => (x p).2.2))).symm + _ = _ := by + simp only [Fintype.sum_prod_type, paddingPairLaw_weight, FiniteLaw.average, mul_sum] + apply sum_congr rfl + intro a _ + apply sum_congr rfl + intro b _ + apply sum_congr rfl + intro c _ + ring + +lemma paddingPairDifference_value (Q : Finset ℕ) (x : Q → Bool × (Bool × Bool)) : + paddingDifferenceValue Q (fun p => paddingPairDifference (x p)) = + paddingLog Q (fun p => (x p).2.1) - paddingLog Q (fun p => (x p).2.2) := by + unfold paddingDifferenceValue paddingLog + rw [← sum_sub_distrib] + apply sum_congr rfl + intro p _ + cases hb : (x p).2.1 <;> cases hc : (x p).2.2 <;> + simp [paddingPairDifference, paddingDifferenceStep, hb, hc] + +/-- Exact law of the difference of two conditionally sampled padding divisors. -/ +theorem padding_pair_difference_average (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) + (F : ℝ → ℝ) : + (paddingAvailableLaw Q hQ).average (fun a => + (paddingDivisorLaw Q a).average (fun b => + (paddingDivisorLaw Q a).average (fun c => F (paddingLog Q b - paddingLog Q c)))) = + (paddingDifferenceLaw Q hQ).average (fun x => F (paddingDifferenceValue Q x)) := by + rw [← paddingPairLaw_average_nested] + simpa only [paddingPairDifference_value] using + paddingPairLaw_average Q hQ (fun x => F (paddingDifferenceValue Q x)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingPolarization.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingPolarization.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb91ba4da623ae377a2a37850f674c7b57f5346b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingPolarization.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.TwoPoint.Walks.BlockTesting +import OAI.NumberTheory.TwoPoint.Bounds.ComplexPolarization + +namespace OAI + +/-! Transfer the existing quadratic graph tests to two bounded sequences. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma paddingTestVector_halfPair {V : Type*} [Fintype V] (Q : Finset ℕ) (L : ℝ) + (site : V → ℤ) (f g : ℤ → ℂ) (z : ℂ) : + paddingTestVector Q L site (halfPairFunction f g z) = + halfPair (paddingTestVector Q L site f) (paddingTestVector Q L site g) z := by + ext i + by_cases hi : actualPaddingDegreeCut Q L (site i) + · simp [paddingTestVector, halfPairFunction, halfPair, hi, div_eq_mul_inv] + ring + · simp [paddingTestVector, halfPairFunction, halfPair, hi] + +theorem uniformAverage_padding_bilinear {Ω V : Type*} [Fintype Ω] [Fintype V] + (Q : Finset ℕ) (L : ℝ) (site : Ω → V → ℤ) + (T : Ω → EuclideanSpace ℂ V →L[ℂ] EuclideanSpace ℂ V) (C : ℝ) + (hquad : ∀ f : ℤ → ℂ, (∀ n, ‖f n‖ ≤ 1) → + uniformAverage (fun x => + let v := paddingTestVector Q L (site x) f + ‖inner ℂ v (T x v)‖) ≤ C) + (f g : ℤ → ℂ) (hf : ∀ n, ‖f n‖ ≤ 1) (hg : ∀ n, ‖g n‖ ≤ 1) : + uniformAverage (fun x => ‖inner ℂ (paddingTestVector Q L (site x) f) + (T x (paddingTestVector Q L (site x) g))‖) ≤ 4 * C := by + let q (z : ℂ) (x : Ω) := + let v := paddingTestVector Q L (site x) (halfPairFunction f g z) + ‖inner ℂ v (T x v)‖ + have hb (z : ℂ) (hz : ‖z‖ ≤ 1) : uniformAverage (q z) ≤ C := + hquad (halfPairFunction f g z) (halfPairFunction_norm_le f g z hf hg hz) + have hp (x : Ω) : ‖inner ℂ (paddingTestVector Q L (site x) f) + (T x (paddingTestVector Q L (site x) g))‖ ≤ + q 1 x + q (-1) x + q Complex.I x + q (-Complex.I) x := by + have h := complex_polarization_norm (T x) + (paddingTestVector Q L (site x) f) (paddingTestVector Q L (site x) g) + simpa only [q, paddingTestVector_halfPair] using h + have hav : uniformAverage (fun x => ‖inner ℂ (paddingTestVector Q L (site x) f) + (T x (paddingTestVector Q L (site x) g))‖) ≤ + uniformAverage (q 1) + uniformAverage (q (-1)) + + uniformAverage (q Complex.I) + uniformAverage (q (-Complex.I)) := by + unfold uniformAverage + simpa only [sum_add_distrib, add_div] using + div_le_div_of_nonneg_right (sum_le_sum (fun x _ => hp x)) + (Nat.cast_nonneg (α := ℝ) (Fintype.card Ω)) + have h1 := hb 1 (by simp) + have hm := hb (-1) (by simp) + have hi := hb Complex.I (by simp) + have hmi := hb (-Complex.I) (by simp) + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingPrimeOscillation.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingPrimeOscillation.lean new file mode 100644 index 0000000000000000000000000000000000000000..199b6fe3ea25bcde3ab5b3093c0d9a22cd1a507e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingPrimeOscillation.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CosineLogIntegral +import OAI.NumberTheory.TwoPoint.Bounds.PrimeSupplyGeometry +import OAI.NumberTheory.TwoPoint.Bounds.PowerSmallBall + +namespace OAI + +/-! The fixed-modulus prime input implies the padding oscillation and the +reciprocal-scale small-ball bound for the actual independent padding law. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +lemma oscillatory_log_substitution (t L : ℝ) (hL : 1 ≤ L) : + (∫ x in Real.exp 1..Real.exp L, oscillatoryReciprocalLog t x) = + ∫ y in (1 : ℝ)..L, (1 - Real.cos (t * y)) / y := by + have hab : Real.exp 1 ≤ Real.exp L := Real.exp_le_exp.mpr hL + have hxn (x : ℝ) (hx : x ∈ Set.uIcc (Real.exp 1) (Real.exp L)) : 0 < x := by + have hx' : x ∈ Set.Icc (Real.exp 1) (Real.exp L) := by + simpa only [Set.uIcc_of_le hab] using hx + exact (Real.exp_pos 1).trans_le hx'.1 + have hderiv (x : ℝ) (hx : x ∈ Set.uIcc (Real.exp 1) (Real.exp L)) : + HasDerivAt Real.log x⁻¹ x := Real.hasDerivAt_log (hxn x hx).ne' + have hdcont : ContinuousOn (fun x : ℝ => x⁻¹) (Set.uIcc (Real.exp 1) (Real.exp L)) := + continuousOn_id.inv₀ (fun x hx => (hxn x hx).ne') + have hg : ContinuousOn (fun y : ℝ => (1 - Real.cos (t * y)) / y) + (Real.log '' Set.uIcc (Real.exp 1) (Real.exp L)) := by + rintro y ⟨x, hx, rfl⟩ + have hx' : x ∈ Set.Icc (Real.exp 1) (Real.exp L) := by + simpa only [Set.uIcc_of_le hab] using hx + have hl : 1 ≤ Real.log x := by + simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1) hx'.1 + have hn : Real.log x ≠ 0 := (zero_lt_one.trans_le hl).ne' + exact (by fun_prop (disch := assumption) : + ContinuousAt (fun y : ℝ => (1 - Real.cos (t * y)) / y) (Real.log x)).continuousWithinAt + have hh := intervalIntegral.integral_comp_mul_deriv' hderiv hdcont hg + rw [Real.log_exp, Real.log_exp] at hh + rw [← hh] + apply intervalIntegral.integral_congr + intro x _ + unfold oscillatoryReciprocalLog reciprocalLog + simp only [Function.comp_def, div_eq_mul_inv] + ring + +lemma modFivePrimeBand_oscillation (E : Finset ℕ) (one : Bool) (a b t : ℝ) : + (∑ p ∈ modFivePrimeBand E one a b, (1 - Real.cos (t * Real.log p)) / p) = + ∑ p ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, oscillatoryReciprocalLog t p * deletedModFiveLogWeight E one p := by + rw [modFivePrimeBand, sum_filter] + apply sum_congr rfl + intro p hp + by_cases hs : ModFivePrime one p ∧ p ∉ E + · rw [ite_eq_left hs] + unfold deletedModFiveLogWeight + rw [ite_eq_left hs] + have hl : Real.log (p : ℝ) ≠ 0 := + (Real.log_pos (by exact_mod_cast hs.1.1.one_lt)).ne' + unfold oscillatoryReciprocalLog reciprocalLog + field_simp + · simp [deletedModFiveLogWeight, hs] + +lemma padding_band_subset (E : Finset ℕ) (a L : ℝ) : + modFivePrimeBand E false a (Real.exp L) ⊆ paddingPrimeSupply E L := by + intro p hp + obtain ⟨hpi, hs, he⟩ := mem_filter.mp hp + apply mem_sdiff.mpr + refine ⟨?_, he⟩ + apply mem_filter.mpr + exact ⟨mem_Icc.mpr ⟨Nat.zero_le _, (mem_Ioc.mp hpi).2⟩, hs⟩ + +theorem ModFiveThetaInput.padding_oscillation (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ C : ℝ, 0 ≤ C ∧ ∀ (L t : ℝ), 1 ≤ L → |t| ≤ 2 → + (3 / 4 : ℝ) * Real.log (1 + L * |t|) - C ≤ + paddingOscillation (paddingPrimeSupply E L) t := by + obtain ⟨K, hK, herror⟩ := hP.deleted_log_error E + refine ⟨10 * K + 15 / 4, by positivity, fun L t hL ht => ?_⟩ + have hh := oscillatory_theta_error (deletedModFiveLogWeight E false) + (modFiveDensity false) K (Real.exp 1) (Real.exp L) t hK le_rfl + (Real.exp_le_exp.mpr hL) ht (fun x hx => by + rw [partialSum_deletedModFive] + apply herror false x + have h2 : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + exact h2.trans hx.1) + rw [← modFivePrimeBand_oscillation, oscillatory_log_substitution t L hL, Real.log_exp] at hh + have hlower := (abs_le.mp hh).1 + have hmain := logarithmic_oscillation_lower t L ht hL + have hsubset : + (∑ p ∈ modFivePrimeBand E false (Real.exp 1) (Real.exp L), + (1 - Real.cos (t * Real.log p)) / p) ≤ paddingOscillation (paddingPrimeSupply E L) t := by + apply sum_le_sum_of_subset_of_nonneg (padding_band_subset E (Real.exp 1) L) + intro p _ _ + exact div_nonneg (sub_nonneg.mpr (Real.cos_le_one _)) (Nat.cast_nonneg p) + norm_num [modFiveDensity] at hlower + linarith + +lemma paddingPrimeSupply_prime {E : Finset ℕ} {L : ℝ} {p : ℕ} + (hp : p ∈ paddingPrimeSupply E L) : p.Prime := + (mem_filter.mp (mem_sdiff.mp hp).1).2.1 + +/-- The precise padding difference law has `O_E(1/L)` mass in every +unit interval centered at zero. Its bound is uniform in all centered tuples. -/ +theorem ModFiveThetaInput.padding_small_ball (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ C : ℝ, 0 < C ∧ ∀ L : ℝ, 1 ≤ L → + (paddingDifferenceLaw (paddingPrimeSupply E L) + (fun _ hp => (paddingPrimeSupply_prime hp).two_le)).probability + (fun x => |paddingDifferenceValue (paddingPrimeSupply E L) x| ≤ 1) ≤ C / L := by + obtain ⟨C, _, hC⟩ := hP.padding_oscillation E + refine ⟨20 * Real.exp ((8 / 5 : ℝ) * C + 64 / 5), by positivity, fun L hL => ?_⟩ + apply paddingDifference_small_ball _ _ L C (zero_lt_one.trans_le hL) + intro t ht + apply hC L t hL + rw [abs_of_nonneg ht.1] + linarith [ht.2] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingResidueEvent.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingResidueEvent.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fae314a0ec4e8234a77754c97484322bc2fd944 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingResidueEvent.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PositiveWordProbability + +namespace OAI + +/-! Padding divisibility in one common residue sample, with arbitrary departures. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def paddingPrimeSupport {R : ℕ} (q : Fin R → ℕ) : Finset ℕ := + univ.biUnion (fun i => (q i).primeFactors) + +def PaddingResidueEvent {R B : ℕ} (Q : Finset ℕ) (q : Fin R → ℕ) + (offset : Fin R → ℤ) (y : Q → Fin B) : Prop := + ∀ (i : Fin R) (p : Q), p.val ∈ (q i).primeFactors → + ((y p).val : ZMod p.val) = -((offset i : ℤ) : ZMod p.val) + +/-- Repeated padding primes impose compatibility conditions on a single +coordinate. The probability pays only one reciprocal per distinct prime. -/ +theorem paddingResidueEvent_probability_le {R : ℕ} (Q : Finset ℕ) + (q : Fin R → ℕ) (offset : Fin R → ℤ) (B : ℕ) + (hp : ∀ p ∈ Q, 0 < p) (hpB : ∀ p ∈ Q, p ≤ B) + (hQ : paddingPrimeSupport q ⊆ Q) : + (FiniteLaw.independent (fun p : Q => + uniformResidueLaw B p.val (hp _ p.property) (hpB _ p.property))).probability + (PaddingResidueEvent Q q offset) ≤ + ∏ p ∈ paddingPrimeSupport q, (p : ℝ)⁻¹ := by + classical + let E (p : Q) (y : Fin B) : Prop := ∀ i : Fin R, p.val ∈ (q i).primeFactors → + (y.val : ZMod p.val) = -((offset i : ℤ) : ZMod p.val) + have he : PaddingResidueEvent (B := B) Q q offset = (fun y => ∀ p, E p (y p)) := by + funext y + exact propext forall_comm + rw [he, FiniteLaw.independent_probability_all] + have hprod : (∏ p : Q, if p.val ∈ paddingPrimeSupport q then (p.val : ℝ)⁻¹ else 1) = + ∏ p ∈ paddingPrimeSupport q, (p : ℝ)⁻¹ := by + rw [← prod_filter] + apply prod_bij (fun p _ => p.val) + · intro p hp' + exact (mem_filter.mp hp').2 + · intro p _ r _ hpr + exact Subtype.ext hpr + · intro p hp' + exact ⟨⟨p, hQ hp'⟩, mem_filter.mpr ⟨mem_univ _, hp'⟩, rfl⟩ + · intro p _ + rfl + rw [← hprod] + apply prod_le_prod₀ + · intro p _ + exact FiniteLaw.probability_nonneg _ _ + · intro p _ + by_cases hp' : p.val ∈ paddingPrimeSupport q + · rw [ite_eq_left hp'] + obtain ⟨i, _, hi⟩ := mem_biUnion.mp hp' + exact ((uniformResidueLaw B p.val (hp _ p.property) (hpB _ p.property)).probability_mono_of_imp + (fun y hy => hy i hi)).trans_eq + (uniformResidueLaw_mod_eq B p.val (hp _ p.property) (hpB _ p.property) + (-((offset i : ℤ) : ZMod p.val))) + · rw [ite_eq_right hp'] + exact FiniteLaw.probability_le_one _ _ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingResidueTilt.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingResidueTilt.lean new file mode 100644 index 0000000000000000000000000000000000000000..055f04182e5a5120911a3fe11733a1bf0a82b700 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingResidueTilt.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingDivisorEncoding +import OAI.NumberTheory.TwoPoint.Bounds.PositiveWordProbability +import OAI.NumberTheory.TwoPoint.Bounds.CommonResidueLift +import OAI.NumberTheory.TwoPoint.Bounds.SieveModel + +namespace OAI + +/-! At every translated site of the uniform residue model, divisibility +indicators give independent Bernoulli(1/p) variables. Thus the exact weighted +residue expectation is the tilted padding law used in the bin-square bound. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def paddingResidueAvailable (Q : Finset ℕ) (B : ℕ) + (n : ℤ) (z : Q → Fin B) (p : Q) : Bool := + decide ((p.val : ℤ) ∣ (z p).val + n) + +lemma padding_residue_single_law (B p : ℕ) (hp : 2 ≤ p) (hpB : p ≤ B) + (n : ℤ) (b : Bool) : + (uniformResidueLaw B p (by omega) hpB).probability + (fun z => decide ((p : ℤ) ∣ (z.val : ℤ) + n) = b) = + (paddingOriginalPrimeLaw p hp).weight b := by + have he (z : Fin B) : (p : ℤ) ∣ (z.val : ℤ) + n ↔ + (z.val : ZMod p) = -(n : ZMod p) := + residue_offset_divisibility (z.val : ZMod p) z.val n (by simp) + have hh : (uniformResidueLaw B p (by omega) hpB).probability + (fun z => (p : ℤ) ∣ (z.val : ℤ) + n) = (p : ℝ)⁻¹ := by + simpa only [he] using uniformResidueLaw_mod_eq B p (by omega) hpB (-(n : ZMod p)) + cases b + · have hc := FiniteLaw.probability_complement (uniformResidueLaw B p (by omega) hpB) + (fun z => (p : ℤ) ∣ (z.val : ℤ) + n) + rw [hh] at hc + simpa [paddingOriginalPrimeLaw, booleanLaw, one_div] using hc + · simpa [paddingOriginalPrimeLaw, booleanLaw, one_div] using hh + +lemma padding_residue_average (Q : Finset ℕ) (B : ℕ) + (hQ : ∀ p ∈ Q, 2 ≤ p) (hQB : ∀ p ∈ Q, p ≤ B) (n : ℤ) + (F : (Q → Bool) → ℝ) : + (FiniteLaw.independent (fun p : Q => + uniformResidueLaw B p.val (by have := hQ p p.property; omega) (hQB p p.property))).average + (fun z => F (paddingResidueAvailable Q B n z)) = + (paddingOriginalLaw Q hQ).average F := by + exact FiniteLaw.independent_average_map + (fun p : Q => uniformResidueLaw B p.val (by have := hQ p p.property; omega) (hQB p p.property)) + (fun p : Q => paddingOriginalPrimeLaw p (hQ p p.property)) + (fun p (z : Fin B) => decide ((p.val : ℤ) ∣ (z.val : ℤ) + n)) + (fun p b => padding_residue_single_law B p (hQ p p.property) (hQB p p.property) n b) F + +lemma padding_residue_tilt (Q : Finset ℕ) (B : ℕ) + (hQ : ∀ p ∈ Q, 2 ≤ p) (hQB : ∀ p ∈ Q, p ≤ B) (n : ℤ) + (F : (Q → Bool) → ℝ) : + (FiniteLaw.independent (fun p : Q => + uniformResidueLaw B p.val (by have := hQ p p.property; omega) (hQB p p.property))).average + (fun z => paddingTiltWeight Q (paddingResidueAvailable Q B n z) * + F (paddingResidueAvailable Q B n z)) / + paddingTiltNormalizer Q = (paddingAvailableLaw Q hQ).average F := by + rw [padding_residue_average Q B hQ hQB n (fun a => paddingTiltWeight Q a * F a), + padding_tilt_average Q hQ F] + exact mul_div_cancel_left₀ _ (paddingTiltNormalizer_pos Q).ne' + +lemma padding_residue_bin_square_le (Q : Finset ℕ) (B : ℕ) + (hQ : ∀ p ∈ Q, p.Prime) (hQB : ∀ p ∈ Q, p ≤ B) (n : ℤ) + (η c : ℝ) (hη : 0 < η) (hη1 : η ≤ 1) (bins : Finset ℤ) : + (FiniteLaw.independent (fun p : Q => + uniformResidueLaw B p.val (hQ p p.property).pos (hQB p p.property))).average + (fun z => paddingTiltWeight Q (paddingResidueAvailable Q B n z) * + ∑ j ∈ bins, (literalPaddingBinMass Q (paddingResidueAvailable Q B n z) η c j) ^ 2) / + paddingTiltNormalizer Q ≤ + (paddingDifferenceLaw Q (fun p hp => (hQ p hp).two_le)).probability + (fun x => |paddingDifferenceValue Q x| ≤ 1) := by + simp_rw [← paddingBinMass_eq_literal Q hQ] + rw [padding_residue_tilt Q B (fun p hp => (hQ p hp).two_le) hQB n + (fun a => ∑ j ∈ bins, (paddingBinMass Q a η c j) ^ 2)] + exact padding_bin_square_small_ball Q _ η c hη hη1 bins + +/-- Literal residue-model `rho_j`, weighted by `w/S`, satisfies the padding +anti-concentration estimate uniformly in site and bin translation. -/ +theorem ModFiveThetaInput.padding_residue_bin_square (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ C : ℝ, 0 < C ∧ ∀ (L η c : ℝ) (B : ℕ) (n : ℤ) (bins : Finset ℤ), + 1 ≤ L → 0 < η → η ≤ 1 → + ∀ hQB : ∀ p ∈ paddingPrimeSupply E L, p ≤ B, + (FiniteLaw.independent (fun p : paddingPrimeSupply E L => + uniformResidueLaw B p.val (paddingPrimeSupply_prime p.property).pos + (hQB p p.property))).average (fun z => + paddingTiltWeight _ (paddingResidueAvailable _ B n z) * + ∑ j ∈ bins, (literalPaddingBinMass _ (paddingResidueAvailable _ B n z) η c j) ^ 2) / + paddingTiltNormalizer (paddingPrimeSupply E L) ≤ C / L := by + obtain ⟨C, hC, hbound⟩ := hP.padding_small_ball E + refine ⟨C, hC, fun L η c B n bins hL hη hη1 hQB => ?_⟩ + exact (padding_residue_bin_square_le (paddingPrimeSupply E L) B + (fun _ hp => paddingPrimeSupply_prime hp) hQB n η c hη hη1 bins).trans (hbound L hL) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingRetainedProbability.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingRetainedProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a1308188ea5c1357f2661ab931ea3d288ccbfbc --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingRetainedProbability.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ReciprocalPaddingLaw +import OAI.NumberTheory.TwoPoint.Bounds.PaddingLogMoment + +namespace OAI + +/-! Under the exact harmonic padding law, more than half the mass obeys +both the degree and logarithmic-size restrictions used to form the bins. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma FiniteLaw.probability_lt_le_average {A : Type*} [Fintype A] + (μ : FiniteLaw A) (Z : A → ℝ) (hZ : ∀ x, 0 ≤ Z x) (t : ℝ) (ht : 0 < t) : + μ.probability (fun x => t < Z x) ≤ μ.average Z / t := by + calc + _ ≤ μ.average (fun x => Z x / t) := by + apply μ.average_mono + intro x + by_cases hx : t < Z x + · rw [ite_eq_left hx] + exact (one_le_div ht).mpr hx.le + · rw [ite_eq_right hx] + exact div_nonneg (hZ x) ht.le + _ = _ := by + simp only [div_eq_mul_inv, μ.average_mul_const] + +lemma FiniteLaw.probability_and_ge {A : Type*} [Fintype A] + (μ : FiniteLaw A) (E F : A → Prop) : + 1 - μ.probability (fun x => ¬ E x) - μ.probability (fun x => ¬ F x) ≤ + μ.probability (fun x => E x ∧ F x) := by + have hh := μ.average_mono (f := fun x => + 1 - (if ¬ E x then 1 else 0) - (if ¬ F x then 1 else 0)) + (g := fun x => if E x ∧ F x then 1 else 0) (fun x => by + by_cases he : E x <;> by_cases hf : F x <;> simp [he, hf]) + simpa [FiniteLaw.average, FiniteLaw.probability, mul_sub, + sum_sub_distrib, μ.total] using hh + +lemma booleanCount_nonneg {ι : Type*} [Fintype ι] (a : ι → Bool) : 0 ≤ booleanCount a := by + apply sum_nonneg + intro i _ + split_ifs <;> norm_num + +lemma paddingLog_nonneg (Q : Finset ℕ) (b : Q → Bool) : 0 ≤ paddingLog Q b := by + apply sum_nonneg + intro p _ + split_ifs + · exact log_nat_nonneg p.val + · exact le_refl _ + +theorem ModFiveThetaInput.eventually_reciprocal_padding_count_mean (hP : ModFiveThetaInput) + (E : Finset ℕ) : + ∀ᶠ L : ℝ in atTop, + (reciprocalPaddingLaw (paddingPrimeSupply E L)).average booleanCount ≤ 4 * Real.log L := by + filter_upwards [hP.eventually_padding_mean E] with L hL + rw [reciprocal_padding_count_average] + refine le_trans (sum_le_sum fun p _ => ?_) hL + exact div_le_div_of_nonneg_right (by norm_num) (by positivity) + +theorem ModFiveThetaInput.eventually_retained_padding_probability (hP : ModFiveThetaInput) + (E : Finset ℕ) : + ∀ᶠ L : ℝ in atTop, + (1 / 2 : ℝ) ≤ (reciprocalPaddingLaw (paddingPrimeSupply E L)).probability + (fun b => booleanCount b ≤ 100 * Real.log L ∧ + paddingLog (paddingPrimeSupply E L) b ≤ 98 * L) := by + filter_upwards [hP.eventually_reciprocal_padding_count_mean E, + hP.eventually_reciprocal_padding_log_mean E, eventually_ge_atTop (2 : ℝ)] + with L hc hl hL + let Q := paddingPrimeSupply E L + let μ := reciprocalPaddingLaw Q + have hLp : 0 < L := lt_of_lt_of_le (by norm_num) hL + have hlog : 0 < Real.log L := Real.log_pos (lt_of_lt_of_le (by norm_num) hL) + have hcount : μ.probability (fun b => 100 * Real.log L < booleanCount b) ≤ 1 / 25 := by + apply (μ.probability_lt_le_average booleanCount booleanCount_nonneg + (100 * Real.log L) (by positivity)).trans + calc + _ ≤ (4 * Real.log L) / (100 * Real.log L) := + div_le_div_of_nonneg_right hc (by positivity) + _ = _ := by field_simp; norm_num + have hsize : μ.probability (fun b => 98 * L < paddingLog Q b) ≤ 2 / 49 := by + apply (μ.probability_lt_le_average (paddingLog Q) (paddingLog_nonneg Q) + (98 * L) (by positivity)).trans + calc + _ ≤ (4 * L) / (98 * L) := by + apply div_le_div_of_nonneg_right _ (by positivity) + change (reciprocalPaddingLaw Q).average (paddingLog Q) ≤ 4 * L + rw [reciprocal_padding_log_average] + exact hl + _ = _ := by field_simp; norm_num + have hh := μ.probability_and_ge (fun b => booleanCount b ≤ 100 * Real.log L) + (fun b => paddingLog Q b ≤ 98 * L) + simp only [not_le] at hh + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingSelectionLaw.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingSelectionLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..acca9cc9da3543813ef049ccfe515659c77e9ebf --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingSelectionLaw.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteLawMapping +import OAI.NumberTheory.TwoPoint.Bounds.PaddingDifferenceLaw + +namespace OAI + +/-! The padding experiment has tilted prime availability `5/(p+4)` and, +given availability, two independent selections of probability `4/5`. +Its exact difference pushforward is the manuscript's three-point law. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def booleanLaw (q : ℝ) (hq0 : 0 ≤ q) (hq1 : q ≤ 1) : FiniteLaw Bool where + weight b := if b then q else 1 - q + nonneg b := by cases b <;> simp [hq0, sub_nonneg.mpr hq1] + total := by simp + +noncomputable def paddingAvailabilityLaw (p : ℕ) (hp : 2 ≤ p) : FiniteLaw Bool := + booleanLaw (5 / ((p : ℝ) + 4)) (by positivity) + (by + apply (div_le_one (by positivity)).mpr + have hpr : (2 : ℝ) ≤ p := by exact_mod_cast hp + linarith) + +noncomputable def paddingSelectionLaw (a : Bool) : FiniteLaw Bool := + booleanLaw (if a then 4 / 5 else 0) (by cases a <;> norm_num) + (by cases a <;> norm_num) + +noncomputable def paddingPairLocal (p : ℕ) (hp : 2 ≤ p) : FiniteLaw (Bool × (Bool × Bool)) := + (paddingAvailabilityLaw p hp).dependentProduct + (fun a => (paddingSelectionLaw a).product (paddingSelectionLaw a)) + +def paddingPairDifference (x : Bool × (Bool × Bool)) : Fin 3 := + if x.2.1 = x.2.2 then 0 else if x.2.1 then 1 else 2 + +lemma paddingPairLocal_average (p : ℕ) (hp : 2 ≤ p) (F : Fin 3 → ℝ) : + (paddingPairLocal p hp).average (fun x => F (paddingPairDifference x)) = + (paddingStepLaw p hp).average F := by + have hd : (p : ℝ) + 4 ≠ 0 := by positivity + simp only [FiniteLaw.average, paddingPairLocal, FiniteLaw.dependentProduct, + paddingAvailabilityLaw, paddingSelectionLaw, booleanLaw, FiniteLaw.product, + Fintype.sum_prod_type, Fintype.sum_bool, paddingPairDifference, + paddingStepLaw, paddingDifferenceAtom, Fin.sum_univ_three] + norm_num + field_simp + ring + +lemma paddingPairLocal_fiber (p : ℕ) (hp : 2 ≤ p) (e : Fin 3) : + (paddingPairLocal p hp).probability (fun x => paddingPairDifference x = e) = + (paddingStepLaw p hp).weight e := by + have hh := paddingPairLocal_average p hp (fun x => if x = e then 1 else 0) + simpa [FiniteLaw.probability, FiniteLaw.average] using hh + +noncomputable def paddingPairLaw (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) : + FiniteLaw (Q → Bool × (Bool × Bool)) := + FiniteLaw.independent (fun p : Q => paddingPairLocal p (hQ p p.property)) + +lemma paddingPairLaw_average (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) + (F : (Q → Fin 3) → ℝ) : + (paddingPairLaw Q hQ).average (fun x => F (fun p => paddingPairDifference (x p))) = + (paddingDifferenceLaw Q hQ).average F := + FiniteLaw.independent_average_map + (fun p : Q => paddingPairLocal p (hQ p p.property)) + (fun p : Q => paddingStepLaw p (hQ p p.property)) + (fun _ => paddingPairDifference) + (fun p => paddingPairLocal_fiber p (hQ p p.property)) F + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingSmoothBound.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingSmoothBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..107416e6dc5cc0258dc1a320540b42b228952320 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingSmoothBound.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingSmoothMass +import Mathlib.Analysis.PSeries + +namespace OAI + +/-! The smooth-dilation cost averaged over the actual reciprocal padding +law is bounded by an absolute convergent product, uniformly in the pool. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def paddingSmoothConstant : ℝ := + Real.exp ((4 / (1 - (2 : ℝ) ^ (-(1 / 2) : ℝ))) * + ∑' n : ℕ, (n : ℝ) ^ (-3 / 2 : ℝ)) + +lemma paddingSmoothConstant_pos : 0 < paddingSmoothConstant := Real.exp_pos _ + +lemma smooth_half_local_bound (p : ℕ) (hp : 2 ≤ p) : + 0 ≤ 4 / ((p : ℝ) + 4) * ((1 - (p : ℝ) ^ (-(1 / 2) : ℝ))⁻¹ - 1) ∧ + 4 / ((p : ℝ) + 4) * ((1 - (p : ℝ) ^ (-(1 / 2) : ℝ))⁻¹ - 1) ≤ + (4 / (1 - (2 : ℝ) ^ (-(1 / 2) : ℝ))) * (p : ℝ) ^ (-3 / 2 : ℝ) := by + have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast hp + have hp0 : (0 : ℝ) < p := by linarith + have hr0 : 0 < (p : ℝ) ^ (-(1 / 2) : ℝ) := Real.rpow_pos_of_pos hp0 _ + have hr1 : (p : ℝ) ^ (-(1 / 2) : ℝ) < 1 := + Real.rpow_lt_one_of_one_lt_of_neg (by linarith) (by norm_num) + have h20 : 0 < (1 - (2 : ℝ) ^ (-(1 / 2) : ℝ)) := by + have hh := Real.rpow_lt_one_of_one_lt_of_neg + (by norm_num : (1 : ℝ) < 2) (by norm_num : (-(1 / 2) : ℝ) < 0) + linarith + have hrle : (p : ℝ) ^ (-(1 / 2) : ℝ) ≤ (2 : ℝ) ^ (-(1 / 2) : ℝ) := + Real.rpow_le_rpow_of_nonpos (by norm_num) hp2 (by norm_num) + have hlocal : (1 - (p : ℝ) ^ (-(1 / 2) : ℝ))⁻¹ - 1 = + (p : ℝ) ^ (-(1 / 2) : ℝ) / (1 - (p : ℝ) ^ (-(1 / 2) : ℝ)) := by + apply (eq_div_iff (ne_of_gt (sub_pos.mpr hr1))).mpr + rw [sub_mul, inv_mul_cancel₀ (ne_of_gt (sub_pos.mpr hr1)), one_mul] + ring + rw [hlocal] + refine ⟨by positivity, ?_⟩ + calc + _ ≤ (4 / (p : ℝ)) * + ((p : ℝ) ^ (-(1 / 2) : ℝ) / (1 - (2 : ℝ) ^ (-(1 / 2) : ℝ))) := by + apply mul_le_mul + · exact div_le_div_of_nonneg_left (by norm_num) hp0 (by linarith) + · exact div_le_div_of_nonneg_left hr0.le h20 (by linarith) + · positivity + · positivity + _ = _ := by + rw [show (-3 / 2 : ℝ) = -1 + (-1 / 2) by norm_num, + Real.rpow_add hp0, Real.rpow_neg_one] + ring_nf + +lemma padding_smooth_half_average_le (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) : + (reciprocalPaddingLaw Q).average + (fun b => smoothReciprocalProduct (paddingSelectedDivisor Q b).primeFactors + (1 / 2 : ℝ)) ≤ paddingSmoothConstant := by + rw [padding_smooth_reciprocal_average Q hQ] + let c := 4 / (1 - (2 : ℝ) ^ (-(1 / 2) : ℝ)) + let e : ℕ → ℝ := fun p => 4 / ((p : ℝ) + 4) * + ((1 - (p : ℝ) ^ (-(1 / 2) : ℝ))⁻¹ - 1) + have hc : 0 ≤ c := by + dsimp [c] + have hh := Real.rpow_lt_one_of_one_lt_of_neg + (by norm_num : (1 : ℝ) < 2) (by norm_num : (-(1 / 2) : ℝ) < 0) + positivity + have hs : Summable (fun n : ℕ => (n : ℝ) ^ (-3 / 2 : ℝ)) := + Real.summable_nat_rpow.mpr (by norm_num) + have hsum : (∑ p : Q, e p.val) ≤ c * ∑' n : ℕ, (n : ℝ) ^ (-3 / 2 : ℝ) := by + calc + _ ≤ ∑ p : Q, c * (p.val : ℝ) ^ (-3 / 2 : ℝ) := by + apply sum_le_sum + intro p _ + exact (smooth_half_local_bound p.val (hQ p.val p.property).two_le).2 + _ = c * ∑ p ∈ Q, (p : ℝ) ^ (-3 / 2 : ℝ) := by + rw [← mul_sum, sum_coe_sort Q (fun p : ℕ => (p : ℝ) ^ (-3 / 2 : ℝ))] + _ ≤ _ := mul_le_mul_of_nonneg_left + (hs.sum_le_tsum Q (fun p _ => Real.rpow_nonneg (Nat.cast_nonneg p) _)) hc + calc + _ ≤ ∏ p : Q, Real.exp (e p.val) := by + apply prod_le_prod₀ + · intro p _ + have hh := (smooth_half_local_bound p.val (hQ p.val p.property).two_le).1 + change 0 ≤ 1 + e p.val + linarith + · intro p _ + simpa only [add_comm] using Real.add_one_le_exp (e p.val) + _ = Real.exp (∑ p : Q, e p.val) := (Real.exp_sum _ _).symm + _ ≤ paddingSmoothConstant := Real.exp_le_exp.mpr hsum + +lemma padding_smooth_half_sum_le (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) : + (∑ q ∈ retainedPrimeDivisors Q, (4 : ℝ) ^ q.primeFactors.card / (q : ℝ) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ)) ≤ + paddingTiltNormalizer Q * paddingSmoothConstant := by + have he := padding_smooth_reciprocal_sum Q hQ (1 / 2 : ℝ) + rw [← padding_smooth_reciprocal_average Q hQ] at he + rw [he] + exact mul_le_mul_of_nonneg_left (padding_smooth_half_average_le Q hQ) + (paddingTiltNormalizer_pos Q).le + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingSmoothMass.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingSmoothMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..909019d5665835dbf6f5c43dbebaa8a3517afc16 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingSmoothMass.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SmoothReciprocalMass +import OAI.NumberTheory.TwoPoint.Bounds.ReciprocalPaddingLaw + +namespace OAI + +/-! Averaging smooth-dilation costs under the actual padding divisor law. +Only one factor is paid at each selected prime. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma smoothReciprocalProduct_selected (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) (b : Q → Bool) (s : ℝ) : + smoothReciprocalProduct (paddingSelectedDivisor Q b).primeFactors s = + ∏ p : Q, if b p then (1 - (p.val : ℝ) ^ (-s))⁻¹ else 1 := by + rw [paddingSelectedDivisor_primeFactors Q hQ, smoothReciprocalProduct, + paddingAvailablePrimes, prod_image] + · simp only [selectedCoordinates, prod_filter] + · intro p _ r _ hpr + exact Subtype.ext hpr + +lemma padding_smooth_reciprocal_average (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) (s : ℝ) : + (reciprocalPaddingLaw Q).average + (fun b => smoothReciprocalProduct (paddingSelectedDivisor Q b).primeFactors s) = + ∏ p : Q, (1 + 4 / ((p.val : ℝ) + 4) * + ((1 - (p.val : ℝ) ^ (-s))⁻¹ - 1)) := by + simp only [smoothReciprocalProduct_selected Q hQ] + rw [reciprocalPaddingLaw, + FiniteLaw.independent_average_product (fun p : Q => reciprocalPaddingPrimeLaw p.val) + (fun (p : Q) (b : Bool) => if b then (1 - (p.val : ℝ) ^ (-s))⁻¹ else 1)] + apply prod_congr rfl + intro p _ + simp only [FiniteLaw.average, reciprocalPaddingPrimeLaw, booleanLaw, Fintype.sum_bool, + Bool.false_eq_true, ite_false, ite_true, mul_one] + ring + +lemma padding_smooth_reciprocal_sum (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) (s : ℝ) : + (∑ q ∈ retainedPrimeDivisors Q, (4 : ℝ) ^ q.primeFactors.card / (q : ℝ) * + smoothReciprocalProduct q.primeFactors s) = + paddingTiltNormalizer Q * + ∏ p : Q, (1 + 4 / ((p.val : ℝ) + 4) * + ((1 - (p.val : ℝ) ^ (-s))⁻¹ - 1)) := by + have he := reciprocal_padding_average Q hQ + (fun q => smoothReciprocalProduct q.primeFactors s) + rw [padding_smooth_reciprocal_average Q hQ] at he + have hpos := paddingTiltNormalizer_pos Q + calc + _ = paddingTiltNormalizer Q * + ((paddingTiltNormalizer Q)⁻¹ * + ∑ q ∈ retainedPrimeDivisors Q, (4 : ℝ) ^ q.primeFactors.card / (q : ℝ) * + smoothReciprocalProduct q.primeFactors s) := by + rw [← mul_assoc, mul_inv_cancel₀ hpos.ne', one_mul] + _ = _ := by rw [← he] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingStateWeights.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingStateWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..dcc8d29335c2119e4fca4eb0959ab7e50e1dbf1a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingStateWeights.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingActiveState +import OAI.NumberTheory.TwoPoint.Walks.WeightedWordCircuit + +namespace OAI + +/-! The actual retained departure coefficient is an explicit function +of the finite padding states at its two endpoints. This is the scalar +coefficient used in the signed finite-law expansion. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def paddingStateDensity {m : ℕ} (Qp Q : Finset ℕ) (e : Fin m ≃ Qp) + (eligible : ℕ → Prop) (S : Finset (Fin m)) : ℝ := + (∑ q ∈ Q, if eligible q ∧ q.primeFactors ⊆ S.image (fun i => (e i).val) + then actualPaddingCoefficient q else 0) / (5 : ℝ) ^ S.card + +noncomputable def paddingStateKeep {m : ℕ} (Qp Q : Finset ℕ) (e : Fin m ≃ Qp) + (eligible : ℕ → Prop) (L K : ℝ) (S : Finset (Fin m)) : Prop := + paddingStateDensity Qp Q e eligible S ≤ K / L ∧ (S.card : ℝ) ≤ 400 * Real.log L + +noncomputable def paddingStateDeparture {m : ℕ} (Qp Q : Finset ℕ) (e : Fin m ≃ Qp) + (eligible : SignedStep → ℕ → Prop) (L K : ℝ) (t : SignedStep) + (S T : Finset (Fin m)) : ℝ := + if t.padding ∈ Q ∧ eligible t t.padding ∧ + t.padding.primeFactors ⊆ S.image (fun i => (e i).val) ∧ + paddingStateKeep Qp Q e (eligible t) L K S ∧ + paddingStateKeep Qp Q e (eligible t) L K T + then L * actualPaddingCoefficient t.padding / (5 : ℝ) ^ S.card else 0 + +lemma paddingDensity_eq_state {m : ℕ} (Qp Q : Finset ℕ) + (hQp : ∀ p ∈ Qp, p.Prime) (hQ : Q ⊆ retainedPrimeDivisors Qp) + (e : Fin m ≃ Qp) (eligible : ℕ → Prop) (n : ℤ) : + paddingDensity Q actualPaddingCoefficient eligible (actualPaddingVertex Qp) n = + paddingStateDensity Qp Q e eligible (paddingActiveState Qp e n) := by + unfold paddingDensity paddingStateDensity + rw [actualPaddingVertex_sq_activeState Qp e n] + congr 1 + apply sum_congr rfl + intro q hq + simp only [retainedPadding_dvd_iff_activeState Qp hQp e q (hQ hq) n] + +lemma integerEdgeKeep_eq_state {m : ℕ} (Qp Q : Finset ℕ) + (hQp : ∀ p ∈ Qp, p.Prime) (hQ : Q ⊆ retainedPrimeDivisors Qp) + (e : Fin m ≃ Qp) (eligible : ℕ → Prop) (L K : ℝ) (n : ℤ) : + integerEdgeKeep Q actualPaddingCoefficient eligible (actualPaddingVertex Qp) L K + (actualPaddingDegreeCut Qp L) n ↔ + paddingStateKeep Qp Q e eligible L K (paddingActiveState Qp e n) := by + simp only [integerEdgeKeep, paddingStateKeep, paddingDensity_eq_state Qp Q hQp hQ e, + actualPaddingDegreeCut, paddingActiveState_card] + +lemma retainedEdgeDeparture_eq_state {m : ℕ} (Qp Q : Finset ℕ) + (hQp : ∀ p ∈ Qp, p.Prime) (hQ : Q ⊆ retainedPrimeDivisors Qp) + (e : Fin m ≃ Qp) (eligible : SignedStep → ℕ → Prop) (L K : ℝ) + (h : ℕ) (t : SignedStep) (n : ℤ) : + retainedEdgeDeparture Q actualPaddingCoefficient eligible (actualPaddingVertex Qp) L K + (fun _ => actualPaddingDegreeCut Qp L) h t n = + paddingStateDeparture Qp Q e eligible L K t + (paddingActiveState Qp e n) (paddingActiveState Qp e (n + t.displacement h)) := by + unfold retainedEdgeDeparture paddingStateDeparture + by_cases hq : t.padding ∈ Q + · simp only [retainedPadding_dvd_iff_activeState Qp hQp e t.padding (hQ hq) n, + integerEdgeKeep_eq_state Qp Q hQp hQ e, + actualPaddingVertex_sq_activeState Qp e n] + · simp only [hq, false_and, ite_false] + +lemma paddingStateDeparture_nonneg {m : ℕ} (Qp Q : Finset ℕ) (e : Fin m ≃ Qp) + (eligible : SignedStep → ℕ → Prop) (L K : ℝ) (t : SignedStep) + (S T : Finset (Fin m)) (hL : 0 ≤ L) : + 0 ≤ paddingStateDeparture Qp Q e eligible L K t S T := by + unfold paddingStateDeparture + split_ifs + · exact div_nonneg (mul_nonneg hL (actualPaddingCoefficient_nonneg _)) (by positivity) + · exact le_rfl + +lemma paddingStateDeparture_le {m : ℕ} (Qp Q : Finset ℕ) (e : Fin m ≃ Qp) + (eligible : SignedStep → ℕ → Prop) (L K : ℝ) (t : SignedStep) + (S T : Finset (Fin m)) (hL : 0 ≤ L) : + paddingStateDeparture Qp Q e eligible L K t S T ≤ L * actualPaddingCoefficient t.padding := by + unfold paddingStateDeparture + split_ifs + · exact div_le_self (mul_nonneg hL (actualPaddingCoefficient_nonneg _)) + (one_le_pow₀ (by norm_num)) + · exact mul_nonneg hL (actualPaddingCoefficient_nonneg _) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ac27ad755e372d0b655b85df1095f063e3ced67 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingSum.lean @@ -0,0 +1,79 @@ +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Tactic + +namespace OAI + +/-! +# Summing padding choices in one fixed residue environment + +This is the backwards induction of manuscript Lemma `q:padding-sum`. +A state is the current integer site. The transitions may depend on the current +padding choice and all earlier choices through that site. No independence of +translated residue coordinates is assumed. +-/ + +open scoped BigOperators + +namespace TwoPointCorrelations + +/-- The finite sum over successive padding choices, with `i` the step index. -/ +def paddingMass (Q : Finset ℕ) (weight : ℕ → ℤ → ℕ → ℝ) + (next : ℕ → ℤ → ℕ → ℤ) : ℕ → ℕ → ℤ → ℝ + | 0, _, _ => 1 + | m + 1, i, n => ∑ q ∈ Q, weight i n q * paddingMass Q weight next m (i + 1) (next i n q) + +/-- A row bound at every site controls the full path sum, despite the dependence +of later sites on earlier padding choices. -/ +theorem paddingMass_le (Q : Finset ℕ) (weight : ℕ → ℤ → ℕ → ℝ) + (next : ℕ → ℤ → ℕ → ℤ) (K : ℝ) (hK : 0 ≤ K) + (hweight : ∀ i n q, q ∈ Q → 0 ≤ weight i n q) + (hrow : ∀ i n, ∑ q ∈ Q, weight i n q ≤ K) + (m i : ℕ) (n : ℤ) : paddingMass Q weight next m i n ≤ K ^ m := by + induction m generalizing i n with + | zero => simp [paddingMass] + | succ m ih => + calc + paddingMass Q weight next (m + 1) i n = + ∑ q ∈ Q, weight i n q * paddingMass Q weight next m (i + 1) (next i n q) := rfl + _ ≤ ∑ q ∈ Q, weight i n q * K ^ m := by + apply Finset.sum_le_sum + intro q hq + exact mul_le_mul_of_nonneg_left (ih _ _) (hweight i n q hq) + _ = (∑ q ∈ Q, weight i n q) * K ^ m := by rw [Finset.sum_mul] + _ ≤ K * K ^ m := mul_le_mul_of_nonneg_right (hrow i n) (pow_nonneg hK _) + _ = K ^ (m + 1) := by ring + +/-- The departure cutoff retains a row only when its total mass is at most `K`. -/ +noncomputable def cutPaddingWeight (Q : Finset ℕ) (raw : ℕ → ℤ → ℕ → ℝ) + (K : ℝ) (i : ℕ) (n : ℤ) (q : ℕ) : ℝ := + if (∑ r ∈ Q, raw i n r) ≤ K then raw i n q else 0 + +theorem cutPaddingWeight_nonneg (Q : Finset ℕ) (raw : ℕ → ℤ → ℕ → ℝ) + (K : ℝ) (hraw : ∀ i n q, q ∈ Q → 0 ≤ raw i n q) + (i : ℕ) (n : ℤ) (q : ℕ) (hq : q ∈ Q) : + 0 ≤ cutPaddingWeight Q raw K i n q := by + unfold cutPaddingWeight + split_ifs + · exact hraw i n q hq + · exact le_rfl + +theorem cutPaddingWeight_row (Q : Finset ℕ) (raw : ℕ → ℤ → ℕ → ℝ) + (K : ℝ) (hK : 0 ≤ K) (i : ℕ) (n : ℤ) : + ∑ q ∈ Q, cutPaddingWeight Q raw K i n q ≤ K := by + by_cases h : (∑ r ∈ Q, raw i n r) ≤ K + · simp [cutPaddingWeight, h] + · simp [cutPaddingWeight, h, hK] + +/-- Manuscript padding bound, after the departure cutoff. The choice +`next i n q = n + εᵢ h q dᵢ` is allowed, as is a different residue at every site. -/ +theorem cut_paddingMass_le (Q : Finset ℕ) (raw : ℕ → ℤ → ℕ → ℝ) + (next : ℕ → ℤ → ℕ → ℤ) (K : ℝ) (hK : 0 ≤ K) + (hraw : ∀ i n q, q ∈ Q → 0 ≤ raw i n q) + (m i : ℕ) (n : ℤ) : + paddingMass Q (cutPaddingWeight Q raw K) next m i n ≤ K ^ m := by + exact paddingMass_le Q _ next K hK (cutPaddingWeight_nonneg Q raw K hraw) + (cutPaddingWeight_row Q raw K hK) m i n + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingTilt.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingTilt.lean new file mode 100644 index 0000000000000000000000000000000000000000..152d859813703be6a81315a33624c8f77052372e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingTilt.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingPairSampling + +namespace OAI + +/-! The literal `5^omega` tilt of independent divisibility indicators gives +exactly the prime availability law used in the padding anti-concentration. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def paddingOriginalPrimeLaw (p : ℕ) (hp : 2 ≤ p) : FiniteLaw Bool := + booleanLaw (1 / (p : ℝ)) (by positivity) (by + apply (div_le_one (by exact_mod_cast (by omega : 0 < p))).mpr + exact_mod_cast (by omega : 1 ≤ p)) + +noncomputable def paddingOriginalLaw (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) : + FiniteLaw (Q → Bool) := + FiniteLaw.independent (fun p : Q => paddingOriginalPrimeLaw p (hQ p p.property)) + +noncomputable def paddingTiltWeight (Q : Finset ℕ) (a : Q → Bool) : ℝ := + ∏ p : Q, if a p then 5 else 1 + +noncomputable def paddingTiltNormalizer (Q : Finset ℕ) : ℝ := + ∏ p : Q, (1 + 4 / (p : ℝ)) + +lemma paddingTiltWeight_pos (Q : Finset ℕ) (a : Q → Bool) : 0 < paddingTiltWeight Q a := by + apply prod_pos + intro p _ + cases a p <;> norm_num + +lemma paddingTiltNormalizer_pos (Q : Finset ℕ) : 0 < paddingTiltNormalizer Q := by + apply prod_pos + intro p _ + positivity + +lemma padding_prime_tilt (p : ℕ) (hp : 2 ≤ p) (a : Bool) : + (paddingOriginalPrimeLaw p hp).weight a * (if a then 5 else 1) = + (paddingAvailabilityLaw p hp).weight a * (1 + 4 / (p : ℝ)) := by + have hp0 : (p : ℝ) ≠ 0 := by exact_mod_cast (by omega : p ≠ 0) + have hp4 : (p : ℝ) + 4 ≠ 0 := by positivity + cases a <;> simp only [paddingOriginalPrimeLaw, paddingAvailabilityLaw, booleanLaw, + Bool.false_eq_true, ↓reduceIte] + all_goals field_simp <;> ring + +lemma padding_tilt_weight (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) (a : Q → Bool) : + (paddingOriginalLaw Q hQ).weight a * paddingTiltWeight Q a = + (paddingAvailableLaw Q hQ).weight a * paddingTiltNormalizer Q := by + simp only [paddingOriginalLaw, paddingAvailableLaw, FiniteLaw.independent, + paddingTiltWeight, paddingTiltNormalizer, ← prod_mul_distrib] + apply prod_congr rfl + intro p _ + exact padding_prime_tilt p (hQ p p.property) (a p) + +lemma padding_tilt_average (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) + (F : (Q → Bool) → ℝ) : + (paddingOriginalLaw Q hQ).average (fun a => paddingTiltWeight Q a * F a) = + paddingTiltNormalizer Q * (paddingAvailableLaw Q hQ).average F := by + simp only [FiniteLaw.average, mul_sum] + apply sum_congr rfl + intro a _ + rw [← mul_assoc, padding_tilt_weight] + ring + +lemma padding_tilt_total (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) : + (paddingOriginalLaw Q hQ).average (paddingTiltWeight Q) = paddingTiltNormalizer Q := by + simpa using padding_tilt_average Q hQ (fun _ => 1) + +noncomputable def paddingDivisorCoefficient (Q : Finset ℕ) (b : Q → Bool) : ℝ := + ∏ p : Q, if b p then 4 else 1 + +def PaddingSelectionSupported (Q : Finset ℕ) (a b : Q → Bool) : Prop := + ∀ p, b p = true → a p = true + +lemma padding_selection_atom (a b : Bool) : + (paddingSelectionLaw a).weight b * (if a then 5 else 1) = + if b then (if a then 4 else 0) else 1 := by + cases a <;> cases b <;> norm_num [paddingSelectionLaw, booleanLaw] + +lemma padding_divisor_weight (Q : Finset ℕ) (a b : Q → Bool) : + (paddingDivisorLaw Q a).weight b * paddingTiltWeight Q a = + if PaddingSelectionSupported Q a b then paddingDivisorCoefficient Q b else 0 := by + simp only [paddingDivisorLaw, FiniteLaw.independent, paddingTiltWeight, + ← prod_mul_distrib, padding_selection_atom] + by_cases hs : PaddingSelectionSupported Q a b + · rw [ite_eq_left hs] + unfold paddingDivisorCoefficient + apply prod_congr rfl + intro p _ + cases hb : b p + · simp + · simp [hs p hb] + · rw [ite_eq_right hs] + change ¬ ∀ p : Q, b p = true → a p = true at hs + push Not at hs + obtain ⟨p, hb, ha⟩ := hs + apply prod_eq_zero (mem_univ p) + simp [hb, ha] + +lemma paddingDivisorLaw_weight_eq (Q : Finset ℕ) (a b : Q → Bool) : + (paddingDivisorLaw Q a).weight b = + if PaddingSelectionSupported Q a b then + paddingDivisorCoefficient Q b / paddingTiltWeight Q a else 0 := by + have hw := paddingTiltWeight_pos Q a + have hh := padding_divisor_weight Q a b + by_cases hs : PaddingSelectionSupported Q a b + · rw [ite_eq_left hs] at hh ⊢ + exact (eq_div_iff hw.ne').mpr hh + · rw [ite_eq_right hs] at hh ⊢ + exact (mul_eq_zero.mp hh).resolve_right hw.ne' + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingWitnessProbability.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingWitnessProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d7d440a1e745bb9c7d286b1f687de3915d26558 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingWitnessProbability.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.TwoPoint.Walks.WitnessProbabilityWeight + +namespace OAI + +/-! Padding tests and the retained witness tests pay the missing reciprocal factors together. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def RetainedMainTests {ι : Type*} [DecidableEq ι] (p : ι → ℕ) (S : Finset ι) + (h B : ℕ) (main : List SignedStep) (x : ι → Fin B) : Prop := + ∀ i, i ∉ S → ∀ k : Fin main.length, + p i ∈ ((main.get k).padding * (main.get k).tuple).primeFactors → + ((x i).val : ZMod (p i)) = -((wordDisplacement h (main.take k.val) : ℤ) : ZMod (p i)) + +theorem retainedMainTests_congr {ι : Type*} [DecidableEq ι] + (p : ι → ℕ) (S : Finset ι) (h B : ℕ) (main : List SignedStep) + (x y : ι → Fin B) (hxy : ∀ i, i ∉ S → x i = y i) : + RetainedMainTests p S h B main x ↔ RetainedMainTests p S h B main y := by + constructor + · intro hx i hi k hk + rw [← hxy i hi] + exact hx i hi k hk + · intro hy i hi k hk + rw [hxy i hi] + exact hy i hi k hk + +theorem tuple_weight_mul_padding_hybrid_probability_le {ι : Type*} + [Fintype ι] [DecidableEq ι] (n B h : ℕ) (p : ι → ℕ) + (hinj : Function.Injective p) (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (S : Finset ι) (main : List SignedStep) (word : Fin n → List SignedStep) + (attachment : Fin n → ℤ) + (hS : ∀ i ∈ S, p i ∈ wordDivisorPrimeSupport main) + (hcover : ∀ q ∈ wordDivisorPrimeSupport (recordedWitnessWord main word), ∃ i, p i = q) : + (∏ i ∈ S, (p i : ℝ)⁻¹) * + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).probability + (fun x => RetainedMainTests p S h B main x ∧ + ∃ y : ι → Fin B, (∀ i, i ∉ S → y i = x i) ∧ + ∀ j, AttachedResiduePositiveWord p h (word j) (attachment j) B y) ≤ + ∏ q ∈ wordDivisorPrimeSupport (recordedWitnessWord main word), (q : ℝ)⁻¹ := by + let words : Fin (n + 1) → List SignedStep := Fin.cases main word + let atts : Fin (n + 1) → ℤ := Fin.cases 0 attachment + have hmono : + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).probability + (fun x => RetainedMainTests p S h B main x ∧ + ∃ y : ι → Fin B, (∀ i, i ∉ S → y i = x i) ∧ + ∀ j, AttachedResiduePositiveWord p h (word j) (attachment j) B y) ≤ + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).probability + (RetainedWitnessTests p S h B words atts) := by + apply FiniteLaw.probability_mono_of_imp + rintro x ⟨hm, y, hy, hw⟩ i hi j + refine Fin.cases ?_ (fun j => ?_) j + · simpa only [words, atts, Fin.cases_zero, zero_add] using hm i hi + · intro k hk + rw [← hy i hi] + exact hw j k i hk + have hb := hmono.trans (retained_witness_probability_le (n + 1) B h p hp hpB S words atts) + apply (mul_le_mul_of_nonneg_left hb (prod_nonneg (fun _ _ => by positivity))).trans_eq + rw [main_witness_reciprocal_product] + have hw (q : ℕ) : (∃ j, q ∈ wordDivisorPrimeSupport (words j)) ↔ + q ∈ wordDivisorPrimeSupport (recordedWitnessWord main word) := by + rw [recordedWitnessWord_support, mem_union, mem_biUnion] + constructor + · rintro ⟨j, hj⟩ + refine Fin.cases ?_ (fun i => ?_) j hj + · exact fun hj => Or.inl hj + · exact fun hj => Or.inr ⟨i, mem_univ _, hj⟩ + · rintro (hm | ⟨j, _, hj⟩) + · exact ⟨0, hm⟩ + · exact ⟨j.succ, hj⟩ + have he : S ∪ univ.filter (fun i => ∃ j, p i ∈ wordDivisorPrimeSupport (words j)) = + univ.filter (fun i => p i ∈ wordDivisorPrimeSupport (recordedWitnessWord main word)) := by + ext i + simp only [mem_union, mem_filter, mem_univ, true_and, hw] + constructor + · rintro (hi | hi) + · rw [recordedWitnessWord_support] + exact mem_union_left _ (hS i hi) + · exact hi + · intro hi + exact Or.inr hi + rw [he] + exact coordinate_reciprocal_product p hinj _ hcover + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingWordSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingWordSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..827c1542d025e28ea60c3f9fdf96d89a6ceda053 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PaddingWordSum.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.TwoPoint.Walks.ClosedWalkNormalization +import OAI.NumberTheory.TwoPoint.Bounds.PaddingSum + +namespace OAI + +/-! The recursive padding bound is the full sum over actual padding words. -/ + +namespace TwoPointCorrelations + +open Finset + +noncomputable def paddingWordWeight (Q : Finset ℕ) (weight : ℕ → ℤ → ℕ → ℝ) + (next : ℕ → ℤ → ℕ → ℤ) : {m : ℕ} → ℕ → ℤ → (Fin m → Q) → ℝ + | 0, _, _, _ => 1 + | _m + 1, i, n, q => weight i n (q 0).val * + paddingWordWeight Q weight next (i + 1) (next i n (q 0).val) (Fin.tail q) + +theorem paddingMass_eq_sum_words (Q : Finset ℕ) (weight : ℕ → ℤ → ℕ → ℝ) + (next : ℕ → ℤ → ℕ → ℤ) (m i : ℕ) (n : ℤ) : + paddingMass Q weight next m i n = ∑ q : Fin m → Q, paddingWordWeight Q weight next i n q := by + classical + induction m generalizing i n with + | zero => simp [paddingMass, paddingWordWeight] + | succ m ih => + rw [paddingMass, sum_fin_cons, ← sum_coe_sort Q] + apply sum_congr rfl + intro q _ + rw [ih, mul_sum] + apply sum_congr rfl + intro tail _ + simp only [paddingWordWeight, Fin.cons_zero, Fin.tail_cons] + +/-- Literal finite path sum, retaining the departure density cutoff at +every visited site, uniformly in all earlier padding choices. -/ +theorem retained_padding_word_sum_le (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → ℕ → Prop) (g : ℤ → ℝ) (L K : ℝ) + (extra : ℕ → ℤ → Prop) (next : ℕ → ℤ → ℕ → ℤ) + (hL : 0 < L) (hK : 0 ≤ K) (hu : ∀ q ∈ Q, 0 ≤ u q) + (m i : ℕ) (n : ℤ) : + (∑ q : Fin m → Q, paddingWordWeight Q + (fun i n q => retainedPaddingAtom Q u (eligible i) g L K (extra i) n q) + next i n q) ≤ K ^ m := by + rw [← paddingMass_eq_sum_words] + apply paddingMass_le Q _ next K hK + · intro i n q hq + exact retainedPaddingAtom_nonneg Q u (eligible i) g L K (extra i) n q hL.le (hu q hq) + · intro i n + exact retainedPaddingAtom_sum_le Q u (eligible i) g L K (extra i) n hL hK + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PairModulusDefect.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PairModulusDefect.lean new file mode 100644 index 0000000000000000000000000000000000000000..d43962414d153aee1cd03a3ed50b458257c9e2bb --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PairModulusDefect.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PairPrimeCosts +import OAI.NumberTheory.TwoPoint.Bounds.MultiplicativePrimeProducts + +namespace OAI + +/-! The mean modulus loss is controlled by the separate tuple and padding +prime-defect moments. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma squarefree_pair_defect {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf1 : f 1 = 1) (hg1 : g 1 = 1) (hf : OneBounded f) (hg : OneBounded g) + {n : ℕ} (hn : Squarefree n) : + 1 - ‖f n * g n‖ ≤ ∑ p ∈ n.primeFactors, (1 - ‖f p * g p‖) := by + have he := multiplicative_prime_product_defect hfm hgm hf1 hg1 hf hg n.primeFactors + (fun _ hp => Nat.prime_of_mem_primeFactors hp) + rwa [Nat.prod_primeFactors_of_squarefree hn] at he + +lemma tuple_padding_modulus_defect {J : ℕ} {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf1 : f 1 = 1) (hg1 : g 1 = 1) (hf : OneBounded f) (hg : OneBounded g) + (P : Fin J → Finset ℕ) (Q : Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (hQ : ∀ p ∈ Q, p.Prime) (hPQ : Disjoint (primeTuplePool P) Q) + (W : ℝ) (hW : 0 < W) (hmass : ∀ j, W ≤ primeHarmonicMass (P j)) : + (∑ d ∈ primeTupleDivisors P, ∑ q ∈ retainedPrimeDivisors Q, + (4 : ℝ) ^ q.primeFactors.card / (d * q : ℕ) * (1 - ‖f (d * q) * g (d * q)‖)) ≤ + paddingTiltNormalizer Q * (∏ j, primeHarmonicMass (P j)) * + ((∑ p ∈ primeTuplePool P, (1 - ‖f p * g p‖) / (p : ℝ)) / W + + ∑ p ∈ Q, (4 / ((p : ℝ) + 4)) * (1 - ‖f p * g p‖)) := by + apply le_trans _ (tuple_padding_prime_cost_bound P Q hprime hdisjoint hQ hPQ + (fun p => 1 - ‖f p * g p‖) (fun p hp => by + have hpp := primeTuplePool_prime hprime hp + rw [norm_mul] + exact sub_nonneg.mpr ((mul_le_mul (hf p hpp.pos) (hg p hpp.pos) + (norm_nonneg _) zero_le_one).trans (by norm_num))) W hW hmass) + apply sum_le_sum + intro d hd + apply sum_le_sum + intro q hq + have hsq : Squarefree (d * q) := (Nat.squarefree_mul + (tuple_padding_coprime P Q hprime hdisjoint hQ hPQ hd hq)).mpr + ⟨(primeTupleDivisors_arithmetic P hprime hdisjoint hd).1, + retainedPrimeDivisor_squarefree Q hQ hq⟩ + exact mul_le_mul_of_nonneg_left (squarefree_pair_defect hfm hgm hf1 hg1 hf hg hsq) + (by positivity) + +lemma padding_modulus_defect_cost_le {f g : ℕ → ℂ} + (hf : OneBounded f) (hg : OneBounded g) + (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) : + (∑ p ∈ Q, (4 / ((p : ℝ) + 4)) * (1 - ‖f p * g p‖)) ≤ + 4 * ∑ p ∈ Q, (1 - ‖f p * g p‖) / (p : ℝ) := by + rw [mul_sum] + apply sum_le_sum + intro p hp + have hpR : (0 : ℝ) < p := by exact_mod_cast (hQ p hp).pos + have hd : 0 ≤ 1 - ‖f p * g p‖ := by + rw [norm_mul] + exact sub_nonneg.mpr ((mul_le_mul (hf p (hQ p hp).pos) (hg p (hQ p hp).pos) + (norm_nonneg _) zero_le_one).trans (by norm_num)) + calc + _ ≤ (4 / (p : ℝ)) * (1 - ‖f p * g p‖) := + mul_le_mul_of_nonneg_right + (div_le_div_of_nonneg_left (by norm_num) hpR (by linarith)) hd + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PairPrimeCosts.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PairPrimeCosts.lean new file mode 100644 index 0000000000000000000000000000000000000000..d8464055c1b67f7906c87ec8e86fb640caa6b894 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PairPrimeCosts.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.TwoPoint.Walks.TuplePrimeCosts +import OAI.NumberTheory.TwoPoint.Bounds.PaddingDefectMass + +namespace OAI + +/-! The tensor product of the tuple and padding laws retains separate first +moments, rather than the largest prime cost of an individual divisor. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma pair_prime_cost_sum (D Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (hcop : ∀ d ∈ D, ∀ q ∈ retainedPrimeDivisors Q, d.Coprime q) + (c : ℕ → ℝ) : + (∑ d ∈ D, ∑ q ∈ retainedPrimeDivisors Q, + (4 : ℝ) ^ q.primeFactors.card / (d * q : ℕ) * + ∑ p ∈ (d * q).primeFactors, c p) = + paddingTiltNormalizer Q * (∑ d ∈ D, (1 / (d : ℝ)) * ∑ p ∈ d.primeFactors, c p) + + (∑ d ∈ D, 1 / (d : ℝ)) * paddingTiltNormalizer Q * + ∑ p ∈ Q, (4 / ((p : ℝ) + 4)) * c p := by + have he (d : ℕ) (hd : d ∈ D) : + (∑ q ∈ retainedPrimeDivisors Q, + (4 : ℝ) ^ q.primeFactors.card / (d * q : ℕ) * + ∑ p ∈ (d * q).primeFactors, c p) = + (1 / (d : ℝ)) * (∑ p ∈ d.primeFactors, c p) * paddingTiltNormalizer Q + + (1 / (d : ℝ)) * (paddingTiltNormalizer Q * + ∑ p ∈ Q, (4 / ((p : ℝ) + 4)) * c p) := by + calc + _ = ∑ q ∈ retainedPrimeDivisors Q, + (((1 / (d : ℝ)) * (∑ p ∈ d.primeFactors, c p)) * + ((4 : ℝ) ^ q.primeFactors.card / (q : ℝ)) + + (1 / (d : ℝ)) * (((4 : ℝ) ^ q.primeFactors.card / (q : ℝ)) * + ∑ p ∈ q.primeFactors, c p)) := by + apply sum_congr rfl + intro q hq + rw [(hcop d hd q hq).primeFactors_mul, + sum_union (hcop d hd q hq).disjoint_primeFactors, Nat.cast_mul] + ring + _ = _ := by + rw [sum_add_distrib, ← mul_sum, ← mul_sum, + ← paddingTiltNormalizer_eq_divisor_sum Q hQ, padding_prime_cost_sum Q hQ] + calc + _ = ∑ d ∈ D, ((1 / (d : ℝ)) * (∑ p ∈ d.primeFactors, c p) * paddingTiltNormalizer Q + + (1 / (d : ℝ)) * (paddingTiltNormalizer Q * + ∑ p ∈ Q, (4 / ((p : ℝ) + 4)) * c p)) := by + apply sum_congr rfl + intro d hd + exact he d hd + _ = _ := by + rw [sum_add_distrib, ← sum_mul, ← sum_mul] + ring + +lemma tuple_padding_coprime {J : ℕ} (P : Fin J → Finset ℕ) (Q : Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (hQ : ∀ p ∈ Q, p.Prime) (hPQ : Disjoint (primeTuplePool P) Q) + {d q : ℕ} (hd : d ∈ primeTupleDivisors P) (hq : q ∈ retainedPrimeDivisors Q) : + d.Coprime q := by + apply Nat.coprime_of_dvd + intro p hp hpd hpq + have hd0 : d ≠ 0 := (primeTupleDivisors_arithmetic P hprime hdisjoint hd).1.ne_zero + have hq0 : q ≠ 0 := (retainedPrimeDivisor_pos Q hQ hq).ne' + have hpD : p ∈ d.primeFactors := Nat.mem_primeFactors.mpr ⟨hp, hpd, hd0⟩ + have hpQ : p ∈ q.primeFactors := Nat.mem_primeFactors.mpr ⟨hp, hpq, hq0⟩ + exact disjoint_left.mp hPQ + ((primeTupleDivisors_arithmetic P hprime hdisjoint hd).2.2 hpD) + (retainedPrimeDivisor_factors Q hQ hq hpQ) + +lemma tuple_padding_prime_cost_bound {J : ℕ} (P : Fin J → Finset ℕ) (Q : Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (hQ : ∀ p ∈ Q, p.Prime) (hPQ : Disjoint (primeTuplePool P) Q) + (c : ℕ → ℝ) (hc : ∀ p ∈ primeTuplePool P, 0 ≤ c p) + (W : ℝ) (hW : 0 < W) (hmass : ∀ j, W ≤ primeHarmonicMass (P j)) : + (∑ d ∈ primeTupleDivisors P, ∑ q ∈ retainedPrimeDivisors Q, + (4 : ℝ) ^ q.primeFactors.card / (d * q : ℕ) * + ∑ p ∈ (d * q).primeFactors, c p) ≤ + paddingTiltNormalizer Q * (∏ j, primeHarmonicMass (P j)) * + ((∑ p ∈ primeTuplePool P, c p / (p : ℝ)) / W + + ∑ p ∈ Q, (4 / ((p : ℝ) + 4)) * c p) := by + rw [pair_prime_cost_sum _ Q hQ + (fun _ hd _ hq => tuple_padding_coprime P Q hprime hdisjoint hQ hPQ hd hq) c] + have hm : (∑ d ∈ primeTupleDivisors P, 1 / (d : ℝ)) = + ∏ j, primeHarmonicMass (P j) := by + rw [primeTupleDivisors_mass P hprime hdisjoint] + simp only [primeHarmonicMass_eq_sum] + rw [hm] + have hb := mul_le_mul_of_nonneg_left + (primeTupleDivisors_cost_bound P hprime hdisjoint c hc W hW hmass) + (paddingTiltNormalizer_pos Q).le + apply (add_le_add hb (le_refl _)).trans_eq + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PartialCentering.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PartialCentering.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3fb8c434d11a6b9a36b0f2063a23b66743aacbe --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PartialCentering.lean @@ -0,0 +1,112 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MixedDifference + +namespace OAI + +/-! Exact singleton centering on selected coordinates of the complete residue sample. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι A : Type*} [Fintype ι] [DecidableEq ι] [Fintype A] [DecidableEq A] + +noncomputable def selectedMixedDifference (S : Finset ι) (a : ι → A) + (F : (ι → A) → ℝ) (x : ι → A) : ℝ := + mixedDifference (fun i : S => a i) + (fun z : S → A => F (joinCoordinates S z (fun i : {i // i ∉ S} => x i))) + (fun i : S => x i) + +omit [Fintype ι] [Fintype A] [DecidableEq A] in +lemma selectedMixedDifference_join (S : Finset ι) (a : ι → A) (F : (ι → A) → ℝ) + (x : S → A) (y : {i // i ∉ S} → A) : + selectedMixedDifference S a F (joinCoordinates S x y) = + mixedDifference (fun i : S => a i) (fun z => F (joinCoordinates S z y)) x := by + simp only [selectedMixedDifference, joinCoordinates_mem, joinCoordinates_notMem] + +omit [Fintype ι] [Fintype A] [DecidableEq A] in +lemma selectedMixedDifference_bound (S : Finset ι) (a : ι → A) (F : (ι → A) → ℝ) + (hF : ∀ x, |F x| ≤ 1) (x : ι → A) : + |selectedMixedDifference S a F x| ≤ 2 ^ S.card := by + simpa only [selectedMixedDifference, Fintype.card_coe] using + abs_mixedDifference_le (fun i : S => a i) + (fun z : S → A => F (joinCoordinates S z (fun i : {i // i ∉ S} => x i))) + (fun z => hF _) (fun i : S => x i) + +namespace FiniteLaw + +/-- The unselected coordinates remain part of the original sample, and +are simply held fixed while applying the exact centering identity. -/ +theorem exact_selected_centering (μ : ι → FiniteLaw A) (S : Finset ι) + (a : ι → A) (F : (ι → A) → ℝ) : + (independent μ).average (fun x => + (∏ i ∈ S, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i))) * F x) = + (∏ i ∈ S, (μ i).weight (a i)) * + (independent μ).average (selectedMixedDifference S a F) := by + rw [independent_average_split μ S] + have hinner (y : {i // i ∉ S} → A) : + (independent (fun i : S => μ i)).average (fun x : S → A => + (∏ i ∈ S, ((if joinCoordinates S x y i = a i then (1 : ℝ) else 0) - + (μ i).weight (a i))) * F (joinCoordinates S x y)) = + (∏ i ∈ S, (μ i).weight (a i)) * + (independent (fun i : S => μ i)).average + (mixedDifference (fun i : S => a i) (fun x => F (joinCoordinates S x y))) := by + have hh := exact_mixed_centering (fun i : S => μ i) (fun i : S => a i) + (fun x => F (joinCoordinates S x y)) + have hp (x : S → A) : + (∏ i ∈ S, ((if joinCoordinates S x y i = a i then (1 : ℝ) else 0) - + (μ i).weight (a i))) = + ∏ i : S, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i)) := by + rw [← prod_coe_sort S] + simp only [joinCoordinates_mem] + simp_rw [hp] + rw [← prod_coe_sort S] + exact hh + simp_rw [hinner] + rw [average_const_mul, independent_average_split μ S (selectedMixedDifference S a F)] + simp only [selectedMixedDifference_join] + +/-- Nonsingletons with at least one lit occurrence are forced once. The +singleton coordinates are then centered on the same sample. -/ +theorem exact_selected_designation (μ : ι → FiniteLaw A) (S T : Finset ι) + (hST : Disjoint S T) (a b : ι → A) (F : (ι → A) → ℝ) : + (independent μ).average (fun x => + (∏ i ∈ T, if x i = b i then (1 : ℝ) else 0) * + ((∏ i ∈ S, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i))) * F x)) = + (∏ i ∈ T, (μ i).weight (b i)) * (∏ i ∈ S, (μ i).weight (a i)) * + (independent μ).average + (selectedMixedDifference S a (fun x => F (forceCoordinates T b x))) := by + rw [independent_forcing μ T b] + have hp (x : ι → A) : + (∏ i ∈ S, ((if forceCoordinates T b x i = a i then (1 : ℝ) else 0) - + (μ i).weight (a i))) = + ∏ i ∈ S, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i)) := by + apply prod_congr rfl + intro i hi + have hiT : i ∉ T := fun hiT => (disjoint_left.mp hST hi hiT) + simp only [forceCoordinates_apply, hiT, ite_false] + simp_rw [hp] + rw [exact_selected_centering μ S a] + ring + +/-- The absolute value is taken only after singleton integration, retaining +the full cancellation caused by the mixed difference. -/ +theorem selected_designation_bound (μ : ι → FiniteLaw A) (S T : Finset ι) + (hST : Disjoint S T) (a b : ι → A) (F : (ι → A) → ℝ) : + |(independent μ).average (fun x => + (∏ i ∈ T, if x i = b i then (1 : ℝ) else 0) * + ((∏ i ∈ S, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i))) * F x))| ≤ + (∏ i ∈ T, (μ i).weight (b i)) * (∏ i ∈ S, (μ i).weight (a i)) * + (independent μ).average (fun x => + |selectedMixedDifference S a (fun x => F (forceCoordinates T b x)) x|) := by + rw [exact_selected_designation μ S T hST a b F, abs_mul, + abs_of_nonneg (mul_nonneg (prod_nonneg (fun i _ => (μ i).nonneg _)) + (prod_nonneg (fun i _ => (μ i).nonneg _)))] + exact mul_le_mul_of_nonneg_left (abs_average_le _ _) + (mul_nonneg (prod_nonneg (fun i _ => (μ i).nonneg _)) + (prod_nonneg (fun i _ => (μ i).nonneg _))) + +end FiniteLaw + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PartialCenteringSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PartialCenteringSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..840a970df5c6d7ff799fcdb5e78961062e61ac3c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PartialCenteringSum.lean @@ -0,0 +1,113 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CenteredTupleProfiles +import OAI.NumberTheory.TwoPoint.Walks.TupleSliceSupport + +namespace OAI + +/-! Exact finite summation of partial-centering errors. Each removed +supply subset costs its retained reciprocal mass, never its number of primes. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma positivePrefix_sum_finite {α : Type*} (S : Finset α) (F : α → ℕ → ℂ) (X : ℕ) : + positivePrefix (fun n => ∑ a ∈ S, F a n) X = + ∑ a ∈ S, positivePrefix (F a) X := by + unfold positivePrefix + exact sum_comm + +lemma tupleCenteredProfile_nonraw_prefix {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (q : ℕ) (hcop : ∀ j, ∀ p ∈ P j, q.Coprime p) + (eligible : ℕ → ℕ → Prop) (l : ℕ) [NeZero l] (b : ZMod l) (h X : ℕ) : + (positivePrefix (tupleCenteredProfile P q eligible l b h) X - + positivePrefix (tuplePartialProfile P ∅ q eligible l b h) X) / (X : ℂ) = + ∑ I ∈ (univ : Finset (Fin J)).powerset.filter Finset.Nonempty, + (-1 : ℂ) ^ I.card * + (positivePrefix (tuplePartialProfile P I q eligible l b h) X / (X : ℂ)) := by + have hp : positivePrefix (fun n => tupleCenteredProfile P q eligible l b h n - + tuplePartialProfile P ∅ q eligible l b h n) X = + positivePrefix (tupleCenteredProfile P q eligible l b h) X - + positivePrefix (tuplePartialProfile P ∅ q eligible l b h) X := by + simp only [positivePrefix, sum_sub_distrib] + rw [← hp] + simp_rw [tupleCenteredProfile_nonraw P hprime hdisjoint q hcop eligible l b h] + rw [positivePrefix_sum_finite, sum_div] + apply sum_congr rfl + intro I _ + rw [positivePrefix_const_mul] + ring + +lemma complement_product_le {J : ℕ} (V : Fin J → ℝ) (hV : ∀ j, 1 ≤ V j) + (I : Finset (Fin J)) : (∏ j : {j // j ∉ I}, V j) ≤ ∏ j, V j := by + rw [← prod_subtype (p := fun j : Fin J => j ∉ I) (F := inferInstance) (univ \ I) (by simp) V] + exact prod_le_prod_of_subset_of_one_le₀ (subset_univ _) + (fun j _ => zero_le_one.trans (hV j)) (fun j _ _ => hV j) + +lemma partial_centering_sum_bound {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (hmass : ∀ j, 1 ≤ primeHarmonicMass (P j)) + (Q : Finset ℕ) (weight : ℕ → ℝ) (hweight : ∀ q ∈ Q, 0 ≤ weight q) + (hcop : ∀ q ∈ Q, ∀ j, ∀ p ∈ P j, q.Coprime p) + (eligible : ℕ → ℕ → Prop) (l : ℕ) [NeZero l] (b : ZMod l) (h X : ℕ) + (E : ℝ) (hE : 0 ≤ E) + (hbound : ∀ q ∈ Q, ∀ I ∈ (univ : Finset (Fin J)).powerset.filter Finset.Nonempty, + ‖positivePrefix (tuplePartialProfile P I q eligible l b h) X / (X : ℂ)‖ ≤ + E * ((1 / (q : ℝ)) * ∏ j : {j // j ∉ I}, primeHarmonicMass (P j))) : + ‖∑ q ∈ Q, (weight q : ℂ) * + ((positivePrefix (tupleCenteredProfile P q eligible l b h) X - + positivePrefix (tuplePartialProfile P ∅ q eligible l b h) X) / (X : ℂ))‖ ≤ + E * (2 : ℝ) ^ J * (∑ q ∈ Q, weight q / (q : ℝ)) * + ∏ j, primeHarmonicMass (P j) := by + let V := ∏ j, primeHarmonicMass (P j) + have hV : 0 ≤ V := prod_nonneg fun j _ => zero_le_one.trans (hmass j) + have hc : (((univ : Finset (Fin J)).powerset.filter Finset.Nonempty).card : ℝ) ≤ + (2 : ℝ) ^ J := by + have hn := card_le_card (filter_subset (s := (univ : Finset (Fin J)).powerset) + (p := Finset.Nonempty)) + simpa only [card_powerset, card_univ, Fintype.card_fin, Nat.cast_pow, Nat.cast_ofNat] using + (show (((univ : Finset (Fin J)).powerset.filter Finset.Nonempty).card : ℝ) ≤ + ((univ : Finset (Fin J)).powerset.card : ℝ) by exact_mod_cast hn) + calc + _ ≤ ∑ q ∈ Q, ‖(weight q : ℂ) * + ((positivePrefix (tupleCenteredProfile P q eligible l b h) X - + positivePrefix (tuplePartialProfile P ∅ q eligible l b h) X) / (X : ℂ))‖ := + norm_sum_le _ _ + _ ≤ ∑ q ∈ Q, weight q * ((2 : ℝ) ^ J * (E * (1 / (q : ℝ)) * V)) := by + apply sum_le_sum + intro q hq + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hweight q hq), + tupleCenteredProfile_nonraw_prefix P hprime hdisjoint q (hcop q hq)] + apply mul_le_mul_of_nonneg_left _ (hweight q hq) + calc + _ ≤ ∑ I ∈ (univ : Finset (Fin J)).powerset.filter Finset.Nonempty, + ‖(-1 : ℂ) ^ I.card * + (positivePrefix (tuplePartialProfile P I q eligible l b h) X / (X : ℂ))‖ := + norm_sum_le _ _ + _ ≤ ∑ _I ∈ (univ : Finset (Fin J)).powerset.filter Finset.Nonempty, + E * (1 / (q : ℝ)) * V := by + apply sum_le_sum + intro I hI + simp only [norm_mul, norm_pow, norm_neg, norm_one, one_pow, one_mul] + apply (hbound q hq I hI).trans + have hv := complement_product_le (fun j => primeHarmonicMass (P j)) hmass I + dsimp only [V] + calc + _ = (E * (1 / (q : ℝ))) * ∏ j : {j // j ∉ I}, primeHarmonicMass (P j) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left hv (by positivity) + _ ≤ (2 : ℝ) ^ J * (E * (1 / (q : ℝ)) * V) := by + simp only [sum_const, nsmul_eq_mul] + exact mul_le_mul_of_nonneg_right hc (by positivity) + _ = _ := by + rw [mul_sum, sum_mul] + apply sum_congr rfl + intro q _ + dsimp only [V] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PatternHarmonicSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PatternHarmonicSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad8a2b01e66403778c83378fb534ca240bf5953f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PatternHarmonicSum.lean @@ -0,0 +1,132 @@ +import OAI.NumberTheory.TwoPoint.Bounds.OccurrenceCounts +import OAI.NumberTheory.TwoPoint.Bounds.PrimeReciprocalLaw + +namespace OAI + +/-! Summing numerical prime labels after the equality pattern has been fixed. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι Λ P : Type*} [Fintype ι] [Fintype Λ] [Fintype P] + [DecidableEq ι] [DecidableEq Λ] [DecidableEq P] + +omit [Fintype ι] [DecidableEq ι] in +/-- Once every occurrence is recovered from its class representative, +only one numerical prime per class is summed. -/ +lemma representative_weighted_sum (F : Finset (ι → P)) (classify : ι → Λ) + (rep : Λ → ι) (a : P → ℝ) (ha : ∀ p, 0 ≤ a p) + (hconstant : ∀ w ∈ F, ∀ i, w i = w (rep (classify i))) : + (∑ w ∈ F, ∏ c, a (w (rep c))) ≤ (∑ p, a p) ^ Fintype.card Λ := by + classical + let encode : (ι → P) → (Λ → P) := fun w c => w (rep c) + have hinj : Set.InjOn encode F := by + intro w hw z hz he + funext i + exact (hconstant w hw i).trans ((congrFun he (classify i)).trans (hconstant z hz i).symm) + calc + _ = ∑ z ∈ F.image encode, ∏ c, a (z c) := by + rw [sum_image hinj] + _ ≤ ∑ z : Λ → P, ∏ c, a (z c) := by + apply sum_le_sum_of_subset_of_nonneg (subset_univ _) + intro z _ _ + exact prod_nonneg (fun c _ => ha (z c)) + _ = _ := by rw [← Fintype.prod_sum]; simp + +omit [DecidableEq ι] in +/-- All words in one decoded equality-pattern fiber have the same bound, +even though the actual numerical primes vary from word to word. -/ +theorem same_pattern_weighted_sum (F : Finset (ι → P)) (template : ι → P) + (a : P → ℝ) (ha : ∀ p, 0 ≤ a p) + (hpattern : ∀ w ∈ F, ∀ i j, w i = w j ↔ template i = template j) : + (∑ w ∈ F, ∏ p ∈ univ.image w, a p) ≤ + (∑ p, a p) ^ (univ.image template).card := by + classical + let C := univ.image template + let rep : C → ι := fun c => Classical.choose (mem_image.mp c.property) + have hrep (c : C) : template (rep c) = c.val := + (Classical.choose_spec (mem_image.mp c.property)).2 + let classify : ι → C := fun i => ⟨template i, mem_image.mpr ⟨i, mem_univ _, rfl⟩⟩ + have hconstant (w : ι → P) (hw : w ∈ F) (i : ι) : + w i = w (rep (classify i)) := by + apply (hpattern w hw i (rep (classify i))).mpr + exact (hrep (classify i)).symm + have hweight (w : ι → P) (hw : w ∈ F) : + (∏ p ∈ univ.image w, a p) = ∏ c : C, a (w (rep c)) := by + have himage : (univ.image (fun c : C => w (rep c))) = univ.image w := by + ext p + constructor + · rintro hp + obtain ⟨c, _, rfl⟩ := mem_image.mp hp + exact mem_image.mpr ⟨rep c, mem_univ _, rfl⟩ + · intro hp + obtain ⟨i, _, rfl⟩ := mem_image.mp hp + exact mem_image.mpr ⟨classify i, mem_univ _, (hconstant w hw i).symm⟩ + rw [← himage, prod_image] + intro c _ d _ hcd + apply Subtype.ext + exact (hrep c).symm.trans (((hpattern w hw _ _).mp hcd).trans (hrep d)) + calc + _ = ∑ w ∈ F, ∏ c : C, a (w (rep c)) := sum_congr rfl hweight + _ ≤ (∑ p, a p) ^ Fintype.card C := + representative_weighted_sum F classify rep a ha hconstant + _ = _ := by rw [Fintype.card_coe] + +omit [DecidableEq ι] in +/-- Specialization to the reciprocal mass of an actual finite prime pool. -/ +theorem same_pattern_reciprocal_sum (P : Finset ℕ) (F : Finset (ι → P)) + (template : ι → P) + (hpattern : ∀ w ∈ F, ∀ i j, w i = w j ↔ template i = template j) : + (∑ w ∈ F, ∏ p ∈ univ.image w, (p.val : ℝ)⁻¹) ≤ + (primeHarmonicMass P) ^ (univ.image template).card := by + exact same_pattern_weighted_sum F template (fun p : P => (p.val : ℝ)⁻¹) + (fun p => by positivity) hpattern + +omit [DecidableEq ι] in +/-- Invalid codes contribute zero. For every valid fiber the reciprocal +sum costs one prime mass per observed label, independently of repetitions. -/ +theorem covered_pattern_weighted_sum {C : Type*} [Fintype C] + (F : Finset (ι → P)) (decode : C → ι → ι → Bool) + (a : P → ℝ) (ha : ∀ p, 0 ≤ a p) (M : ℕ) + (hV : 1 ≤ ∑ p, a p) + (hlabels : ∀ w ∈ F, (univ.image w).card ≤ M) + (hcover : ∀ w ∈ F, ∃ c, ∀ i j, decode c i j = decide (w i = w j)) : + (∑ w ∈ F, ∏ p ∈ univ.image w, a p) ≤ + (Fintype.card C : ℝ) * (∑ p, a p) ^ M := by + classical + let mass (w : ι → P) : ℝ := ∏ p ∈ univ.image w, a p + let fiber (c : C) := F.filter (fun w => ∀ i j, decode c i j = decide (w i = w j)) + have hmass (w : ι → P) : 0 ≤ mass w := prod_nonneg (fun p _ => ha p) + have hsum : (∑ w ∈ F, mass w) ≤ ∑ c, ∑ w ∈ fiber c, mass w := by + calc + _ ≤ ∑ w ∈ F, ∑ c, if ∀ i j, decode c i j = decide (w i = w j) then mass w else 0 := by + apply sum_le_sum + intro w hw + obtain ⟨c, hc⟩ := hcover w hw + calc + _ = if ∀ i j, decode c i j = decide (w i = w j) then mass w else 0 := by simp [hc] + _ ≤ _ := single_le_sum (s := (univ : Finset C)) + (f := fun d : C => if ∀ i j, decode d i j = decide (w i = w j) then mass w else 0) + (fun d _ => ite_nonneg (hmass w) le_rfl) (mem_univ c) + _ = _ := by rw [sum_comm]; simp only [fiber, sum_filter] + have hfiber (c : C) : (∑ w ∈ fiber c, mass w) ≤ (∑ p, a p) ^ M := by + by_cases he : (fiber c).Nonempty + · obtain ⟨v, hv⟩ := he + have hvF : v ∈ F := (mem_filter.mp hv).1 + have hp : ∀ w ∈ fiber c, ∀ i j, w i = w j ↔ v i = v j := by + intro w hw i j + have heq := ((mem_filter.mp hw).2 i j).symm.trans ((mem_filter.mp hv).2 i j) + exact decide_eq_decide.mp heq + exact (same_pattern_weighted_sum (fiber c) v a ha hp).trans + (pow_le_pow_right₀ hV (hlabels v hvF)) + · simp only [not_nonempty_iff_eq_empty.mp he, sum_empty] + positivity + calc + _ ≤ _ := hsum + _ ≤ ∑ _c : C, (∑ p, a p) ^ M := sum_le_sum (fun c _ => hfiber c) + _ = _ := by simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PatternResampling.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PatternResampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..4505f901df806d730ff1872120c124c10df5848b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PatternResampling.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PatternHarmonicSum + +namespace OAI + +/-! Resample one prime per observed equality class, retaining arbitrary nonnegative events. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {τ P : Type*} [Fintype τ] [DecidableEq P] + +def patternClasses (template : τ → P) : Finset P := univ.image template + +def patternCoordinate (template : τ → P) (t : τ) : patternClasses template := + ⟨template t, mem_image.mpr ⟨t, mem_univ _, rfl⟩⟩ + +noncomputable def patternRepresentative (template : τ → P) (c : patternClasses template) : τ := + Classical.choose (mem_image.mp c.property) + +lemma patternRepresentative_value (template : τ → P) (c : patternClasses template) : + template (patternRepresentative template c) = c.val := + (Classical.choose_spec (mem_image.mp c.property)).2 + +noncomputable def patternEncode (template w : τ → P) (c : patternClasses template) : P := + w (patternRepresentative template c) + +def patternResample (template : τ → P) (a : patternClasses template → P) (t : τ) : P := + a (patternCoordinate template t) + +lemma patternResample_encode (template w : τ → P) + (hpattern : ∀ i j, w i = w j ↔ template i = template j) : + patternResample template (patternEncode template w) = w := by + funext t + exact (hpattern _ _).mpr (patternRepresentative_value template (patternCoordinate template t)) + +lemma patternEncode_injOn (template : τ → P) (F : Finset (τ → P)) + (hpattern : ∀ w ∈ F, ∀ i j, w i = w j ↔ template i = template j) : + Set.InjOn (patternEncode template) F := by + intro w hw v hv he + calc + w = patternResample template (patternEncode template w) := + (patternResample_encode template w (hpattern w hw)).symm + _ = patternResample template (patternEncode template v) := congrArg _ he + _ = v := patternResample_encode template v (hpattern v hv) + +lemma patternEncode_weight (template w : τ → P) (a : P → ℝ) + (hpattern : ∀ i j, w i = w j ↔ template i = template j) : + (∏ p ∈ univ.image w, a p) = ∏ c : patternClasses template, a (patternEncode template w c) := by + have hc (t : τ) : w t = patternEncode template w (patternCoordinate template t) := by + exact (congrFun (patternResample_encode template w hpattern) t).symm + have he : univ.image (patternEncode template w) = univ.image w := by + ext p + constructor + · rintro hp + obtain ⟨c, _, rfl⟩ := mem_image.mp hp + exact mem_image.mpr ⟨patternRepresentative template c, mem_univ _, rfl⟩ + · rintro hp + obtain ⟨t, _, rfl⟩ := mem_image.mp hp + exact mem_image.mpr ⟨patternCoordinate template t, mem_univ _, (hc t).symm⟩ + rw [← he, prod_image] + intro c _ d _ hcd + apply Subtype.ext + exact (patternRepresentative_value template c).symm.trans + (((hpattern _ _).mp hcd).trans (patternRepresentative_value template d)) + +/-- Numerical restrictions and outside weights are preserved by the +resampling map. They are not discarded before the high-rank estimate. -/ +theorem same_pattern_resampled_sum [Fintype P] + (template : τ → P) (F : Finset (τ → P)) (a : P → ℝ) (ha : ∀ p, 0 ≤ a p) + (potential : (τ → P) → ℝ) (hpotential : ∀ w, 0 ≤ potential w) + (hpattern : ∀ w ∈ F, ∀ i j, w i = w j ↔ template i = template j) : + (∑ w ∈ F, (∏ p ∈ univ.image w, a p) * potential w) ≤ + ∑ x : patternClasses template → P, + (∏ c, a (x c)) * potential (patternResample template x) := by + calc + _ = ∑ x ∈ F.image (patternEncode template), + (∏ c, a (x c)) * potential (patternResample template x) := by + rw [sum_image (patternEncode_injOn template F hpattern)] + apply sum_congr rfl + intro w hw + rw [patternResample_encode template w (hpattern w hw), + patternEncode_weight template w a (hpattern w hw)] + _ ≤ _ := by + apply sum_le_sum_of_subset_of_nonneg (subset_univ _) + intro x _ _ + exact mul_nonneg (prod_nonneg (fun c _ => ha (x c))) (hpotential _) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PerfectBlockPartition.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PerfectBlockPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..113d445d7347e52e6f3a881f21de4e83e5471e1d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PerfectBlockPartition.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShortBlockPartition +import OAI.NumberTheory.TwoPoint.Bounds.RunPartitionProperties + +namespace OAI + +/-! Construct short perfect blocks from the actual position-status list. -/ + +namespace TwoPointCorrelations + +variable {α β : Type*} + +def initialColumnChunks (entries : List (α × Bool)) : List (List α ⊕ α) := + (partitionColumnRuns (fun a => !a.2) entries).map (Sum.map (List.map Prod.fst) Prod.fst) + +/-- The initial cut preserves every label and its original perfect status. -/ +theorem initialColumnChunks_entries (entries : List (α × Bool)) : + columnChunkEntries (initialColumnChunks entries) = entries := by + let raw := partitionColumnRuns (fun a : α × Bool => !a.2) entries + have hf := partitionColumnRuns_flatten (fun a : α × Bool => !a.2) entries + change columnChunkEntries (raw.map (Sum.map (List.map Prod.fst) Prod.fst)) = entries + apply Eq.trans _ hf + simp only [columnChunkEntries, List.flatMap_map] + apply List.flatMap_congr + intro piece hp + cases piece with + | inl segment => + have hreg := (partitionColumnRuns_regular_entries (fun a : α × Bool => !a.2) + entries segment hp).2 + simp only [Function.comp_def, Sum.map_inl, Sum.elim_inl, List.map_map, id_eq] + calc + _ = segment.map id := by + apply List.map_congr_left + intro a ha + have hb := hreg a ha + cases a with + | mk a b => cases b <;> simp_all + _ = segment := List.map_id _ + | inr a => + have hom : a ∈ raw.filterMap (Sum.elim (fun _ => none) some) := + List.mem_filterMap.mpr ⟨.inr a, hp, rfl⟩ + rw [show raw.filterMap (Sum.elim (fun _ => none) some) = + entries.filter (fun a => !a.2) from partitionColumnRuns_omitted _ _] at hom + have hb := (List.mem_filter.mp hom).2 + cases a with + | mk a b => cases b <;> simp_all [Sum.map, Function.comp_def, List.singleton] + +lemma perfectChunkCount_map (f : α → β) (chunks : List (List α ⊕ α)) : + perfectChunkCount (chunks.map (Sum.map (List.map f) f)) = perfectChunkCount chunks := by + induction chunks with + | nil => rfl + | cons chunk rest ih => cases chunk <;> + simpa [perfectChunkCount, Sum.map, List.filterMap_cons, Sum.elim] using ih + +lemma perfectChunkLength_le_entries (chunks : List (List α ⊕ α)) : + perfectChunkLength chunks ≤ (columnChunkEntries chunks).length := by + induction chunks with + | nil => rfl + | cons chunk rest ih => + cases chunk with + | inl l => simpa [perfectChunkLength, columnChunkEntries] using Nat.add_le_add_left ih l.length + | inr a => simpa [perfectChunkLength, columnChunkEntries] using ih.trans (Nat.le_succ _) + +/-- Each maximal perfect interval is charged to a preceding imperfect +position, except for a possible first interval. -/ +theorem initialColumnChunks_count (entries : List (α × Bool)) : + perfectChunkCount (initialColumnChunks entries) ≤ + (entries.filter (fun a => !a.2)).length + 1 := by + unfold initialColumnChunks + rw [perfectChunkCount_map] + exact partitionColumnRuns_regular_count _ _ + +def shortPerfectColumnChunks (s : ℕ) (entries : List (α × Bool)) : List (List α ⊕ α) := + subdivideColumnChunks s (initialColumnChunks entries) + +@[simp] theorem shortPerfectColumnChunks_entries (s : ℕ) (entries : List (α × Bool)) : + columnChunkEntries (shortPerfectColumnChunks s entries) = entries := by + rw [shortPerfectColumnChunks, subdivideColumnChunks_entries, initialColumnChunks_entries] + +/-- This is the explicit one-half version of the manuscript's perfect-block +count. Applying it to both halves gives the stated absolute bound. -/ +theorem shortPerfectColumnChunks_count (s : ℕ) (entries : List (α × Bool)) : + perfectChunkCount (shortPerfectColumnChunks s entries) ≤ + entries.length / s + (entries.filter (fun a => !a.2)).length + 1 := by + have h := subdivideColumnChunks_count s (initialColumnChunks entries) + have hn := perfectChunkLength_le_entries (initialColumnChunks entries) + rw [initialColumnChunks_entries] at hn + have hd := Nat.div_le_div_right (c := s) hn + have hc := initialColumnChunks_count entries + exact h.trans (by omega) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PerfectBlockPositions.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PerfectBlockPositions.lean new file mode 100644 index 0000000000000000000000000000000000000000..148c5e5116c6cb4d1ab9257b06d7e61365adbef5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PerfectBlockPositions.lean @@ -0,0 +1,122 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PerfectBlockPartition +import OAI.NumberTheory.TwoPoint.Walks.IndexedRuns + +namespace OAI + +/-! The constructed perfect blocks are actual contiguous intervals of positions. -/ + +namespace TwoPointCorrelations + +variable {α : Type*} + +theorem subdivideColumnChunks_regular_origin (s : ℕ) (chunks : List (List α ⊕ α)) + (block : List α) (hb : Sum.inl block ∈ subdivideColumnChunks s chunks) : + ∃ large, Sum.inl large ∈ chunks ∧ block ∈ shortBlocks s large := by + obtain ⟨piece, hp, hb⟩ := List.mem_flatMap.mp hb + cases piece with + | inl large => + simp only [Sum.elim_inl, List.mem_map, Sum.inl.injEq] at hb + obtain ⟨l, hl, rfl⟩ := hb + exact ⟨large, hp, hl⟩ + | inr a => simp at hb + +theorem initialColumnChunks_regular_origin (entries : List (α × Bool)) + (block : List α) (hb : Sum.inl block ∈ initialColumnChunks entries) : + ∃ raw, Sum.inl raw ∈ partitionColumnRuns (fun a : α × Bool => !a.2) entries ∧ + block = raw.map Prod.fst := by + obtain ⟨piece, hp, he⟩ := List.mem_map.mp hb + cases piece with + | inl raw => + simp only [Sum.map_inl, Sum.inl.injEq] at he + exact ⟨raw, hp, he.symm⟩ + | inr a => simp at he + +/-- Every constructed block is a contiguous part of the original column, +and all its positions have their original perfect status. -/ +theorem shortPerfectColumnChunks_regular_positions (s : ℕ) (entries : List (α × Bool)) + (block : List α) (hb : Sum.inl block ∈ shortPerfectColumnChunks s entries) : + block.IsInfix (entries.map Prod.fst) ∧ ∀ a ∈ block, (a, true) ∈ entries := by + obtain ⟨large, hl, hsub⟩ := subdivideColumnChunks_regular_origin s + (initialColumnChunks entries) block hb + obtain ⟨raw, hr, rfl⟩ := initialColumnChunks_regular_origin entries large hl + have hi := partitionColumnRuns_regular_infix (fun a : α × Bool => !a.2) entries raw hr + have hs := shortBlocks_infix s (raw.map Prod.fst) block hsub + refine ⟨hs.trans (hi.map Prod.fst), ?_⟩ + intro a ha + obtain ⟨p, hp, he⟩ := List.mem_map.mp (hs.subset ha) + have hpreg := (partitionColumnRuns_regular_entries (fun a : α × Bool => !a.2) entries raw hr).2 p hp + have hmem := hi.subset hp + rcases p with ⟨b, perfect⟩ + cases perfect <;> simp_all + +/-- A prefix of the position-indexed label list is the same label list +with the shortened length. -/ +theorem blockLabelList_take (label : ℕ → α) (start total len : ℕ) (h : len ≤ total) : + (blockLabelList label start total).take len = blockLabelList label start len := by + induction len generalizing start total with + | zero => simp [blockLabelList] + | succ len ih => + cases total with + | zero => omega + | succ total => + rw [blockLabelList_succ, blockLabelList_succ, List.take_succ_cons, ih] + omega + +theorem blockLabelList_drop_take (label : ℕ → α) (start total a len : ℕ) + (h : a + len ≤ total) : + ((blockLabelList label start total).drop a).take len = blockLabelList label (start + a) len := by + induction a generalizing start total with + | zero => simpa using blockLabelList_take label start total len (by simpa using h) + | succ a ih => + cases total with + | zero => omega + | succ total => + rw [blockLabelList_succ, List.drop_succ_cons, ih (start + 1) total (by omega)] + congr 1 + omega + +/-- Every contiguous part of a position-indexed list has an actual bounded +starting index, so no extra run-position data need be postulated. -/ +theorem infix_blockLabelList_positions (label : ℕ → α) (start total : ℕ) + (block : List α) (hb : block.IsInfix (blockLabelList label start total)) : + ∃ a, a + block.length ≤ total ∧ block = blockLabelList label (start + a) block.length := by + obtain ⟨before, after, he⟩ := hb + have hlen : before.length + block.length ≤ total := by + have ht := congrArg List.length he + simp only [List.length_append, blockLabelList, List.length_map, List.length_range] at ht + omega + refine ⟨before.length, hlen, ?_⟩ + rw [← blockLabelList_drop_take label start total before.length block.length hlen, ← he] + simp + +/-- Each short block has the promised maximum length. -/ +theorem shortPerfectColumnChunks_regular_size (s : ℕ) (hs : 0 < s) + (entries : List (α × Bool)) (block : List α) + (hb : Sum.inl block ∈ shortPerfectColumnChunks s entries) : block.length ≤ s := by + obtain ⟨large, _, hsub⟩ := subdivideColumnChunks_regular_origin s + (initialColumnChunks entries) block hb + exact shortBlocks_size s hs large block hsub + +/-- On the actual consecutive position list, every generated block has a +bounded starting index and contains only perfect positions. -/ +theorem shortPerfectColumnChunks_position_intervals (N s : ℕ) (perfect : ℕ → Bool) + (block : List ℕ) + (hb : Sum.inl block ∈ shortPerfectColumnChunks s + ((List.range N).map (fun i => (i, perfect i)))) : + ∃ start, start + block.length ≤ N ∧ + block = (List.range block.length).map (fun i => start + i) ∧ + ∀ i ∈ block, perfect i = true := by + obtain ⟨hinfix, hperfect⟩ := shortPerfectColumnChunks_regular_positions s _ block hb + have hi : block.IsInfix (blockLabelList id 0 N) := by + simpa [blockLabelList, List.map_map, Function.comp_def] using hinfix + obtain ⟨start, hbound, hblock⟩ := infix_blockLabelList_positions id 0 N block hi + refine ⟨start, hbound, ?_, ?_⟩ + · simpa [blockLabelList] using hblock + · intro i hi + obtain ⟨j, _, heq⟩ := List.mem_map.mp (hperfect i hi) + have hji : j = i := congrArg Prod.fst heq + simpa only [hji] using congrArg Prod.snd heq + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PerfectIntervalFamily.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PerfectIntervalFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..aed5027e025154672d224633b810b08a3192b420 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PerfectIntervalFamily.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PerfectBlockPositions + +namespace OAI + +/-! Choose numerical intervals for the constructed perfect blocks, preserving all budgets. -/ + +namespace TwoPointCorrelations + +def intervalPositions (b : ℕ × ℕ) : List ℕ := + (List.range b.2).map (fun j => b.1 + j) + +private theorem choose_interval_family (N : ℕ) (perfect : ℕ → Bool) + (blocks : List (List ℕ)) + (hblocks : ∀ block ∈ blocks, ∃ start, start + block.length ≤ N ∧ + block = intervalPositions (start, block.length) ∧ ∀ i ∈ block, perfect i = true) : + ∃ intervals : List (ℕ × ℕ), intervals.map intervalPositions = blocks ∧ + ∀ b ∈ intervals, b.1 + b.2 ≤ N ∧ ∀ i ∈ intervalPositions b, perfect i = true := by + induction blocks with + | nil => exact ⟨[], rfl, by simp⟩ + | cons block blocks ih => + obtain ⟨start, hbound, heq, hp⟩ := hblocks block List.mem_cons_self + obtain ⟨intervals, hi, hv⟩ := ih (fun b hb => hblocks b (List.mem_cons_of_mem _ hb)) + refine ⟨(start, block.length) :: intervals, ?_, ?_⟩ + · simpa only [List.map_cons, hi] using congrArg (fun tail => tail :: blocks) heq.symm + · intro b hb + rcases List.mem_cons.mp hb with rfl | hb + · exact ⟨hbound, by simpa only [← heq] using hp⟩ + · exact hv b hb + +variable {α : Type*} + +theorem perfectChunkLength_eq_sum (chunks : List (List α ⊕ α)) : + perfectChunkLength chunks = + ((chunks.filterMap (Sum.elim some (fun _ => none))).map List.length).sum := by + induction chunks with + | nil => rfl + | cons chunk chunks ih => + cases chunk with + | inl block => + simpa [perfectChunkLength, List.filterMap_cons, Sum.elim] using + congrArg (fun n => block.length + n) ih + | inr a => + simpa [perfectChunkLength, List.filterMap_cons, Sum.elim] using ih + +/-- The actual short-block partition admits numerical interval parameters. +Their total length is at most the original length; every selected position +retains its original perfect flag. Empty terminal blocks cost zero. -/ +theorem shortPerfectColumnChunks_interval_family (N s : ℕ) (perfect : ℕ → Bool) : + ∃ intervals : List (ℕ × ℕ), + intervals.map intervalPositions = + ((shortPerfectColumnChunks s ((List.range N).map (fun i => (i, perfect i)))).filterMap + (Sum.elim some (fun _ => none))) ∧ + intervals.length = perfectChunkCount + (shortPerfectColumnChunks s ((List.range N).map (fun i => (i, perfect i)))) ∧ + (intervals.map Prod.snd).sum ≤ N ∧ + ∀ b ∈ intervals, b.1 + b.2 ≤ N ∧ ∀ i ∈ intervalPositions b, perfect i = true := by + let chunks := shortPerfectColumnChunks s ((List.range N).map (fun i => (i, perfect i))) + obtain ⟨intervals, he, hv⟩ := choose_interval_family N perfect + (chunks.filterMap (Sum.elim some (fun _ => none))) (by + intro block hb + obtain ⟨piece, hp, heq⟩ := List.mem_filterMap.mp hb + cases piece with + | inl b => + cases heq + exact shortPerfectColumnChunks_position_intervals N s perfect block hp + | inr a => simp at heq) + refine ⟨intervals, he, ?_, ?_, hv⟩ + · have h := congrArg List.length he + simpa only [List.length_map, perfectChunkCount] using h + · have hlen : (intervals.map Prod.snd).sum = perfectChunkLength chunks := by + rw [perfectChunkLength_eq_sum, ← he, List.map_map] + simp only [intervalPositions, List.length_map, List.length_range, Function.comp_def] + rw [hlen] + have h := perfectChunkLength_le_entries chunks + rw [show columnChunkEntries chunks = (List.range N).map (fun i => (i, perfect i)) from + shortPerfectColumnChunks_entries s _] at h + simpa only [List.length_map, List.length_range] using h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PerfectRows.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PerfectRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..a41402d0b509291fc0d0f8689f34de33b9e53e27 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PerfectRows.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.TwoPoint.Bounds.OccurrenceCounts + +namespace OAI + +/-! The imperfect-row budget comes from actual singleton and unlit slots. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {ι τ : Type*} [Fintype ι] [Fintype τ] [DecidableEq ι] + +lemma singleton_slot_count (label : τ → ι) : + (univ.filter (fun t : τ => label t ∈ singletonLabels label)).card = + (singletonLabels label).card := by + have hf := sum_card_fiberwise_eq_card_filter (univ : Finset τ) (singletonLabels label) label + have hs : (∑ i ∈ singletonLabels label, (labelOccurrences label i).card) = + (singletonLabels label).card := by + calc + _ = ∑ _i ∈ singletonLabels label, 1 := by + apply sum_congr rfl + intro i hi + exact (mem_filter.mp hi).2 + _ = _ := by simp + exact hf.symm.trans hs + +omit [Fintype ι] in +lemma unlit_slot_count (label : τ → ι) (lit : τ → Bool) (S : Finset ι) : + (univ.filter (fun t : τ => label t ∈ S ∧ lit t = false)).card = + ∑ i ∈ S, (unlitOccurrences label lit i).card := by + have hf := sum_card_fiberwise_eq_card_filter + (univ.filter (fun t : τ => lit t = false)) S label + have he (i : ι) : + ((univ.filter (fun t : τ => lit t = false)).filter (fun t => label t = i)) = + unlitOccurrences label lit i := by + ext t + simp [unlitOccurrences, labelOccurrences, and_comm] + simp only [he] at hf + rw [hf] + congr 1 + ext t + simp [and_comm] + +variable {n J : ℕ} + +/-- Every slot in a perfect row is lit and belongs to a nonsingleton label. -/ +def PerfectRow (label : Fin n × Fin J → ι) (lit : Fin n × Fin J → Bool) + (r : Fin n) : Prop := + ∀ j, label (r, j) ∈ nonsingletonLabels label ∧ lit (r, j) = true + +/-- Charge a bad row to one singleton slot or one unlit nonsingleton slot. +The image under the row projection can only decrease cardinality. -/ +theorem imperfect_rows_le_singletons_add_unlit (label : Fin n × Fin J → ι) + (lit : Fin n × Fin J → Bool) : + (univ.filter (fun r : Fin n => ¬PerfectRow label lit r)).card ≤ + (singletonLabels label).card + + ∑ i : nonsingletonLabels label, (unlitOccurrences label lit i.val).card := by + classical + let A := univ.filter (fun t : Fin n × Fin J => label t ∈ singletonLabels label) + let B := univ.filter (fun t : Fin n × Fin J => + label t ∈ nonsingletonLabels label ∧ lit t = false) + have hsub : (univ.filter (fun r : Fin n => ¬PerfectRow label lit r)) ⊆ + A.image Prod.fst ∪ B.image Prod.fst := by + intro r hr + have hbad := (mem_filter.mp hr).2 + obtain ⟨j, hj⟩ : ∃ j, ¬(label (r, j) ∈ nonsingletonLabels label ∧ lit (r, j) = true) := by + simpa only [PerfectRow, not_forall] using hbad + by_cases hns : label (r, j) ∈ nonsingletonLabels label + · have hlit : lit (r, j) = false := by + cases hval : lit (r, j) <;> simp_all + exact mem_union_right _ (mem_image.mpr ⟨(r, j), mem_filter.mpr ⟨mem_univ _, hns, hlit⟩, rfl⟩) + · have hpos : 0 < (labelOccurrences label (label (r, j))).card := + card_pos.mpr ⟨(r, j), mem_filter.mpr ⟨mem_univ _, rfl⟩⟩ + have hlt : ¬2 ≤ (labelOccurrences label (label (r, j))).card := by + simpa only [nonsingletonLabels, mem_filter, mem_univ, true_and] using hns + have hsingle : label (r, j) ∈ singletonLabels label := + mem_filter.mpr ⟨mem_univ _, by omega⟩ + exact mem_union_left _ (mem_image.mpr ⟨(r, j), mem_filter.mpr ⟨mem_univ _, hsingle⟩, rfl⟩) + calc + _ ≤ (A.image Prod.fst ∪ B.image Prod.fst).card := card_le_card hsub + _ ≤ (A.image Prod.fst).card + (B.image Prod.fst).card := card_union_le _ _ + _ ≤ A.card + B.card := Nat.add_le_add (card_image_le) (card_image_le) + _ = _ := by + rw [show A.card = (singletonLabels label).card from singleton_slot_count label, + show B.card = ∑ i ∈ nonsingletonLabels label, (unlitOccurrences label lit i).card from + unlit_slot_count label lit (nonsingletonLabels label), ← sum_coe_sort] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PhaseSelection.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PhaseSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..62a858595d9da7f22d78dcb6eef69ebaa3294594 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PhaseSelection.lean @@ -0,0 +1,62 @@ +import Mathlib.Analysis.Complex.Basic +import Mathlib.Algebra.BigOperators.Group.Finset.Basic +import Mathlib.Tactic + +namespace OAI + +/-! A numerical subfamily can retain complex mass without cancellation. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +private lemma coordinate_mass_le {ι : Type*} (s : Finset ι) (z : ι → ℂ) + (φ : ℂ →+ ℝ) (hφ : ∀ x, |φ x| ≤ ‖x‖) : + (∑ i ∈ s, |φ (z i)|) ≤ + ‖∑ i ∈ s.filter (fun i => 0 ≤ φ (z i)), z i‖ + + ‖∑ i ∈ s.filter (fun i => ¬0 ≤ φ (z i)), z i‖ := by + have he : (∑ i ∈ s, |φ (z i)|) = + (∑ i ∈ s.filter (fun i => 0 ≤ φ (z i)), φ (z i)) - + ∑ i ∈ s.filter (fun i => ¬0 ≤ φ (z i)), φ (z i) := by + simp only [sum_filter, ← sum_sub_distrib] + apply sum_congr rfl + intro i _ + by_cases hi : 0 ≤ φ (z i) + · simp [hi, abs_of_nonneg hi] + · simp [hi, abs_of_neg (lt_of_not_ge hi)] + rw [he, ← map_sum, ← map_sum] + have hp := hφ (∑ i ∈ s.filter (fun i => 0 ≤ φ (z i)), z i) + have hn := hφ (∑ i ∈ s.filter (fun i => ¬0 ≤ φ (z i)), z i) + linarith [le_abs_self (φ (∑ i ∈ s.filter (fun i => 0 ≤ φ (z i)), z i)), + neg_le_abs (φ (∑ i ∈ s.filter (fun i => ¬0 ≤ φ (z i)), z i))] + +/-- Four half-plane selections suffice. The selected family depends only +on the numerical coefficients, so it can be used as graph eligibility. -/ +theorem exists_subfamily_complex_mass {ι : Type*} (s : Finset ι) (z : ι → ℂ) : + ∃ t ⊆ s, (∑ i ∈ s, ‖z i‖) / 4 ≤ ‖∑ i ∈ t, z i‖ := by + let rp := s.filter (fun i => 0 ≤ (z i).re) + let rn := s.filter (fun i => ¬0 ≤ (z i).re) + let ip := s.filter (fun i => 0 ≤ (z i).im) + let inn := s.filter (fun i => ¬0 ≤ (z i).im) + have hr := coordinate_mass_le s z Complex.reAddGroupHom Complex.abs_re_le_norm + have hi := coordinate_mass_le s z Complex.imAddGroupHom Complex.abs_im_le_norm + change (∑ i ∈ s, |(z i).re|) ≤ ‖∑ i ∈ rp, z i‖ + ‖∑ i ∈ rn, z i‖ at hr + change (∑ i ∈ s, |(z i).im|) ≤ ‖∑ i ∈ ip, z i‖ + ‖∑ i ∈ inn, z i‖ at hi + have ht : (∑ i ∈ s, ‖z i‖) ≤ + ‖∑ i ∈ rp, z i‖ + ‖∑ i ∈ rn, z i‖ + ‖∑ i ∈ ip, z i‖ + ‖∑ i ∈ inn, z i‖ := by + have h := sum_le_sum (fun i (_ : i ∈ s) => Complex.norm_le_abs_re_add_abs_im (z i)) + rw [sum_add_distrib] at h + dsimp only [rp, rn, ip, inn] + linarith + by_contra h + push Not at h + have h₁ := h rp (filter_subset _ _) + have h₂ := h rn (filter_subset _ _) + have h₃ := h ip (filter_subset _ _) + have h₄ := h inn (filter_subset _ _) + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PhysicalMatrixComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PhysicalMatrixComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b1909e8996019e969bbf1809ceb08d1ae81401d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PhysicalMatrixComparison.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShiftTraceComparison +import OAI.NumberTheory.TwoPoint.Bounds.ShiftedIntegerPaths +import OAI.NumberTheory.TwoPoint.Bounds.FiniteAverages + +namespace OAI + +/-! Compare physical matrix moments by their signed closed scalar words. +Copy gates remain fixed while only the arithmetic origin is averaged. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def FiniteLaw.uniform (α : Type*) [Fintype α] [Nonempty α] : FiniteLaw α where + weight _ := (Fintype.card α : ℝ)⁻¹ + nonneg _ := inv_nonneg.mpr (Nat.cast_nonneg _) + total := by simp + +lemma FiniteLaw.uniform_average {α : Type*} [Fintype α] [Nonempty α] (f : α → ℝ) : + (FiniteLaw.uniform α).average f = uniformAverage f := by + simp only [FiniteLaw.average, FiniteLaw.uniform, uniformAverage, ← mul_sum, div_eq_mul_inv] + ring + +theorem physicalMatrix_moment_comparison {D V α β : Type*} + [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] [Fintype α] [Fintype β] + (embed : V → D × ℤ) (hinj : Function.Injective embed) + (Q : Finset ℕ) (tuple : D → ℕ) (h : ℕ) (gate : D → ℤ → ℤ → Prop) + (weight : SignedStep → ℤ → ℝ) + (hflip : ∀ t n, weight t.flip (n + t.displacement h) = weight t n) + (μ : FiniteLaw α) (ν : FiniteLaw β) (origin : α → ℤ) (origin' : β → ℤ) + (k : ℕ) (ε : ℝ) (hε : 0 ≤ ε) + (hcompare : ∀ (i : V) (a b : Fin k → D × (Q × Bool)), + shiftWordEnd (integerShiftNext Q tuple h) (embed i) a = + shiftWordEnd (integerShiftNext Q tuple h) (embed i) b → + |μ.average (fun x => scalarWalkProduct h weight ((embed i).2 + origin x) + (integerClosedWordCode Q tuple (a, b))) - + ν.average (fun x => scalarWalkProduct h weight ((embed i).2 + origin' x) + (integerClosedWordCode Q tuple (a, b)))| ≤ ε) : + |μ.average (fun x => matrixFrobeniusSq (shiftMatrix embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate (fun t n => weight t (n + origin x))) ^ k)) - + ν.average (fun x => matrixFrobeniusSq (shiftMatrix embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate (fun t n => weight t (n + origin' x))) ^ k))| ≤ + (Fintype.card V : ℝ) * (Fintype.card (D × (Q × Bool)) : ℝ) ^ (2 * k) * ε := by + apply shiftMatrix_moment_comparison embed hinj + intro i a b + by_cases hend : shiftWordEnd (integerShiftNext Q tuple h) (embed i) a = + shiftWordEnd (integerShiftNext Q tuple h) (embed i) b + · have ha (x : α) : shiftClosedWeight embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate (fun t n => weight t (n + origin x))) k i a b = + (integerPathMask embed Q tuple h gate (embed i) a * + integerPathMask embed Q tuple h gate (embed i) b) * + scalarWalkProduct h weight ((embed i).2 + origin x) (integerClosedWordCode Q tuple (a, b)) := by + rw [shiftClosedWeight, ite_eq_left hend] + exact physicalShiftWord_closed_pair embed Q tuple h gate weight hflip _ _ a b hend + have hb (x : β) : shiftClosedWeight embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate (fun t n => weight t (n + origin' x))) k i a b = + (integerPathMask embed Q tuple h gate (embed i) a * + integerPathMask embed Q tuple h gate (embed i) b) * + scalarWalkProduct h weight ((embed i).2 + origin' x) (integerClosedWordCode Q tuple (a, b)) := by + rw [shiftClosedWeight, ite_eq_left hend] + exact physicalShiftWord_closed_pair embed Q tuple h gate weight hflip _ _ a b hend + simp_rw [ha, hb] + rcases integerPathMask_zero_or_one embed Q tuple h gate (embed i) a with hma | hma <;> + rcases integerPathMask_zero_or_one embed Q tuple h gate (embed i) b with hmb | hmb + all_goals simp only [hma, hmb, zero_mul, mul_zero, one_mul, FiniteLaw.average_const, + sub_self, abs_zero] + all_goals first | exact hε | exact hcompare i a b hend + · simpa only [shiftClosedWeight, hend, ite_false, FiniteLaw.average_const, sub_self, abs_zero] using hε + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PhysicalPathSupport.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PhysicalPathSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b17e455f6ae2ac736b6c89907115c3959122194 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PhysicalPathSupport.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShiftedIntegerPaths +import OAI.NumberTheory.TwoPoint.Walks.ReversedSegments + +namespace OAI + +/-! The numerical support of a nonzero translated matrix path. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +variable {D V : Type*} [DecidableEq D] [Fintype V] + +lemma physicalShiftWeight_nonzero (Q : Finset ℕ) (tuple : D → ℕ) (h : ℕ) + (gate : D → ℤ → ℤ → Prop) (weight : SignedStep → ℤ → ℝ) + (e : D × (Q × Bool)) (x : D × ℤ) + (he : physicalShiftWeight Q tuple h gate weight e x ≠ 0) : + x.1 ≠ e.1 ∧ weight ⟨e.2.2, tuple e.1, e.2.1⟩ x.2 ≠ 0 := by + unfold physicalShiftWeight at he + split_ifs at he with hc + · exact ⟨hc.1, he⟩ + · contradiction + +lemma physicalShiftWord_copy_chain (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (h : ℕ) (gate : D → ℤ → ℤ → Prop) + (weight : SignedStep → ℤ → ℝ) {k : ℕ} + (x : D × ℤ) (w : Fin k → D × (Q × Bool)) + (hw : shiftWordWeight embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate weight) x w ≠ 0) : + (x.1 :: (List.ofFn w).map Prod.fst).IsChain (fun a b => a ≠ b) := by + induction k generalizing x with + | zero => simp + | succ k ih => + have hp := mul_ne_zero_iff.mp hw + have he := (retainedShiftWeight_nonzero _ _ _ _ _ hp.1).2 + have hc := (physicalShiftWeight_nonzero Q tuple h gate weight (w 0) x he).1 + have ht := ih (integerShiftNext Q tuple h (w 0) x) (Fin.tail w) hp.2 + simp only [List.ofFn_succ, List.map_cons] + exact ht.cons_cons hc + +theorem physicalShiftWord_tuple_chain (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (hinj : Function.Injective tuple) (h : ℕ) + (gate : D → ℤ → ℤ → Prop) (weight : SignedStep → ℤ → ℝ) {k : ℕ} + (x : D × ℤ) (w : Fin k → D × (Q × Bool)) + (hw : shiftWordWeight embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate weight) x w ≠ 0) : + (integerStepWord Q tuple w).IsChain (fun a b => a.tuple ≠ b.tuple) := by + have hc := (physicalShiftWord_copy_chain embed Q tuple h gate weight x w hw).tail + have hs := (List.isChain_map Prod.fst).mp hc + apply (List.isChain_map (fun e : D × (Q × Bool) => + SignedStep.mk e.2.2 (tuple e.1) e.2.1.val)).mpr + exact hs.imp (fun _ _ hne he => hne (hinj he)) + +theorem physicalShiftWord_pairs (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (h : ℕ) (gate : D → ℤ → ℤ → Prop) + (weight : SignedStep → ℤ → ℝ) (pairs : Finset (ℕ × ℕ)) + (hsupport : ∀ t n, weight t n ≠ 0 → (t.tuple, t.padding) ∈ pairs) + {k : ℕ} (x : D × ℤ) (w : Fin k → D × (Q × Bool)) + (hw : shiftWordWeight embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate weight) x w ≠ 0) : + ∀ i, (tuple (w i).1, ((w i).2.1).val) ∈ pairs := by + induction k generalizing x with + | zero => intro i; exact Fin.elim0 i + | succ k ih => + have hp := mul_ne_zero_iff.mp hw + have he := (retainedShiftWeight_nonzero _ _ _ _ _ hp.1).2 + have hs := (physicalShiftWeight_nonzero Q tuple h gate weight (w 0) x he).2 + intro i + refine Fin.cases ?_ (fun j => ?_) i + · exact hsupport _ _ hs + · exact ih (integerShiftNext Q tuple h (w 0) x) (Fin.tail w) hp.2 j + +lemma scalarWalkProduct_one (h : ℕ) (n : ℤ) (w : List SignedStep) : + scalarWalkProduct h (fun _ _ => 1) n w = 1 := by + induction w generalizing n with + | nil => rfl + | cons t w ih => simp only [scalarWalkProduct, ih, one_mul] + +theorem integerPathMask_tuple_chain (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (hinj : Function.Injective tuple) (h : ℕ) + (gate : D → ℤ → ℤ → Prop) {k : ℕ} + (x : D × ℤ) (w : Fin k → D × (Q × Bool)) + (hw : integerPathMask embed Q tuple h gate x w ≠ 0) : + (integerStepWord Q tuple w).IsChain (fun a b => a.tuple ≠ b.tuple) := by + apply physicalShiftWord_tuple_chain embed Q tuple hinj h gate (fun _ _ => 1) x w + rw [physicalShiftWord_product, scalarWalkProduct_one, mul_one] + exact hw + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveCostPeriodicity.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveCostPeriodicity.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1af1ede34ec8a63c66aaf63c691cc09873ad1b4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveCostPeriodicity.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Bounds.EndpointResidueAverage +import OAI.NumberTheory.TwoPoint.Bounds.PaddingDeletionIdentity + +namespace OAI + +/-! Periodicity needed to shift each numerical pair separately before +averaging its nonnegative deletion cost. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma ProhibitedPrimeFamily.paddingRejectionAtom_congr {h J M : ℕ} + (data : ProhibitedPrimeFamily h J M) (S R : Finset ℕ) + (hS : S ⊆ data.P ∪ data.Q) (hR : R ⊆ retainedPrimeDivisors data.Q) + (eligible : ℕ → Prop) (L K : ℝ) (q : ℕ) (hq : q ∈ retainedPrimeDivisors data.Q) + (n m : ℤ) + (hnm : ∀ p : ↥(data.P ∪ data.Q), (n : ZMod p.val) = (m : ZMod p.val)) : + paddingRejectionAtom data.Q S R eligible L K q n = + paddingRejectionAtom data.Q S R eligible L K q m := by + have hw := positivePrimeWeight_residue_congr S n m (fun p hp => hnm ⟨p, hS hp⟩) + have hd := squarefree_divisor_congr data.Q q + (retainedPrimeDivisor_squarefree data.Q data.primeQ hq) + (retainedPrimeDivisor_factors data.Q data.primeQ hq) n m + (fun p hp => hnm ⟨p, mem_union_right _ hp⟩) + have hk := actualPaddingKeep_residue_congr data.Q data.primeQ R hR eligible L K n m + (fun p hp => hnm ⟨p, mem_union_right _ hp⟩) + simp only [paddingRejectionAtom, hw, hd, hk] + +lemma ProhibitedPrimeFamily.padding_rejection_average_translate {h J M B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (S R : Finset ℕ) (hS : S ⊆ data.P ∪ data.Q) (hR : R ⊆ retainedPrimeDivisors data.Q) + (eligible : ℕ → Prop) (L K : ℝ) (q : ℕ) (hq : q ∈ retainedPrimeDivisors data.Q) + (site : ℤ) : + (data.residueLaw B hB).average (fun x => + paddingRejectionAtom data.Q S R eligible L K q (data.residueOrigin x + site)) = + (data.residueLaw B hB).average (fun x => + paddingRejectionAtom data.Q S R eligible L K q (data.residueOrigin x)) := + data.residue_average_translate hB _ + (fun n m hnm => data.paddingRejectionAtom_congr S R hS hR eligible L K q hq n m hnm) site + +lemma ProhibitedPrimeFamily.prohibited_cost_average_translate {h J M B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (S : Finset ℕ) (hS : S ⊆ data.P ∪ data.Q) (s q : ℕ) + (hq : q ∈ retainedPrimeDivisors data.Q) (site : ℤ) : + (data.residueLaw B hB).average (fun x => actualPaddingCoefficient q * + positivePrimeWeight S (data.residueOrigin x + site) * + if (q : ℤ) ∣ data.residueOrigin x + site ∧ + ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) (data.residueOrigin x + site) + then 1 else 0) = + (data.residueLaw B hB).average (fun x => actualPaddingCoefficient q * + positivePrimeWeight S (data.residueOrigin x) * + if (q : ℤ) ∣ data.residueOrigin x ∧ + ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) (data.residueOrigin x) + then 1 else 0) := by + let F := fun n : ℤ => actualPaddingCoefficient q * positivePrimeWeight S n * + if (q : ℤ) ∣ n ∧ ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) n then 1 else 0 + have hF (n m : ℤ) + (hnm : ∀ p : ↥(data.P ∪ data.Q), (n : ZMod p.val) = (m : ZMod p.val)) : F n = F m := by + have hw := positivePrimeWeight_residue_congr S n m (fun p hp => hnm ⟨p, hS hp⟩) + have hd := squarefree_divisor_congr data.Q q + (retainedPrimeDivisor_squarefree data.Q data.primeQ hq) + (retainedPrimeDivisor_factors data.Q data.primeQ hq) n m + (fun p hp => hnm ⟨p, mem_union_right _ hp⟩) + have hp := data.prohibitedSite_congr hB s n m hnm + simp only [F, hw, hd, hp] + exact data.residue_average_translate hB F hF site + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveNormalization.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..c914625ef9b7f6ad53efc8a078177bd3a4900f90 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveNormalization.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShiftTransfer +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftBoundary + +namespace OAI + +/-! Setting the unused value at zero to zero permits globally bounded graph +test vectors without changing any of the theorem's positive correlations. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def positiveNormalization (f : ℕ → ℂ) (n : ℕ) : ℂ := + if n = 0 then 0 else f n + +lemma positiveNormalization_eq {f : ℕ → ℂ} {n : ℕ} (hn : 0 < n) : + positiveNormalization f n = f n := by + simp only [positiveNormalization, ne_of_gt hn, ite_false] + +lemma positiveNormalization_norm {f : ℕ → ℂ} (hf : OneBounded f) (n : ℕ) : + ‖positiveNormalization f n‖ ≤ 1 := by + by_cases hn : n = 0 + · simp [positiveNormalization, hn] + · rw [positiveNormalization_eq (Nat.pos_of_ne_zero hn)] + exact hf n (Nat.pos_of_ne_zero hn) + +lemma Multiplicative.positiveNormalization {f : ℕ → ℂ} (hf : Multiplicative f) : + Multiplicative (positiveNormalization f) := by + intro m n hm hn hcop + rw [positiveNormalization_eq (Nat.mul_pos hm hn), positiveNormalization_eq hm, + positiveNormalization_eq hn] + exact hf m n hm hn hcop + +lemma UniformlyNonpretentious.positiveNormalization {f : ℕ → ℂ} + (hnp : UniformlyNonpretentious f) (hf : OneBounded f) : + UniformlyNonpretentious (positiveNormalization f) := by + apply hnp.finite_prime_change ∅ hf (fun n _ => positiveNormalization_norm hf n) + intro p hp _ + exact positiveNormalization_eq hp.pos + +lemma positiveNormalization_prefix (f g : ℕ → ℂ) (h N : ℕ) : + positivePrefix (fun n => positiveNormalization f n * positiveNormalization g (n + h)) N = + positivePrefix (fun n => f n * g (n + h)) N := by + unfold positivePrefix + apply sum_congr rfl + intro n _ + dsimp only + rw [positiveNormalization_eq (by omega), positiveNormalization_eq (by omega)] + +lemma correlationSum_eq_positivePrefix (f g : ℕ → ℂ) (h N : ℕ) : + correlationSum f g 0 h N = positivePrefix (fun n => f n * g (n + h)) N := by + unfold correlationSum positivePrefix + simp only [Nat.add_zero] + rw [← Ico_add_one_right_eq_Icc, ← zero_add 1, + ← sum_Ico_add' (fun n => f n * g (n + h)) 0 N 1, range_eq_Ico] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PositivePrimeCostComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PositivePrimeCostComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..aee596103fc3eea9f406cd06b69bb021e27f0243 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PositivePrimeCostComparison.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PositiveWeightComparison +import OAI.NumberTheory.TwoPoint.Bounds.PrimeCoordinates + +namespace OAI + +/-! Actual integer-origin transfer of one positive deletion cost. The +event is represented by its literal prime-residue circuit, and the +comparison uses the same CRT law as the graph estimates. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem BravermanDepth22Input.eventually_positive_prime_cost_comparison + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M) + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (S : Finset ℕ), S ⊆ data.P ∪ data.Q → (S.card : ℝ) ≤ L ^ 2 → + ∀ (r ninput : ℕ), (r : ℝ) ≤ 100 * Real.log L → + ∀ (literal : Fin ninput → ↥(data.P ∪ data.Q) × ℤ) + (index : Fin (Fintype.card S) → Fin ninput) (site : ℤ), + (∀ i, (literal (index i)).1.val = ((Fintype.equivFin S).symm i).val ∧ + (literal (index i)).2 = site) → + ∀ (c : AC0Circuit ninput), c.depth ≤ 19 → (c.size : ℝ) ≤ Real.exp (L ^ 3) → + ∀ (bad : ℤ → Prop), + (∀ n, c.eval (fun i => decide (((literal i).1.val : ℤ) ∣ n + (literal i).2)) = true ↔ + bad n) → + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let F := fun n : ℤ => (4 : ℝ) ^ r * positivePrimeWeight S (n + site) * + if bad n then 1 else 0 + |uniformAverage (fun x : Fin N => F (a + x.val)) - + (data.residueLaw B hB).average (fun x => F (data.residueOrigin x))| ≤ + Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_positive_weight_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hb] with L hb + intro h J M B data hB hpool hBL S hS hSL r ninput hr literal index site hindex + c hc hsize bad hbad a N hN + let primes := data.P ∪ data.Q + let modulus := primeResidueModuli primes + let (i : Fin (Fintype.card primes)) : NeZero (modulus i) := + ⟨(primeResidueModuli_prime primes (fun p hp => data.prime ⟨p, hp⟩) i).ne_zero⟩ + let e : Fin (Fintype.card S) ≃ S := (Fintype.equivFin S).symm + let p : Fin (Fintype.card S) → ℕ := fun i => (e i).val + let F := fun z : ∀ i, ZMod (modulus i) => + let bits := residueCircuitInputs modulus (primeLiteralCoordinate primes literal) + (primeLiteralTest primes literal) z + positivePrimeTable p r (fun i => bits (index i)) * c.indicator bits + let cost := fun n : ℤ => (4 : ℝ) ^ r * positivePrimeWeight S (n + site) * + if bad n then 1 else 0 + have hp (i : Fin (Fintype.card S)) : 1 ≤ p i := + (data.prime ⟨p i, hS (e i).property⟩).one_lt.le + have hcard : (Fintype.card primes : ℝ) ≤ Real.exp L := by + have hh := primePool_card_bound primes (fun p hp => data.prime ⟨p, hp⟩) B hB + have hh' : (primes.card : ℝ) ≤ B := by exact_mod_cast hh + simpa only [Fintype.card_coe] using hh'.trans hBL + have hm : 0 < Fintype.card primes := by + simpa only [Fintype.card_coe] using card_pos.mpr hpool + have hmod (i : Fin (Fintype.card primes)) : (modulus i : ℝ) ≤ Real.exp L := + primeResidueModuli_bound primes (Real.exp L) + (fun p hp => (show (p : ℝ) ≤ B by exact_mod_cast hB p hp).trans hBL) i + have hh := hb (Fintype.card primes) modulus hm (by linarith) + (primeResidueModuli_coprime primes (fun p hp => data.prime ⟨p, hp⟩)) hmod + (Fintype.card S) r ninput p hp (by simpa only [Fintype.card_coe] using hSL) hr + (primeLiteralCoordinate primes literal) (primeLiteralTest primes literal) index c + hc hsize a N hN + change |uniformAverage (fun x : Fin N => F (fun i => (a + x.val : ZMod (modulus i)))) - + uniformAverage F| ≤ Real.exp (-(L ^ 9)) at hh + have hF (n : ℤ) : F (fun i => (n : ZMod (modulus i))) = cost n := by + let bits := residueCircuitInputs modulus (primeLiteralCoordinate primes literal) + (primeLiteralTest primes literal) (fun i => (n : ZMod (modulus i))) + have hall : bits = fun i => decide (((literal i).1.val : ℤ) ∣ n + (literal i).2) := by + funext i + exact primeLiteral_integer_input primes literal n i + have hbits (i : Fin (Fintype.card S)) : bits (index i) = + decide ((p i : ℤ) ∣ n + site) := by + rw [hall] + simp only [(hindex i).1, (hindex i).2, p, e] + have hgate : c.indicator bits = if bad n then 1 else 0 := by + have heval : c.eval bits = true ↔ bad n := by + simpa only [hall] using hbad n + simp only [AC0Circuit.indicator, heval] + change positivePrimeTable p r (fun i => bits (index i)) * c.indicator bits = cost n + simp only [hbits, hgate] + rw [positivePrimeTable_actual S e r (n + site)] + have hmodel : (data.residueLaw B hB).average (fun x => cost (data.residueOrigin x)) = + uniformAverage F := by + rw [← data.residue_average_canonical hB F] + apply congrArg (data.residueLaw B hB).average + funext x + rw [← hF, data.canonical_origin] + dsimp only + rw [hmodel] + have hsample : (fun x : Fin N => cost (a + x.val)) = + (fun x : Fin N => F (fun i => (a + x.val : ZMod (modulus i)))) := by + funext x + simpa only [Int.cast_add, Int.cast_natCast, Nat.cast_add] using (hF (a + x.val)).symm + rw [hsample] + exact hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PositivePrimeTilt.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PositivePrimeTilt.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ac2721c0fd2b5ce7a554fa958e958025f18d70b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PositivePrimeTilt.lean @@ -0,0 +1,147 @@ +import OAI.NumberTheory.TwoPoint.Bounds.BernoulliTail +import Mathlib.Analysis.Complex.ExponentialBounds + +namespace OAI + +/-! Tilting the prime divisibility law by the positive majorant of one +tuple of centered prime factors. Selected primes have parameter +`(1 + q)/2`; every other prime keeps its original parameter. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def positiveCenterWeight (q : ι → ℝ) (S : Finset ι) + (a : ι → Bool) : ℝ := + ∏ i, if i ∈ S then (if a i then 1 else 0) + q i else 1 + +noncomputable def positiveCenterNormalizer (q : ι → ℝ) (S : Finset ι) : ℝ := + ∏ i, if i ∈ S then 2 * q i else 1 + +noncomputable def positiveCenterParameter (q : ι → ℝ) (S : Finset ι) (i : ι) : ℝ := + if i ∈ S then (1 + q i) / 2 else q i + +omit [Fintype ι] in +lemma positiveCenterParameter_nonneg (q : ι → ℝ) (S : Finset ι) + (hq : ∀ i, 0 ≤ q i) (i : ι) : 0 ≤ positiveCenterParameter q S i := by + unfold positiveCenterParameter + split_ifs + · exact div_nonneg (add_nonneg zero_le_one (hq i)) (by norm_num) + · exact hq i + +omit [Fintype ι] in +lemma positiveCenterParameter_le_one (q : ι → ℝ) (S : Finset ι) + (hq : ∀ i, q i ≤ 1) (i : ι) : positiveCenterParameter q S i ≤ 1 := by + unfold positiveCenterParameter + split_ifs + · linarith [hq i] + · exact hq i + +noncomputable def positiveCenterLaw (q : ι → ℝ) (S : Finset ι) + (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) : FiniteLaw (ι → Bool) := + FiniteLaw.independent (fun i => booleanLaw (positiveCenterParameter q S i) + (positiveCenterParameter_nonneg q S hq0 i) (positiveCenterParameter_le_one q S hq1 i)) + +lemma positiveCenterWeight_eq (q : ι → ℝ) (S : Finset ι) (a : ι → Bool) : + positiveCenterWeight q S a = ∏ i ∈ S, ((if a i then 1 else 0) + q i) := by + simp only [positiveCenterWeight, ← prod_filter, filter_mem_eq_inter, univ_inter] + +lemma positiveCenterNormalizer_eq (q : ι → ℝ) (S : Finset ι) : + positiveCenterNormalizer q S = ∏ i ∈ S, 2 * q i := by + simp only [positiveCenterNormalizer, ← prod_filter, filter_mem_eq_inter, univ_inter] + +lemma positiveCenterNormalizer_nonneg (q : ι → ℝ) (S : Finset ι) + (hq : ∀ i, 0 ≤ q i) : 0 ≤ positiveCenterNormalizer q S := by + unfold positiveCenterNormalizer + apply prod_nonneg + intro i _ + split_ifs + · exact mul_nonneg (by norm_num) (hq i) + · exact zero_le_one + +lemma positive_center_tilt_weight (q : ι → ℝ) (S : Finset ι) + (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) (a : ι → Bool) : + (FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i))).weight a * + positiveCenterWeight q S a = + (positiveCenterLaw q S hq0 hq1).weight a * positiveCenterNormalizer q S := by + simp only [FiniteLaw.independent, positiveCenterLaw, positiveCenterWeight, + positiveCenterNormalizer, ← prod_mul_distrib] + apply prod_congr rfl + intro i _ + by_cases hi : i ∈ S <;> cases a i <;> + simp [positiveCenterParameter, hi, booleanLaw] <;> ring + +lemma positive_center_tilt_average (q : ι → ℝ) (S : Finset ι) + (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) (F : (ι → Bool) → ℝ) : + (FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i))).average + (fun a => positiveCenterWeight q S a * F a) = + positiveCenterNormalizer q S * (positiveCenterLaw q S hq0 hq1).average F := by + simp only [FiniteLaw.average, mul_sum] + apply sum_congr rfl + intro a _ + rw [← mul_assoc, positive_center_tilt_weight] + ring + +lemma positive_center_tilt_total (q : ι → ℝ) (S : Finset ι) + (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) : + (FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i))).average + (positiveCenterWeight q S) = positiveCenterNormalizer q S := by + simpa only [mul_one, FiniteLaw.average_const] using + positive_center_tilt_average q S hq0 hq1 (fun _ => 1) + +lemma positiveCenterParameter_sum_le (q : ι → ℝ) (S : Finset ι) + (hq0 : ∀ i, 0 ≤ q i) : + (∑ i, positiveCenterParameter q S i) ≤ (S.card : ℝ) + ∑ i, q i := by + calc + _ ≤ ∑ i, ((if i ∈ S then (1 : ℝ) else 0) + q i) := by + apply sum_le_sum + intro i _ + unfold positiveCenterParameter + by_cases hi : i ∈ S + · simp only [hi, ite_true] + linarith [hq0 i] + · simp only [hi, ite_false, zero_add, le_refl] + _ = _ := by simp only [sum_add_distrib, sum_boole, filter_mem_eq_inter, + univ_inter] + +/-- The selected primes may be bounded simply by their number. The +remaining Bernoulli mean is at most the original total reciprocal mass. -/ +theorem positive_center_degree_tail (q : ι → ℝ) (S : Finset ι) + (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) + (W : ℝ) (hW : 10 ≤ W) (hmass : (∑ i, q i) ≤ 2 * W * S.card) : + (positiveCenterLaw q S hq0 hq1).probability + (fun a => 6 * W * S.card < booleanCount a) ≤ Real.exp (-2 * W * S.card) := by + have hJ : 0 ≤ (S.card : ℝ) := Nat.cast_nonneg _ + have hM : (∑ i, positiveCenterParameter q S i) ≤ + (S.card : ℝ) + 2 * W * S.card := + (positiveCenterParameter_sum_le q S hq0).trans (add_le_add le_rfl hmass) + have hb := independent_boolean_tail (positiveCenterParameter q S) + (positiveCenterParameter_nonneg q S hq0) (positiveCenterParameter_le_one q S hq1) + 1 ((S.card : ℝ) + 2 * W * S.card) (6 * W * S.card) (by norm_num) hM + apply hb.trans + apply Real.exp_le_exp.mpr + have he : Real.exp 1 - 1 ≤ (7 / 4 : ℝ) := by + linarith [Real.exp_one_lt_d9] + have hW0 : 0 ≤ W := by linarith + have hM0 : 0 ≤ (S.card : ℝ) + 2 * W * S.card := + add_nonneg hJ (mul_nonneg (mul_nonneg (by norm_num) hW0) hJ) + have heM := mul_le_mul_of_nonneg_right he hM0 + nlinarith [mul_nonneg (sub_nonneg.mpr hW) hJ] + +theorem positive_center_weighted_degree_tail (q : ι → ℝ) (S : Finset ι) + (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) + (W : ℝ) (hW : 10 ≤ W) (hmass : (∑ i, q i) ≤ 2 * W * S.card) : + (FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i))).average + (fun a => positiveCenterWeight q S a * + if 6 * W * S.card < booleanCount a then 1 else 0) ≤ + positiveCenterNormalizer q S * Real.exp (-2 * W * S.card) := by + rw [positive_center_tilt_average] + exact mul_le_mul_of_nonneg_left (positive_center_degree_tail q S hq0 hq1 W hW hmass) + (positiveCenterNormalizer_nonneg q S hq0) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveRowMajorant.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveRowMajorant.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e1f24682dea469069684da920b9dcb0dbfc6078 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveRowMajorant.lean @@ -0,0 +1,114 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeRowMoments +import OAI.NumberTheory.TwoPoint.Bounds.PrimeTupleMass +import OAI.NumberTheory.TwoPoint.Bounds.ActualCenterDegree + +namespace OAI + +/-! The literal sum of positive tuple weights is the row majorant +whose second moment was estimated under the product law. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma positivePrimeWeight_tuple {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (d : (j : Fin J) → P j) (n : ℤ) : + positivePrimeWeight (∏ j, (d j).val).primeFactors n = + ∏ j, ((if ((d j).val : ℤ) ∣ n then 1 else 0) + 1 / ((d j).val : ℝ)) := by + have hinj := selectedPrimeValues_injective d hdisjoint + have hf : (∏ j, (d j).val).primeFactors = univ.image (fun j => (d j).val) := + familyTuple_primeFactors (fun j (p : P j) => p.val) + (fun j p => hprime j _ p.property) d hinj + rw [positivePrimeWeight, hf] + rw [prod_image] + intro i _ j _ hij + exact hinj hij + +lemma positivePrimeWeight_tuple_sum {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) (n : ℤ) : + (∑ d ∈ primeTupleDivisors P, positivePrimeWeight d.primeFactors n) = + ∏ j, ((actualPaddingDegree (P j) n : ℝ) + primeHarmonicMass (P j)) := by + rw [primeTupleDivisors, sum_image] + · simp_rw [positivePrimeWeight_tuple P hprime hdisjoint] + have he := (Fintype.prod_sum (fun j (p : P j) => + (if (p.val : ℤ) ∣ n then (1 : ℝ) else 0) + 1 / (p.val : ℝ))).symm + apply he.trans + apply prod_congr rfl + intro j _ + rw [sum_add_distrib, actualPrimeDegree_eq_count] + simp only [booleanCount, primeHarmonicMass, decide_eq_true_eq, one_div] + · intro x _ y _ hxy + exact primeTuple_injective hprime hdisjoint hxy + +lemma positivePrimeWeight_tuple_sum_le {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) (n : ℤ) (W : ℝ) + (hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W) + (hdegree : (actualPaddingDegree (univ.biUnion P) n : ℝ) ≤ 6 * W * J) : + (∑ d ∈ primeTupleDivisors P, positivePrimeWeight d.primeFactors n) ≤ (8 * W) ^ J := by + rw [positivePrimeWeight_tuple_sum P hprime hdisjoint] + have hd : (∑ j, (actualPaddingDegree (P j) n : ℝ)) ≤ 6 * W * J := by + rw [← Nat.cast_sum, ← actualPaddingDegree_biUnion P hdisjoint] + exact hdegree + have hb := nonneg_product_le_power_card + (fun j => (actualPaddingDegree (P j) n : ℝ) + primeHarmonicMass (P j)) (8 * W) + (fun j => add_nonneg (Nat.cast_nonneg _) (by unfold primeHarmonicMass; positivity)) + (sum_degree_budget (fun j => (actualPaddingDegree (P j) n : ℝ)) + (fun j => primeHarmonicMass (P j)) W hV (by simpa only [Fintype.card_fin] using hd)) + simpa only [Fintype.card_fin] using hb + +/-- The deterministic first-power bound needed when testing the graph +against bounded vectors. The degree projection is the only site restriction. -/ +lemma abs_centeredTuple_sum_le {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) (n : ℤ) (W : ℝ) + (hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W) + (hdegree : (actualPaddingDegree (univ.biUnion P) n : ℝ) ≤ 6 * W * J) : + (∑ d ∈ primeTupleDivisors P, |centeredTuple d.primeFactors n|) ≤ (8 * W) ^ J := by + exact (sum_le_sum (fun d _ => abs_centeredTuple_le_positivePrimeWeight d.primeFactors n)).trans + (positivePrimeWeight_tuple_sum_le P hprime hdisjoint n W hV hdegree) + +lemma positive_tuple_padding_row_bound {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (Q D : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) (hD : D ⊆ primeTupleDivisors P) + (padding : ℕ → Finset ℕ) (hpadding : ∀ d ∈ D, padding d ⊆ retainedPrimeDivisors Q) + (n : ℤ) : + (∑ d ∈ D, ∑ q ∈ padding d, + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors n * + if (q : ℤ) ∣ n then 1 else 0) ≤ primeRowMajorant P Q n := by + calc + _ ≤ ∑ d ∈ D, positivePrimeWeight d.primeFactors n * actualPaddingWeight Q n := by + apply sum_le_sum + intro d hd + calc + _ = positivePrimeWeight d.primeFactors n * + (∑ q ∈ padding d, if (q : ℤ) ∣ n then actualPaddingCoefficient q else 0) := by + rw [mul_sum] + apply sum_congr rfl + intro q _ + split_ifs <;> ring + _ ≤ _ := mul_le_mul_of_nonneg_left (by + rw [actualPaddingWeight_eq_divisor_sum Q hQ n] + exact sum_le_sum_of_subset_of_nonneg (hpadding d hd) (by + intro q _ _ + split_ifs + · exact actualPaddingCoefficient_nonneg q + · exact le_rfl)) (positivePrimeWeight_nonneg _ _) + _ ≤ ∑ d ∈ primeTupleDivisors P, + positivePrimeWeight d.primeFactors n * actualPaddingWeight Q n := + sum_le_sum_of_subset_of_nonneg hD (by + intro d _ _ + exact mul_nonneg (positivePrimeWeight_nonneg _ _) (by + exact zero_le_one.trans (actualPaddingWeight_one_le Q n))) + _ = _ := by + rw [← sum_mul, positivePrimeWeight_tuple_sum P hprime hdisjoint] + exact mul_comm _ _ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveWeightComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveWeightComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb031f80e5d5b1022f3e569221b3ad7026a106f8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveWeightComparison.lean @@ -0,0 +1,122 @@ +import OAI.NumberTheory.TwoPoint.Walks.WeightedWordComparison +import OAI.NumberTheory.TwoPoint.Bounds.PrimeDegreeTail + +namespace OAI + +/-! Finite-interval comparison for the positive tuple majorant used in +deletion costs. The selected-prime values are kept in one bounded +coefficient table; no subset expansion is needed. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def positivePrimeTable {t : ℕ} (p : Fin t → ℕ) (r : ℕ) + (bits : BooleanCube t) : ℝ := + (4 : ℝ) ^ r * ∏ i, ((if bits i then 1 else 0) + 1 / (p i : ℝ)) + +lemma positivePrimeTable_nonneg {t : ℕ} (p : Fin t → ℕ) (r : ℕ) + (bits : BooleanCube t) : 0 ≤ positivePrimeTable p r bits := by + apply mul_nonneg (pow_nonneg (by norm_num) _) + apply prod_nonneg + intro i _ + split_ifs <;> positivity + +lemma positivePrimeTable_bound {t : ℕ} (p : Fin t → ℕ) + (hp : ∀ i, 1 ≤ p i) (r : ℕ) (bits : BooleanCube t) : + positivePrimeTable p r bits ≤ (4 : ℝ) ^ r * (2 : ℝ) ^ t := by + apply mul_le_mul_of_nonneg_left _ (pow_nonneg (by norm_num) _) + calc + _ ≤ ∏ _i : Fin t, (2 : ℝ) := by + apply prod_le_prod₀ + · intro i _ + split_ifs <;> positivity + · intro i _ + have hpi : (1 : ℝ) ≤ p i := by exact_mod_cast hp i + have hi : 1 / (p i : ℝ) ≤ 1 := (div_le_one (by linarith)).mpr hpi + split_ifs <;> linarith + _ = _ := by simp + +lemma positivePrimeTable_budget {t : ℕ} (p : Fin t → ℕ) + (hp : ∀ i, 1 ≤ p i) (r : ℕ) (L : ℝ) + (hL : 4800 ≤ L) (ht : (t : ℝ) ≤ L ^ 2) + (hr : (r : ℝ) ≤ 100 * Real.log L) (bits : BooleanCube t) : + |positivePrimeTable p r bits| ≤ Real.exp (L ^ 4) := by + rw [abs_of_nonneg (positivePrimeTable_nonneg p r bits)] + have hL0 : 0 ≤ L := by linarith + have hlog : Real.log L ≤ L := + (Real.log_le_sub_one_of_pos (by linarith)).trans (by linarith) + have h4 : (4 : ℝ) ≤ Real.exp 4 := by linarith [Real.add_one_le_exp (4 : ℝ)] + have h2 : (2 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + calc + _ ≤ (4 : ℝ) ^ r * (2 : ℝ) ^ t := positivePrimeTable_bound p hp r bits + _ ≤ (Real.exp 4) ^ r * (Real.exp 2) ^ t := + mul_le_mul (pow_le_pow_left₀ (by norm_num) h4 r) + (pow_le_pow_left₀ (by norm_num) h2 t) (by positivity) (by positivity) + _ = Real.exp ((r : ℝ) * 4 + (t : ℝ) * 2) := by + rw [← Real.exp_nat_mul, ← Real.exp_nat_mul, ← Real.exp_add] + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have hquad := mul_nonneg hL0 (show 0 ≤ L - 400 by linarith) + have hfour := mul_nonneg (sq_nonneg L) (show 0 ≤ L ^ 2 - 3 by nlinarith) + nlinarith + +lemma positivePrimeTable_actual {t : ℕ} (S : Finset ℕ) (e : Fin t ≃ S) + (r : ℕ) (n : ℤ) : + positivePrimeTable (fun i => (e i).val) r (fun i => decide (((e i).val : ℤ) ∣ n)) = + (4 : ℝ) ^ r * positivePrimeWeight S n := by + unfold positivePrimeTable positivePrimeWeight + simp only [decide_eq_true_eq] + congr 1 + rw [← prod_coe_sort S (fun p : ℕ => (if (p : ℤ) ∣ n then (1 : ℝ) else 0) + 1 / (p : ℝ))] + exact e.prod_comp (fun p : S => + (if (p.val : ℤ) ∣ n then (1 : ℝ) else 0) + 1 / (p.val : ℝ)) + +theorem BravermanDepth22Input.eventually_positive_weight_comparison + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (m : ℕ) (s : Fin m → ℕ) [∀ i, NeZero (s i)], + 0 < m → (m : ℝ) ≤ Real.exp L + 1 → + Pairwise (fun i j => (s i).Coprime (s j)) → + (∀ i, (s i : ℝ) ≤ Real.exp L) → + ∀ (t r Ninput : ℕ) (p : Fin t → ℕ), + (∀ i, 1 ≤ p i) → (t : ℝ) ≤ L ^ 2 → (r : ℝ) ≤ 100 * Real.log L → + ∀ (coord : Fin Ninput → Fin m) + (test : ∀ i, ZMod (s (coord i)) → Bool) (pindex : Fin t → Fin Ninput) + (c : AC0Circuit Ninput), c.depth ≤ 19 → (c.size : ℝ) ≤ Real.exp (L ^ 3) → + ∀ a N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let F := fun z : ∀ j, ZMod (s j) => + let bits := residueCircuitInputs s coord test z + positivePrimeTable p r (fun i => bits (pindex i)) * c.indicator bits + |uniformAverage (fun x : Fin N => F (fun j => (a + x.val : ZMod (s j)))) - + uniformAverage F| ≤ Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_weighted_word_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hb, eventually_ge_atTop (4800 : ℝ)] with L hb hL + intro m s _ hm hmexp hcop hs t r Ninput p hp ht hr coord test pindex c hc hsize a N hN + let qindex : Fin 0 → Fin 0 → Fin Ninput := fun i => Fin.elim0 i + let f : (Fin 0 → Finset (Fin 0)) → BooleanCube t → ℝ := + fun _ bits => positivePrimeTable p r bits + have hlog : 0 ≤ 400 * Real.log L := + mul_nonneg (by norm_num) (Real.log_nonneg (by linarith)) + have hh := hb m s hm hmexp hcop hs 0 0 t Ninput 0 + (by simpa only [Nat.cast_zero] using (Real.exp_pos L).le) + (by simpa only [Nat.cast_zero] using hlog) + (by simp only [Nat.cast_zero]; linarith) ht coord test qindex pindex f c + (fun b => positivePrimeTable_budget p hp r L hL ht hr b.2) hc hsize a N hN + have he (z : ∀ j, ZMod (s j)) : + (if (∀ i : Fin 0, (activeState (fun j => residueCircuitInputs s coord test z + (qindex i j))).card ≤ 0) ∧ c.eval (residueCircuitInputs s coord test z) = true + then f (fun i => activeState (fun j => residueCircuitInputs s coord test z (qindex i j))) + (fun i => residueCircuitInputs s coord test z (pindex i)) else 0) = + positivePrimeTable p r (fun i => residueCircuitInputs s coord test z (pindex i)) * + c.indicator (residueCircuitInputs s coord test z) := by + simp only [Fin.forall_fin_zero, true_and, f, AC0Circuit.indicator] + split_ifs <;> simp + dsimp only at hh ⊢ + simpa only [he] using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveWordProbability.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveWordProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9a75a2ba03acc164d692d3f1efe5c27f3008a58 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PositiveWordProbability.lean @@ -0,0 +1,201 @@ +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedCircuit +import OAI.NumberTheory.TwoPoint.Bounds.UniformResidues +import OAI.NumberTheory.TwoPoint.Bounds.IndependentSampling +import OAI.NumberTheory.TwoPoint.Bounds.CrudeWordCounting + +namespace OAI + +/-! +# Probability of one positive numerical word + +The same residue coordinate is reused at every occurrence of a prime. +Selecting one occurrence per distinct prime therefore bounds the probability +by one reciprocal per distinct prime, including all padding factors. There +is no independence assumption between different sites of the word. +-/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma FiniteLaw.probability_mono_of_imp {A : Type*} [Fintype A] + (μ : FiniteLaw A) {E F : A → Prop} (h : ∀ x, E x → F x) : + μ.probability E ≤ μ.probability F := by + apply μ.average_mono + intro x + by_cases he : E x + · simp only [ite_eq_left he, ite_eq_left (h x he), le_refl] + · simp only [ite_eq_right he] + split_ifs <;> norm_num + +/-- Every residue modulo the true modulus has precisely its uniform mass, +even though the common carrier `Fin B` also contains zero-weight points. -/ +theorem uniformResidueLaw_mod_eq (B p : ℕ) (hp : 0 < p) (hpB : p ≤ B) (r : ZMod p) : + (uniformResidueLaw B p hp hpB).probability + (fun x => (x.val : ZMod p) = r) = (p : ℝ)⁻¹ := by + classical + let : NeZero p := ⟨hp.ne'⟩ + let : DecidableEq (ZMod p) := fun _ _ => Classical.propDecidable _ + let a : Fin B := ⟨r.val, r.val_lt.trans_le hpB⟩ + have ha : a.val < p := r.val_lt + have har : (a.val : ZMod p) = r := ZMod.natCast_zmod_val r + have hterm (x : Fin B) : + (uniformResidueLaw B p hp hpB).weight x * + (if (x.val : ZMod p) = r then (1 : ℝ) else 0) = + if x = a then (p : ℝ)⁻¹ else 0 := by + by_cases hx : x = a + · subst x + simp only [uniformResidueLaw_weight B p hp hpB a ha, har, ite_true, mul_one] + · by_cases hxp : x.val < p + · have hxr : (x.val : ZMod p) ≠ r := by + intro he + have hv := congrArg ZMod.val he + rw [ZMod.val_natCast_of_lt hxp] at hv + exact hx (Fin.ext hv) + simp only [uniformResidueLaw_weight B p hp hpB x hxp, ite_eq_right hxr, + mul_zero, ite_eq_right hx] + · simp only [uniformResidueLaw, ite_eq_right hxp, zero_mul, ite_eq_right hx] + unfold FiniteLaw.probability FiniteLaw.average + dsimp only + calc + _ = ∑ x : Fin B, if x = a then (p : ℝ)⁻¹ else 0 := + Finset.sum_congr rfl (fun x _ => hterm x) + _ = _ := by simp + +/-- Distinct prime factors in all the step divisors, both tuples and padding. -/ +def wordDivisorPrimeSupport (w : List SignedStep) : Finset ℕ := + w.toFinset.biUnion (fun a => (a.padding * a.tuple).primeFactors) + +lemma mem_wordDivisorPrimeSupport (w : List SignedStep) (p : ℕ) : + p ∈ wordDivisorPrimeSupport w ↔ + ∃ k : Fin w.length, p ∈ ((w.get k).padding * (w.get k).tuple).primeFactors := by + simp only [wordDivisorPrimeSupport, mem_biUnion, List.mem_toFinset] + exact List.exists_mem_iff_get + +/-- Positivity expressed in the one common set of residue coordinates. -/ +def ResiduePositiveWord {ι : Type*} (p : ι → ℕ) (h : ℕ) (w : List SignedStep) + (r : ∀ i, ZMod (p i)) : Prop := + ∀ (k : Fin w.length) (i : ι), + p i ∈ ((w.get k).padding * (w.get k).tuple).primeFactors → + r i = -((wordDisplacement h (w.take k.val) : ℤ) : ZMod (p i)) + +/-- A residue test is exact arithmetic positivity at any common integer lift. -/ +theorem residuePositiveWord_iff {ι : Type*} (p : ι → ℕ) (h : ℕ) + (w : List SignedStep) (r : ∀ i, ZMod (p i)) (n : ℤ) + (hn : ∀ i, (n : ZMod (p i)) = r i) + (hsq : ∀ a ∈ w, Squarefree (a.padding * a.tuple)) + (hcover : ∀ q ∈ wordDivisorPrimeSupport w, ∃ i, p i = q) : + ResiduePositiveWord p h w r ↔ PositiveWord h n w := by + rw [positiveWord_iff_prime_tests h n w hsq] + constructor + · intro hr k q hq + have hmem : q ∈ wordDivisorPrimeSupport w := + (mem_wordDivisorPrimeSupport w q).mpr ⟨k, hq⟩ + obtain ⟨i, rfl⟩ := hcover q hmem + exact (residue_offset_divisibility (r i) n _ (hn i)).mpr (hr k i hq) + · intro hn' k i hi + exact (residue_offset_divisibility (r i) n _ (hn i)).mp (hn' k (p i) hi) + +/-- One reciprocal factor for every used residue coordinate. Repeated +occurrences can only make the event smaller, by adding compatibility tests. -/ +theorem residuePositiveWord_probability_le {ι : Type*} [Fintype ι] [DecidableEq ι] + (B : ℕ) (p : ι → ℕ) (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (h : ℕ) (w : List SignedStep) : + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).probability + (fun x => ResiduePositiveWord p h w (fun i => ((x i).val : ZMod (p i)))) ≤ + ∏ i ∈ univ.filter (fun i => p i ∈ wordDivisorPrimeSupport w), (p i : ℝ)⁻¹ := by + let E : ∀ i, Fin B → Prop := fun i x => ∀ k : Fin w.length, + p i ∈ ((w.get k).padding * (w.get k).tuple).primeFactors → + (x.val : ZMod (p i)) = -((wordDisplacement h (w.take k.val) : ℤ) : ZMod (p i)) + have he : (fun x : ι → Fin B => ResiduePositiveWord p h w + (fun i => ((x i).val : ZMod (p i)))) = (fun x => ∀ i, E i (x i)) := by + funext x + exact propext (forall_comm) + rw [he, FiniteLaw.independent_probability_all] + rw [prod_filter] + apply prod_le_prod₀ + · intro i _ + exact FiniteLaw.probability_nonneg _ _ + · intro i _ + by_cases hi : p i ∈ wordDivisorPrimeSupport w + · rw [ite_eq_left hi] + obtain ⟨k, hk⟩ := (mem_wordDivisorPrimeSupport w (p i)).mp hi + exact ((uniformResidueLaw B (p i) (hp i) (hpB i)).probability_mono_of_imp + (fun x hx => hx k hk)).trans_eq + (uniformResidueLaw_mod_eq B (p i) (hp i) (hpB i) + (-((wordDisplacement h (w.take k.val) : ℤ) : ZMod (p i)))) + · rw [ite_eq_right hi] + exact FiniteLaw.probability_le_one _ _ + +/-- For an injectively indexed prime pool covering every step factor, the +bound is literally the product over distinct numerical primes in the word. -/ +theorem residuePositiveWord_probability_distinct_primes {ι : Type*} + [Fintype ι] [DecidableEq ι] (B : ℕ) (p : ι → ℕ) + (hinj : Function.Injective p) (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (h : ℕ) (w : List SignedStep) + (hcover : ∀ q ∈ wordDivisorPrimeSupport w, ∃ i, p i = q) : + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).probability + (fun x => ResiduePositiveWord p h w (fun i => ((x i).val : ZMod (p i)))) ≤ + ∏ q ∈ wordDivisorPrimeSupport w, (q : ℝ)⁻¹ := by + have himage : (univ.filter (fun i => p i ∈ wordDivisorPrimeSupport w)).image p = + wordDivisorPrimeSupport w := by + ext q + simp only [mem_image, mem_filter, mem_univ, true_and] + constructor + · rintro ⟨i, hi, rfl⟩ + exact hi + · intro hq + obtain ⟨i, rfl⟩ := hcover q hq + exact ⟨i, hq, rfl⟩ + have hbound := residuePositiveWord_probability_le B p hp hpB h w + rw [← himage, prod_image (fun i _ j _ hij => hinj hij)] + exact hbound + +/-- The finite catalog's modular event is exactly the deleted event at any +common integer lift. Minimality remains in the catalog, not in the random law. -/ +theorem prohibited_residue_catalog_iff {ι : Type*} (p : ι → ℕ) + (pairs : Finset (ℕ × ℕ)) (h s : ℕ) (r : ∀ i, ZMod (p i)) (n : ℤ) + (hn : ∀ i, (n : ZMod (p i)) = r i) + (hsq : ∀ dq ∈ pairs, Squarefree (dq.2 * dq.1)) + (hcover : ∀ c : ProhibitedCatalog pairs h s, + ∀ q ∈ wordDivisorPrimeSupport (decodeStepWord c.val), ∃ i, p i = q) : + (∃ c : ProhibitedCatalog pairs h s, ResiduePositiveWord p h (decodeStepWord c.val) r) ↔ + ProhibitedSite h s (fun d q => (d, q) ∈ pairs) n := by + have he (c : ProhibitedCatalog pairs h s) : + ResiduePositiveWord p h (decodeStepWord c.val) r ↔ + PositiveWord h n (decodeStepWord c.val) := + residuePositiveWord_iff p h _ r n hn + (fun a ha => hsq _ (c.property.1.2.2.1 a ha)) (hcover c) + simp_rw [he] + constructor + · rintro ⟨c, hc⟩ + exact ⟨decodeStepWord c.val, hc, c.property⟩ + · rintro ⟨w, hw, hmin⟩ + obtain ⟨c, hc⟩ := stepWord_covered pairs s w hmin.1.2.1 hmin.1.2.2.1 + refine ⟨⟨c, ?_⟩, ?_⟩ + · simpa only [hc] using hmin + · simpa only [hc] using hw + +/-- A literal union bound for the actual minimal-word catalog. The remaining +arithmetic task is to sum these distinct-prime weights over that catalog. -/ +theorem prohibited_residue_probability_le_catalog {ι : Type*} + [Fintype ι] [DecidableEq ι] (B : ℕ) (p : ι → ℕ) + (hinj : Function.Injective p) (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (pairs : Finset (ℕ × ℕ)) (h s : ℕ) + (hcover : ∀ c : ProhibitedCatalog pairs h s, + ∀ q ∈ wordDivisorPrimeSupport (decodeStepWord c.val), ∃ i, p i = q) : + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).probability + (fun x => ∃ c : ProhibitedCatalog pairs h s, + ResiduePositiveWord p h (decodeStepWord c.val) + (fun i => ((x i).val : ZMod (p i)))) ≤ + ∑ c : ProhibitedCatalog pairs h s, + ∏ q ∈ wordDivisorPrimeSupport (decodeStepWord c.val), (q : ℝ)⁻¹ := by + apply (FiniteLaw.probability_exists_le _ _).trans + apply sum_le_sum + intro c _ + exact residuePositiveWord_probability_distinct_primes B p hinj hp hpB h _ (hcover c) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PowerSmallBall.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PowerSmallBall.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c474122c916411239b3667d84dba30814cefb0f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PowerSmallBall.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.TwoPoint.Bounds.TriangleKernel +import OAI.NumberTheory.TwoPoint.Bounds.PaddingDifferenceLaw + +namespace OAI + +/-! Integrating the `6/5` Fourier decay gives the required reciprocal-scale +small-ball bound, directly for a finite probability law. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +lemma padding_power_integral (L : ℝ) (hL : 0 < L) : + (∫ t in (0 : ℝ)..1, (1 + L * t) ^ (-6 / 5 : ℝ)) ≤ 5 / L := by + have hs := intervalIntegral.integral_comp_mul_add + (a := (0 : ℝ)) (b := 1) (fun x : ℝ => x ^ (-6 / 5 : ℝ)) hL.ne' 1 + have he := integral_rpow (a := (1 : ℝ)) (b := L + 1) (r := (-6 / 5 : ℝ)) + (Or.inr ⟨by norm_num, by + rw [Set.uIcc_of_le (by linarith : (1 : ℝ) ≤ L + 1)] + simp only [Set.mem_Icc, not_and_or] + left + norm_num⟩) + have he' : (∫ x in (1 : ℝ)..L + 1, x ^ (-6 / 5 : ℝ)) = + 5 * (1 - (L + 1) ^ (-1 / 5 : ℝ)) := by + rw [he] + norm_num + ring + have hi : (∫ t in (0 : ℝ)..1, (1 + L * t) ^ (-6 / 5 : ℝ)) = + L⁻¹ * (5 * (1 - (L + 1) ^ (-1 / 5 : ℝ))) := by + have hs' : (∫ t in (0 : ℝ)..1, (L * t + 1) ^ (-6 / 5 : ℝ)) = + L⁻¹ * (∫ x in (1 : ℝ)..L + 1, x ^ (-6 / 5 : ℝ)) := by + simpa only [mul_zero, zero_add, mul_one, smul_eq_mul] using hs + rw [he'] at hs' + simpa only [add_comm] using hs' + have hp : 0 ≤ (L + 1) ^ (-1 / 5 : ℝ) := Real.rpow_nonneg (by linarith) _ + rw [hi] + calc + _ ≤ L⁻¹ * 5 := mul_le_mul_of_nonneg_left (by linarith) (inv_nonneg.mpr hL.le) + _ = _ := by ring + +theorem FiniteLaw.unit_small_ball_of_decay {Ω : Type*} [Fintype Ω] + (μ : FiniteLaw Ω) (Z : Ω → ℝ) (L C : ℝ) (hL : 0 < L) (hC : 0 ≤ C) + (hchar : ∀ t ∈ Set.Icc (0 : ℝ) 1, + μ.average (fun x => Real.cos (t * Z x)) ≤ C * (1 + L * t) ^ (-6 / 5 : ℝ)) : + μ.probability (fun x => |Z x| ≤ 1) ≤ 20 * C / L := by + have hp (t : ℝ) (ht : t ∈ Set.Icc (0 : ℝ) 1) : 0 < 1 + L * t := by + have ht0 := ht.1 + positivity + have hg : IntervalIntegrable (fun t : ℝ => C * (1 + L * t) ^ (-6 / 5 : ℝ)) volume 0 1 := by + apply ContinuousOn.intervalIntegrable_of_Icc (h := by norm_num) + intro t ht + have hpt := hp t ht + have hc : ContinuousAt (fun t : ℝ => 1 + L * t) t := by fun_prop + exact ((hc.rpow_const (Or.inl hpt.ne')).const_mul C).continuousWithinAt + have hf : IntervalIntegrable + (fun t : ℝ => (1 - t) * μ.average (fun x => Real.cos (t * Z x))) volume 0 1 := by + unfold FiniteLaw.average + exact (by fun_prop : Continuous + (fun t : ℝ => (1 - t) * ∑ x, μ.weight x * Real.cos (t * Z x))).intervalIntegrable _ _ + have hm : (∫ t in (0 : ℝ)..1, (1 - t) * μ.average (fun x => Real.cos (t * Z x))) ≤ + C * (5 / L) := by + calc + _ ≤ ∫ t in (0 : ℝ)..1, C * (1 + L * t) ^ (-6 / 5 : ℝ) := by + apply intervalIntegral.integral_mono_on (by norm_num) hf hg + intro t ht + have hh := mul_le_mul_of_nonneg_left (hchar t ht) (sub_nonneg.mpr ht.2) + have hn : 0 ≤ C * (1 + L * t) ^ (-6 / 5 : ℝ) := + mul_nonneg hC (Real.rpow_nonneg (hp t ht).le _) + nlinarith [mul_nonneg ht.1 hn] + _ = C * (∫ t in (0 : ℝ)..1, (1 + L * t) ^ (-6 / 5 : ℝ)) := + intervalIntegral.integral_const_mul _ _ + _ ≤ _ := mul_le_mul_of_nonneg_left (padding_power_integral L hL) hC + apply (μ.unit_small_ball_le Z).trans + calc + _ ≤ 4 * (C * (5 / L)) := mul_le_mul_of_nonneg_left hm (by norm_num) + _ = _ := by ring + +theorem paddingDifference_small_ball (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) + (L C : ℝ) (hL : 0 < L) + (hprime : ∀ t ∈ Set.Icc (0 : ℝ) 1, + (3 / 4 : ℝ) * Real.log (1 + L * |t|) - C ≤ paddingOscillation Q t) : + (paddingDifferenceLaw Q hQ).probability (fun x => |paddingDifferenceValue Q x| ≤ 1) ≤ + 20 * Real.exp ((8 / 5 : ℝ) * C + 64 / 5) / L := by + apply FiniteLaw.unit_small_ball_of_decay _ _ L _ hL (Real.exp_pos _).le + intro t ht + rw [paddingDifference_cosine] + have hh := paddingCharacteristic_power_bound Q hQ L C t hL.le (hprime t ht) + simpa only [abs_of_nonneg ht.1] using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrefixDeletionBridge.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrefixDeletionBridge.lean new file mode 100644 index 0000000000000000000000000000000000000000..587556b12905b9038eb10fa8cabc462f22dadd97 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrefixDeletionBridge.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.TwoPoint.Walks.RetainedDeletionBridge + +namespace OAI + +/-! Sum the pointwise endpoint loss over the same positive prefixes as +the spectral test, retaining every tuple and padding weight. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma normalized_prefix_difference_le (F G : ℕ → ℂ) (cost : ℕ → ℝ) (N : ℕ) + (hb : ∀ n, ‖F n - G n‖ ≤ cost n) : + ‖positivePrefix F N / (N : ℂ) - positivePrefix G N / (N : ℂ)‖ ≤ + uniformAverage (fun x : Fin N => cost (x.val + 1)) := by + rw [← sub_div] + have he : positivePrefix F N - positivePrefix G N = positivePrefix (fun n => F n - G n) N := by + simp only [positivePrefix, sum_sub_distrib] + rw [he, norm_div, Complex.norm_natCast] + unfold positivePrefix uniformAverage + rw [Fintype.card_fin, Fin.sum_univ_eq_sum_range (fun x => cost (x + 1)) N] + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + exact (norm_sum_le _ _).trans (sum_le_sum (fun n _ => hb (n + 1))) + +noncomputable def uncutPrimePrefix {J : ℕ} (P : Fin J → Finset ℕ) + (R : Finset ℕ) (eligible : ℕ → ℕ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (N : ℕ) : ℂ := + positivePrefix (fun n => ∑ d ∈ primeTupleDivisors P, ∑ q ∈ R, + uncutNumericalEdge R eligible h gate d q n ((n : ℤ) + (h * q * d : ℕ))) N / (N : ℂ) + +theorem uncut_sub_retained_prefix_le {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ i, ∀ p ∈ P i, p.Prime) + (hdisjoint : ∀ i k, k ≠ i → Disjoint (P i) (P k)) + (R Q : Finset ℕ) (η : ℝ) (c : ℕ → ℝ) (L K W : ℝ) + (eligible : ℤ → ℕ → ℕ → Prop) (h : ℕ) (gate : ℕ → ℤ → ℤ → Prop) + (bad : ℤ → ℤ → Prop) (j : ℤ) (N : ℕ) + (hsub : ∀ d ∈ primeTupleDivisors P, ∀ q ∈ R, + eligible j d q → actualPaddingBin η (c d) j q) : + ‖uncutPrimePrefix P R (eligible j) h gate N - + retainedPrimePrefix P R Q actualPaddingCoefficient (eligible j) L K W + (fun _ => actualPaddingDegreeCut Q L) h gate (fun z => ¬bad j z) N‖ ≤ + (∑ d ∈ primeTupleDivisors P, ∑ q ∈ R, + uniformAverage (fun x : Fin N => positiveDeletionAtom (primeTuplePool P) Q R + η c L K W eligible bad j d q ((x.val + 1 : ℕ) : ℤ))) + + (∑ d ∈ primeTupleDivisors P, ∑ q ∈ R, + uniformAverage (fun x : Fin N => positiveDeletionAtom (primeTuplePool P) Q R + η c L K W eligible bad j d q (((x.val + 1 : ℕ) : ℤ) + (h * q * d : ℕ)))) := by + rw [retainedPrimePrefix_eq_numerical P hprime hdisjoint] + unfold uncutPrimePrefix + have hb (n : ℕ) : + ‖(∑ d ∈ primeTupleDivisors P, ∑ q ∈ R, + uncutNumericalEdge R (eligible j) h gate d q n ((n : ℤ) + (h * q * d : ℕ))) - + (∑ d ∈ primeTupleDivisors P, ∑ q ∈ R, + retainedNumericalEdge P R Q actualPaddingCoefficient (eligible j) L K W + (fun _ => actualPaddingDegreeCut Q L) h gate (fun z => ¬bad j z) + d q n ((n : ℤ) + (h * q * d : ℕ)))‖ ≤ + ∑ d ∈ primeTupleDivisors P, ∑ q ∈ R, + (positiveDeletionAtom (primeTuplePool P) Q R η c L K W eligible bad j d q n + + positiveDeletionAtom (primeTuplePool P) Q R η c L K W eligible bad j d q + ((n : ℤ) + (h * q * d : ℕ))) := by + simp only [← sum_sub_distrib] + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro d hd + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro q _ + exact uncut_sub_retained_edge_le P R Q η c L K W eligible h gate bad j d q n + (hsub d hd) (primeTupleDivisors_arithmetic P hprime hdisjoint hd).2.1 + have hp := normalized_prefix_difference_le _ _ _ N hb + apply hp.trans_eq + have hadd (f g : Fin N → ℝ) : uniformAverage (fun x => f x + g x) = + uniformAverage f + uniformAverage g := by + simp only [uniformAverage, sum_add_distrib, add_div] + simp only [uniformAverage_finset_sum, hadd, sum_add_distrib] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PreorderNumbering.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PreorderNumbering.lean new file mode 100644 index 0000000000000000000000000000000000000000..089129a6a5c41962e02ae7c85b05c6b2675056e2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PreorderNumbering.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.TwoPoint.Bounds.LabeledForest +import Mathlib.Data.List.Basic + +namespace OAI + +/-! Preorder numbering depends only on the ordered forest shape. -/ + +namespace TwoPointCorrelations + +open BinaryTree + +variable {V W : Type*} + +lemma forest_map_congr (t : BinaryTree V) (f g : V → W) + (h : ∀ x ∈ forestNodes t, f x = g x) : t.map f = t.map g := by + induction t with + | nil => rfl + | node v l r hl hr => + simp only [BinaryTree.map] + congr 1 + · exact h v (by simp [forestNodes]) + · exact hl (fun x hx => h x (by simp [forestNodes, hx])) + · exact hr (fun x hx => h x (by simp [forestNodes, hx])) + + +@[simp] lemma forest_numNodes_map (f : V → W) (t : BinaryTree V) : + (t.map f).numNodes = t.numNodes := by + induction t <;> simp [BinaryTree.map, *] + +def numberForest : BinaryTree V → ℕ → BinaryTree ℕ + | .nil, _ => .nil + | .node _ l r, start => + .node start (numberForest l (start + 1)) (numberForest r (start + 1 + l.numNodes)) + +@[simp] lemma numberForest_map (f : V → W) (t : BinaryTree V) (start : ℕ) : + numberForest (t.map f) start = numberForest t start := by + induction t generalizing start <;> simp [BinaryTree.map, numberForest, *] + +lemma numberForest_eq_map_idxOf [DecidableEq V] (t : BinaryTree V) + (ht : (forestNodes t).Nodup) (start : ℕ) : + numberForest t start = t.map (fun v => start + (forestNodes t).idxOf v) := by + induction t generalizing start with + | nil => rfl + | node v l r hl hr => + have hn := List.nodup_cons.mp ht + have hp := List.nodup_append.mp hn.2 + simp only [numberForest, BinaryTree.map] + congr 1 + · simp [forestNodes] + · rw [hl hp.1 (start + 1)] + apply forest_map_congr + intro x hx + have hv : v ≠ x := by intro heq; subst x; exact hn.1 (List.mem_append_left _ hx) + simp only [forestNodes, List.idxOf_cons_ne _ hv, List.idxOf_append_of_mem hx] + omega + · rw [hr hp.2.1 (start + 1 + l.numNodes)] + apply forest_map_congr + intro x hx + have hv : v ≠ x := by intro heq; subst x; exact hn.1 (List.mem_append_right _ hx) + have hxl : x ∉ forestNodes l := by + intro hxl + exact hp.2.2 x hxl x hx rfl + simp only [forestNodes, List.idxOf_cons_ne _ hv, List.idxOf_append_of_notMem hxl, + forestNodes_length] + omega + +/-- Thus erasing numerical labels preserves the canonical numbered graph. -/ +theorem numberForest_eq_of_same_shape (t : BinaryTree V) (s : BinaryTree W) + (hts : t.map (fun _ => ()) = s.map (fun _ => ())) (start : ℕ) : + numberForest t start = numberForest s start := by + have h := congrArg (fun a => numberForest a start) hts + simpa only [numberForest_map] using h + +lemma preorder_index_injective [DecidableEq V] (t : BinaryTree V) + (hcover : ∀ v, v ∈ forestNodes t) : + Function.Injective (fun v => (forestNodes t).idxOf v) := by + intro x y hxy + exact (List.idxOf_inj (hcover x)).mp hxy + +/-- Numbering transports every edge without retaining its original labels. -/ +theorem numberForest_adjacent [DecidableEq V] (t : BinaryTree V) + (ht : (forestNodes t).Nodup) (hcover : ∀ v, v ∈ forestNodes t) (x y : V) : + forestAdjacent (numberForest t 0) ((forestNodes t).idxOf x) ((forestNodes t).idxOf y) ↔ + forestAdjacent t x y := by + rw [numberForest_eq_map_idxOf t ht 0] + simpa only [zero_add] using forestAdjacent_map + (fun v => (forestNodes t).idxOf v) (preorder_index_injective t hcover) t x y + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeAlphabetSize.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeAlphabetSize.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a77d5ed9096383e779909bb089bba7b3100e457 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeAlphabetSize.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeBlockDimension + +namespace OAI + +/-! The full forced-step alphabet includes all bounded padding divisors. +Its size still fits the polynomial exponential budget of finite-law +comparison; no eligibility restriction is needed for this count. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma boundedPaddingDivisor_real_upper (E : Finset ℕ) (L : ℝ) (hL : 1 ≤ L) + (q : ℕ) (hq : q ∈ boundedPaddingDivisors (paddingPrimeSupply E L) ⌊100 * Real.log L⌋₊) : + (q : ℝ) ≤ Real.exp (100 * L ^ 2) := by + have hr := (mem_filter.mp hq).1 + have hsq := retainedPrimeDivisor_squarefree (paddingPrimeSupply E L) + (fun _ hp => paddingPrimeSupply_prime hp) hr + have hpool := retainedPrimeDivisor_factors (paddingPrimeSupply E L) + (fun _ hp => paddingPrimeSupply_prime hp) hr + have hdeg : (q.primeFactors.card : ℝ) ≤ 100 * Real.log L := + (show (q.primeFactors.card : ℝ) ≤ (⌊100 * Real.log L⌋₊ : ℝ) by + exact_mod_cast (mem_filter.mp hq).2).trans + (Nat.floor_le (mul_nonneg (by norm_num) (Real.log_nonneg hL))) + have hlog : Real.log L ≤ L := + (Real.log_le_sub_one_of_pos (by linarith)).trans (by linarith) + calc + _ = ∏ p ∈ q.primeFactors, (p : ℝ) := by + rw [← Nat.cast_prod, Nat.prod_primeFactors_of_squarefree hsq] + _ ≤ ∏ _p ∈ q.primeFactors, Real.exp L := + prod_le_prod₀ (fun p _ => Nat.cast_nonneg p) + (fun p hp => paddingPrimeSupply_bounds E L (hpool hp)) + _ = Real.exp ((q.primeFactors.card : ℝ) * L) := by + rw [prod_const, Real.exp_nat_mul] + _ ≤ _ := by apply Real.exp_le_exp.mpr; nlinarith + +lemma boundedPaddingDivisors_card (E : Finset ℕ) (L : ℝ) (hL : 1 ≤ L) : + ((boundedPaddingDivisors (paddingPrimeSupply E L) ⌊100 * Real.log L⌋₊).card : ℝ) ≤ + Real.exp (100 * L ^ 2) := by + let Q := boundedPaddingDivisors (paddingPrimeSupply E L) ⌊100 * Real.log L⌋₊ + let N := ⌊Real.exp (100 * L ^ 2)⌋₊ + have hp (q : Q) : 0 < q.val := retainedPrimeDivisor_pos (paddingPrimeSupply E L) + (fun _ hp => paddingPrimeSupply_prime hp) (mem_filter.mp q.property).1 + have hq (q : Q) : q.val ≤ N := + (Nat.le_floor_iff (Real.exp_pos _).le).mpr (boundedPaddingDivisor_real_upper E L hL _ q.property) + let f : Q → Fin N := fun q => ⟨q.val - 1, by have := hp q; have := hq q; omega⟩ + have hf : Function.Injective f := by + intro a b hab + apply Subtype.ext + have he : a.val - 1 = b.val - 1 := congrArg Fin.val hab + have ha := hp a + have hb := hp b + omega + have hc : Q.card ≤ N := by + simpa only [Fintype.card_coe, Fintype.card_fin] using Fintype.card_le_of_injective f hf + exact (show (Q.card : ℝ) ≤ N by exact_mod_cast hc).trans (Nat.floor_le (Real.exp_pos _).le) + +lemma actual_prime_alphabet_size (E : Finset ℕ) (W L : ℝ) (hW : 1 ≤ W) (hL : 4800 ≤ L) : + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := boundedPaddingDivisors (paddingPrimeSupply E L) ⌊100 * Real.log L⌋₊ + (Fintype.card (((j : Fin J) → P j) × (Q × Bool)) : ℝ) ≤ Real.exp (L ^ 4) := by + dsimp only + let J := primeSupplyCount W L + let A := L ^ (199 / 200 : ℝ) + let P := centeredPrimeBands E A W J + have hA : 0 < A := Real.rpow_pos_of_pos (by linarith) _ + have hend : primeSupplyEndpoint A W J ≤ L := primeSupplyScale_endpoint W L (by linarith) (by linarith) + have hd : Fintype.card ((j : Fin J) → P j) ≤ ⌊Real.exp (2 * L)⌋₊ := by + apply primeTuple_card_le P (centeredPrimeBands_prime E A W J) + (centeredPrimeBands_disjoint E A W J hA.le (by linarith)) + intro d + exact centeredPrimeTuple_upper E A W L J hA hW hend (mem_image.mpr ⟨d, mem_univ _, rfl⟩) + have hd' : (Fintype.card ((j : Fin J) → P j) : ℝ) ≤ Real.exp (2 * L) := + (show (Fintype.card ((j : Fin J) → P j) : ℝ) ≤ (⌊Real.exp (2 * L)⌋₊ : ℝ) by exact_mod_cast hd).trans + (Nat.floor_le (Real.exp_pos _).le) + have hq := boundedPaddingDivisors_card E L (by linarith) + have htwo : (2 : ℝ) ≤ Real.exp L := by linarith [Real.add_one_le_exp L] + simp only [Fintype.card_prod, Fintype.card_coe, Fintype.card_bool, Nat.cast_mul, Nat.cast_ofNat] + calc + _ ≤ Real.exp (2 * L) * (Real.exp (100 * L ^ 2) * Real.exp L) := by gcongr + _ = Real.exp (100 * L ^ 2 + 3 * L) := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have hL2 : 103 ≤ L ^ 2 := by nlinarith + nlinarith [mul_nonneg (show 0 ≤ L ^ 2 - 103 by linarith) (sq_nonneg L)] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeBlockDimension.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeBlockDimension.lean new file mode 100644 index 0000000000000000000000000000000000000000..94780a803e0bbcd9ec1126eacfcc119347090c2e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeBlockDimension.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualPrimeScale + +namespace OAI + +/-! The actual tuple copies and the length-exp(103L) block fit the +exp(106L) starting-vertex allowance in the matrix trace. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma primeTuple_card_le {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) (Dmax : ℕ) + (hmax : ∀ d : (j : Fin J) → P j, (∏ j, (d j).val) ≤ Dmax) : + Fintype.card ((j : Fin J) → P j) ≤ Dmax := by + have hp (d : (j : Fin J) → P j) : 0 < ∏ j, (d j).val := + prod_pos (fun j _ => (hprime j _ (d j).property).pos) + let f : ((j : Fin J) → P j) → Fin Dmax := fun d => + ⟨(∏ j, (d j).val) - 1, by have := hmax d; have := hp d; omega⟩ + have hf : Function.Injective f := by + intro a b hab + apply primeTuple_injective hprime hdisjoint + have he := congrArg Fin.val hab + have ha := hp a + have hb := hp b + change (∏ j, (a j).val) - 1 = (∏ j, (b j).val) - 1 at he + change (∏ j, (a j).val) = (∏ j, (b j).val) + omega + simpa only [Fintype.card_fin] using Fintype.card_le_of_injective f hf + +theorem actual_prime_block_dimension (E : Finset ℕ) (W L : ℝ) + (hW : 1 ≤ W) (hL : 1 ≤ L) : + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + (Fintype.card (((j : Fin J) → P j) × Fin ⌈Real.exp (103 * L)⌉₊) : ℝ) ≤ + Real.exp (106 * L) := by + dsimp only + let J := primeSupplyCount W L + let A := L ^ (199 / 200 : ℝ) + let P := centeredPrimeBands E A W J + have hA : 0 < A := Real.rpow_pos_of_pos (zero_lt_one.trans_le hL) _ + have hend : primeSupplyEndpoint A W J ≤ L := + primeSupplyScale_endpoint W L (zero_lt_one.trans_le hW) hL + have hd : Fintype.card ((j : Fin J) → P j) ≤ ⌊Real.exp (2 * L)⌋₊ := by + apply primeTuple_card_le P (centeredPrimeBands_prime E A W J) + (centeredPrimeBands_disjoint E A W J hA.le (zero_le_one.trans hW)) + intro d + exact centeredPrimeTuple_upper E A W L J hA hW hend (mem_image.mpr ⟨d, mem_univ _, rfl⟩) + have hdc : (Fintype.card ((j : Fin J) → P j) : ℝ) ≤ (⌊Real.exp (2 * L)⌋₊ : ℝ) := by + exact_mod_cast hd + have hd' : (Fintype.card ((j : Fin J) → P j) : ℝ) ≤ Real.exp (2 * L) := + hdc.trans (Nat.floor_le (Real.exp_pos _).le) + have hm : (⌈Real.exp (103 * L)⌉₊ : ℝ) ≤ 2 * Real.exp (103 * L) := by + have he := Real.one_le_exp (show 0 ≤ 103 * L by linarith) + have hc : (⌈Real.exp (103 * L)⌉₊ : ℝ) ≤ Real.exp (103 * L) + 1 := + (Nat.ceil_lt_add_one (show 0 ≤ Real.exp (103 * L) from (Real.exp_pos _).le)).le + linarith + rw [Fintype.card_prod, Fintype.card_fin, Nat.cast_mul] + calc + _ ≤ Real.exp (2 * L) * (2 * Real.exp (103 * L)) := + mul_le_mul hd' hm (Nat.cast_nonneg _) (Real.exp_pos _).le + _ = 2 * (Real.exp (2 * L) * Real.exp (103 * L)) := by ring + _ = 2 * Real.exp (105 * L) := by rw [← Real.exp_add]; congr 2; ring + _ ≤ Real.exp L * Real.exp (105 * L) := by + apply mul_le_mul_of_nonneg_right _ (Real.exp_pos _).le + linarith [Real.add_one_le_exp L] + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeComplexMatrix.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeComplexMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b07419fb916e0f4794662f9c5d8379d1d1c7a75 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeComplexMatrix.lean @@ -0,0 +1,114 @@ +import OAI.NumberTheory.TwoPoint.Walks.RetainedComplexMatrix +import OAI.NumberTheory.TwoPoint.Bounds.PrimeLiouvilleQuadratic +import OAI.NumberTheory.TwoPoint.Bounds.ProjectedLiouvilleVector + +namespace OAI + +/-! The canonical tuple graph has the same retained real kernel for all bounded tests. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def retainedPrimeMatrix {J : ℕ} {V : Type*} [Fintype V] + (P : Fin J → Finset ℕ) (site : V → ℤ) (Q : Finset ℕ) + (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) (g : ℤ → ℝ) + (L K : ℝ) (extra : ℕ → ℤ → Prop) (keep : ℤ → Prop) (h : ℕ) + (gate : ℕ → V → V → Prop) : Matrix V V ℂ := + ∑ d : (j : Fin J) → P j, retainedDirectedMatrix site Q u + (eligible (∏ j, (d j).val)) g (centeredTuple (∏ j, (d j).val).primeFactors) + L K (extra (∏ j, (d j).val)) keep h (∏ j, (d j).val) (gate (∏ j, (d j).val)) + +theorem prime_graph_retained_bilinear {J : ℕ} {V : Type*} [Fintype V] [DecidableEq V] + (P : Fin J → Finset ℕ) (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (site : V → ℤ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) (keep : ℤ → Prop) (h : ℕ) + (gate : ℕ → V → V → Prop) (hgate : ∀ d i j, gate d i j ↔ gate d j i) + (hg : ∀ z, g z ≠ 0) (F G : ℤ → ℂ) : + let vf := WithLp.toLp 2 (fun i => retainedComplexScalar g keep (fun z => star (F z)) (site i)) + let vg := WithLp.toLp 2 (fun i => retainedComplexScalar g keep G (site i)) + let A := retainedPrimeMatrix P site Q u eligible g L K extra keep h gate + inner ℂ vf ((∑ d, primeFamilyGraphOperator (fun j (p : P j) => p.val) + (fun _ _ => 0) site Q u eligible g L K extra h gate d) vg) = + ∑ i, ∑ j, F (site i) * G (site j) * (A i j + A j i) := by + dsimp only + let vf : EuclideanSpace ℂ V := WithLp.toLp 2 + (fun i => retainedComplexScalar g keep (fun z => star (F z)) (site i)) + let vg : EuclideanSpace ℂ V := WithLp.toLp 2 + (fun i => retainedComplexScalar g keep G (site i)) + have hd (d : (j : Fin J) → P j) : + inner ℂ vf (primeFamilyGraphOperator (fun j (p : P j) => p.val) + (fun _ _ => 0) site Q u eligible g L K extra h gate d vg) = + ∑ i, ∑ j, F (site i) * G (site j) * + (retainedDirectedMatrix site Q u (eligible (∏ j, (d j).val)) g + (centeredTuple (∏ j, (d j).val).primeFactors) L K + (extra (∏ j, (d j).val)) keep h (∏ j, (d j).val) (gate (∏ j, (d j).val)) i j + + retainedDirectedMatrix site Q u (eligible (∏ j, (d j).val)) g + (centeredTuple (∏ j, (d j).val).primeFactors) L K + (extra (∏ j, (d j).val)) keep h (∏ j, (d j).val) (gate (∏ j, (d j).val)) j i) := by + have hc : familyCenter (fun j (p : P j) => p.val) (fun _ _ => 0) d = + centeredTuple (∏ j, (d j).val).primeFactors := by + funext n + exact familyCenter_zero_eq_centeredTuple _ (fun j p => hprime j _ p.property) + d (selectedPrimeValues_injective d hdisjoint) n + unfold primeFamilyGraphOperator + rw [hc] + exact retained_matrix_bilinear site Q u _ g _ L K _ keep h _ _ (hgate _) hg F G + change inner ℂ vf ((∑ d, primeFamilyGraphOperator (fun j (p : P j) => p.val) + (fun _ _ => 0) site Q u eligible g L K extra h gate d) vg) = _ + rw [_root_.sum_apply, inner_sum] + simp_rw [hd] + rw [sum_comm] + apply sum_congr rfl + intro i _ + rw [sum_comm] + apply sum_congr rfl + intro j _ + simp only [retainedPrimeMatrix, Matrix.sum_apply, ← mul_sum, ← sum_add_distrib] + +lemma projectedComplexVector_eq {V : Type*} [Fintype V] [DecidableEq V] + (Q : Finset ℕ) (L : ℝ) (site : V → ℤ) (keep : ℤ → Prop) (F : ℤ → ℂ) : + coordinateProjection (fun i => keep (site i)) (paddingTestVector Q L site F) = + WithLp.toLp 2 (fun i => retainedComplexScalar (actualPaddingVertex Q) + (fun n => keep n ∧ actualPaddingDegreeCut Q L n) F (site i)) := by + ext i + by_cases hp : keep (site i) <;> by_cases hq : actualPaddingDegreeCut Q L (site i) <;> + simp [coordinateProjection_apply, paddingTestVector, retainedComplexScalar, hp, hq] + +theorem projected_prime_complex_bilinear {J : ℕ} {V : Type*} [Fintype V] [DecidableEq V] + (P : Fin J → Finset ℕ) (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (site : V → ℤ) (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → V → V → Prop) (hgate : ∀ d i j, gate d i j ↔ gate d j i) + (F G : ℤ → ℂ) : + let B := primeFamilyGraphOperator (fun j (p : P j) => p.val) (fun _ _ => 0) + site Q u eligible (actualPaddingVertex Qp) L K extra h gate + let keep := fun n => (actualPaddingDegree (univ.biUnion P) n : ℝ) ≤ 6 * W * J + let proj := coordinateProjection (fun i => keep (site i)) + let vf := paddingTestVector Qp L site (fun n => star (F n)) + let vg := paddingTestVector Qp L site G + let A := retainedPrimeMatrix P site Q u eligible (actualPaddingVertex Qp) L K extra + (fun n => keep n ∧ actualPaddingDegreeCut Qp L n) h gate + inner ℂ vf ((proj * (∑ d, B d) * proj) vg) = + ∑ i, ∑ j, F (site i) * G (site j) * (A i j + A j i) := by + dsimp only + let keep := fun n => (actualPaddingDegree (univ.biUnion P) n : ℝ) ≤ 6 * W * J + let proj := coordinateProjection (fun i => keep (site i)) + let B := primeFamilyGraphOperator (fun j (p : P j) => p.val) (fun _ _ => 0) + site Q u eligible (actualPaddingVertex Qp) L K extra h gate + let vf := paddingTestVector Qp L site (fun n => star (F n)) + let vg := paddingTestVector Qp L site G + have he := (coordinateProjection_selfAdjoint (fun i => keep (site i))).isSymmetric + vf ((∑ d, B d) (proj vg)) + have hmain := prime_graph_retained_bilinear P hprime hdisjoint site Q u eligible + (actualPaddingVertex Qp) L K extra (fun n => keep n ∧ actualPaddingDegreeCut Qp L n) + h gate hgate (actualPaddingVertex_ne_zero Qp) F G + rw [← projectedComplexVector_eq, ← projectedComplexVector_eq] at hmain + exact he.symm.trans hmain + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeCoordinates.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..86e26e872519388089c58983c76091152a85d410 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeCoordinates.lean @@ -0,0 +1,41 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeLiteralEncoding +import OAI.NumberTheory.TwoPoint.Bounds.ResidueRestriction +import OAI.NumberTheory.TwoPoint.Bounds.ResidueLawUniform + +namespace OAI + +/-! The common padded prime law in the canonical finite coordinate order. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +local instance canonicalPrime_neZero {h J M : ℕ} (data : ProhibitedPrimeFamily h J M) + (i : Fin (Fintype.card ↥(data.P ∪ data.Q))) : + NeZero (primeResidueModuli (data.P ∪ data.Q) i) := + ⟨(primeResidueModuli_prime _ (fun p hp => data.prime ⟨p, hp⟩) i).ne_zero⟩ + +lemma ProhibitedPrimeFamily.residue_average_canonical {h J M B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (F : (∀ i, ZMod (primeResidueModuli (data.P ∪ data.Q) i)) → ℝ) : + (data.residueLaw B hB).average + (fun x => F (fun i => (x ((Fintype.equivFin ↥(data.P ∪ data.Q)).symm i)).val)) = + uniformAverage F := by + unfold ProhibitedPrimeFamily.residueLaw + rw [FiniteLaw.independent_average_reindex (Fintype.equivFin ↥(data.P ∪ data.Q)).symm] + simp only [Equiv.symm_symm, Equiv.apply_symm_apply] + exact uniformResidue_product_average B (primeResidueModuli (data.P ∪ data.Q)) + (fun i => (data.prime _).pos) (fun i => hB _ ((Fintype.equivFin ↥(data.P ∪ data.Q)).symm i).property) F + +lemma ProhibitedPrimeFamily.canonical_origin {h J M B : ℕ} + (data : ProhibitedPrimeFamily h J M) (x : ↥(data.P ∪ data.Q) → Fin B) : + (fun i => (data.residueOrigin x : ZMod (primeResidueModuli (data.P ∪ data.Q) i))) = + (fun i => ((x ((Fintype.equivFin ↥(data.P ∪ data.Q)).symm i)).val : + ZMod (primeResidueModuli (data.P ∪ data.Q) i))) := by + funext i + exact data.residueOrigin_spec x ((Fintype.equivFin ↥(data.P ∪ data.Q)).symm i) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeCostTails.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeCostTails.lean new file mode 100644 index 0000000000000000000000000000000000000000..7cddaab316cd324fe5c63851a058c3291d78b034 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeCostTails.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MultiplicativePrimeProducts +import Mathlib.Analysis.Normed.Group.InfiniteSum +import Mathlib.Analysis.PSeries + +namespace OAI + +/-! A fixed finite exclusion set makes all later finite prime costs small. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma summable_prime_cost_tail (r : ℕ → ℝ) + (hr : ∀ p, p.Prime → 0 ≤ r p) + (hs : Summable (fun p : ℕ => if p.Prime then r p else 0)) + (E₀ : Finset ℕ) (ε : ℝ) (hε : 0 < ε) : + ∃ E : Finset ℕ, E₀ ⊆ E ∧ ∀ P : Finset ℕ, + (∀ p ∈ P, p.Prime) → Disjoint P E → (∑ p ∈ P, r p) < ε := by + obtain ⟨S, hS⟩ := summable_iff_vanishing_norm.mp hs ε hε + refine ⟨E₀ ∪ S, subset_union_left, ?_⟩ + intro P hP hdis + have hd : Disjoint P S := hdis.mono_right subset_union_right + have hh := hS P hd + have he : (∑ p ∈ P, if p.Prime then r p else 0) = ∑ p ∈ P, r p := by + apply sum_congr rfl + intro p hp + rw [ite_eq_left (hP p hp)] + rw [he, Real.norm_eq_abs, abs_of_nonneg (sum_nonneg (fun p hp => hr p (hP p hp)))] at hh + exact hh + +lemma pair_prime_defect_summable {f g : ℕ → ℂ} + (hf : OneBounded f) (hg : OneBounded g) + (hsf : Summable (fun p : ℕ => if p.Prime then (1 - ‖f p‖) / (p : ℝ) else 0)) + (hsg : Summable (fun p : ℕ => if p.Prime then (1 - ‖g p‖) / (p : ℝ) else 0)) : + Summable (fun p : ℕ => if p.Prime then (1 - ‖f p * g p‖) / (p : ℝ) else 0) := by + apply Summable.of_nonneg_of_le _ _ (hsf.add hsg) + · intro p + split_ifs with hp + · apply div_nonneg _ (Nat.cast_nonneg p) + rw [norm_mul] + exact sub_nonneg.mpr ((mul_le_mul (hf p hp.pos) (hg p hp.pos) + (norm_nonneg _) zero_le_one).trans (by norm_num)) + · exact le_rfl + · intro p + by_cases hp : p.Prime + · simp only [hp, ite_true] + rw [← add_div] + exact div_le_div_of_nonneg_right (prime_product_pair_defect hf hg p hp.pos) + (Nat.cast_nonneg p) + · simp only [hp, ite_false, add_zero, le_refl] + +lemma exists_prime_defect_exclusion {f g : ℕ → ℂ} + (hf : OneBounded f) (hg : OneBounded g) + (hsf : Summable (fun p : ℕ => if p.Prime then (1 - ‖f p‖) / (p : ℝ) else 0)) + (hsg : Summable (fun p : ℕ => if p.Prime then (1 - ‖g p‖) / (p : ℝ) else 0)) + (E₀ : Finset ℕ) (ε : ℝ) (hε : 0 < ε) : + ∃ E : Finset ℕ, E₀ ⊆ E ∧ ∀ P : Finset ℕ, + (∀ p ∈ P, p.Prime) → Disjoint P E → + (∑ p ∈ P, (1 - ‖f p * g p‖) / (p : ℝ)) < ε ∧ + (∑ p ∈ P, 1 / (p : ℝ) ^ 2) < ε := by + have hd := pair_prime_defect_summable hf hg hsf hsg + have hsq : Summable (fun p : ℕ => if p.Prime then 1 / (p : ℝ) ^ 2 else 0) := by + apply Summable.of_nonneg_of_le (fun p => by positivity) _ + (Real.summable_one_div_nat_pow.mpr (by norm_num : 1 < (2 : ℕ))) + intro p + split_ifs <;> first | exact le_rfl | positivity + obtain ⟨E₁, hE₁, htail₁⟩ := summable_prime_cost_tail + (fun p => (1 - ‖f p * g p‖) / (p : ℝ)) (fun p hp => by + apply div_nonneg _ (Nat.cast_nonneg p) + rw [norm_mul] + exact sub_nonneg.mpr ((mul_le_mul (hf p hp.pos) (hg p hp.pos) + (norm_nonneg _) zero_le_one).trans (by norm_num))) hd E₀ ε hε + obtain ⟨E₂, hE₂, htail₂⟩ := summable_prime_cost_tail + (fun p => 1 / (p : ℝ) ^ 2) (fun p _ => by positivity) hsq E₁ ε hε + refine ⟨E₂, hE₁.trans hE₂, ?_⟩ + intro P hP hPE + exact ⟨htail₁ P hP (hPE.mono_right hE₂), htail₂ P hP hPE⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeCountDilation.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeCountDilation.lean new file mode 100644 index 0000000000000000000000000000000000000000..d36fb545e88f5faa9484e447523ce9f028141e2b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeCountDilation.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FourierPrimeCutoff + +namespace OAI + +/-! Extracting `x=u*z` from the core-prime cutoff. Primes excluded because +they divide `u` do not reappear in the count, even at exceptional integers +where the multiplicative functions themselves cannot yet be factored. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma finitePrimeDivisorCount_mul_of_avoids (P : Finset ℕ) + (hP : ∀ p ∈ P, Nat.Prime p) (u n : ℕ) (hu : ∀ p ∈ P, ¬p ∣ u) : + finitePrimeDivisorCount P (u * n) = finitePrimeDivisorCount P n := by + unfold finitePrimeDivisorCount + apply sum_congr rfl + intro p hp + simp only [(hP p hp).dvd_mul, hu p hp, false_or] + +lemma finitePrimeDivisorCount_filter_mul (C : Finset ℕ) + (hC : ∀ p ∈ C, Nat.Prime p) (u n : ℕ) : + finitePrimeDivisorCount (C.filter (fun p => ¬p ∣ u)) (u * n) = + finitePrimeDivisorCount (C.filter (fun p => ¬p ∣ u)) n := by + apply finitePrimeDivisorCount_mul_of_avoids + · intro p hp + exact hC p (mem_filter.mp hp).1 + · intro p hp + exact (mem_filter.mp hp).2 + +/-- The expanded divisor `d` and retained divisor `u` have the same core +prime factors, so the core cutoff depends only on the reduced variable. -/ +lemma finitePrimeDivisorCount_same_core_factors (C : Finset ℕ) + (hC : ∀ p ∈ C, Nat.Prime p) (d u n : ℕ) + (hcore : ∀ p ∈ C, p ∣ d ↔ p ∣ u) : + finitePrimeDivisorCount (C.filter (fun p => ¬p ∣ d)) (u * n) = + finitePrimeDivisorCount (C.filter (fun p => ¬p ∣ u)) n := by + have heq : C.filter (fun p => ¬p ∣ d) = C.filter (fun p => ¬p ∣ u) := by + ext p + by_cases hp : p ∈ C + · simp only [mem_filter, hp, true_and, hcore p hp] + · simp only [mem_filter, hp, false_and] + rw [heq, finitePrimeDivisorCount_filter_mul C hC u n] + +lemma primeCountCutoff_same_core_factors (C : Finset ℕ) + (hC : ∀ p ∈ C, Nat.Prime p) (d u n : ℕ) + (hcore : ∀ p ∈ C, p ∣ d ↔ p ∣ u) (μ σ : ℝ) (w : ℝ → ℂ) : + primeCountCutoff (C.filter (fun p => ¬p ∣ d)) μ σ w (u * n) = + primeCountCutoff (C.filter (fun p => ¬p ∣ u)) μ σ w n := by + rw [primeCountCutoff_eq_fourierInv, primeCountCutoff_eq_fourierInv, + finitePrimeDivisorCount_same_core_factors C hC d u n hcore] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectBias.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectBias.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc983dd3d28b2b72a3ce5b9a4f26c5b468ab3e04 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectBias.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeDefectLimit +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftBoundary + +namespace OAI + +/-! Persistent ordinary two-point bias forces finite reciprocal prime-modulus +defect for both factors. This is an elementary consequence of the p² CRT +majorant, with no additional mean-value input. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Topology + +lemma shifted_modulus_sum_le {g : ℕ → ℂ} (hg : OneBounded g) (N h : ℕ) : + (∑ n ∈ range N, ‖g (n + 1 + h)‖) ≤ + (∑ n ∈ range N, ‖g (n + 1)‖) + h := by + have hleft := sum_range_add (fun n => ‖g (n + 1)‖) h N + have hright := sum_range_add (fun n => ‖g (n + 1)‖) N h + have he : (∑ n ∈ range h, ‖g (n + 1)‖) + + (∑ n ∈ range N, ‖g (n + 1 + h)‖) = + (∑ n ∈ range N, ‖g (n + 1)‖) + + (∑ n ∈ range h, ‖g (n + 1 + N)‖) := by + simpa only [Nat.add_comm, Nat.add_left_comm, Nat.add_assoc] using hleft.symm.trans + ((congrArg (fun K => ∑ n ∈ range K, ‖g (n + 1)‖) (Nat.add_comm h N)).trans hright) + have hn : 0 ≤ ∑ n ∈ range h, ‖g (n + 1)‖ := sum_nonneg (fun _ _ => norm_nonneg _) + have ht : (∑ n ∈ range h, ‖g (n + 1 + N)‖) ≤ (h : ℝ) := by + calc + _ ≤ ∑ _n ∈ range h, (1 : ℝ) := sum_le_sum (fun n _ => hg _ (by omega)) + _ = _ := by simp + linarith + +lemma normalized_correlation_le_first_modulus {f g : ℕ → ℂ} (hg : OneBounded g) + (h N : ℕ) : + ‖positivePrefix (fun n => f n * g (n + h)) N / (N : ℂ)‖ ≤ + (∑ n ∈ range N, ‖f (n + 1)‖) / (N : ℝ) := by + rw [norm_div, Complex.norm_natCast] + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg N) + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro n _ + rw [norm_mul] + exact (mul_le_mul_of_nonneg_left (hg _ (by omega)) (norm_nonneg _)).trans_eq (mul_one _) + +lemma normalized_correlation_le_second_modulus {f g : ℕ → ℂ} (hf : OneBounded f) + (hg : OneBounded g) (h N : ℕ) : + ‖positivePrefix (fun n => f n * g (n + h)) N / (N : ℂ)‖ ≤ + (∑ n ∈ range N, ‖g (n + 1)‖) / (N : ℝ) + (h : ℝ) / N := by + rw [← add_div, norm_div, Complex.norm_natCast] + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg N) + apply le_trans _ (shifted_modulus_sum_le hg N h) + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro n _ + rw [norm_mul] + exact (mul_le_mul_of_nonneg_right (hf _ (by omega)) (norm_nonneg _)).trans_eq (one_mul _) + +theorem correlation_zero_of_first_modulus_mean_zero {f g : ℕ → ℂ} + (hg : OneBounded g) (h : ℕ) + (hz : Tendsto (fun N : ℕ => (∑ n ∈ range N, ‖f (n + 1)‖) / (N : ℝ)) + atTop (𝓝 0)) : + Tendsto (fun N : ℕ => positivePrefix (fun n => f n * g (n + h)) N / (N : ℂ)) + atTop (𝓝 0) := by + apply tendsto_zero_iff_norm_tendsto_zero.mpr + exact squeeze_zero (fun _ => norm_nonneg _) (normalized_correlation_le_first_modulus hg h) hz + +theorem correlation_zero_of_second_modulus_mean_zero {f g : ℕ → ℂ} + (hf : OneBounded f) (hg : OneBounded g) (h : ℕ) + (hz : Tendsto (fun N : ℕ => (∑ n ∈ range N, ‖g (n + 1)‖) / (N : ℝ)) + atTop (𝓝 0)) : + Tendsto (fun N : ℕ => positivePrefix (fun n => f n * g (n + h)) N / (N : ℂ)) + atTop (𝓝 0) := by + apply tendsto_zero_iff_norm_tendsto_zero.mpr + have ht := hz.add (tendsto_const_div_atTop_nhds_zero_nat (h : ℝ)) + simp only [zero_add] at ht + exact squeeze_zero (fun _ => norm_nonneg _) + (normalized_correlation_le_second_modulus hf hg h) ht + +theorem persistent_correlation_prime_defects {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf : OneBounded f) (hg : OneBounded g) (h : ℕ) + (hbias : ¬Tendsto + (fun N : ℕ => positivePrefix (fun n => f n * g (n + h)) N / (N : ℂ)) + atTop (𝓝 0)) : + Summable (primeModulusDefect f) ∧ Summable (primeModulusDefect g) := by + constructor + · by_contra hn + exact hbias (correlation_zero_of_first_modulus_mean_zero hg h + (mean_modulus_zero_of_not_summable_prime_defect hfm hf hn)) + · by_contra hn + exact hbias (correlation_zero_of_second_modulus_mean_zero hf hg h + (mean_modulus_zero_of_not_summable_prime_defect hgm hg hn)) + +theorem persistent_correlation_one_values {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) (h : ℕ) + (hbias : ¬Tendsto + (fun N : ℕ => positivePrefix (fun n => f n * g (n + h)) N / (N : ℂ)) + atTop (𝓝 0)) : f 1 = 1 ∧ g 1 = 1 := by + have hzero (hz : ∀ n, 0 < n → f n * g (n + h) = 0) : False := by + apply hbias + have he : (fun N : ℕ => positivePrefix (fun n => f n * g (n + h)) N / (N : ℂ)) = + fun _ => 0 := by + funext N + unfold positivePrefix + rw [sum_eq_zero (fun n _ => hz _ (by omega)), zero_div] + rw [he] + exact tendsto_const_nhds + constructor + · by_contra hn + exact hzero (fun n hnpos => by rw [hfm.eq_zero_of_one_ne hn n hnpos, zero_mul]) + · by_contra hn + exact hzero (fun n hnpos => by rw [hgm.eq_zero_of_one_ne hn (n + h) (by omega), mul_zero]) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectCRT.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectCRT.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4ed3493371e6e01249407bb560e467112b8a5e1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectCRT.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeDefectMean +import OAI.NumberTheory.TwoPoint.Bounds.CRTComparison + +namespace OAI + +/-! The ordinary mean of the finite prime-defect majorant is computed by +CRT modulo the squared primes. Only the finite interval boundary remains. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma uniformAverage_pi_product {ι : Type*} [Fintype ι] [DecidableEq ι] + (β : ι → Type*) [∀ i, Fintype (β i)] (F : ∀ i, β i → ℝ) : + uniformAverage (fun r : ∀ i, β i => ∏ i, F i (r i)) = + ∏ i, uniformAverage (F i) := by + unfold uniformAverage + rw [Fintype.card_pi, Nat.cast_prod, ← Fintype.prod_sum, prod_div_distrib] + +lemma primeDefectMajorant_crt_bound {f : ℕ → ℂ} + (hfm : Multiplicative f) (hf1 : f 1 = 1) (hf : OneBounded f) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (N : ℕ) (hN : 0 < N) : + (∑ n ∈ range N, ‖f (n + 1)‖) / (N : ℝ) ≤ + (∏ p ∈ P, (1 - (1 - ‖f p‖) * (1 / (p : ℝ) - 1 / (p : ℝ) ^ 2))) + + (∏ p ∈ P, (p : ℝ) ^ 2) / N := by + let s : P → ℕ := fun p => p.val ^ 2 + let : ∀ p : P, NeZero (s p) := fun p => ⟨pow_ne_zero _ (hP p.val p.property).ne_zero⟩ + let F : (∀ p : P, ZMod (s p)) → ℝ := fun r => + ∏ p : P, primeDefectLocal f p.val (r p).val + have hcop : Pairwise (fun p q : P => (s p).Coprime (s q)) := by + intro p q hpq + have hp : p.val.Coprime q.val := (Nat.coprime_primes + (hP p.val p.property) (hP q.val q.property)).mpr (by + intro h + exact hpq (Subtype.ext h)) + exact (hp.pow_left 2).pow_right 2 + have hF : ∀ r, |F r| ≤ 1 := by + intro r + have hn : 0 ≤ F r := prod_nonneg (fun p _ => primeDefectLocal_nonneg f _ _) + rw [abs_of_nonneg hn] + exact prod_le_one₀ (fun p _ => primeDefectLocal_nonneg f _ _) + (fun p _ => primeDefectLocal_le_one hf (hP p.val p.property) _) + have hmodel : uniformAverage F = + ∏ p ∈ P, (1 - (1 - ‖f p‖) * (1 / (p : ℝ) - 1 / (p : ℝ) ^ 2)) := by + change uniformAverage (fun r : ∀ p : P, ZMod (s p) => + ∏ p : P, primeDefectLocal f p.val (r p).val) = _ + rw [uniformAverage_pi_product (fun p : P => ZMod (s p)) + (fun p r => primeDefectLocal f p.val r.val)] + calc + _ = ∏ p : P, (1 - (1 - ‖f p.val‖) * + (1 / (p.val : ℝ) - 1 / (p.val : ℝ) ^ 2)) := by + apply prod_congr rfl + intro p _ + exact primeDefectLocal_average f (hP p.val p.property) + _ = _ := prod_coe_sort P (fun p : ℕ => + 1 - (1 - ‖f p‖) * (1 / (p : ℝ) - 1 / (p : ℝ) ^ 2)) + have hpoint (n : ℕ) : + F (ZMod.prodEquivPi s hcop (n : ZMod (∏ p : P, s p))) = + primeDefectMajorant f P n := by + have he : ZMod.prodEquivPi s hcop (n : ZMod (∏ p : P, s p)) = + fun p => (n : ZMod (s p)) := by + funext p + simp only [ZMod.prodEquivPi_apply] + exact ZMod.cast_natCast (dvd_prod_of_mem s (mem_univ p)) n + rw [he] + change (∏ p : P, primeDefectLocal f p.val (n : ZMod (s p)).val) = _ + simp only [ZMod.val_natCast, s, primeDefectLocal_mod] + exact prod_coe_sort P (fun p => primeDefectLocal f p n) + have he := crt_observable_difference s hcop (1 : ZMod (∏ p : P, s p)) N hN F hF + have hreal : uniformAverage (fun j : Fin N => + F (ZMod.prodEquivPi s hcop (1 + (j.val : ZMod (∏ p : P, s p))))) = + (∑ n ∈ range N, primeDefectMajorant f P (n + 1)) / (N : ℝ) := by + unfold uniformAverage + rw [Fintype.card_fin, ← Fin.sum_univ_eq_sum_range] + congr 1 + apply sum_congr rfl + intro j _ + change F (ZMod.prodEquivPi s hcop (1 + (j.val : ZMod (∏ p : P, s p)))) = _ + rw [show (1 : ZMod (∏ p : P, s p)) + (j.val : ZMod (∏ p : P, s p)) = + ((j.val + 1 : ℕ) : ZMod (∏ p : P, s p)) by push_cast; ring, hpoint] + rw [hreal, hmodel] at he + have hprod : ((∏ p : P, s p : ℕ) : ℝ) = ∏ p ∈ P, (p : ℝ) ^ 2 := by + simp only [Nat.cast_prod, s, Nat.cast_pow] + exact prod_coe_sort P (fun p : ℕ => (p : ℝ) ^ 2) + rw [hprod] at he + apply (div_le_div_of_nonneg_right + (sum_le_sum (fun n _ => norm_le_primeDefectMajorant hfm hf1 hf P hP (n + 1) (by omega))) + (Nat.cast_nonneg N)).trans + have hb := le_trans (le_abs_self _) he + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectLimit.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4ef392250612ba14d333215b3a4318d8ebb326d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectLimit.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeModulusDefect +import Mathlib.Analysis.SpecificLimits.Basic + +namespace OAI + +/-! Divergent reciprocal prime-modulus defect forces vanishing ordinary +mean modulus, using only the finite p² CRT majorants. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical Topology + +lemma Multiplicative.eq_zero_of_one_ne {f : ℕ → ℂ} + (hf : Multiplicative f) (h1 : f 1 ≠ 1) (n : ℕ) (hn : 0 < n) : f n = 0 := by + have he : f n = f 1 * f n := by + simpa only [one_mul] using hf 1 n (by omega) hn (Nat.coprime_one_left n) + have hm : (1 - f 1) * f n = 0 := by linear_combination he + rcases mul_eq_zero.mp hm with h | h + · exact False.elim (h1 (sub_eq_zero.mp h).symm) + · exact h + +lemma modulus_mean_nonneg (f : ℕ → ℂ) (N : ℕ) : + 0 ≤ (∑ n ∈ range N, ‖f (n + 1)‖) / (N : ℝ) := + div_nonneg (sum_nonneg (fun _ _ => norm_nonneg _)) (Nat.cast_nonneg N) + +theorem mean_modulus_zero_of_not_summable_prime_defect {f : ℕ → ℂ} + (hfm : Multiplicative f) (hf : OneBounded f) + (hns : ¬Summable (primeModulusDefect f)) : + Tendsto (fun N : ℕ => (∑ n ∈ range N, ‖f (n + 1)‖) / (N : ℝ)) + atTop (𝓝 0) := by + by_cases hf1 : f 1 = 1 + · have hsum := (not_summable_iff_tendsto_nat_atTop_of_nonneg + (primeModulusDefect_nonneg hf)).mp hns + apply Metric.tendsto_atTop.2 + intro ε hε + have hε2 : 0 < ε / 2 := by positivity + obtain ⟨M, hM⟩ := (hsum.eventually + (eventually_ge_atTop (-2 * Real.log (ε / 2)))).exists + let P := (range M).filter Nat.Prime + have hP : ∀ p ∈ P, p.Prime := fun p hp => (mem_filter.mp hp).2 + have hpsum : (∑ p ∈ P, primeModulusDefect f p) = + ∑ p ∈ range M, primeModulusDefect f p := by + rw [sum_filter] + apply sum_congr rfl + intro p _ + by_cases hp : p.Prime <;> simp [primeModulusDefect, hp] + have hprod : (∏ p ∈ P, (1 - (1 - ‖f p‖) * + (1 / (p : ℝ) - 1 / (p : ℝ) ^ 2))) ≤ ε / 2 := by + apply (prime_square_defect_product_le_exp hf P hP).trans + have hh : -(∑ p ∈ P, primeModulusDefect f p) / 2 ≤ Real.log (ε / 2) := by + rw [hpsum] + linarith + exact (Real.exp_le_exp.mpr hh).trans_eq (Real.exp_log hε2) + let Q := ∏ p ∈ P, (p : ℝ) ^ 2 + have htail : Tendsto (fun N : ℕ => Q / (N : ℝ)) atTop (𝓝 0) := + tendsto_const_div_atTop_nhds_zero_nat Q + obtain ⟨N₀, hN₀⟩ := eventually_atTop.mp + ((htail.eventually (gt_mem_nhds hε2)).and (eventually_ge_atTop 1)) + refine ⟨N₀, ?_⟩ + intro N hN + obtain ⟨hsmall, hN1⟩ := hN₀ N hN + rw [Real.dist_eq, sub_zero, abs_of_nonneg (modulus_mean_nonneg f N)] + have hbound := primeDefectMajorant_crt_bound hfm hf1 hf P hP N (by omega) + change _ ≤ _ + Q / N at hbound + linarith + · have he : (fun N : ℕ => (∑ n ∈ range N, ‖f (n + 1)‖) / (N : ℝ)) = + fun _ => 0 := by + funext N + have hz : (∑ n ∈ range N, ‖f (n + 1)‖) = 0 := by + apply sum_eq_zero + intro n _ + rw [hfm.eq_zero_of_one_ne hf1 (n + 1) (by omega), norm_zero] + rw [hz, zero_div] + rw [he] + exact tendsto_const_nhds + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectMajorant.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectMajorant.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e3a46648a3c96d0049b61e661b732fc6ddc2407 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectMajorant.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.TwoPoint.Bounds.LocalExpansion + +namespace OAI + +/-! The elementary p²-periodic majorant from the qualitative analytic +transfer. Prime powers of exponent at least two are left unrestricted. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def primeDefectLocal (f : ℕ → ℂ) (p n : ℕ) : ℝ := + if p ∣ n ∧ ¬p ^ 2 ∣ n then ‖f p‖ else 1 + +noncomputable def primeDefectMajorant (f : ℕ → ℂ) (P : Finset ℕ) (n : ℕ) : ℝ := + ∏ p ∈ P, primeDefectLocal f p n + +lemma primeDefectLocal_nonneg (f : ℕ → ℂ) (p n : ℕ) : 0 ≤ primeDefectLocal f p n := by + unfold primeDefectLocal + split_ifs <;> positivity + +lemma primeDefectLocal_le_one {f : ℕ → ℂ} (hf : OneBounded f) + {p : ℕ} (hp : p.Prime) (n : ℕ) : primeDefectLocal f p n ≤ 1 := by + unfold primeDefectLocal + split_ifs + · exact hf p hp.pos + · exact le_rfl + +lemma primeDefectMajorant_nonneg (f : ℕ → ℂ) (P : Finset ℕ) (n : ℕ) : + 0 ≤ primeDefectMajorant f P n := + prod_nonneg (fun p _ => primeDefectLocal_nonneg f p n) + +lemma primeDefectMajorant_le_one {f : ℕ → ℂ} (hf : OneBounded f) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (n : ℕ) : + primeDefectMajorant f P n ≤ 1 := + prod_le_one₀ (fun p _ => primeDefectLocal_nonneg f p n) + (fun p hp => primeDefectLocal_le_one hf (hP p hp) n) + +lemma prime_valuation_one_iff {p n : ℕ} (hp : p.Prime) (hn : 0 < n) : + (p ∣ n ∧ ¬p ^ 2 ∣ n) ↔ n.factorization p = 1 := by + rw [hp.dvd_iff_one_le_factorization hn.ne', hp.pow_dvd_iff_le_factorization hn.ne'] + omega + +lemma norm_le_primeDefectMajorant {f : ℕ → ℂ} + (hfm : Multiplicative f) (hf1 : f 1 = 1) (hf : OneBounded f) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (n : ℕ) (hn : 0 < n) : + ‖f n‖ ≤ primeDefectMajorant f P n := by + have he : f n = (∏ p ∈ P, f (p ^ n.factorization p)) * + ∏ p ∈ n.primeFactors \ P, f (p ^ n.factorization p) := by + rw [← fromPrimePowers_reconstruct f hfm hf1 hn] + exact fromPrimePowers_split _ P (by intro p; simp [hf1]) n + have hout : (∏ p ∈ n.primeFactors \ P, ‖f (p ^ n.factorization p)‖) ≤ 1 := by + apply prod_le_one₀ (fun _ _ => norm_nonneg _) + intro p hp + have hprime := Nat.prime_of_mem_primeFactors (mem_sdiff.mp hp).1 + exact hf _ (pow_pos hprime.pos _) + rw [he, norm_mul, norm_prod, norm_prod] + calc + _ ≤ (∏ p ∈ P, ‖f (p ^ n.factorization p)‖) * 1 := + mul_le_mul_of_nonneg_left hout (prod_nonneg (fun _ _ => norm_nonneg _)) + _ = ∏ p ∈ P, ‖f (p ^ n.factorization p)‖ := mul_one _ + _ ≤ primeDefectMajorant f P n := by + apply prod_le_prod₀ (fun _ _ => norm_nonneg _) + intro p hp + unfold primeDefectLocal + split_ifs with hv + · rw [(prime_valuation_one_iff (hP p hp) hn).mp hv, pow_one] + · exact hf _ (pow_pos (hP p hp).pos _) + +lemma primeDefectLocal_formula (f : ℕ → ℂ) (p n : ℕ) : + primeDefectLocal f p n = 1 - (1 - ‖f p‖) * + ((if p ∣ n then (1 : ℝ) else 0) - (if p ^ 2 ∣ n then (1 : ℝ) else 0)) := by + have hp : p ∣ p ^ 2 := by simp [pow_two] + by_cases hpn : p ∣ n + · by_cases hp2n : p ^ 2 ∣ n <;> simp [primeDefectLocal, hpn, hp2n] + · have hp2n : ¬p ^ 2 ∣ n := fun hh => hpn (hp.trans hh) + simp [primeDefectLocal, hpn, hp2n] + +lemma primeDefectLocal_mod (f : ℕ → ℂ) (p n : ℕ) : + primeDefectLocal f p (n % p ^ 2) = primeDefectLocal f p n := by + unfold primeDefectLocal + have hp : p ∣ p ^ 2 := by simp [pow_two] + simp only [Nat.dvd_mod_iff hp, Nat.dvd_mod_iff (dvd_refl (p ^ 2))] + +lemma primeDefectLocal_periodic (f : ℕ → ℂ) (p : ℕ) : + Function.Periodic (primeDefectLocal f p) (p ^ 2) := by + intro n + rw [← primeDefectLocal_mod f p (n + p ^ 2), Nat.add_mod_right, + primeDefectLocal_mod] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectMean.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d589d518a060498ec4a4f80e5f840f713553579 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectMean.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeDefectMajorant +import OAI.NumberTheory.TwoPoint.Bounds.FiniteAverages + +namespace OAI + +/-! Exact one-prime p² averages of the elementary modulus majorant. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma sum_zero_multiples_of_dvd (a N : ℕ) (haN : a ∣ N) : + (∑ v ∈ range N, if a ∣ v then (1 : ℝ) else 0) = (N / a : ℕ) := by + let F : ℕ → ℝ := fun v => if a ∣ v then 1 else 0 + have hpos : (∑ v ∈ range N, F (v + 1)) = (N / a : ℕ) := by + have hh := congrArg (fun n : ℕ => (n : ℝ)) (Nat.card_multiples N a) + simpa only [card_filter, Nat.cast_sum, Nat.cast_ite, Nat.cast_one, Nat.cast_zero] using hh + have h1 := sum_range_succ F N + have h2 := sum_range_succ' F N + have hF0 : F 0 = 1 := by simp [F] + have hFN : F N = 1 := by simp [F, haN] + change (∑ v ∈ range N, F v) = _ + linarith + +lemma primeDefectLocal_sum (f : ℕ → ℂ) {p : ℕ} (hp : p.Prime) : + (∑ n ∈ range (p ^ 2), primeDefectLocal f p n) = + (p : ℝ) ^ 2 - (1 - ‖f p‖) * ((p : ℝ) - 1) := by + simp_rw [primeDefectLocal_formula] + rw [sum_sub_distrib, ← mul_sum, sum_sub_distrib, + sum_zero_multiples_of_dvd p (p ^ 2) (by simp [pow_two]), + sum_zero_multiples_of_dvd (p ^ 2) (p ^ 2) (dvd_refl _)] + have hpp : p ^ 2 / p = p := by rw [pow_two, Nat.mul_div_cancel_left _ hp.pos] + rw [hpp, Nat.div_self (pow_pos hp.pos 2)] + simp + +lemma primeDefectLocal_average (f : ℕ → ℂ) {p : ℕ} [NeZero (p ^ 2)] (hp : p.Prime) : + uniformAverage (fun r : ZMod (p ^ 2) => primeDefectLocal f p r.val) = + 1 - (1 - ‖f p‖) * (1 / (p : ℝ) - 1 / (p : ℝ) ^ 2) := by + have hp0 : (p : ℝ) ≠ 0 := by exact_mod_cast hp.ne_zero + let e : Fin (p ^ 2) ≃ ZMod (p ^ 2) := + { toFun := fun i => (i.val : ZMod (p ^ 2)) + invFun := fun r => ⟨r.val, r.val_lt⟩ + left_inv := fun i => Fin.ext (ZMod.val_natCast_of_lt i.isLt) + right_inv := fun r => ZMod.natCast_zmod_val r } + have hsum : (∑ r : ZMod (p ^ 2), primeDefectLocal f p r.val) = + ∑ n ∈ range (p ^ 2), primeDefectLocal f p n := by + rw [← e.sum_comp (fun r => primeDefectLocal f p r.val)] + rw [← Fin.sum_univ_eq_sum_range] + apply sum_congr rfl + intro i _ + exact congrArg (primeDefectLocal f p) (ZMod.val_natCast_of_lt i.isLt) + unfold uniformAverage + rw [hsum, ZMod.card, primeDefectLocal_sum f hp, Nat.cast_pow] + field_simp [hp0] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectPhase.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectPhase.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf3d9d87bd282b42d0b9638f8fbf4d858ae89adf --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDefectPhase.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ComplexPairSelection + +namespace OAI + +/-! Small prime-defect moments produce a numerical phase-selected family +whose coefficient is comparable to the full retained bin mass. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma exists_pair_phase_of_prime_defect {J : ℕ} {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf1 : f 1 = 1) (hg1 : g 1 = 1) (hf : OneBounded f) (hg : OneBounded g) + (P : Fin J → Finset ℕ) (Q : Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (hQ : ∀ p ∈ Q, p.Prime) (hPQ : Disjoint (primeTuplePool P) Q) + (W L η : ℝ) (hW : 0 < W) (hη : 0 < η) + (hmass : ∀ j, W ≤ primeHarmonicMass (P j)) + (htotal : paddingTiltNormalizer Q * (∏ j, primeHarmonicMass (P j)) / 2 ≤ + totalPaddingBinMass (primeTupleDivisors P) Q L η) + (hdefect : (∑ p ∈ primeTuplePool P, (1 - ‖f p * g p‖) / (p : ℝ)) / W + + 4 * (∑ p ∈ Q, (1 - ‖f p * g p‖) / (p : ℝ)) ≤ 1 / 4) : + ∃ A ⊆ eligibleComplexPairs (primeTupleDivisors P) Q (PaddingPairEligible L η), + totalPaddingBinMass (primeTupleDivisors P) Q L η / 8 ≤ + ‖∑ dq ∈ A, (complexPairWeight dq : ℂ) * + (f (dq.1 * dq.2) * g (dq.1 * dq.2))‖ := by + apply exists_eligible_pair_phase (primeTupleDivisors P) Q L η hη + have hv : 0 ≤ paddingTiltNormalizer Q * ∏ j, primeHarmonicMass (P j) := + mul_nonneg (paddingTiltNormalizer_pos Q).le + (prod_nonneg (fun j _ => (hW.trans_le (hmass j)).le)) + have hD : ∀ d ∈ primeTupleDivisors P, 0 < d := by + intro d hd + exact Nat.pos_of_ne_zero (primeTupleDivisors_arithmetic P hprime hdisjoint hd).1.ne_zero + apply (eligibleComplexPairs_defect_le hf hg (primeTupleDivisors P) Q hD hQ _).trans + have hb := tuple_padding_modulus_defect hfm hgm hf1 hg1 hf hg P Q hprime hdisjoint + hQ hPQ W hW hmass + have hc := padding_modulus_defect_cost_le hf hg Q hQ + have hs := mul_le_mul_of_nonneg_left + (add_le_add (le_refl ((∑ p ∈ primeTuplePool P, (1 - ‖f p * g p‖) / (p : ℝ)) / W)) hc) hv + have ht := mul_le_mul_of_nonneg_left hdefect hv + exact hb.trans (hs.trans (ht.trans (by linarith))) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDegreeCircuit.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDegreeCircuit.lean new file mode 100644 index 0000000000000000000000000000000000000000..57819d013e5e2602cba4ec7a2c04f4b0efeb152e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDegreeCircuit.lean @@ -0,0 +1,153 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DegreeThresholdCircuit +import OAI.NumberTheory.TwoPoint.Bounds.PrimeLiteralEncoding +import OAI.NumberTheory.TwoPoint.Bounds.PaddingActiveState + +namespace OAI + +/-! Literal degree deletion together with divisibility by a fixed +padding divisor. All tests use the common prime coordinates. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def primeSubsetIndex (U S : Finset ℕ) (hS : S ⊆ U) : + Fin (Fintype.card S) → Fin (Fintype.card U) := + fun i => (Fintype.equivFin U) + ⟨((Fintype.equivFin S).symm i).val, hS ((Fintype.equivFin S).symm i).property⟩ + +lemma primeSubsetIndex_value (U S : Finset ℕ) (hS : S ⊆ U) + (i : Fin (Fintype.card S)) : + ((Fintype.equivFin U).symm (primeSubsetIndex U S hS i)).val = + ((Fintype.equivFin S).symm i).val := by + simp only [primeSubsetIndex, Equiv.symm_apply_apply] + +noncomputable def primeSiteBits (U : Finset ℕ) (n : ℤ) : + BooleanCube (Fintype.card U) := + fun i => decide ((((Fintype.equivFin U).symm i).val : ℤ) ∣ n) + +lemma primeSubsetIndex_bits (U S : Finset ℕ) (hS : S ⊆ U) (n : ℤ) : + (fun i => primeSiteBits U n (primeSubsetIndex U S hS i)) = primeSiteBits S n := by + funext i + simp only [primeSiteBits, primeSubsetIndex_value] + +lemma primeSiteBits_card (U : Finset ℕ) (n : ℤ) : + (activeState (primeSiteBits U n)).card = actualPaddingDegree U n := + paddingActiveState_card U (Fintype.equivFin U).symm n + +noncomputable def degreeDivisorCircuit {m n t : ℕ} + (pindex : Fin n → Fin m) (qindex : Fin t → Fin m) (r : ℕ) : AC0Circuit m := + AC0Circuit.conjunction (fun b : Bool => if b then + AC0Circuit.relabel pindex (degreeThresholdCircuit n r) else + AC0Circuit.relabel qindex (degreeSubsetCircuit univ)) + +lemma degreeDivisorCircuit_eval {m n t : ℕ} + (pindex : Fin n → Fin m) (qindex : Fin t → Fin m) (r : ℕ) + (x : BooleanCube m) : + (degreeDivisorCircuit pindex qindex r).eval x = true ↔ + (∀ i, x (qindex i) = true) ∧ r ≤ (activeState (fun i => x (pindex i))).card := by + rw [degreeDivisorCircuit, AC0Circuit.conjunction_eval] + simp only [Bool.forall_bool, Bool.false_eq_true, ite_false, ite_true, + AC0Circuit.relabel_eval, degreeThresholdCircuit_eval, degreeSubsetCircuit_eval] + have he : (univ : Finset (Fin t)) ⊆ activeState (fun i => x (qindex i)) ↔ + ∀ i, x (qindex i) = true := by + simp only [subset_iff, mem_univ, activeState, mem_filter, true_and, forall_const] + rw [he] + +lemma degreeDivisorCircuit_depth {m n t : ℕ} + (pindex : Fin n → Fin m) (qindex : Fin t → Fin m) (r : ℕ) : + (degreeDivisorCircuit pindex qindex r).depth ≤ 3 := by + apply AC0Circuit.conjunction_depth + intro b + cases b + · exact (AC0Circuit.relabel_depth _ _).trans ((degreeSubsetCircuit_depth _).trans (by omega)) + · exact (AC0Circuit.relabel_depth _ _).trans (degreeThresholdCircuit_depth _ _) + +lemma degreeDivisorCircuit_size {m n t : ℕ} + (pindex : Fin n → Fin m) (qindex : Fin t → Fin m) (r : ℕ) : + (degreeDivisorCircuit pindex qindex r).size ≤ + 3 + t + (r + 1) * (n + 1) ^ r := by + rw [degreeDivisorCircuit, AC0Circuit.conjunction_size] + simp only [Fintype.sum_bool, Bool.false_eq_true, ite_false, ite_true] + have hq := AC0Circuit.relabel_size qindex (degreeSubsetCircuit (univ : Finset (Fin t))) + have hp := AC0Circuit.relabel_size pindex (degreeThresholdCircuit n r) + have hd := degreeThresholdCircuit_size_le n r + simp only [degreeSubsetCircuit_size, card_univ, Fintype.card_fin] at hq + omega + +lemma degreeDivisorCircuit_size_exp {m n t : ℕ} + (pindex : Fin n → Fin m) (qindex : Fin t → Fin m) (r : ℕ) (L : ℝ) + (hL : 4800 ≤ L) (hn : (n : ℝ) ≤ Real.exp L) + (ht : (t : ℝ) ≤ 100 * Real.log L) (hr : (r : ℝ) ≤ 400 * Real.log L + 1) : + ((degreeDivisorCircuit pindex qindex r).size : ℝ) ≤ Real.exp (L ^ 3) := by + have hL0 : 0 ≤ L := by linarith + have hlog : Real.log L ≤ L := + (Real.log_le_sub_one_of_pos (by linarith)).trans (by linarith) + have hrL : (r : ℝ) ≤ 401 * L := by nlinarith + have htwo : (2 : ℝ) ≤ Real.exp L := by linarith [Real.add_one_le_exp L] + have hn' : (n : ℝ) + 1 ≤ Real.exp (2 * L) := by + rw [show 2 * L = L + L by ring, Real.exp_add] + nlinarith + have hprod : ((r : ℝ) + 1) * ((n : ℝ) + 1) ^ r ≤ + Real.exp (1203 * L ^ 2) := by + calc + _ ≤ Real.exp (r : ℝ) * (Real.exp (2 * L)) ^ r := + mul_le_mul (Real.add_one_le_exp (r : ℝ)) + (pow_le_pow_left₀ (by positivity) hn' r) (by positivity) (by positivity) + _ = Real.exp ((r : ℝ) * (1 + 2 * L)) := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + congr 1 + ring + _ ≤ _ := Real.exp_le_exp.mpr (by + have hm := mul_le_mul_of_nonneg_right hrL (show 0 ≤ 1 + 2 * L by positivity) + have hs := mul_nonneg hL0 (show 0 ≤ L - 1 by linarith) + nlinarith) + have hsmall : 3 + (t : ℝ) ≤ Real.exp (1203 * L ^ 2) := by + have he := Real.add_one_le_exp (1203 * L ^ 2) + nlinarith [sq_nonneg (L - 1)] + have hc : ((degreeDivisorCircuit pindex qindex r).size : ℝ) ≤ + 3 + t + ((r : ℝ) + 1) * ((n : ℝ) + 1) ^ r := by + exact_mod_cast degreeDivisorCircuit_size pindex qindex r + calc + _ ≤ 2 * Real.exp (1203 * L ^ 2) := by linarith + _ ≤ Real.exp (1 + 1203 * L ^ 2) := by + rw [Real.exp_add] + exact mul_le_mul_of_nonneg_right + (by linarith [Real.add_one_le_exp (1 : ℝ)]) (Real.exp_pos _).le + _ ≤ _ := Real.exp_le_exp.mpr (by + have hsq : (1 : ℝ) ≤ L ^ 2 := by nlinarith + have hh := mul_nonneg (sq_nonneg L) (show 0 ≤ L - 1204 by linarith) + nlinarith) + +lemma prime_divisor_all_bits (U Q : Finset ℕ) (hQU : Q ⊆ U) + (hQ : ∀ p ∈ Q, p.Prime) (q : ℕ) (hq : q ∈ retainedPrimeDivisors Q) (n : ℤ) : + (∀ i : Fin (Fintype.card q.primeFactors), + primeSiteBits U n (primeSubsetIndex U q.primeFactors + ((retainedPrimeDivisor_factors Q hQ hq).trans hQU) i) = true) ↔ + (q : ℤ) ∣ n := by + rw [← padding_literal_support_iff_dvd Q hQ n q hq, paddingAvailablePrimes_integer] + constructor + · intro hb p hp + let i := (Fintype.equivFin q.primeFactors) ⟨p, hp⟩ + have hi := hb i + simp only [primeSiteBits, primeSubsetIndex_value, i, Equiv.symm_apply_apply, + decide_eq_true_eq] at hi + exact mem_filter.mpr ⟨retainedPrimeDivisor_factors Q hQ hq hp, hi⟩ + · intro hb i + have hh := hb ((Fintype.equivFin q.primeFactors).symm i).property + simpa only [primeSiteBits, primeSubsetIndex_value, decide_eq_true_eq] using (mem_filter.mp hh).2 + +lemma degreeDivisorCircuit_integer (U P Q : Finset ℕ) (hPU : P ⊆ U) + (hQU : Q ⊆ U) (hQ : ∀ p ∈ Q, p.Prime) (q : ℕ) + (hq : q ∈ retainedPrimeDivisors Q) (T : ℝ) (hT : 0 ≤ T) (n : ℤ) : + (degreeDivisorCircuit (primeSubsetIndex U P hPU) + (primeSubsetIndex U q.primeFactors ((retainedPrimeDivisor_factors Q hQ hq).trans hQU)) + (⌊T⌋₊ + 1)).eval (primeSiteBits U n) = true ↔ + (q : ℤ) ∣ n ∧ T < (actualPaddingDegree P n : ℝ) := by + rw [degreeDivisorCircuit_eval, prime_divisor_all_bits U Q hQU hQ q hq n, + primeSubsetIndex_bits, primeSiteBits_card, ← Nat.lt_iff_add_one_le, Nat.floor_lt hT] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDegreeTail.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDegreeTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..a6504bbec807e1c19b2f7069d7afcc0b353cfbf9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeDegreeTail.lean @@ -0,0 +1,194 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PositivePrimeTilt +import OAI.NumberTheory.TwoPoint.Bounds.ActualPaddingResidues +import OAI.NumberTheory.TwoPoint.Bounds.ResidueRestriction + +namespace OAI + +/-! The prime-degree deletion under the literal full residue law. The +positive tuple majorant has mean `2^omega(d)/d`, and its tilted degree +tail is exponentially small in `W * omega(d)`. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def primeSelection (P S : Finset ℕ) (hSP : S ⊆ P) : Finset P := + S.attach.image (fun p => (⟨p.val, hSP p.property⟩ : P)) + +lemma primeSelection_card (P S : Finset ℕ) (hSP : S ⊆ P) : + (primeSelection P S hSP).card = S.card := by + have hi : Function.Injective (fun p : S => (⟨p.val, hSP p.property⟩ : P)) := by + intro p q hpq + exact Subtype.ext (congrArg (fun r : P => r.val) hpq) + simp only [primeSelection, card_image_of_injective _ hi, card_attach] + +noncomputable def positivePrimeWeight (S : Finset ℕ) (n : ℤ) : ℝ := + ∏ p ∈ S, ((if (p : ℤ) ∣ n then 1 else 0) + 1 / (p : ℝ)) + +noncomputable def positivePrimeNormalizer (S : Finset ℕ) : ℝ := + ∏ p ∈ S, 2 / (p : ℝ) + +lemma positivePrimeWeight_nonneg (S : Finset ℕ) (n : ℤ) : + 0 ≤ positivePrimeWeight S n := by + apply prod_nonneg + intro p _ + split_ifs <;> positivity + +lemma abs_centeredTuple_le_positivePrimeWeight (S : Finset ℕ) (n : ℤ) : + |centeredTuple S n| ≤ positivePrimeWeight S n := by + rw [centeredTuple, abs_prod] + apply prod_le_prod₀ (fun _ _ => abs_nonneg _) + intro p _ + have hi : 0 ≤ (if (p : ℤ) ∣ n then (1 : ℝ) else 0) := by + split_ifs <;> norm_num + have hp : 0 ≤ (p : ℝ)⁻¹ := by positivity + simpa only [sub_zero, zero_sub, abs_neg, abs_of_nonneg hi, abs_of_nonneg hp, one_div] using + abs_sub_le (if (p : ℤ) ∣ n then (1 : ℝ) else 0) 0 (p : ℝ)⁻¹ + +lemma positivePrimeWeight_eq_selection (P S : Finset ℕ) (hSP : S ⊆ P) (n : ℤ) : + positivePrimeWeight S n = + positiveCenterWeight (fun p : P => 1 / (p.val : ℝ)) (primeSelection P S hSP) + (fun p => decide ((p.val : ℤ) ∣ n)) := by + rw [positiveCenterWeight_eq] + unfold primeSelection + rw [prod_image] + · simp only [positivePrimeWeight, decide_eq_true_eq] + exact (prod_attach S (fun p : ℕ => + (if (p : ℤ) ∣ n then (1 : ℝ) else 0) + 1 / (p : ℝ))).symm + · intro p _ q _ hpq + exact Subtype.ext (congrArg (fun r : P => r.val) hpq) + +lemma positivePrimeNormalizer_eq_selection (P S : Finset ℕ) (hSP : S ⊆ P) : + positivePrimeNormalizer S = + positiveCenterNormalizer (fun p : P => 1 / (p.val : ℝ)) (primeSelection P S hSP) := by + rw [positiveCenterNormalizer_eq] + unfold primeSelection + rw [prod_image] + · simp only [positivePrimeNormalizer, mul_one_div] + exact (prod_attach S (fun p : ℕ => (2 : ℝ) / p)).symm + · intro p _ q _ hpq + exact Subtype.ext (congrArg (fun r : P => r.val) hpq) + +lemma positivePrimeNormalizer_squarefree (d : ℕ) (hd : Squarefree d) : + positivePrimeNormalizer d.primeFactors = (2 : ℝ) ^ d.primeFactors.card / d := by + unfold positivePrimeNormalizer + rw [prod_div_distrib, prod_const] + congr 1 + rw [← Nat.cast_prod, Nat.prod_primeFactors_of_squarefree hd] + +lemma actualPrimeDegree_eq_count (P : Finset ℕ) (n : ℤ) : + (actualPaddingDegree P n : ℝ) = + booleanCount (fun p : P => decide ((p.val : ℤ) ∣ n)) := by + rw [actualPaddingDegree_eq_available, paddingAvailablePrimes_card, booleanCount_eq_card] + rfl + +namespace ProhibitedPrimeFamily + +variable {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + +/-- Every prime coordinate retains its Bernoulli divisibility law under +the full tuple-and-padding law, also at a translated CRT origin. -/ +lemma residue_average_prime_availability + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) (site : ℤ) + (F : (data.P → Bool) → ℝ) : + (data.residueLaw B hB).average (fun x => + F (fun p : data.P => decide ((p.val : ℤ) ∣ data.residueOrigin x + site))) = + (paddingOriginalLaw data.P (fun p hp => (data.primeP p hp).two_le)).average F := by + let e : data.P → ↥(data.P ∪ data.Q) := fun p => ⟨p.val, mem_union_left _ p.property⟩ + have he : Function.Injective e := by + intro p q hpq + exact Subtype.ext (congrArg (fun r : ↥(data.P ∪ data.Q) => r.val) hpq) + calc + _ = (data.residueLaw B hB).average (fun x => + F (paddingResidueAvailable data.P B site (fun p => x (e p)))) := by + apply congrArg (data.residueLaw B hB).average + funext x + apply congrArg F + funext p + change decide ((p.val : ℤ) ∣ data.residueOrigin x + site) = + decide ((p.val : ℤ) ∣ (x (e p)).val + site) + have hdiv : (p.val : ℤ) ∣ data.residueOrigin x + site ↔ + (p.val : ℤ) ∣ (x (e p)).val + site := data.residueOrigin_divisibility x (e p) site + simp only [hdiv] + _ = (FiniteLaw.independent (fun p : data.P => uniformResidueLaw B p.val + (data.primeP p p.property).pos (hB p (mem_union_left _ p.property)))).average + (fun z => F (paddingResidueAvailable data.P B site z)) := + FiniteLaw.independent_average_embedding e he + (fun p => uniformResidueLaw B p.val (data.prime p).pos (hB p p.property)) + (fun z => F (paddingResidueAvailable data.P B site z)) + _ = _ := padding_residue_average data.P B (fun p hp => (data.primeP p hp).two_le) + (fun p hp => hB p (mem_union_left _ hp)) site F + +lemma positive_prime_mean (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (S : Finset ℕ) (hSP : S ⊆ data.P) (site : ℤ) : + (data.residueLaw B hB).average + (fun x => positivePrimeWeight S (data.residueOrigin x + site)) = + positivePrimeNormalizer S := by + let q := fun p : data.P => 1 / (p.val : ℝ) + let T := primeSelection data.P S hSP + have hq0 (p : data.P) : 0 ≤ q p := by dsimp [q]; positivity + have hq1 (p : data.P) : q p ≤ 1 := by + apply (div_le_one (by exact_mod_cast (data.primeP p p.property).pos)).mpr + exact_mod_cast (data.primeP p p.property).one_lt.le + simp_rw [positivePrimeWeight_eq_selection data.P S hSP] + rw [data.residue_average_prime_availability hB site (positiveCenterWeight q T)] + exact (positive_center_tilt_total q T hq0 hq1).trans + (positivePrimeNormalizer_eq_selection data.P S hSP).symm + +/-- The positive centered-prime majorant, with a prime-degree failure, +is bounded by its exact mean times `exp(-2W * #S)`. -/ +theorem positive_prime_degree_tail (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (S : Finset ℕ) (hSP : S ⊆ data.P) (W : ℝ) (hW : 10 ≤ W) + (hmass : (∑ p ∈ data.P, 1 / (p : ℝ)) ≤ 2 * W * S.card) (site : ℤ) : + (data.residueLaw B hB).average (fun x => + positivePrimeWeight S (data.residueOrigin x + site) * + if 6 * W * S.card < (actualPaddingDegree data.P (data.residueOrigin x + site) : ℝ) + then 1 else 0) ≤ + positivePrimeNormalizer S * Real.exp (-2 * W * S.card) := by + let q := fun p : data.P => 1 / (p.val : ℝ) + let T := primeSelection data.P S hSP + have hq0 (p : data.P) : 0 ≤ q p := by dsimp [q]; positivity + have hq1 (p : data.P) : q p ≤ 1 := by + apply (div_le_one (by exact_mod_cast (data.primeP p p.property).pos)).mpr + exact_mod_cast (data.primeP p p.property).one_lt.le + have hm : (∑ p : data.P, q p) ≤ 2 * W * T.card := by + rw [primeSelection_card] + change (∑ p : data.P, 1 / (p.val : ℝ)) ≤ 2 * W * S.card + rw [sum_coe_sort data.P (fun p : ℕ => 1 / (p : ℝ))] + exact hmass + have he (x : ↥(data.P ∪ data.Q) → Fin B) : + positivePrimeWeight S (data.residueOrigin x + site) * + (if 6 * W * S.card < (actualPaddingDegree data.P (data.residueOrigin x + site) : ℝ) + then (1 : ℝ) else 0) = + positiveCenterWeight q T (fun p : data.P => + decide ((p.val : ℤ) ∣ data.residueOrigin x + site)) * + (if 6 * W * T.card < booleanCount (fun p : data.P => + decide ((p.val : ℤ) ∣ data.residueOrigin x + site)) then 1 else 0) := by + rw [positivePrimeWeight_eq_selection data.P S hSP, + actualPrimeDegree_eq_count, primeSelection_card] + simp_rw [he] + rw [data.residue_average_prime_availability hB site (fun a => + positiveCenterWeight q T a * if 6 * W * T.card < booleanCount a then 1 else 0)] + have ht := positive_center_weighted_degree_tail q T hq0 hq1 W hW hm + rw [primeSelection_card, ← positivePrimeNormalizer_eq_selection] at ht + simpa only [paddingOriginalLaw, paddingOriginalPrimeLaw, T, q, primeSelection_card] using ht + +theorem positive_tuple_degree_tail (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (d : ℕ) (hd : Squarefree d) (hdP : d.primeFactors ⊆ data.P) + (hdJ : d.primeFactors.card = J) (W : ℝ) (hW : 10 ≤ W) + (hmass : (∑ p ∈ data.P, 1 / (p : ℝ)) ≤ 2 * W * J) (site : ℤ) : + (data.residueLaw B hB).average (fun x => + positivePrimeWeight d.primeFactors (data.residueOrigin x + site) * + if 6 * W * J < (actualPaddingDegree data.P (data.residueOrigin x + site) : ℝ) + then 1 else 0) ≤ + ((2 : ℝ) ^ J / d) * Real.exp (-2 * W * J) := by + have ht := data.positive_prime_degree_tail hB d.primeFactors hdP W hW + (by simpa only [hdJ] using hmass) site + simpa only [positivePrimeNormalizer_squarefree d hd, hdJ] using ht + +end ProhibitedPrimeFamily + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeFamilyGraph.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeFamilyGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..c08f4d227cb69c58e72ad4fa86ea0f254b408a3b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeFamilyGraph.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeFamilyWeights +import OAI.NumberTheory.TwoPoint.Bounds.MaskedIntegerEdges +import OAI.NumberTheory.TwoPoint.Bounds.MatrixAction + +namespace OAI + +/-! +# The weighted-row lemma for concrete prime-family graph operators + +This constructs the operators, rather than assuming a coordinate formula. +Arbitrary prime residue offsets cover both models. The symmetric gate can +include the progression test and any further edge deletions. The cutoff +uses the explicitly defined padding density. +-/ + +namespace TwoPointCorrelations + +open Finset + +variable {α ι : Type*} [Fintype α] [DecidableEq α] [Fintype ι] [DecidableEq ι] + {P : α → Type*} [∀ i, Fintype (P i)] + +noncomputable def primeFamilyGraphOperator + (value : (i : α) → P i → ℕ) (offset : (i : α) → P i → ℤ) + (site : ι → ℤ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ι → ι → Prop) (x : (i : α) → P i) : + EuclideanSpace ℂ ι →L[ℂ] EuclideanSpace ℂ ι := + matrixOperator (maskedIntegerEdgeMatrix site Q u (eligible (familyTuple value x)) + g (familyCenter value offset x) L K (extra (familyTuple value x)) h + (familyTuple value x) (gate (familyTuple value x))) + +omit [DecidableEq α] [∀ i, Fintype (P i)] in +theorem primeFamilyGraphOperator_selfAdjoint + (value : (i : α) → P i → ℕ) (offset : (i : α) → P i → ℤ) + (site : ι → ℤ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ι → ι → Prop) (hgate : ∀ d i j, gate d i j ↔ gate d j i) + (x : (i : α) → P i) : + IsSelfAdjoint (primeFamilyGraphOperator value offset site Q u eligible g L K extra h gate x) := by + apply matrixOperator_selfAdjoint + exact maskedIntegerEdgeMatrix_symmetric site Q u (eligible (familyTuple value x)) + g (familyCenter value offset x) L K (extra (familyTuple value x)) h + (familyTuple value x) (gate (familyTuple value x)) (hgate _) + +omit [DecidableEq α] [∀ i, Fintype (P i)] in +/-- The single-operator assertion of manuscript `q:weighted-rows`. -/ +theorem primeFamilyGraphOperator_norm_le + (value : (i : α) → P i → ℕ) (hprime : ∀ i p, (value i p).Prime) + (offset : (i : α) → P i → ℤ) (site : ι → ℤ) (hinj : Function.Injective site) + (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ι → ι → Prop) (hgate : ∀ d i j, gate d i j ↔ gate d j i) + (hL : 0 < L) (hK : 0 ≤ K) (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (x : (i : α) → P i) : + ‖primeFamilyGraphOperator value offset site Q u eligible g L K extra h gate x‖ ≤ 2 * K := by + let d := familyTuple value x + let center := familyCenter value offset x + let A := maskedIntegerEdgeMatrix site Q u (eligible d) g center L K (extra d) h d (gate d) + have hperiod : ∀ q ∈ Q, ∀ n, center (n + (h * q * d : ℕ)) = center n := + fun q _ n => familyCenter_padding_periodic value offset x h q n + change ‖matrixOperator A‖ ≤ _ + apply weighted_operator_norm_le (matrixOperator A) A (matrixOperator_apply A) + (fun i => g (site i)) (fun i => |center (site i)|) (2 * K) (by positivity) + (fun i => hg _) (fun i => abs_nonneg _) (fun i => familyCenter_abs_le_one value hprime offset x _) + · intro i j + dsimp [A] + rw [maskedIntegerEdgeMatrix_symmetric site Q u (eligible d) g center L K (extra d) h d (gate d) (hgate d) i j, norm_star] + · exact maskedIntegerEdgeMatrix_level site Q u (eligible d) g center L K (extra d) h d (gate d) hperiod + · exact maskedIntegerEdgeMatrix_weighted_row site hinj Q u (eligible d) g center L K (extra d) h d (gate d) hL hK hu hg hperiod + +/-- The square-function assertion of manuscript `q:weighted-rows`, with +its exact `4 K² (8W)^J` constant and the degree projection's support condition. -/ +theorem primeFamilyGraphOperator_square_sum + (value : (i : α) → P i → ℕ) (hprime : ∀ i p, (value i p).Prime) + (offset : (i : α) → P i → ℤ) (site : ι → ℤ) (hinj : Function.Injective site) + (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ι → ι → Prop) (hgate : ∀ d i j, gate d i j ↔ gate d j i) + (hL : 0 < L) (hK : 0 ≤ K) (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (hV : ∀ i, ∑ p, (value i p : ℝ)⁻¹ ≤ 2 * W) + (v : EuclideanSpace ℂ ι) + (hdegree : ∀ k, v k ≠ 0 → + (∑ i, ∑ p : P i, if (value i p : ℤ) ∣ offset i p + site k then (1 : ℝ) else 0) ≤ + 6 * W * Fintype.card α) : + (∑ x, ‖primeFamilyGraphOperator value offset site Q u eligible g L K extra h gate x v‖ ^ 2) ≤ + 4 * K ^ 2 * (8 * W) ^ Fintype.card α * ‖v‖ ^ 2 := by + let A (x : (i : α) → P i) := maskedIntegerEdgeMatrix site Q u (eligible (familyTuple value x)) + g (familyCenter value offset x) L K (extra (familyTuple value x)) h + (familyTuple value x) (gate (familyTuple value x)) + have hlocal (x : (i : α) → P i) : + (∑ i, ‖∑ j, A x i j * v j‖ ^ 2) ≤ + (2 * K) ^ 2 * ∑ i, |familyCenter value offset x (site i)| ^ 2 * ‖v i‖ ^ 2 := by + have hh := maskedIntegerEdgeMatrix_localized_square site hinj Q u (eligible (familyTuple value x)) + g (familyCenter value offset x) L K (extra (familyTuple value x)) h (familyTuple value x) + (gate (familyTuple value x)) (hgate _) hL hK hu hg + (fun q _ n => familyCenter_padding_periodic value offset x h q n) (fun i => v i) + convert hh using 1 + ring + have hs := localized_square_sum A (fun x i => |familyCenter value offset x (site i)|) + (2 * K) ((8 * W) ^ Fintype.card α) (fun i => v i) hlocal + (fun i hi => familyCenter_square_sum_le value hprime offset (site i) W hV (hdegree i hi)) + calc + _ = ∑ x, ∑ i, ‖∑ j, A x i j * v j‖ ^ 2 := by + simp only [EuclideanSpace.norm_sq_eq, primeFamilyGraphOperator, matrixOperator_apply, A] + _ ≤ (2 * K) ^ 2 * (8 * W) ^ Fintype.card α * ∑ i, ‖v i‖ ^ 2 := hs + _ = _ := by rw [EuclideanSpace.norm_sq_eq]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeFamilyWeights.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeFamilyWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..fb6217a9bbcb8ab107b02180ad300a650607e08a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeFamilyWeights.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.TwoPoint.Bounds.IntegerEdges +import Mathlib.Data.Nat.Squarefree + +namespace OAI + +/-! Tuple weights in integer and product residue environments. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {α : Type*} [Fintype α] [DecidableEq α] + {P : α → Type*} [∀ i, Fintype (P i)] + +/-- An arbitrary offset for every prime coordinate includes all product +residue environments. The integer environment has every offset equal to zero. -/ +noncomputable def familyCenter (value : (i : α) → P i → ℕ) + (offset : (i : α) → P i → ℤ) (x : (i : α) → P i) (n : ℤ) : ℝ := + ∏ i, ((if (value i (x i) : ℤ) ∣ offset i (x i) + n then 1 else 0) - (value i (x i) : ℝ)⁻¹) + +noncomputable def familyTuple (value : (i : α) → P i → ℕ) (x : (i : α) → P i) : ℕ := + ∏ i, value i (x i) + +omit [DecidableEq α] [∀ i, Fintype (P i)] in +lemma familyCenter_abs (value : (i : α) → P i → ℕ) + (offset : (i : α) → P i → ℤ) (x : (i : α) → P i) (n : ℤ) : + |familyCenter value offset x n| = + ∏ i, centerMagnitude (value i (x i) : ℝ)⁻¹ (decide ((value i (x i) : ℤ) ∣ offset i (x i) + n)) := by + simp [familyCenter, abs_prod, centerMagnitude] + +omit [DecidableEq α] [∀ i, Fintype (P i)] in +lemma familyCenter_abs_le_one (value : (i : α) → P i → ℕ) + (hprime : ∀ i p, (value i p).Prime) + (offset : (i : α) → P i → ℤ) (x : (i : α) → P i) (n : ℤ) : + |familyCenter value offset x n| ≤ 1 := by + rw [familyCenter_abs] + apply prod_le_one₀ + · intro i _ + exact centerMagnitude_nonneg _ _ + · intro i _ + have hp : (1 : ℝ) ≤ value i (x i) := by exact_mod_cast (hprime i (x i)).one_lt.le + exact centerMagnitude_le_one _ _ (by positivity) ((inv_le_one₀ (by positivity)).mpr hp) + +omit [DecidableEq α] [∀ i, Fintype (P i)] in +lemma familyCenter_padding_periodic (value : (i : α) → P i → ℕ) + (offset : (i : α) → P i → ℤ) (x : (i : α) → P i) (h q : ℕ) (n : ℤ) : + familyCenter value offset x (n + (h * q * familyTuple value x : ℕ)) = + familyCenter value offset x n := by + unfold familyCenter + apply prod_congr rfl + intro i _ + have hdiv : value i (x i) ∣ h * q * familyTuple value x := + dvd_mul_of_dvd_right (dvd_prod_of_mem (fun i => value i (x i)) (mem_univ i)) (h * q) + have hdivInt : (value i (x i) : ℤ) ∣ (h * q * familyTuple value x : ℕ) := by exact_mod_cast hdiv + simp only [← add_assoc, dvd_add_left hdivInt] + +/-- The exact degree estimate, uniform over all residue offsets. -/ +theorem familyCenter_square_sum_le (value : (i : α) → P i → ℕ) + (hprime : ∀ i p, (value i p).Prime) + (offset : (i : α) → P i → ℤ) (n : ℤ) (W : ℝ) + (hV : ∀ i, ∑ p, (value i p : ℝ)⁻¹ ≤ 2 * W) + (hdegree : (∑ i, ∑ p : P i, if (value i p : ℤ) ∣ offset i p + n then (1 : ℝ) else 0) ≤ + 6 * W * Fintype.card α) : + (∑ x : (i : α) → P i, |familyCenter value offset x n| ^ 2) ≤ + (8 * W) ^ Fintype.card α := by + simp only [familyCenter_abs] + apply squared_center_products_le (fun i p => (value i p : ℝ)⁻¹) + (fun i p => decide ((value i p : ℤ) ∣ offset i p + n)) W + · intro i p + positivity + · intro i p + have hp : (1 : ℝ) ≤ value i p := by exact_mod_cast (hprime i p).one_lt.le + exact (inv_le_one₀ (by positivity)).mpr hp + · exact hV + · simpa using hdegree + +omit [DecidableEq α] [∀ i, Fintype (P i)] in +lemma familyTuple_primeFactors (value : (i : α) → P i → ℕ) + (hprime : ∀ i p, (value i p).Prime) (x : (i : α) → P i) + (hinj : Function.Injective (fun i => value i (x i))) : + (familyTuple value x).primeFactors = univ.image (fun i => value i (x i)) := by + classical + have hprod : (∏ p ∈ univ.image (fun i => value i (x i)), p) = familyTuple value x := by + rw [prod_image] + · rfl + · exact fun i _ j _ hij => hinj hij + rw [← hprod] + apply Nat.primeFactors_prod + intro p hp + obtain ⟨i, _, rfl⟩ := mem_image.mp hp + exact hprime i (x i) + +omit [DecidableEq α] [∀ i, Fintype (P i)] in +/-- With distinct selected primes, the integer family center is exactly the +paper's product over prime divisors of the numerical tuple. -/ +lemma familyCenter_zero_eq_centeredTuple (value : (i : α) → P i → ℕ) + (hprime : ∀ i p, (value i p).Prime) (x : (i : α) → P i) + (hinj : Function.Injective (fun i => value i (x i))) (n : ℤ) : + familyCenter value (fun _ _ => 0) x n = centeredTuple (familyTuple value x).primeFactors n := by + classical + rw [familyTuple_primeFactors value hprime x hinj, centeredTuple, prod_image] + · simp only [familyCenter, zero_add] + · exact fun i _ j _ hij => hinj hij + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeLiouvilleQuadratic.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeLiouvilleQuadratic.lean new file mode 100644 index 0000000000000000000000000000000000000000..4affe5d42dfee2868b650d1d6b4c8f6e569c7a69 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeLiouvilleQuadratic.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TwoPoint.Bounds.GraphMatrixCompression +import OAI.NumberTheory.TwoPoint.Bounds.LiouvilleQuadraticIdentity + +namespace OAI + +/-! The full tuple graph tests to the literal sum of retained directed +Liouville edges, with the original numerical tuple and padding divisor. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem prime_graph_liouville_quadratic {J : ℕ} {V : Type*} [Fintype V] [DecidableEq V] + (P : Fin J → Finset ℕ) (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (site : V → ℤ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) (keep : ℤ → Prop) (h : ℕ) + (gate : ℕ → V → V → Prop) (hgate : ∀ d i j, gate d i j ↔ gate d j i) + (hg : ∀ z, g z ≠ 0) : + let v := WithLp.toLp 2 (fun i => retainedLiouvilleScalar g keep (site i)) + inner ℂ v ((∑ d, primeFamilyGraphOperator (fun j (p : P j) => p.val) + (fun _ _ => 0) site Q u eligible g L K extra h gate d) v) = + (2 * (L : ℂ)) * ∑ d : (j : Fin J) → P j, ∑ i, ∑ j, + if gate (∏ k, (d k).val) i j then ∑ q ∈ Q, + retainedLiouvilleEdge Q u (eligible (∏ k, (d k).val)) g + (centeredTuple (∏ k, (d k).val).primeFactors) L K + (extra (∏ k, (d k).val)) keep h (∏ k, (d k).val) q (site i) (site j) + else 0 := by + dsimp only + let v : EuclideanSpace ℂ V := WithLp.toLp 2 (fun i => retainedLiouvilleScalar g keep (site i)) + have hd (d : (j : Fin J) → P j) : + inner ℂ v (primeFamilyGraphOperator (fun j (p : P j) => p.val) + (fun _ _ => 0) site Q u eligible g L K extra h gate d v) = + (2 * (L : ℂ)) * ∑ i, ∑ j, + if gate (∏ k, (d k).val) i j then ∑ q ∈ Q, + retainedLiouvilleEdge Q u (eligible (∏ k, (d k).val)) g + (centeredTuple (∏ k, (d k).val).primeFactors) L K + (extra (∏ k, (d k).val)) keep h (∏ k, (d k).val) q (site i) (site j) + else 0 := by + have hc : familyCenter (fun j (p : P j) => p.val) (fun _ _ => 0) d = + centeredTuple (∏ j, (d j).val).primeFactors := by + funext n + exact familyCenter_zero_eq_centeredTuple _ (fun j p => hprime j _ p.property) + d (selectedPrimeValues_injective d hdisjoint) n + unfold primeFamilyGraphOperator + rw [hc] + exact maskedLiouville_quadratic site Q u _ g _ L K _ keep h _ _ (hgate _) hg + change inner ℂ v ((∑ d, primeFamilyGraphOperator (fun j (p : P j) => p.val) + (fun _ _ => 0) site Q u eligible g L K extra h gate d) v) = _ + rw [_root_.sum_apply, inner_sum] + simp_rw [hd] + rw [mul_sum] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeLiteralEncoding.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeLiteralEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..99433c6e777dd3406386577231d6c6fb9785dfcb --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeLiteralEncoding.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteResidueComparison +import OAI.NumberTheory.TwoPoint.Bounds.CommonResidueLift +import Mathlib.Data.Nat.Prime.Basic + +namespace OAI + +/-! Canonical residue coordinates for the prime-and-offset literals +occurring in a weighted matrix word. Repeated tests share one prime +coordinate, and may have different offsets. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def primeResidueModuli (P : Finset ℕ) : Fin (Fintype.card P) → ℕ := + fun i => ((Fintype.equivFin P).symm i).val + +noncomputable def primeLiteralCoordinate (P : Finset ℕ) {n : ℕ} + (literal : Fin n → P × ℤ) : Fin n → Fin (Fintype.card P) := + fun i => (Fintype.equivFin P) (literal i).1 + +noncomputable def primeLiteralTest (P : Finset ℕ) {n : ℕ} + (literal : Fin n → P × ℤ) (i : Fin n) + (z : ZMod (primeResidueModuli P (primeLiteralCoordinate P literal i))) : Bool := + decide (z = -((literal i).2 : ZMod (primeResidueModuli P (primeLiteralCoordinate P literal i)))) + +lemma primeResidueModuli_coordinate (P : Finset ℕ) {n : ℕ} + (literal : Fin n → P × ℤ) (i : Fin n) : + primeResidueModuli P (primeLiteralCoordinate P literal i) = (literal i).1.val := by + simp [primeResidueModuli, primeLiteralCoordinate] + +lemma primeLiteral_integer_input (P : Finset ℕ) {n : ℕ} + (literal : Fin n → P × ℤ) (a : ℤ) (i : Fin n) : + residueCircuitInputs (primeResidueModuli P) (primeLiteralCoordinate P literal) + (primeLiteralTest P literal) (fun j => (a : ZMod (primeResidueModuli P j))) i = + decide (((literal i).1.val : ℤ) ∣ a + (literal i).2) := by + change decide ((a : ZMod (primeResidueModuli P (primeLiteralCoordinate P literal i))) = + -((literal i).2 : ZMod (primeResidueModuli P (primeLiteralCoordinate P literal i)))) = _ + apply Bool.decide_congr + exact (residue_offset_divisibility + (a : ZMod (primeResidueModuli P (primeLiteralCoordinate P literal i))) + a (literal i).2 rfl).symm.trans (by rw [primeResidueModuli_coordinate]) + +lemma primeResidueModuli_prime (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (i : Fin (Fintype.card P)) : (primeResidueModuli P i).Prime := + hP _ ((Fintype.equivFin P).symm i).property + +lemma primeResidueModuli_coprime (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) : + Pairwise (fun i j => (primeResidueModuli P i).Coprime (primeResidueModuli P j)) := by + intro i j hij + apply (Nat.coprime_primes (primeResidueModuli_prime P hP i) + (primeResidueModuli_prime P hP j)).mpr + intro he + apply hij + apply (Fintype.equivFin P).symm.injective + exact Subtype.ext he + +lemma primeResidueModuli_bound (P : Finset ℕ) (B : ℝ) + (hP : ∀ p ∈ P, (p : ℝ) ≤ B) (i : Fin (Fintype.card P)) : + (primeResidueModuli P i : ℝ) ≤ B := hP _ ((Fintype.equivFin P).symm i).property + +lemma primePool_card_bound (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (B : ℕ) (hB : ∀ p ∈ P, p ≤ B) : P.card ≤ B := by + let f : P → Fin B := fun p => ⟨p.val - 1, by have := (hP _ p.property).pos; have := hB _ p.property; omega⟩ + have hf : Function.Injective f := by + intro p q hpq + apply Subtype.ext + have he : p.val - 1 = q.val - 1 := congrArg Fin.val hpq + have hp := (hP _ p.property).pos + have hq := (hP _ q.property).pos + omega + simpa only [Fintype.card_coe, Fintype.card_fin] using Fintype.card_le_of_injective f hf + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeMatrixResidues.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeMatrixResidues.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f43c024cb3ccf47fff3b79139d3ed8edd0e8324 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeMatrixResidues.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResidueMatrixMoment +import OAI.NumberTheory.TwoPoint.Walks.ClosedTraceEncoding + +namespace OAI + +/-! Discharge residue periodicity for the literal prime-family matrix weights. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem primeClosedPair_residue_congr {h J M B k : ℕ} {P : Fin J → Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (hP : ∀ j, P j ⊆ data.P) (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (s : ℕ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) + (hsq : ∀ q ∈ Q, Squarefree q) (hpool : ∀ q ∈ Q, q.primeFactors ⊆ data.Q) + (hg : ∀ n m : ℤ, (∀ p ∈ data.Q, (n : ZMod p) = (m : ZMod p)) → g n = g m) + (hextra : ∀ d n m, (∀ p ∈ data.Q, (n : ZMod p) = (m : ZMod p)) → + (extra d n ↔ extra d m)) + (a b : Fin k → ((j : Fin J) → P j) × (Q × Bool)) + (t : SignedStep) + (ht : t ∈ integerClosedWordCode Q (fun d => ∏ j, (d j).val) (a, b)) + (n m : ℤ) (hnm : ∀ p : ↥(data.P ∪ data.Q), (n : ZMod p.val) = (m : ZMod p.val)) : + maskedSignedIntegerWeight Q u eligible g (fun d => centeredTuple d.primeFactors) + L K extra h (fun z => ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) z) t n = + maskedSignedIntegerWeight Q u eligible g (fun d => centeredTuple d.primeFactors) + L K extra h (fun z => ¬ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) z) t m := by + rw [← closedTraceEncoding_word Q (a, b)] at ht + obtain ⟨i, rfl⟩ := List.mem_ofFn.mp ht + apply maskedSignedIntegerWeight_residue_congr data hB s Q u eligible g L K extra + hsq hpool hg hextra _ _ n m hnm + rw [columnTuple_primeFactors _ i hprime hdisjoint] + intro p hp + obtain ⟨j, _, rfl⟩ := mem_image.mp hp + exact hP j ((closedTraceEncoding Q (a, b)).2.1 j i).property + +lemma maskedSignedIntegerWeight_pairs (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → ℕ → Prop) (g : ℤ → ℝ) (center : ℕ → ℤ → ℝ) + (L K : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) (keep : ℤ → Prop) + (pairs : Finset (ℕ × ℕ)) (hallowed : ∀ d q, eligible d q → (d, q) ∈ pairs) + (t : SignedStep) (n : ℤ) + (hw : maskedSignedIntegerWeight Q u eligible g center L K extra h keep t n ≠ 0) : + (t.tuple, t.padding) ∈ pairs := by + have hs := (mul_ne_zero_iff.mp (mul_ne_zero_iff.mp hw).1).2 + exact hallowed _ _ (signedIntegerWeight_nonzero Q u (eligible t.tuple) g + (center t.tuple) L K (extra t.tuple) h t n hs).2.1 + +lemma scalarWalkProduct_pairs (h : ℕ) (weight : SignedStep → ℤ → ℝ) + (pairs : Finset (ℕ × ℕ)) + (hsupport : ∀ t n, weight t n ≠ 0 → (t.tuple, t.padding) ∈ pairs) + (w : List SignedStep) (n : ℤ) (hw : scalarWalkProduct h weight n w ≠ 0) : + ∀ t ∈ w, (t.tuple, t.padding) ∈ pairs := by + induction w generalizing n with + | nil => simp + | cons t w ih => + have hp := mul_ne_zero_iff.mp hw + intro a ha + rcases List.mem_cons.mp ha with rfl | ha + · exact hsupport _ _ hp.1 + · exact ih _ hp.2 a ha + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeModulusDefect.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeModulusDefect.lean new file mode 100644 index 0000000000000000000000000000000000000000..72e5cc9263a44632a001e0d648a60453db1e0eac --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeModulusDefect.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeDefectCRT +import Mathlib.Topology.Algebra.InfiniteSum.Real + +namespace OAI + +/-! The exact modulus-defect series used in the qualitative reduction. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def primeModulusDefect (f : ℕ → ℂ) (p : ℕ) : ℝ := + if p.Prime then (1 - ‖f p‖) / (p : ℝ) else 0 + +lemma primeModulusDefect_nonneg {f : ℕ → ℂ} (hf : OneBounded f) (p : ℕ) : + 0 ≤ primeModulusDefect f p := by + unfold primeModulusDefect + split_ifs with hp + · exact div_nonneg (sub_nonneg.mpr (hf p hp.pos)) (Nat.cast_nonneg p) + · exact le_rfl + +lemma prime_square_density_lower {p : ℕ} (hp : p.Prime) : + (1 / (p : ℝ)) / 2 ≤ 1 / (p : ℝ) - 1 / (p : ℝ) ^ 2 := by + have hp0 : (0 : ℝ) < p := by exact_mod_cast hp.pos + have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast hp.two_le + calc + _ = ((p : ℝ) / 2) / (p : ℝ) ^ 2 := by field_simp [hp0.ne'] + _ ≤ ((p : ℝ) - 1) / (p : ℝ) ^ 2 := + div_le_div_of_nonneg_right (by linarith) (sq_nonneg _) + _ = _ := by field_simp [hp0.ne'] + +lemma prime_square_defect_factor_nonneg {f : ℕ → ℂ} (hf : OneBounded f) + {p : ℕ} (hp : p.Prime) : + 0 ≤ 1 - (1 - ‖f p‖) * (1 / (p : ℝ) - 1 / (p : ℝ) ^ 2) := by + have hp1 : (1 : ℝ) ≤ p := by exact_mod_cast hp.pos + have hi : 1 / (p : ℝ) ≤ 1 := (div_le_one (by exact_mod_cast hp.pos)).mpr hp1 + have hc : 0 ≤ 1 - ‖f p‖ := sub_nonneg.mpr (hf p hp.pos) + have hd : 1 / (p : ℝ) - 1 / (p : ℝ) ^ 2 ≤ 1 := by + have hh : 0 ≤ 1 / (p : ℝ) ^ 2 := by positivity + linarith + have hb := mul_le_mul_of_nonneg_left hd hc + have hn := norm_nonneg (f p) + nlinarith + +lemma prime_square_defect_factor_le_exp {f : ℕ → ℂ} (hf : OneBounded f) + {p : ℕ} (hp : p.Prime) : + 1 - (1 - ‖f p‖) * (1 / (p : ℝ) - 1 / (p : ℝ) ^ 2) ≤ + Real.exp (-primeModulusDefect f p / 2) := by + have hc : 0 ≤ 1 - ‖f p‖ := sub_nonneg.mpr (hf p hp.pos) + have hd := mul_le_mul_of_nonneg_left (prime_square_density_lower hp) hc + have hd' : primeModulusDefect f p / 2 ≤ + (1 - ‖f p‖) * (1 / (p : ℝ) - 1 / (p : ℝ) ^ 2) := by + simpa only [primeModulusDefect, ite_eq_left hp, div_eq_mul_inv, one_mul, + mul_assoc] using hd + have he := Real.add_one_le_exp (-primeModulusDefect f p / 2) + linarith + +lemma prime_square_defect_product_le_exp {f : ℕ → ℂ} (hf : OneBounded f) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) : + (∏ p ∈ P, (1 - (1 - ‖f p‖) * (1 / (p : ℝ) - 1 / (p : ℝ) ^ 2))) ≤ + Real.exp (-(∑ p ∈ P, primeModulusDefect f p) / 2) := by + calc + _ ≤ ∏ p ∈ P, Real.exp (-primeModulusDefect f p / 2) := + prod_le_prod₀ (fun p hp => prime_square_defect_factor_nonneg hf (hP p hp)) + (fun p hp => prime_square_defect_factor_le_exp hf (hP p hp)) + _ = _ := by rw [← Real.exp_sum, ← sum_div, sum_neg_distrib] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePaddingDeletion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePaddingDeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c9d2205c401b66012a7decc40023f374574f155 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePaddingDeletion.lean @@ -0,0 +1,114 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimePaddingFactorization + +namespace OAI + +/-! The literal tuple-degree deletion keeps the padding weight. Its +expectation factors because the two prime pools are disjoint. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace ProhibitedPrimeFamily + +variable {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + +lemma padding_vertex_square_average (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (site : ℤ) : + (data.paddingResidueLaw B hB).average (fun z => + (actualPaddingVertex data.Q (data.paddingResidueOrigin z + site)) ^ 2) = + paddingTiltNormalizer data.Q := by + have he (z : data.Q → Fin B) : + (actualPaddingVertex data.Q (data.paddingResidueOrigin z + site)) ^ 2 = + paddingTiltWeight data.Q (paddingResidueAvailable data.Q B site z) := by + rw [actualPaddingVertex_sq] + apply actualPaddingWeight_lift + intro p + rw [Int.cast_add, data.paddingResidueOrigin_spec] + simp_rw [he] + change (FiniteLaw.independent (fun p : data.Q => + uniformResidueLaw B p.val (data.primeQ p p.property).pos + (hB p (mem_union_right _ p.property)))).average + (fun z => paddingTiltWeight data.Q (paddingResidueAvailable data.Q B site z)) = _ + rw [padding_residue_average data.Q B (fun p hp => (data.primeQ p hp).two_le) + (fun p hp => hB p (mem_union_right _ hp)) site (paddingTiltWeight data.Q)] + exact padding_tilt_total data.Q _ + +lemma positive_prime_padding_square_average + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (S : Finset ℕ) (hSP : S ⊆ data.P) (site : ℤ) : + (data.residueLaw B hB).average (fun x => + positivePrimeWeight S (data.residueOrigin x + site) * + (actualPaddingVertex data.Q (data.residueOrigin x + site)) ^ 2) = + positivePrimeNormalizer S * paddingTiltNormalizer data.Q := by + have hh := data.positive_prime_padding_average hB S hSP site + (fun n => (actualPaddingVertex data.Q n) ^ 2) + (fun n m hnm => congrArg (fun t : ℝ => t ^ 2) + (actualPaddingVertex_residue_congr data.Q n m hnm)) + rw [data.padding_vertex_square_average hB site] at hh + exact hh + +theorem positive_prime_padding_square_degree_tail + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (S : Finset ℕ) (hSP : S ⊆ data.P) (W : ℝ) (hW : 10 ≤ W) + (hmass : (∑ p ∈ data.P, 1 / (p : ℝ)) ≤ 2 * W * S.card) (site : ℤ) : + (data.residueLaw B hB).average (fun x => + (positivePrimeWeight S (data.residueOrigin x + site) * + if 6 * W * S.card < (actualPaddingDegree data.P (data.residueOrigin x + site) : ℝ) + then 1 else 0) * (actualPaddingVertex data.Q (data.residueOrigin x + site)) ^ 2) ≤ + (positivePrimeNormalizer S * Real.exp (-2 * W * S.card)) * + paddingTiltNormalizer data.Q := by + have hh := data.positive_prime_padding_degree_tail hB S hSP W hW hmass site + (fun n => (actualPaddingVertex data.Q n) ^ 2) (fun n => sq_nonneg _) + (fun n m hnm => congrArg (fun t : ℝ => t ^ 2) + (actualPaddingVertex_residue_congr data.Q n m hnm)) + rw [data.padding_vertex_square_average hB site] at hh + exact hh + +theorem centered_tuple_padding_square_average + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (d : ℕ) (hd : Squarefree d) (hdP : d.primeFactors ⊆ data.P) + (hdJ : d.primeFactors.card = J) (site : ℤ) : + (data.residueLaw B hB).average (fun x => + |centeredTuple d.primeFactors (data.residueOrigin x + site)| * + (actualPaddingVertex data.Q (data.residueOrigin x + site)) ^ 2) ≤ + ((2 : ℝ) ^ J / d) * paddingTiltNormalizer data.Q := by + calc + _ ≤ (data.residueLaw B hB).average (fun x => + positivePrimeWeight d.primeFactors (data.residueOrigin x + site) * + (actualPaddingVertex data.Q (data.residueOrigin x + site)) ^ 2) := by + apply FiniteLaw.average_mono + intro x + exact mul_le_mul_of_nonneg_right (abs_centeredTuple_le_positivePrimeWeight _ _) + (sq_nonneg _) + _ = _ := by + rw [data.positive_prime_padding_square_average hB d.primeFactors hdP site, + positivePrimeNormalizer_squarefree d hd, hdJ] + +theorem centered_tuple_padding_square_degree_tail + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (d : ℕ) (hd : Squarefree d) (hdP : d.primeFactors ⊆ data.P) + (hdJ : d.primeFactors.card = J) (W : ℝ) (hW : 10 ≤ W) + (hmass : (∑ p ∈ data.P, 1 / (p : ℝ)) ≤ 2 * W * J) (site : ℤ) : + (data.residueLaw B hB).average (fun x => + (|centeredTuple d.primeFactors (data.residueOrigin x + site)| * + if 6 * W * J < (actualPaddingDegree data.P (data.residueOrigin x + site) : ℝ) + then 1 else 0) * (actualPaddingVertex data.Q (data.residueOrigin x + site)) ^ 2) ≤ + (((2 : ℝ) ^ J / d) * Real.exp (-2 * W * J)) * + paddingTiltNormalizer data.Q := by + have ht := data.positive_prime_padding_square_degree_tail hB d.primeFactors hdP W hW + (by simpa only [hdJ] using hmass) site + rw [positivePrimeNormalizer_squarefree d hd, hdJ] at ht + apply le_trans _ ht + apply FiniteLaw.average_mono + intro x + apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) + apply mul_le_mul_of_nonneg_right (abs_centeredTuple_le_positivePrimeWeight _ _) + split_ifs <;> norm_num + +end ProhibitedPrimeFamily + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePaddingFactorization.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePaddingFactorization.lean new file mode 100644 index 0000000000000000000000000000000000000000..f16d66b5bcdacf935639c55262fa87738f383437 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePaddingFactorization.lean @@ -0,0 +1,202 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResidueRestriction +import OAI.NumberTheory.TwoPoint.Bounds.PaddingResidueTilt +import OAI.NumberTheory.TwoPoint.Bounds.PrimeDegreeTail + +namespace OAI + +/-! Exact independence of tuple-prime and padding-prime observables under +the actual union residue law. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace FiniteLaw + +lemma independent_average_sum_product {ι κ A : Type*} + [Fintype ι] [Fintype κ] [Fintype A] [DecidableEq ι] [DecidableEq κ] + (μ : ι → FiniteLaw A) (ν : κ → FiniteLaw A) + (f : (ι → A) → ℝ) (g : (κ → A) → ℝ) : + (independent (Sum.elim μ ν)).average + (fun x => f (fun i => x (Sum.inl i)) * g (fun k => x (Sum.inr k))) = + (independent μ).average f * (independent ν).average g := by + let e := Equiv.sumArrowEquivProdArrow ι κ A + calc + _ = ∑ xy : (ι → A) × (κ → A), + (independent (Sum.elim μ ν)).weight (Sum.elim xy.1 xy.2) * (f xy.1 * g xy.2) := + (e.symm.sum_comp (fun x => (independent (Sum.elim μ ν)).weight x * + (f (fun i => x (Sum.inl i)) * g (fun k => x (Sum.inr k))))).symm + _ = _ := by + simp only [Fintype.sum_prod_type, independent, Fintype.prod_sum_type, + Sum.elim_inl, Sum.elim_inr, average] + rw [sum_mul] + apply sum_congr rfl + intro x _ + rw [mul_sum] + apply sum_congr rfl + intro y _ + ring + +end FiniteLaw + +namespace ProhibitedPrimeFamily + +variable {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + +def tupleRestriction (x : ↥(data.P ∪ data.Q) → Fin B) : data.P → Fin B := + fun p => x ⟨p.val, mem_union_left _ p.property⟩ + +noncomputable def tupleResidueLaw (B : ℕ) + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) : FiniteLaw (data.P → Fin B) := + FiniteLaw.independent (fun p : data.P => + uniformResidueLaw B p.val (data.primeP _ p.property).pos + (hB _ (mem_union_left _ p.property))) + +lemma residue_average_tuple_padding + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (f : (data.P → Fin B) → ℝ) (g : (data.Q → Fin B) → ℝ) : + (data.residueLaw B hB).average (fun x => + f (data.tupleRestriction x) * g (data.paddingRestriction x)) = + (data.tupleResidueLaw B hB).average f * + (data.paddingResidueLaw B hB).average g := by + let e : data.P ⊕ data.Q → ↥(data.P ∪ data.Q) := Sum.elim + (fun p => ⟨p.val, mem_union_left _ p.property⟩) + (fun p => ⟨p.val, mem_union_right _ p.property⟩) + have he : Function.Injective e := by + intro x y hxy + have hv := congrArg (fun p : ↥(data.P ∪ data.Q) => p.val) hxy + cases x with + | inl p => + cases y with + | inl q => exact congrArg Sum.inl (Subtype.ext hv) + | inr q => + exact False.elim (disjoint_left.mp data.disjoint p.property (hv.symm ▸ q.property)) + | inr p => + cases y with + | inl q => + exact False.elim (disjoint_left.mp data.disjoint q.property (hv ▸ p.property)) + | inr q => exact congrArg Sum.inr (Subtype.ext hv) + let μ := fun p : ↥(data.P ∪ data.Q) => + uniformResidueLaw B p.val (data.prime p).pos (hB _ p.property) + have hμ : (fun i => μ (e i)) = Sum.elim + (fun p : data.P => uniformResidueLaw B p.val (data.primeP _ p.property).pos + (hB _ (mem_union_left _ p.property))) + (fun p : data.Q => uniformResidueLaw B p.val (data.primeQ _ p.property).pos + (hB _ (mem_union_right _ p.property))) := by + funext i + cases i <;> rfl + have ht := FiniteLaw.independent_average_embedding e he μ + (fun x => f (fun p => x (Sum.inl p)) * g (fun p => x (Sum.inr p))) + rw [hμ, FiniteLaw.independent_average_sum_product] at ht + exact ht + +/-- Prime divisibility observables and an arbitrary padding-periodic +integer weight are independent at the same translated CRT origin. -/ +lemma residue_average_prime_boolean_padding + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) (site : ℤ) + (F : (data.P → Bool) → ℝ) (g : ℤ → ℝ) + (hg : ∀ n m : ℤ, (∀ q ∈ data.Q, (n : ZMod q) = (m : ZMod q)) → g n = g m) : + (data.residueLaw B hB).average (fun x => + F (fun p : data.P => decide ((p.val : ℤ) ∣ data.residueOrigin x + site)) * + g (data.residueOrigin x + site)) = + (paddingOriginalLaw data.P (fun p hp => (data.primeP p hp).two_le)).average F * + (data.paddingResidueLaw B hB).average (fun z => + g (data.paddingResidueOrigin z + site)) := by + calc + _ = (data.residueLaw B hB).average (fun x => + F (paddingResidueAvailable data.P B site (data.tupleRestriction x)) * + g (data.paddingResidueOrigin (data.paddingRestriction x) + site)) := by + apply congrArg (data.residueLaw B hB).average + funext x + apply congrArg₂ (fun a b : ℝ => a * b) + · apply congrArg F + funext p + change decide ((p.val : ℤ) ∣ data.residueOrigin x + site) = + decide ((p.val : ℤ) ∣ (x ⟨p.val, mem_union_left _ p.property⟩).val + site) + have hdiv : (p.val : ℤ) ∣ data.residueOrigin x + site ↔ + (p.val : ℤ) ∣ (x ⟨p.val, mem_union_left _ p.property⟩).val + site := + data.residueOrigin_divisibility x ⟨p.val, mem_union_left _ p.property⟩ site + simp only [hdiv] + · apply hg + intro q hq + let p : data.Q := ⟨q, hq⟩ + rw [Int.cast_add, Int.cast_add] + exact congrArg (fun a : ZMod q => a + (site : ZMod q)) + ((data.residueOrigin_spec x (data.paddingCoordinate p)).trans + (data.paddingResidueOrigin_spec (data.paddingRestriction x) p).symm) + _ = (data.tupleResidueLaw B hB).average + (fun z => F (paddingResidueAvailable data.P B site z)) * + (data.paddingResidueLaw B hB).average + (fun z => g (data.paddingResidueOrigin z + site)) := + data.residue_average_tuple_padding hB + (fun z : data.P → Fin B => F (paddingResidueAvailable data.P B site z)) + (fun z : data.Q → Fin B => g (data.paddingResidueOrigin z + site)) + _ = _ := by + congr 1 + exact padding_residue_average data.P B (fun p hp => (data.primeP p hp).two_le) + (fun p hp => hB p (mem_union_left _ hp)) site F + +lemma positive_prime_padding_average + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (S : Finset ℕ) (hSP : S ⊆ data.P) (site : ℤ) (g : ℤ → ℝ) + (hg : ∀ n m : ℤ, (∀ q ∈ data.Q, (n : ZMod q) = (m : ZMod q)) → g n = g m) : + (data.residueLaw B hB).average (fun x => + positivePrimeWeight S (data.residueOrigin x + site) * g (data.residueOrigin x + site)) = + positivePrimeNormalizer S * (data.paddingResidueLaw B hB).average + (fun z => g (data.paddingResidueOrigin z + site)) := by + let q := fun p : data.P => 1 / (p.val : ℝ) + let T := primeSelection data.P S hSP + have hq0 (p : data.P) : 0 ≤ q p := by dsimp [q]; positivity + have hq1 (p : data.P) : q p ≤ 1 := by + apply (div_le_one (by exact_mod_cast (data.primeP p p.property).pos)).mpr + exact_mod_cast (data.primeP p p.property).one_lt.le + simp_rw [positivePrimeWeight_eq_selection data.P S hSP] + rw [data.residue_average_prime_boolean_padding hB site (positiveCenterWeight q T) g hg] + have hm : (paddingOriginalLaw data.P (fun p hp => (data.primeP p hp).two_le)).average + (positiveCenterWeight q T) = positivePrimeNormalizer S := by + simpa only [paddingOriginalLaw, paddingOriginalPrimeLaw, q, T] using + (positive_center_tilt_total q T hq0 hq1).trans + (positivePrimeNormalizer_eq_selection data.P S hSP).symm + rw [hm] + +theorem positive_prime_padding_degree_tail + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (S : Finset ℕ) (hSP : S ⊆ data.P) (W : ℝ) (hW : 10 ≤ W) + (hmass : (∑ p ∈ data.P, 1 / (p : ℝ)) ≤ 2 * W * S.card) + (site : ℤ) (g : ℤ → ℝ) (hg0 : ∀ n, 0 ≤ g n) + (hg : ∀ n m : ℤ, (∀ q ∈ data.Q, (n : ZMod q) = (m : ZMod q)) → g n = g m) : + (data.residueLaw B hB).average (fun x => + (positivePrimeWeight S (data.residueOrigin x + site) * + if 6 * W * S.card < (actualPaddingDegree data.P (data.residueOrigin x + site) : ℝ) + then 1 else 0) * g (data.residueOrigin x + site)) ≤ + (positivePrimeNormalizer S * Real.exp (-2 * W * S.card)) * + (data.paddingResidueLaw B hB).average (fun z => + g (data.paddingResidueOrigin z + site)) := by + let q := fun p : data.P => 1 / (p.val : ℝ) + let T := primeSelection data.P S hSP + let F := fun a : data.P → Bool => positiveCenterWeight q T a * + if 6 * W * T.card < booleanCount a then (1 : ℝ) else 0 + have he (x : ↥(data.P ∪ data.Q) → Fin B) : + (positivePrimeWeight S (data.residueOrigin x + site) * + if 6 * W * S.card < (actualPaddingDegree data.P (data.residueOrigin x + site) : ℝ) + then (1 : ℝ) else 0) = + F (fun p : data.P => decide ((p.val : ℤ) ∣ data.residueOrigin x + site)) := by + dsimp [F] + rw [positivePrimeWeight_eq_selection data.P S hSP, + actualPrimeDegree_eq_count, primeSelection_card] + have htail : (paddingOriginalLaw data.P (fun p hp => (data.primeP p hp).two_le)).average F ≤ + positivePrimeNormalizer S * Real.exp (-2 * W * S.card) := by + rw [← data.residue_average_prime_availability hB site F] + simp_rw [← he] + exact data.positive_prime_degree_tail hB S hSP W hW hmass site + simp_rw [he] + rw [data.residue_average_prime_boolean_padding hB site F g hg] + exact mul_le_mul_of_nonneg_right htail + ((data.paddingResidueLaw B hB).average_nonneg (fun z => hg0 _)) + +end ProhibitedPrimeFamily + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePairCatalog.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePairCatalog.lean new file mode 100644 index 0000000000000000000000000000000000000000..f12d17a54476bad29e01cdeee22a688424bbd050 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePairCatalog.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualPrimeScale + +namespace OAI + +/-! The tuple/padding pair catalog injects into its integer product: +the two factors have disjoint prime supports. Thus the numerical bin +endpoint bounds the whole catalog, without an extra tuple factor. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma ProhibitedPrimeFamily.pair_cross_coprime {h J M : ℕ} + (data : ProhibitedPrimeFamily h J M) (a b : data.pairs) : a.val.1.Coprime b.val.2 := by + apply (Nat.disjoint_primeFactors (data.tuple_squarefree _ a.property).ne_zero + (data.padding_squarefree _ b.property).ne_zero).mp + exact data.disjoint.mono (data.tuple_pool _ a.property) (data.padding_pool _ b.property) + +lemma ProhibitedPrimeFamily.pair_product_injective {h J M : ℕ} + (data : ProhibitedPrimeFamily h J M) : + Function.Injective (fun a : data.pairs => a.val.1 * a.val.2) := by + intro a b hab + change a.val.1 * a.val.2 = b.val.1 * b.val.2 at hab + have hdab : a.val.1 ∣ b.val.1 := (data.pair_cross_coprime a b).dvd_of_dvd_mul_right + (hab ▸ dvd_mul_right a.val.1 a.val.2) + have hdba : b.val.1 ∣ a.val.1 := (data.pair_cross_coprime b a).dvd_of_dvd_mul_right + (hab.symm ▸ dvd_mul_right b.val.1 b.val.2) + have hd : a.val.1 = b.val.1 := Nat.dvd_antisymm hdab hdba + have hq : a.val.2 = b.val.2 := by + rw [← hd] at hab + exact Nat.eq_of_mul_eq_mul_left + (Nat.pos_of_ne_zero (data.tuple_squarefree _ a.property).ne_zero) hab + exact Subtype.ext (Prod.ext hd hq) + +lemma ProhibitedPrimeFamily.pairs_card_le {h J M : ℕ} + (data : ProhibitedPrimeFamily h J M) (B : ℕ) + (hB : ∀ dq ∈ data.pairs, dq.1 * dq.2 ≤ B) : data.pairs.card ≤ B := by + have hp (a : data.pairs) : 0 < a.val.1 * a.val.2 := + Nat.mul_pos (Nat.pos_of_ne_zero (data.tuple_squarefree _ a.property).ne_zero) + (Nat.pos_of_ne_zero (data.padding_squarefree _ a.property).ne_zero) + let f : data.pairs → Fin B := fun a => + ⟨a.val.1 * a.val.2 - 1, by have := hp a; have := hB _ a.property; omega⟩ + have hf : Function.Injective f := by + intro a b hab + apply data.pair_product_injective + change a.val.1 * a.val.2 = b.val.1 * b.val.2 + have he : a.val.1 * a.val.2 - 1 = b.val.1 * b.val.2 - 1 := congrArg Fin.val hab + have ha := hp a + have hb := hp b + omega + simpa only [Fintype.card_coe, Fintype.card_fin] using Fintype.card_le_of_injective f hf + +lemma paddingPairEligible_product_upper {L η : ℝ} {d q : ℕ} + (hη : 0 < η) (hηone : η ≤ 1) (he : PaddingPairEligible L η d q) : + d * q ≤ ⌊Real.exp (100 * L + 1)⌋₊ := by + by_cases hz : d * q = 0 + · simp [hz] + let j := paddingBin η 0 (Real.log (d * q : ℕ)) + have hj := (mem_paddingBinIndices_iff L η j hη).mp he.2 + have hx := (paddingBin_eq_iff η 0 (Real.log (d * q : ℕ)) j hη).mp rfl + simp only [add_zero] at hx + have hu : Real.log (d * q : ℕ) ≤ 100 * L + 1 := by + nlinarith [hj.2, hx.2] + apply (Nat.le_floor_iff (Real.exp_pos _).le).mpr + have hp : (0 : ℝ) < (d * q : ℕ) := by exact_mod_cast Nat.pos_of_ne_zero hz + simpa only [Real.exp_log hp] using Real.exp_le_exp.mpr hu + +lemma actualProhibitedPrimeFamily_pairs_card (h J M : ℕ) (E : Finset ℕ) + (A W L η : ℝ) (eligible : ℕ → ℕ → Prop) (hA : 0 ≤ A) (hW : 0 ≤ W) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) (hL : 1 ≤ L) + (hη : 0 < η) (hηone : η ≤ 1) + (he : ∀ d q, eligible d q → PaddingPairEligible L η d q) : + ((actualProhibitedPrimeFamily h J M E A W L eligible hA hW hE).pairs.card : ℝ) ≤ + Real.exp (101 * L) := by + let data := actualProhibitedPrimeFamily h J M E A W L eligible hA hW hE + have hb : data.pairs.card ≤ ⌊Real.exp (100 * L + 1)⌋₊ := by + apply data.pairs_card_le + intro dq hdq + have hm := (actualProhibitedPrimeFamily_pairs h J M E A W L eligible hA hW hE + dq.1 dq.2).mp hdq + exact paddingPairEligible_product_upper hη hηone (he _ _ hm.2.2.2) + have hbr : (data.pairs.card : ℝ) ≤ (⌊Real.exp (100 * L + 1)⌋₊ : ℝ) := by exact_mod_cast hb + exact (hbr.trans (Nat.floor_le (Real.exp_pos _).le)).trans + (Real.exp_le_exp.mpr (by linarith)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePartialSummation.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePartialSummation.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c913337cf2d79d8f696a57a107b3d44f6b15d6a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePartialSummation.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePrimes +import Mathlib.NumberTheory.AbelSummation +import Mathlib.MeasureTheory.Integral.IntervalIntegral.IntegrationByParts + +namespace OAI + +/-! Exact partial summation, with the prime-count error retained inside the +integral. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +noncomputable def partialCoefficientSum (c : ℕ → ℝ) (x : ℝ) : ℝ := + ∑ n ∈ Icc 0 ⌊x⌋₊, c n + +theorem centered_partial_summation (c : ℕ → ℝ) (α a b : ℝ) (ha : 0 ≤ a) + (hab : a ≤ b) (f : ℝ → ℝ) + (hf : ∀ x ∈ Set.Icc a b, DifferentiableAt ℝ f x) + (hdf : ContinuousOn (deriv f) (Set.Icc a b)) : + (∑ n ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, f n * c n) - α * (∫ t in a..b, f t) = + f b * (partialCoefficientSum c b - α * b) - + f a * (partialCoefficientSum c a - α * a) - + ∫ t in a..b, deriv f t * (partialCoefficientSum c t - α * t) := by + have hfc : ContinuousOn f (Set.Icc a b) := + fun x hx => (hf x hx).continuousAt.continuousWithinAt + have hfi : IntervalIntegrable f volume a b := hfc.intervalIntegrable_of_Icc hab + have hdfi : IntervalIntegrable (deriv f) volume a b := + hdf.intervalIntegrable_of_Icc hab + have hdmain : IntervalIntegrable (fun t => deriv f t * t) volume a b := + hdfi.mul_continuousOn continuous_id.continuousOn + have hsum : IntervalIntegrable + (fun t => deriv f t * partialCoefficientSum c t) volume a b := by + apply (intervalIntegrable_iff_integrableOn_Icc_of_le hab).mpr + exact integrableOn_mul_sum_Icc c ha + (hdf.integrableOn_Icc) + have hAbel := sum_mul_eq_sub_sub_integral_mul c ha hab hf hdf.integrableOn_Icc + rw [← intervalIntegral.integral_of_le hab] at hAbel + change (∑ n ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, f n * c n) = + f b * partialCoefficientSum c b - f a * partialCoefficientSum c a - + ∫ t in a..b, deriv f t * partialCoefficientSum c t at hAbel + have hparts := intervalIntegral.integral_deriv_mul_eq_sub + (fun x hx => (hf x (by simpa [Set.uIcc_of_le hab] using hx)).hasDerivAt) + (fun x (_ : x ∈ Set.uIcc a b) => hasDerivAt_id x) hdfi intervalIntegrable_const + simp only [id_eq] at hparts + have hsplit : (∫ t in a..b, deriv f t * t + f t * 1) = + (∫ t in a..b, deriv f t * t) + ∫ t in a..b, f t := by + simp only [mul_one] + exact intervalIntegral.integral_add hdmain hfi + rw [hsplit] at hparts + have herr : (∫ t in a..b, deriv f t * (partialCoefficientSum c t - α * t)) = + (∫ t in a..b, deriv f t * partialCoefficientSum c t) - + α * (∫ t in a..b, deriv f t * t) := by + simp only [mul_sub, show ∀ t, deriv f t * (α * t) = α * (deriv f t * t) by + intro t; ring] + rw [intervalIntegral.integral_sub hsum (hdmain.const_mul α), + intervalIntegral.integral_const_mul] + rw [herr, hAbel] + linear_combination -α * hparts + +/-- The same identity for either of the actual modulus-five prime selections. -/ +theorem modFive_centered_partial_summation (one : Bool) (a b : ℝ) + (ha : 0 ≤ a) (hab : a ≤ b) (f : ℝ → ℝ) + (hf : ∀ x ∈ Set.Icc a b, DifferentiableAt ℝ f x) + (hdf : ContinuousOn (deriv f) (Set.Icc a b)) : + (∑ n ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, f n * modFiveLogWeight one n) - + modFiveDensity one * (∫ t in a..b, f t) = + f b * (modFiveTheta one b - modFiveDensity one * b) - + f a * (modFiveTheta one a - modFiveDensity one * a) - + ∫ t in a..b, deriv f t * (modFiveTheta one t - modFiveDensity one * t) := + centered_partial_summation (modFiveLogWeight one) (modFiveDensity one) a b ha hab f hf hdf + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePhysicalMatrix.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePhysicalMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..25f998c22ea6b50b34b2c4ef051a5f2e2323fd57 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimePhysicalMatrix.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.TwoPoint.Bounds.GraphMatrixCompression +import OAI.NumberTheory.TwoPoint.Bounds.ShiftMatrixTranslation + +namespace OAI + +/-! Match the translated physical matrix with the concrete prime graph, +including the original endpoint masks. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem primePhysicalMatrix_eq {J : ℕ} {V : Type*} [Fintype V] [DecidableEq V] + (P : Fin J → Finset ℕ) (site : V → ℤ) (Q : Finset ℕ) + (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) (g : ℤ → ℝ) + (L K : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (keep : ℤ → Prop) (c : ℤ) : + shiftMatrix (fun x : ((j : Fin J) → P j) × V => (x.1, site x.2)) + (integerShiftNext Q (fun d => ∏ j, (d j).val) h) + (physicalShiftWeight Q (fun d => ∏ j, (d j).val) h + (fun d n m => gate (∏ j, (d j).val) n m) + (fun t n => maskedSignedIntegerWeight Q u eligible g + (fun d => centeredTuple d.primeFactors) L K extra h keep t (n + c))) = + blockNonbacktrackingMatrix (primeRealEdgeMatrix P (fun i => site i + c) + Q u eligible g L K extra h (fun d i j => + gate d (site i) (site j) ∧ keep (site i + c) ∧ keep (site j + c))) := by + have hs := physicalBlockMatrix_eq_integer site Q (fun d : (j : Fin J) → P j => ∏ j, (d j).val) h + (fun d n m => gate (∏ j, (d j).val) n m) u eligible g + (fun d => centeredTuple d.primeFactors) L K extra keep c + apply hs.trans + congr 1 + funext d i j + unfold primeRealEdgeMatrix + by_cases hc : gate (∏ j, (d j).val) (site i) (site j) ∧ + keep (site i + c) ∧ keep (site j + c) + · simp only [ite_eq_left hc] + · simp only [ite_eq_right hc] + +theorem prime_physical_compression {J : ℕ} {V : Type*} [Fintype V] [DecidableEq V] + (P : Fin J → Finset ℕ) (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (site : V → ℤ) (hinj : Function.Injective site) + (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (hgate : ∀ d n m, gate d n m ↔ gate d m n) + (keep : ℤ → Prop) (c : ℤ) + (hL : 0 < L) (hK : 0 ≤ K) (hu : ∀ q ∈ Q, 0 ≤ u q) (hg : ∀ n, 0 < g n) + (hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W) + (R : ℝ) (hR : 0 ≤ R) (hsingle : 2 * K ≤ R) + (hsquare : 4 * K ^ 2 * (8 * W) ^ J ≤ R ^ 2) + (hradius : realMatrixSpectralRadius + (shiftMatrix (fun x : ((j : Fin J) → P j) × V => (x.1, site x.2)) + (integerShiftNext Q (fun d => ∏ j, (d j).val) h) + (physicalShiftWeight Q (fun d => ∏ j, (d j).val) h + (fun d n m => gate (∏ j, (d j).val) n m) + (fun t n => maskedSignedIntegerWeight Q u eligible g + (fun d => centeredTuple d.primeFactors) L K extra h keep t (n + c)))) ≤ R) : + let B := primeFamilyGraphOperator (fun j (p : P j) => p.val) (fun _ _ => 0) + (fun i => site i + c) Q u eligible g L K extra h + (fun d i j => gate d (site i) (site j) ∧ keep (site i + c) ∧ keep (site j + c)) + let proj := coordinateProjection (fun i : V => + (actualPaddingDegree (univ.biUnion P) (site i + c) : ℝ) ≤ 6 * W * J) + ‖proj * (∑ d, B d) * proj‖ ≤ 3 * R := by + rw [primePhysicalMatrix_eq] at hradius + apply prime_graph_compression_of_matrix_radius P hprime hdisjoint (fun i => site i + c) + (fun i j hij => hinj (add_right_cancel hij)) Q u eligible g L K W extra h + (fun d i j => gate d (site i) (site j) ∧ keep (site i + c) ∧ keep (site j + c)) + ?_ hL hK hu hg hV R hR hsingle hsquare hradius + intro d i j + rw [hgate d (site i) (site j)] + tauto + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeReciprocalLaw.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeReciprocalLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ad18e9412eddd8cb2f24d3d1bbc3040ce26bdbb --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeReciprocalLaw.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteProbability + +namespace OAI + +/-! Restore the harmonic mass after using the normalized prime law. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def primeHarmonicMass (P : Finset ℕ) : ℝ := + ∑ p : P, (p.val : ℝ)⁻¹ + +noncomputable def primeReciprocalLaw (P : Finset ℕ) (hV : 0 < primeHarmonicMass P) : FiniteLaw P where + weight p := (p.val : ℝ)⁻¹ / primeHarmonicMass P + nonneg p := div_nonneg (inv_nonneg.mpr (Nat.cast_nonneg _)) hV.le + total := by + rw [← sum_div] + exact div_self hV.ne' + +lemma primeReciprocalLaw_atom_le (P : Finset ℕ) (hV : 0 < primeHarmonicMass P) + (H : ℕ) (hH : 0 < H) (hlo : ∀ p ∈ P, H ≤ p) (p : P) : + (primeReciprocalLaw P hV).weight p ≤ (primeHarmonicMass P * H)⁻¹ := by + have hp : (H : ℝ) ≤ (p.val : ℝ) := by exact_mod_cast hlo _ p.property + have hH' : (0 : ℝ) < H := by exact_mod_cast hH + calc + _ ≤ (H : ℝ)⁻¹ / primeHarmonicMass P := + div_le_div_of_nonneg_right (inv_anti₀ hH' hp) hV.le + _ = _ := by rw [div_eq_mul_inv, mul_inv_rev] + +variable {α : Type*} [Fintype α] [DecidableEq α] + +lemma primeReciprocalLaw_mass_product (P : Finset ℕ) (hV : 0 < primeHarmonicMass P) + (x : α → P) : + primeHarmonicMass P ^ Fintype.card α * + (FiniteLaw.independent (fun _ : α => primeReciprocalLaw P hV)).weight x = + ∏ z, ((x z).val : ℝ)⁻¹ := by + change primeHarmonicMass P ^ Fintype.card α * + (∏ z, ((x z).val : ℝ)⁻¹ / primeHarmonicMass P) = _ + rw [prod_div_distrib] + simp only [prod_const, card_univ] + exact mul_div_cancel₀ _ (pow_ne_zero _ hV.ne') + +/-- Every abstract label keeps its reciprocal factor, even when distinct +labels receive the same numerical prime. -/ +lemma primeReciprocalLaw_restore (P : Finset ℕ) (hV : 0 < primeHarmonicMass P) + (E : (α → P) → Prop) : + (∑ x : α → P, if E x then ∏ z, ((x z).val : ℝ)⁻¹ else 0) = + primeHarmonicMass P ^ Fintype.card α * + (FiniteLaw.independent (fun _ : α => primeReciprocalLaw P hV)).probability E := by + classical + simp only [FiniteLaw.probability, FiniteLaw.average, mul_sum] + apply sum_congr rfl + intro x _ + by_cases hx : E x + · simp only [hx, ite_true, mul_one] + exact (primeReciprocalLaw_mass_product P hV x).symm + · simp only [hx, ite_false, mul_zero] + +lemma primeReciprocalLaw_restore_bound (P : Finset ℕ) (hV : 0 < primeHarmonicMass P) + (E : (α → P) → Prop) (B : ℝ) + (hB : (FiniteLaw.independent (fun _ : α => primeReciprocalLaw P hV)).probability E ≤ B) : + (∑ x : α → P, if E x then ∏ z, ((x z).val : ℝ)⁻¹ else 0) ≤ + primeHarmonicMass P ^ Fintype.card α * B := by + rw [primeReciprocalLaw_restore P hV E] + exact mul_le_mul_of_nonneg_left hB (pow_nonneg hV.le _) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeReciprocalTheorem.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeReciprocalTheorem.lean new file mode 100644 index 0000000000000000000000000000000000000000..5dacdbe763e4aac5f1ac8e48f63bc0d55e6f1f42 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeReciprocalTheorem.lean @@ -0,0 +1,36 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MertensScale +import PrimeNumberTheoremAnd.Erdos970.MertensClassical + +namespace OAI + +/-! Mertens' second theorem in bounded-error form. + +The formal proof uses `Erdos970.Mertens.sum_prime_div_eq_log_log`. +Only the convention for the finite prime set differs from +`PrimeReciprocalInput`; zero contributes no prime to either convention. +-/ + +namespace TwoPointCorrelations + +open Finset + +lemma sievePrimesUpTo_eq_Ioc (x : ℝ) : + sievePrimesUpTo x = (Ioc 0 ⌊x⌋₊).filter Nat.Prime := by + ext p + simp only [sievePrimesUpTo, mem_filter, mem_Iic, mem_Ioc] + constructor + · rintro ⟨hp, hprime⟩ + exact ⟨⟨hprime.pos, hp⟩, hprime⟩ + · rintro ⟨⟨_, hp⟩, hprime⟩ + exact ⟨hp, hprime⟩ + +/-- Mertens' second theorem implies the reciprocal-prime estimate. -/ +theorem primeReciprocalInput : PrimeReciprocalInput := by + obtain ⟨C, hC⟩ := Erdos970.Mertens.sum_prime_div_eq_log_log + refine ⟨C, fun x hx => ?_⟩ + rw [sievePrimesUpTo_eq_Ioc] + exact hC x hx + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeRelations.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeRelations.lean new file mode 100644 index 0000000000000000000000000000000000000000..f948704741bf73bb6f760e890a5ba33b32fd596c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeRelations.lean @@ -0,0 +1,180 @@ +import OAI.NumberTheory.TwoPoint.Bounds.TriangularElimination + +namespace OAI + +/-! +# Exact prime-variable relations + +A monomial has one factor for each distinct label in a squarefree tuple. +Its integer coefficient contains the orientation, common shift multiplier, +and padding. Numerical coincidences among different labels are allowed. +-/ + +namespace TwoPointCorrelations + +open Finset + +structure PrimeMonomial (ι : Type*) where + coefficient : ℤ + labels : Finset ι + +namespace PrimeMonomial + +variable {ι : Type*} [DecidableEq ι] + +def eval (m : PrimeMonomial ι) (x : ι → ℤ) : ℤ := + m.coefficient * ∏ j ∈ m.labels, x j + +def coefficientAt (m : PrimeMonomial ι) (i : ι) (x : ι → ℤ) : ℤ := + if i ∈ m.labels then m.coefficient * ∏ j ∈ m.labels.erase i, x j else 0 + +def constantAt (m : PrimeMonomial ι) (i : ι) (x : ι → ℤ) : ℤ := + if i ∈ m.labels then 0 else m.eval x + +lemma eval_affine (m : PrimeMonomial ι) (i : ι) (x : ι → ℤ) : + m.eval x = x i * m.coefficientAt i x + m.constantAt i x := by + by_cases hi : i ∈ m.labels + · simp only [eval, coefficientAt, constantAt, hi, ite_true, add_zero] + rw [← Finset.mul_prod_erase m.labels x hi] + ring + · simp only [coefficientAt, constantAt, hi, ite_false, mul_zero, zero_add] + +lemma eval_update_of_not_mem (m : PrimeMonomial ι) (i : ι) (x : ι → ℤ) (a : ℤ) + (hi : i ∉ m.labels) : m.eval (Function.update x i a) = m.eval x := by + unfold eval + congr 1 + apply prod_congr rfl + intro j hj + have hji : j ≠ i := fun h => hi (h ▸ hj) + simp [hji] + +lemma coefficientAt_update_self (m : PrimeMonomial ι) (i : ι) (x : ι → ℤ) (a : ℤ) : + m.coefficientAt i (Function.update x i a) = m.coefficientAt i x := by + unfold coefficientAt + split + · congr 1 + apply prod_congr rfl + intro j hj + simp [(mem_erase.mp hj).1] + · rfl + +lemma constantAt_update_self (m : PrimeMonomial ι) (i : ι) (x : ι → ℤ) (a : ℤ) : + m.constantAt i (Function.update x i a) = m.constantAt i x := by + unfold constantAt + split + · rfl + · exact m.eval_update_of_not_mem i x a ‹i ∉ m.labels› + +lemma coefficientAt_update_of_not_mem (m : PrimeMonomial ι) (i j : ι) + (x : ι → ℤ) (a : ℤ) (hj : j ∉ m.labels) : + m.coefficientAt i (Function.update x j a) = m.coefficientAt i x := by + unfold coefficientAt + split + · congr 1 + apply prod_congr rfl + intro k hk + have hkj : k ≠ j := fun h => hj (h ▸ (mem_erase.mp hk).2) + simp [hkj] + · rfl + +end PrimeMonomial + +variable {ι τ : Type*} [DecidableEq ι] [Fintype τ] + +def primeRelationEval (m : τ → PrimeMonomial ι) (x : ι → ℤ) : ℤ := ∑ t, (m t).eval x + +def primeRelationCoefficient (m : τ → PrimeMonomial ι) (i : ι) (x : ι → ℤ) : ℤ := + ∑ t, (m t).coefficientAt i x + +def primeRelationConstant (m : τ → PrimeMonomial ι) (i : ι) (x : ι → ℤ) : ℤ := + ∑ t, (m t).constantAt i x + +/-- The contribution of precisely the terms containing this label. -/ +def primeRelationContribution (m : τ → PrimeMonomial ι) (i : ι) (x : ι → ℤ) : ℤ := + ∑ t, if i ∈ (m t).labels then (m t).eval x else 0 + +def primeRelationSupport (m : τ → PrimeMonomial ι) : Finset ι := univ.biUnion (fun t => (m t).labels) + +lemma primeRelation_affine (m : τ → PrimeMonomial ι) (i : ι) (x : ι → ℤ) : + primeRelationEval m x = x i * primeRelationCoefficient m i x + primeRelationConstant m i x := by + unfold primeRelationEval primeRelationCoefficient primeRelationConstant + rw [mul_sum, ← sum_add_distrib] + apply sum_congr rfl + intro t _ + exact (m t).eval_affine i x + +lemma primeRelation_contribution_eq (m : τ → PrimeMonomial ι) (i : ι) (x : ι → ℤ) : + primeRelationContribution m i x = x i * primeRelationCoefficient m i x := by + unfold primeRelationContribution primeRelationCoefficient + rw [mul_sum] + apply sum_congr rfl + intro t _ + by_cases hi : i ∈ (m t).labels + · rw [ite_eq_left hi, (m t).eval_affine i x] + simp only [PrimeMonomial.constantAt, hi, ite_true, add_zero] + · simp only [hi, ite_false, PrimeMonomial.coefficientAt, mul_zero] + +lemma primeRelation_coefficient_update_self (m : τ → PrimeMonomial ι) + (i : ι) (x : ι → ℤ) (a : ℤ) : + primeRelationCoefficient m i (Function.update x i a) = primeRelationCoefficient m i x := by + unfold primeRelationCoefficient + exact sum_congr rfl (fun t _ => (m t).coefficientAt_update_self i x a) + +lemma primeRelation_constant_update_self (m : τ → PrimeMonomial ι) + (i : ι) (x : ι → ℤ) (a : ℤ) : + primeRelationConstant m i (Function.update x i a) = primeRelationConstant m i x := by + unfold primeRelationConstant + exact sum_congr rfl (fun t _ => (m t).constantAt_update_self i x a) + +lemma primeRelation_update_affine (m : τ → PrimeMonomial ι) + (i : ι) (x : ι → ℤ) (a : ℤ) : + primeRelationEval m (Function.update x i a) = + a * primeRelationCoefficient m i x + primeRelationConstant m i x := by + rw [primeRelation_affine m i, Function.update_self, + primeRelation_coefficient_update_self, primeRelation_constant_update_self] + +lemma primeRelation_update_of_not_mem (m : τ → PrimeMonomial ι) + (i : ι) (x : ι → ℤ) (a : ℤ) (hi : i ∉ primeRelationSupport m) : + primeRelationEval m (Function.update x i a) = primeRelationEval m x := by + unfold primeRelationEval + apply sum_congr rfl + intro t _ + apply (m t).eval_update_of_not_mem + exact fun hit => hi (mem_biUnion.mpr ⟨t, mem_univ _, hit⟩) + +lemma primeRelation_coefficient_update_of_not_mem (m : τ → PrimeMonomial ι) + (i j : ι) (x : ι → ℤ) (a : ℤ) (hj : j ∉ primeRelationSupport m) : + primeRelationCoefficient m i (Function.update x j a) = primeRelationCoefficient m i x := by + unfold primeRelationCoefficient + apply sum_congr rfl + intro t _ + apply (m t).coefficientAt_update_of_not_mem + exact fun hjt => hj (mem_biUnion.mpr ⟨t, mem_univ _, hjt⟩) + +/-- Retaining the nonzero-contribution test gives precisely the coefficient +condition needed for a single-prime reciprocal saving. -/ +lemma primeRelation_coefficient_nondegenerate (m : τ → PrimeMonomial ι) + (i : ι) (x : ι → ℤ) (p : ℤ) + (hnonzero : ¬p ∣ primeRelationContribution m i x) : + ¬p ∣ primeRelationCoefficient m i x := by + intro hd + apply hnonzero + rw [primeRelation_contribution_eq] + exact hd.mul_left (x i) + +/-- The whole congruence, including its nondegeneracy test and controlling +prime, ignores a variable outside the recorded support and control. -/ +def primeRelationEvent (m : τ → PrimeMonomial ι) (selected control : ι) (x : ι → ℤ) : Prop := + x control ∣ primeRelationEval m x ∧ ¬x control ∣ primeRelationCoefficient m selected x + +lemma primeRelationEvent_update (m : τ → PrimeMonomial ι) (selected control j : ι) + (x : ι → ℤ) (a : ℤ) (hj : j ∉ primeRelationSupport m) (hjc : control ≠ j) : + primeRelationEvent m selected control (Function.update x j a) ↔ + primeRelationEvent m selected control x := by + unfold primeRelationEvent + rw [Function.update_of_ne hjc, primeRelation_update_of_not_mem m j x a hj, + primeRelation_coefficient_update_of_not_mem m selected j x a hj] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeResidueLift.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeResidueLift.lean new file mode 100644 index 0000000000000000000000000000000000000000..d7b783b12e8f393dec5128668647af74c57bf0fb --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeResidueLift.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedDensity +import OAI.NumberTheory.TwoPoint.Bounds.CommonResidueLift + +namespace OAI + +/-! Evaluate the actual padding-periodic weights at one common integer lift of the product-law sample. -/ + +namespace TwoPointCorrelations.ProhibitedPrimeFamily + +open Finset +open scoped Classical + +theorem exists_residue_origin {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + (x : ↥(data.P ∪ data.Q) → Fin B) : + ∃ n : ℤ, ∀ p : ↥(data.P ∪ data.Q), (n : ZMod p.val) = ((x p).val : ZMod p.val) := by + let (p : ↥(data.P ∪ data.Q)) : NeZero p.val := ⟨(data.prime p).ne_zero⟩ + apply exists_common_integer_residue (fun p : ↥(data.P ∪ data.Q) => p.val) + intro p q hpq + exact (Nat.coprime_primes (data.prime p) (data.prime q)).mpr + (fun he => hpq (Subtype.ext he)) + +noncomputable def residueOrigin {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + (x : ↥(data.P ∪ data.Q) → Fin B) : ℤ := + (data.exists_residue_origin x).choose + +lemma residueOrigin_spec {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + (x : ↥(data.P ∪ data.Q) → Fin B) (p : ↥(data.P ∪ data.Q)) : + (data.residueOrigin x : ZMod p.val) = ((x p).val : ZMod p.val) := + (data.exists_residue_origin x).choose_spec p + +lemma residueOrigin_divisibility {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + (x : ↥(data.P ∪ data.Q) → Fin B) (p : ↥(data.P ∪ data.Q)) (offset : ℤ) : + (p.val : ℤ) ∣ data.residueOrigin x + offset ↔ + (p.val : ℤ) ∣ (x p).val + offset := by + exact (residue_offset_divisibility _ _ _ (data.residueOrigin_spec x p)).trans + (residue_offset_divisibility ((x p).val : ZMod p.val) ((x p).val : ℤ) offset + (by simp)).symm + +noncomputable def residueValue {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + (f : ℤ → ℝ) (x : ↥(data.P ∪ data.Q) → Fin B) : ℝ := f (data.residueOrigin x) + +theorem residueValue_eq_of_lift {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + (f : ℤ → ℝ) + (hf : ∀ n m : ℤ, (∀ q ∈ data.Q, (n : ZMod q) = (m : ZMod q)) → f n = f m) + (x : ↥(data.P ∪ data.Q) → Fin B) (n : ℤ) + (hn : ∀ p : ↥(data.P ∪ data.Q), p.val ∈ data.Q → + (n : ZMod p.val) = ((x p).val : ZMod p.val)) : + data.residueValue f x = f n := by + apply hf + intro q hq + let p : ↥(data.P ∪ data.Q) := ⟨q, mem_union_right _ hq⟩ + exact (data.residueOrigin_spec x p).trans (hn p hq).symm + +theorem residueValue_independent_tuple {h J M B : ℕ} {τ : Type*} [Fintype τ] + (data : ProhibitedPrimeFamily h J M) (label : τ → ↥(data.P ∪ data.Q)) + (hlabel : ∀ p ∈ univ.image label, p.val ∈ data.P) + (f : ℤ → ℝ) + (hf : ∀ n m : ℤ, (∀ q ∈ data.Q, (n : ZMod q) = (m : ZMod q)) → f n = f m) + (x y : ↥(data.P ∪ data.Q) → Fin B) + (hxy : ∀ p, p ∉ univ.image label → x p = y p) : + data.residueValue f x = data.residueValue f y := by + apply hf + intro q hq + let p : ↥(data.P ∪ data.Q) := ⟨q, mem_union_right _ hq⟩ + have hp : p ∉ univ.image label := by + intro hp + exact disjoint_left.mp data.disjoint (hlabel p hp) hq + rw [data.residueOrigin_spec x p, data.residueOrigin_spec y p, hxy p hp] + +end TwoPointCorrelations.ProhibitedPrimeFamily + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeRowMomentScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeRowMomentScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..8cd593117a9457e9e9c6b53e6db522d79aca95c8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeRowMomentScale.lean @@ -0,0 +1,129 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeRowMoments + +namespace OAI + +/-! The rare-site row majorant has a fixed polynomial second moment, +uniformly in the band-width parameter W. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma prime_row_moment_product_bound {J : ℕ} (Q : Finset ℕ) (V : Fin J → ℝ) + (L W : ℝ) (hL : 1 ≤ L) (hW : 10 ≤ W) + (hQ : (∑ p ∈ Q, 1 / (p : ℝ)) ≤ Real.log L) + (hV0 : ∀ j, 0 ≤ V j) (hV : ∀ j, V j ≤ 2 * W) + (hJ : (J : ℝ) * (6 * W) ≤ Real.log L) : + (∏ q : Q, (1 + 24 / (q.val : ℝ))) * + (∏ j : Fin J, (4 * (V j) ^ 2 + V j)) ≤ L ^ (25 : ℕ) := by + have hLp : 0 < L := zero_lt_one.trans_le hL + have hQprod : (∏ q : Q, (1 + 24 / (q.val : ℝ))) ≤ Real.exp (24 * Real.log L) := by + calc + _ ≤ ∏ q : Q, Real.exp (24 / (q.val : ℝ)) := by + apply prod_le_prod₀ + · intro q _ + positivity + · intro q _ + simpa only [add_comm] using Real.add_one_le_exp (24 / (q.val : ℝ)) + _ = Real.exp (24 * ∑ p ∈ Q, 1 / (p : ℝ)) := by + rw [← Real.exp_sum, ← sum_coe_sort Q (fun p : ℕ => 1 / (p : ℝ)), mul_sum] + congr 1 + apply sum_congr rfl + intro q _ + ring + _ ≤ _ := Real.exp_le_exp.mpr (by linarith) + have hbase : 18 * W ^ 2 ≤ Real.exp (6 * W) := by + have hE : W ≤ Real.exp W := by linarith [Real.add_one_le_exp W] + have hE4 : (18 : ℝ) ≤ Real.exp (4 * W) := by + linarith [Real.add_one_le_exp (4 * W)] + calc + _ ≤ Real.exp (4 * W) * (Real.exp W) ^ 2 := + mul_le_mul hE4 (pow_le_pow_left₀ (by linarith) hE 2) + (sq_nonneg W) (Real.exp_pos _).le + _ = _ := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + congr 1 + ring + have hVprod : (∏ j : Fin J, (4 * (V j) ^ 2 + V j)) ≤ Real.exp (Real.log L) := by + calc + _ ≤ ∏ _j : Fin J, Real.exp (6 * W) := by + apply prod_le_prod₀ + · intro j _ + exact add_nonneg (mul_nonneg (by norm_num) (sq_nonneg _)) (hV0 j) + · intro j _ + have hv : 4 * (V j) ^ 2 + V j ≤ 18 * W ^ 2 := by + have hs := mul_nonneg (hV0 j) (sub_nonneg.mpr (hV j)) + have ht := sq_nonneg (2 * W - V j) + nlinarith [hV j, hV0 j] + exact hv.trans hbase + _ = Real.exp ((J : ℝ) * (6 * W)) := by + simp only [prod_const, card_univ, Fintype.card_fin] + rw [Real.exp_nat_mul] + _ ≤ _ := Real.exp_le_exp.mpr hJ + calc + _ ≤ Real.exp (24 * Real.log L) * Real.exp (Real.log L) := + mul_le_mul hQprod hVprod (prod_nonneg (fun j _ => + add_nonneg (mul_nonneg (by norm_num) (sq_nonneg _)) (hV0 j))) (Real.exp_pos _).le + _ = L ^ (25 : ℕ) := by + rw [← Real.exp_add] + rw [show 24 * Real.log L + Real.log L = (25 : ℕ) * Real.log L by norm_num; ring] + rw [Real.exp_nat_mul, Real.exp_log hLp] + +namespace FiniteLaw + +lemma square_event_average_le {α : Type*} [Fintype α] (μ : FiniteLaw α) + (f : α → ℝ) (E : α → Prop) : + (μ.average (fun x => f x * if E x then 1 else 0)) ^ 2 ≤ + μ.average (fun x => (f x) ^ 2) * μ.probability E := by + have hh := sum_sq_le_sum_mul_sum_of_sq_le_mul univ + (f := fun x => μ.weight x * (f x) ^ 2) + (g := fun x => μ.weight x * if E x then 1 else 0) + (r := fun x => μ.weight x * (f x * if E x then 1 else 0)) + (fun x _ => mul_nonneg (μ.nonneg x) (sq_nonneg _)) + (fun x _ => mul_nonneg (μ.nonneg x) (by split_ifs <;> norm_num)) + (fun x _ => by split_ifs <;> ring_nf <;> exact le_rfl) + exact hh + +end FiniteLaw + +namespace ProhibitedPrimeFamily + +variable {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + +theorem prime_row_second_moment_polynomial (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (P : Fin J → Finset ℕ) (hsub : ∀ j, P j ⊆ data.P) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) (site : ℤ) + (L W : ℝ) (hL : 1 ≤ L) (hW : 10 ≤ W) + (hQ : (∑ p ∈ data.Q, 1 / (p : ℝ)) ≤ Real.log L) + (hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W) + (hJ : (J : ℝ) * (6 * W) ≤ Real.log L) : + (data.residueLaw B hB).average (fun x => + (primeRowMajorant P data.Q (data.residueOrigin x + site)) ^ 2) ≤ L ^ (25 : ℕ) := by + apply (data.prime_row_second_moment hB P hsub hdisjoint site).trans + exact prime_row_moment_product_bound data.Q (fun j => primeHarmonicMass (P j)) L W + hL hW hQ (fun j => by unfold primeHarmonicMass; positivity) hV hJ + +theorem prime_row_rare_square_bound (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (P : Fin J → Finset ℕ) (hsub : ∀ j, P j ⊆ data.P) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) (site : ℤ) + (L W : ℝ) (hL : 1 ≤ L) (hW : 10 ≤ W) + (hQ : (∑ p ∈ data.Q, 1 / (p : ℝ)) ≤ Real.log L) + (hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W) + (hJ : (J : ℝ) * (6 * W) ≤ Real.log L) + (E : (↥(data.P ∪ data.Q) → Fin B) → Prop) + (hE : (data.residueLaw B hB).probability E ≤ + Real.exp (-(1 / 2 : ℝ) * L ^ (199 / 200 : ℝ))) : + ((data.residueLaw B hB).average (fun x => + primeRowMajorant P data.Q (data.residueOrigin x + site) * if E x then 1 else 0)) ^ 2 ≤ + L ^ (25 : ℕ) * Real.exp (-(1 / 2 : ℝ) * L ^ (199 / 200 : ℝ)) := by + apply ((data.residueLaw B hB).square_event_average_le _ E).trans + exact mul_le_mul (data.prime_row_second_moment_polynomial hB P hsub hdisjoint site + L W hL hW hQ hV hJ) hE + ((data.residueLaw B hB).probability_nonneg E) (by positivity) + +end ProhibitedPrimeFamily + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeRowMoments.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeRowMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c537c8c6040a592e7aaa6af1698a4cbc7f18d56 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeRowMoments.lean @@ -0,0 +1,136 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeRowSecondMoment +import OAI.NumberTheory.TwoPoint.Bounds.ActualPrimeScale + +namespace OAI + +/-! Group the disjoint prime bands before taking their row moments. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace FiniteLaw + +lemma independent_average_grouped {ι A : Type*} [Fintype ι] [DecidableEq ι] + {κ : ι → Type*} [∀ i, Fintype (κ i)] [∀ i, DecidableEq (κ i)] [Fintype A] + (μ : (i : ι) → κ i → FiniteLaw A) (F : ((i : ι) → κ i → A) → ℝ) : + (independent (fun p : Sigma κ => μ p.1 p.2)).average + (fun x => F (fun i k => x ⟨i, k⟩)) = + (dependentIndependent (fun i => independent (μ i))).average F := by + let e := Equiv.piCurry (fun (i : ι) (_ : κ i) => A) + calc + _ = ∑ x : (i : ι) → κ i → A, + (independent (fun p : Sigma κ => μ p.1 p.2)).weight (e.symm x) * F x := + (e.symm.sum_comp (fun x : Sigma κ → A => + (independent (fun p : Sigma κ => μ p.1 p.2)).weight x * + F (fun i k => x ⟨i, k⟩))).symm + _ = _ := by + simp only [average, dependentIndependent, independent, Fintype.prod_sigma] + rfl + +lemma independent_average_disjoint_products {ι I A : Type*} + [Fintype ι] [DecidableEq ι] [Fintype I] [DecidableEq I] + {κ : I → Type*} [∀ i, Fintype (κ i)] [∀ i, DecidableEq (κ i)] [Fintype A] + (μ : ι → FiniteLaw A) (e : (i : I) → κ i → ι) + (he : Function.Injective (fun p : Sigma κ => e p.1 p.2)) + (f : (i : I) → (κ i → A) → ℝ) : + (independent μ).average (fun x => ∏ i, f i (fun k => x (e i k))) = + ∏ i, (independent (fun k => μ (e i k))).average (f i) := by + have hb := independent_average_embedding (fun p : Sigma κ => e p.1 p.2) he μ + (fun x : Sigma κ → A => ∏ i, f i (fun k => x ⟨i, k⟩)) + rw [independent_average_grouped (fun i k => μ (e i k)) + (fun x => ∏ i, f i (x i)), dependentIndependent_average_product] at hb + exact hb + +end FiniteLaw + +lemma prime_band_row_second_moment {J : ℕ} (P : Fin J → Finset ℕ) + (hP : ∀ j p, p ∈ P j → 2 ≤ p) (ambient : Finset ℕ) + (hambient : ∀ p ∈ ambient, 2 ≤ p) (hsub : ∀ j, P j ⊆ ambient) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) : + (paddingOriginalLaw ambient hambient).average (fun x => + ∏ j : Fin J, (booleanCount (fun p : P j => x ⟨p.val, hsub j p.property⟩) + + primeHarmonicMass (P j)) ^ 2) ≤ + ∏ j : Fin J, (4 * (primeHarmonicMass (P j)) ^ 2 + primeHarmonicMass (P j)) := by + let e : (j : Fin J) → P j → ambient := fun j p => ⟨p.val, hsub j p.property⟩ + have he : Function.Injective (fun p : Sigma (fun j => P j) => e p.1 p.2) := by + rintro ⟨j, p⟩ ⟨l, q⟩ hpq + have hv : p.val = q.val := congrArg Subtype.val hpq + have hjl : j = l := by + by_contra hne + exact disjoint_left.mp (hdisjoint j l (Ne.symm hne)) p.property (hv.symm ▸ q.property) + subst l + exact congrArg (Sigma.mk j) (Subtype.ext hv) + rw [paddingOriginalLaw, + FiniteLaw.independent_average_disjoint_products + (fun p : ambient => paddingOriginalPrimeLaw p (hambient p p.property)) e he + (fun j a => (booleanCount a + primeHarmonicMass (P j)) ^ 2)] + apply prod_le_prod₀ + · intro j _ + exact FiniteLaw.average_nonneg _ (fun _ => sq_nonneg _) + · intro j _ + have hm : (∑ p : P j, 1 / (p.val : ℝ)) = primeHarmonicMass (P j) := by + simp only [primeHarmonicMass, one_div] + simpa only [paddingOriginalPrimeLaw, e, hm] using + independent_boolean_shifted_count_square + (fun p : P j => 1 / (p.val : ℝ)) (fun _ => by positivity) + (fun p => by + apply (div_le_one (by exact_mod_cast (show 0 < p.val by have := hP j p p.property; omega))).mpr + exact_mod_cast (show 1 ≤ p.val by have := hP j p p.property; omega)) + +noncomputable def primeRowMajorant {J : ℕ} (P : Fin J → Finset ℕ) (Q : Finset ℕ) + (n : ℤ) : ℝ := + actualPaddingWeight Q n * + ∏ j : Fin J, ((actualPaddingDegree (P j) n : ℝ) + primeHarmonicMass (P j)) + +namespace ProhibitedPrimeFamily + +variable {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + +theorem prime_row_second_moment (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (P : Fin J → Finset ℕ) (hsub : ∀ j, P j ⊆ data.P) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) (site : ℤ) : + (data.residueLaw B hB).average (fun x => + (primeRowMajorant P data.Q (data.residueOrigin x + site)) ^ 2) ≤ + (∏ q : data.Q, (1 + 24 / (q.val : ℝ))) * + ∏ j : Fin J, (4 * (primeHarmonicMass (P j)) ^ 2 + primeHarmonicMass (P j)) := by + let F := fun x : data.P → Bool => + ∏ j : Fin J, (booleanCount (fun p : P j => x ⟨p.val, hsub j p.property⟩) + + primeHarmonicMass (P j)) ^ 2 + let g := fun n : ℤ => (actualPaddingWeight data.Q n) ^ 2 + have he (x : ↥(data.P ∪ data.Q) → Fin B) : + (primeRowMajorant P data.Q (data.residueOrigin x + site)) ^ 2 = + F (fun p => decide ((p.val : ℤ) ∣ data.residueOrigin x + site)) * + g (data.residueOrigin x + site) := by + simp only [primeRowMajorant, mul_pow, prod_pow, F, g, actualPrimeDegree_eq_count] + ring + simp_rw [he] + rw [data.residue_average_prime_boolean_padding hB site F g + (fun n m hnm => congrArg (fun t : ℝ => t ^ 2) + (actualPaddingWeight_residue_congr data.Q n m hnm))] + have hq : (data.paddingResidueLaw B hB).average + (fun z => g (data.paddingResidueOrigin z + site)) = + ∏ q : data.Q, (1 + 24 / (q.val : ℝ)) := by + have hl (z : data.Q → Fin B) : g (data.paddingResidueOrigin z + site) = + (paddingTiltWeight data.Q (paddingResidueAvailable data.Q B site z)) ^ 2 := by + dsimp only [g] + rw [actualPaddingWeight_lift data.Q B site z (data.paddingResidueOrigin z + site) + (fun p => by rw [Int.cast_add, data.paddingResidueOrigin_spec])] + simp_rw [hl] + rw [paddingResidueLaw, padding_residue_average data.Q B + (fun p hp => (data.primeQ p hp).two_le) + (fun p hp => hB p (mem_union_right _ hp)) site + (fun a => (paddingTiltWeight data.Q a) ^ 2)] + exact padding_weight_square_average data.Q _ + rw [hq, mul_comm] + apply mul_le_mul_of_nonneg_left _ (prod_nonneg (fun _ _ => by positivity)) + exact prime_band_row_second_moment P + (fun j p hp => (data.primeP p (hsub j hp)).two_le) data.P + (fun p hp => (data.primeP p hp).two_le) hsub hdisjoint + +end ProhibitedPrimeFamily + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeRowSecondMoment.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeRowSecondMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..db0adf21dbdfcb35d8ef0c2a77a0964de0e0fae4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeRowSecondMoment.lean @@ -0,0 +1,138 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimePaddingDeletion + +namespace OAI + +/-! Finite second moments for the positive row majorant used to delete +rare sites. Independence is used only under the auxiliary product law. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace FiniteLaw + +lemma average_add {α : Type*} [Fintype α] (μ : FiniteLaw α) (f g : α → ℝ) : + μ.average (fun x => f x + g x) = μ.average f + μ.average g := by + simp only [average, mul_add, sum_add_distrib] + +lemma independent_average_coordinate_mul {ι α : Type*} [Fintype ι] [DecidableEq ι] + [Fintype α] (μ : ι → FiniteLaw α) (i j : ι) (hij : i ≠ j) (f g : α → ℝ) : + (independent μ).average (fun x => f (x i) * g (x j)) = + (μ i).average f * (μ j).average g := by + let F : ι → α → ℝ := fun k a => + (if k = i then f a else 1) * (if k = j then g a else 1) + have he (x : ι → α) : (∏ k, F k (x k)) = f (x i) * g (x j) := by + simp only [F, prod_mul_distrib] + simp + have hm (k : ι) : (μ k).average (F k) = + (if k = i then (μ i).average f else 1) * + (if k = j then (μ j).average g else 1) := by + by_cases hki : k = i + · subst k + simp [F, hij] + · by_cases hkj : k = j + · subst k + simp [F, hki] + · simp [F, hki, hkj] + calc + _ = (independent μ).average (fun x => ∏ k, F k (x k)) := by simp only [he] + _ = ∏ k, (μ k).average (F k) := independent_average_product μ F + _ = _ := by simp only [hm, prod_mul_distrib]; simp + +end FiniteLaw + +lemma booleanLaw_indicator_average (q : ℝ) (hq0 : 0 ≤ q) (hq1 : q ≤ 1) : + (booleanLaw q hq0 hq1).average (fun b => if b then (1 : ℝ) else 0) = q := by + simp [booleanLaw, FiniteLaw.average] + +lemma independent_boolean_count_average {ι : Type*} [Fintype ι] [DecidableEq ι] + (q : ι → ℝ) (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) : + (FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i))).average + booleanCount = ∑ i, q i := by + rw [show booleanCount = (fun a : ι → Bool => ∑ i, if a i then (1 : ℝ) else 0) from rfl, + FiniteLaw.average_sum] + apply sum_congr rfl + intro i _ + rw [FiniteLaw.independent_average_coordinate + (fun k => booleanLaw (q k) (hq0 k) (hq1 k)) i + (fun b => if b then (1 : ℝ) else 0), booleanLaw_indicator_average] + +lemma independent_boolean_count_square {ι : Type*} [Fintype ι] [DecidableEq ι] + (q : ι → ℝ) (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) : + (FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i))).average + (fun a => (booleanCount a) ^ 2) ≤ (∑ i, q i) ^ 2 + ∑ i, q i := by + let μ := FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i)) + have hp (i j : ι) : μ.average (fun a => + (if a i then (1 : ℝ) else 0) * (if a j then 1 else 0)) ≤ + q i * q j + if i = j then q i else 0 := by + by_cases hij : i = j + · subst j + have he (a : ι → Bool) : + (if a i then (1 : ℝ) else 0) * (if a i then 1 else 0) = + if a i then 1 else 0 := by cases a i <;> norm_num + simp only [he, ite_true] + rw [FiniteLaw.independent_average_coordinate + (fun k => booleanLaw (q k) (hq0 k) (hq1 k)) i + (fun b => if b then (1 : ℝ) else 0), booleanLaw_indicator_average] + nlinarith [sq_nonneg (q i)] + · simp only [hij, ite_false, add_zero] + exact le_of_eq ((FiniteLaw.independent_average_coordinate_mul + (fun i => booleanLaw (q i) (hq0 i) (hq1 i)) i j hij + (fun b => if b then (1 : ℝ) else 0) (fun b => if b then (1 : ℝ) else 0)).trans + (by rw [booleanLaw_indicator_average, booleanLaw_indicator_average])) + have he (a : ι → Bool) : (booleanCount a) ^ 2 = + ∑ i, ∑ j, (if a i then (1 : ℝ) else 0) * (if a j then 1 else 0) := by + simp only [booleanCount, pow_two, sum_mul, mul_sum] + rw [sum_comm] + change μ.average (fun a => (booleanCount a) ^ 2) ≤ (∑ i, q i) ^ 2 + ∑ i, q i + simp_rw [he, μ.average_sum] + calc + _ ≤ ∑ i, ∑ j, (q i * q j + if i = j then q i else 0) := + sum_le_sum (fun i _ => sum_le_sum (fun j _ => hp i j)) + _ = _ := by + simp only [sum_add_distrib, ← mul_sum, sum_ite_eq, mem_univ, ite_true, ← sum_mul] + ring + +lemma independent_boolean_shifted_count_square {ι : Type*} [Fintype ι] [DecidableEq ι] + (q : ι → ℝ) (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) : + (FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i))).average + (fun a => (booleanCount a + ∑ i, q i) ^ 2) ≤ + 4 * (∑ i, q i) ^ 2 + ∑ i, q i := by + let μ := FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i)) + let V := ∑ i, q i + have he (a : ι → Bool) : (booleanCount a + V) ^ 2 = + (booleanCount a) ^ 2 + booleanCount a * (2 * V) + V ^ 2 := by ring + change μ.average (fun a => (booleanCount a + V) ^ 2) ≤ 4 * V ^ 2 + V + simp_rw [he] + rw [μ.average_add, μ.average_add, μ.average_mul_const, μ.average_const] + have hm := independent_boolean_count_average q hq0 hq1 + have hs := independent_boolean_count_square q hq0 hq1 + change μ.average booleanCount = V at hm + change μ.average (fun a => (booleanCount a) ^ 2) ≤ V ^ 2 + V at hs + change μ.average (fun a => (booleanCount a) ^ 2) + + μ.average booleanCount * (2 * V) + V ^ 2 ≤ 4 * V ^ 2 + V + rw [hm] + nlinarith + +lemma padding_weight_square_average (Q : Finset ℕ) (hQ : ∀ p ∈ Q, 2 ≤ p) : + (paddingOriginalLaw Q hQ).average (fun a => (paddingTiltWeight Q a) ^ 2) = + ∏ p : Q, (1 + 24 / (p.val : ℝ)) := by + have he (a : Q → Bool) : (paddingTiltWeight Q a) ^ 2 = + ∏ p : Q, if a p then (25 : ℝ) else 1 := by + rw [paddingTiltWeight, ← prod_pow] + apply prod_congr rfl + intro p _ + cases a p <;> norm_num + simp_rw [he] + rw [paddingOriginalLaw, FiniteLaw.independent_average_product + (fun p : Q => paddingOriginalPrimeLaw p (hQ p p.property)) + (fun _ b => if b then (25 : ℝ) else 1)] + apply prod_congr rfl + intro p _ + simp [paddingOriginalPrimeLaw, booleanLaw, FiniteLaw.average] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSlotClasses.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSlotClasses.lean new file mode 100644 index 0000000000000000000000000000000000000000..bbb9d6ae283efde2c437c40915ce961a2b1abe66 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSlotClasses.lean @@ -0,0 +1,110 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeSlotCode +import OAI.NumberTheory.TwoPoint.Walks.WordResampling +import OAI.NumberTheory.TwoPoint.Bounds.IndependentSampling + +namespace OAI + +/-! Tuple classes can be resampled while all padding classes remain fixed. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace CrudeWordCode + +variable {R N : ℕ} + +def recordedSlots (c : CrudeWordCode R N R) (i : Fin R) (b : Bool) : Finset (Fin N) := + univ.filter (fun j => c.2.2.1 j = i ∧ c.2.2.2 j = b) + +def KindConsistent (c : CrudeWordCode R N R) : Prop := + ∀ j, c.2.2.2 (c.2.1 j) = c.2.2.2 j + +def RowInjective (c : CrudeWordCode R N R) : Prop := + ∀ i b, Set.InjOn c.2.1 (c.recordedSlots i b) + +def tupleClasses (c : CrudeWordCode R N R) : Finset c.usedClasses := + univ.filter (fun z => c.2.2.2 z.val = false) + +def tupleLabels (c : CrudeWordCode R N R) (i : Fin R) : Finset c.tupleClasses := + ((c.recordedSlots i false).image c.classAt).subtype (fun z => z ∈ c.tupleClasses) + +lemma classAt_mem_tupleClasses (c : CrudeWordCode R N R) (hc : c.KindConsistent) + (j : Fin N) (hj : c.2.2.2 j = false) : c.classAt j ∈ c.tupleClasses := by + simp only [tupleClasses, mem_filter, mem_univ, true_and, classAt] + exact (hc j).trans hj + +lemma classAt_notMem_tupleClasses (c : CrudeWordCode R N R) (hc : c.KindConsistent) + (j : Fin N) (hj : c.2.2.2 j = true) : c.classAt j ∉ c.tupleClasses := by + simp only [tupleClasses, mem_filter, mem_univ, true_and, classAt] + rw [hc j, hj] + decide + +/-- Rowwise squarefreeness makes the tuple product a product over its classes. -/ +lemma tuple_product (c : CrudeWordCode R N R) (hc : c.KindConsistent) + (hi : c.RowInjective) (i : Fin R) (a : c.tupleClasses → ℕ) + (b : {z : c.usedClasses // z ∉ c.tupleClasses} → ℕ) : + (∏ j ∈ c.recordedSlots i false, + joinCoordinates c.tupleClasses a b (c.classAt j)) = + ∏ z ∈ c.tupleLabels i, a z := by + let f (j : Fin N) (hj : j ∈ c.recordedSlots i false) : c.tupleClasses := + ⟨c.classAt j, c.classAt_mem_tupleClasses hc j (mem_filter.mp hj).2.2⟩ + apply prod_bij f + · intro j hj + exact mem_subtype.mpr (mem_image.mpr ⟨j, hj, rfl⟩) + · intro j hj k hk he + exact hi i false hj hk (congrArg (fun z : c.tupleClasses => z.val.val) he) + · intro z hz + obtain ⟨j, hj, he⟩ := mem_image.mp (mem_subtype.mp hz) + exact ⟨j, hj, Subtype.ext he⟩ + · intro j hj + exact joinCoordinates_mem c.tupleClasses a b (f j hj) + +lemma padding_product (c : CrudeWordCode R N R) (hc : c.KindConsistent) + (i : Fin R) (a a' : c.tupleClasses → ℕ) + (b : {z : c.usedClasses // z ∉ c.tupleClasses} → ℕ) : + (∏ j ∈ c.recordedSlots i true, joinCoordinates c.tupleClasses a b (c.classAt j)) = + ∏ j ∈ c.recordedSlots i true, joinCoordinates c.tupleClasses a' b (c.classAt j) := by + apply prod_congr rfl + intro j hj + have hn := c.classAt_notMem_tupleClasses hc j (mem_filter.mp hj).2.2 + simp only [joinCoordinates, hn, dite_false] + +/-- A fixed padding assignment and a tuple-class support define the symbolic word. -/ +def labeledWord (c : CrudeWordCode R N R) + (b : {z : c.usedClasses // z ∉ c.tupleClasses} → ℕ) : LabeledPrimeWord c.tupleClasses where + word := c.numericalWord (joinCoordinates c.tupleClasses (fun _ => 1) b) + labels i := c.tupleLabels ⟨i.val, by + exact lt_of_lt_of_eq i.isLt (numericalWord_length c _)⟩ + +lemma labeledWord_length (c : CrudeWordCode R N R) + (b : {z : c.usedClasses // z ∉ c.tupleClasses} → ℕ) : + (c.labeledWord b).word.length = R := c.numericalWord_length _ + +/-- Resampling changes exactly the tuple primes, with no additional padding choices. -/ +theorem labeledWord_resample (c : CrudeWordCode R N R) (hc : c.KindConsistent) + (hi : c.RowInjective) (a : c.tupleClasses → ℕ) + (b : {z : c.usedClasses // z ∉ c.tupleClasses} → ℕ) : + ((c.labeledWord b).resample a).word = + c.numericalWord (joinCoordinates c.tupleClasses a b) := by + apply List.ext_getElem + · rw [LabeledPrimeWord.resample_length, labeledWord_length, numericalWord_length] + · intro i hi₁ hi₂ + have hiR : i < R := by simpa only [numericalWord_length] using hi₂ + let j : Fin R := ⟨i, hiR⟩ + have hp := c.padding_product hc j (fun _ => 1) a b + have ht := c.tuple_product hc hi j a b + have hf := c.numericalWord_get (joinCoordinates c.tupleClasses (fun _ => 1) b) j + simp only [LabeledPrimeWord.resample, List.getElem_ofFn, labeledWord] + rw [c.numericalWord_get _ j] + congr 1 + · exact congrArg SignedStep.forward hf + · exact ht.symm + · exact (congrArg SignedStep.padding hf).trans hp + +end CrudeWordCode + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSlotCode.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSlotCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..e728f697b8eabaeae8ffcefe84acb07f067a08be --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSlotCode.lean @@ -0,0 +1,96 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CrudeWordCounting +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedWords + +namespace OAI + +/-! A complete equality-pattern code for tuple and padding prime occurrences. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +/-- Each occurrence records its step, whether it belongs to the padding, +and its numerical prime. Unused slots are avoided by taking the actual total length. -/ +structure PrimeSlotData (R N : ℕ) where + forward : Fin R → Bool + row : Fin N → Fin R + isPadding : Fin N → Bool + prime : Fin N → ℕ + +namespace PrimeSlotData + +variable {R N : ℕ} + +def slots (a : PrimeSlotData R N) (i : Fin R) (b : Bool) : Finset (Fin N) := + univ.filter (fun j => a.row j = i ∧ a.isPadding j = b) + +def factor (a : PrimeSlotData R N) (i : Fin R) (b : Bool) : ℕ := + ∏ j ∈ a.slots i b, a.prime j + +def word (a : PrimeSlotData R N) : List SignedStep := + List.ofFn (fun i => ⟨a.forward i, a.factor i false, a.factor i true⟩) + +noncomputable def code (a : PrimeSlotData R N) : CrudeWordCode R N R := + (a.forward, columnRepresentative a.prime ∅, a.row, a.isPadding) + +lemma code_class_eq_iff (a : PrimeSlotData R N) (i j : Fin N) : + a.code.2.1 i = a.code.2.1 j ↔ a.prime i = a.prime j := + columnRepresentative_eq_iff a.prime ∅ i j + +lemma code_class_prime (a : PrimeSlotData R N) (i : Fin N) : + a.prime (a.code.2.1 i) = a.prime i := + columnRepresentative_label a.prime ∅ i + +end PrimeSlotData + +namespace CrudeWordCode + +variable {R N : ℕ} + +def usedClasses (c : CrudeWordCode R N R) : Finset (Fin N) := univ.image c.2.1 + +def classAt (c : CrudeWordCode R N R) (i : Fin N) : c.usedClasses := + ⟨c.2.1 i, mem_image.mpr ⟨i, mem_univ _, rfl⟩⟩ + +def primeData (c : CrudeWordCode R N R) (value : c.usedClasses → ℕ) : PrimeSlotData R N where + forward := c.1 + row := c.2.2.1 + isPadding := c.2.2.2 + prime i := value (c.classAt i) + +def numericalWord (c : CrudeWordCode R N R) (value : c.usedClasses → ℕ) : List SignedStep := + (c.primeData value).word + +lemma primeData_encode (a : PrimeSlotData R N) : + a.code.primeData (fun c => a.prime c.val) = a := by + cases a with + | mk forward row isPadding prime => + unfold primeData PrimeSlotData.code + congr 1 + funext i + exact columnRepresentative_label prime ∅ i + +lemma numericalWord_encode (a : PrimeSlotData R N) : + a.code.numericalWord (fun c => a.prime c.val) = a.word := by + exact congrArg PrimeSlotData.word (primeData_encode a) + +lemma numericalWord_length (c : CrudeWordCode R N R) (value : c.usedClasses → ℕ) : + (c.numericalWord value).length = R := by + simp [numericalWord, PrimeSlotData.word] + +/-- Padding is reconstructed from the same prime classes as tuple factors, +so repetitions across steps never introduce new independent numerical choices. -/ +lemma numericalWord_get (c : CrudeWordCode R N R) (value : c.usedClasses → ℕ) (i : Fin R) : + (c.numericalWord value)[i.val]'(by rw [numericalWord_length]; exact i.isLt) = + ⟨c.1 i, + ∏ j ∈ univ.filter (fun j => c.2.2.1 j = i ∧ c.2.2.2 j = false), value (c.classAt j), + ∏ j ∈ univ.filter (fun j => c.2.2.1 j = i ∧ c.2.2.2 j = true), value (c.classAt j)⟩ := by + simp [numericalWord, PrimeSlotData.word, PrimeSlotData.factor, PrimeSlotData.slots, primeData] + constructor <;> congr 1 + +end CrudeWordCode + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSubsetSplitting.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSubsetSplitting.lean new file mode 100644 index 0000000000000000000000000000000000000000..c872f45f897155135cd37b867f5a6c3bc0b081a6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSubsetSplitting.lean @@ -0,0 +1,103 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CenterBandReindex +import OAI.NumberTheory.TwoPoint.Bounds.NonrawRoughData +import Mathlib.Data.Nat.GCD.BigOperators + +namespace OAI + +/-! The subset reindexing gives exactly the numerical rough support: +disjoint prime subsets are equivalent to coprime squarefree products. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma primeSubset_products_coprime (U W : Finset ℕ) + (hU : ∀ p ∈ U, Nat.Prime p) (hW : ∀ p ∈ W, Nat.Prime p) : + Nat.Coprime (∏ p ∈ U, p) (∏ p ∈ W, p) ↔ Disjoint U W := by + rw [Nat.coprime_prod_left_iff] + constructor + · intro h + apply disjoint_left.mpr + intro p hpU hpW + have hpp := Nat.coprime_prod_right_iff.mp (h p hpU) p hpW + exact (Nat.coprime_primes (hU p hpU) (hW p hpW)).mp hpp rfl + · intro hd p hp + apply Nat.coprime_prod_right_iff.mpr + intro q hq + apply (Nat.coprime_primes (hU p hp) (hW q hq)).mpr + intro heq + subst q + exact disjoint_left.mp hd hp hq + +lemma retainedPrimeDivisors_avoiding (U T : Finset ℕ) + (hU : ∀ p ∈ U, Nat.Prime p) (hT : ∀ p ∈ T, Nat.Prime p) : + (retainedPrimeDivisors T).filter (fun w => Nat.Coprime (∏ p ∈ U, p) w) = + retainedPrimeDivisors (T \ U) := by + ext w + constructor + · intro hw + obtain ⟨W, hWT, rfl⟩ := mem_image.mp (mem_filter.mp hw).1 + have hsub : W ⊆ T := mem_powerset.mp hWT + have hd := (primeSubset_products_coprime U W hU (fun p hp => hT p (hsub hp))).mp + (mem_filter.mp hw).2 + apply mem_image.mpr + refine ⟨W, mem_powerset.mpr ?_, rfl⟩ + intro p hp + exact mem_sdiff.mpr ⟨hsub hp, fun hpU => disjoint_left.mp hd hpU hp⟩ + · intro hw + obtain ⟨W, hW, rfl⟩ := mem_image.mp hw + have hsub : W ⊆ T \ U := mem_powerset.mp hW + have hWT : W ⊆ T := fun p hp => (mem_sdiff.mp (hsub hp)).1 + apply mem_filter.mpr + refine ⟨mem_image.mpr ⟨W, mem_powerset.mpr hWT, rfl⟩, ?_⟩ + apply (primeSubset_products_coprime U W hU (fun p hp => hT p (hWT hp))).mpr + apply disjoint_left.mpr + intro p hpU hpW + exact (mem_sdiff.mp (hsub hpW)).2 hpU + +lemma nonrawRoughSupport_of_primeSubset (U T : Finset ℕ) + (hU : ∀ p ∈ U, Nat.Prime p) (hT : ∀ p ∈ T, Nat.Prime p) + (H τ : ℝ) : + nonrawRoughSupport T H τ (∏ p ∈ U, p) = + (retainedPrimeDivisors (T \ U)).filter (fun w => + 1 < w ∧ H < (((∏ p ∈ U, p) * w : ℕ) : ℝ) ∧ + (((∏ p ∈ U, p) * w : ℕ) : ℝ) ≤ τ * H) := by + rw [← retainedPrimeDivisors_avoiding U T hU hT] + ext w + simp only [nonrawRoughSupport, mem_filter] + tauto + +lemma primeSubset_core_retained (C D W : Finset ℕ) + (hCW : Disjoint C W) : (D \ W) ∩ C = D ∩ C := by + ext p + simp only [mem_inter, mem_sdiff] + constructor + · exact fun h => ⟨h.1.1, h.2⟩ + · intro h + exact ⟨⟨h.1, fun hpW => disjoint_left.mp hCW h.2 hpW⟩, h.2⟩ + +/-- The removed-subset sum is exactly the numerical rough-support sum, +including its reciprocal coefficient and the prime-factor exponent. -/ +theorem nonraw_subset_sum (U T : Finset ℕ) + (hU : ∀ p ∈ U, Nat.Prime p) (hT : ∀ p ∈ T, Nat.Prime p) + (H τ : ℝ) (θ : ℂ) (F : ℕ → ℂ) : + (∑ W ∈ (T \ U).powerset, + if 1 < (∏ p ∈ W, p) ∧ H < (((∏ p ∈ U, p) * (∏ p ∈ W, p) : ℕ) : ℝ) ∧ + (((∏ p ∈ U, p) * (∏ p ∈ W, p) : ℕ) : ℝ) ≤ τ * H + then ((-θ) ^ W.card / ((∏ p ∈ W, p : ℕ) : ℂ)) * F (∏ p ∈ W, p) + else 0) = + ∑ w ∈ nonrawRoughSupport T H τ (∏ p ∈ U, p), + ((-θ) ^ w.primeFactors.card / (w : ℂ)) * F w := by + symm + rw [nonrawRoughSupport_of_primeSubset U T hU hT, sum_filter, + retainedPrimeDivisors, sum_image (primeSubset_product_injective (T \ U) + (fun p hp => hT p (mem_sdiff.mp hp).1))] + apply sum_congr rfl + intro W hW + rw [Nat.primeFactors_prod (fun p hp => hT p + (mem_sdiff.mp (mem_powerset.mp hW hp)).1)] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSupplyGeometry.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSupplyGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0c45e5c59593cbdf6522a13fe85cb3a0b0c1ad1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSupplyGeometry.lean @@ -0,0 +1,149 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePrimeBands + +namespace OAI + +/-! Actual disjoint prime supplies at geometric logarithmic scales. Their +mass follows from the published fixed-modulus input through the proved +partial-summation chain, and all support assertions are finite identities. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def primeSupplyEndpoint (A W : ℝ) (i : ℕ) : ℝ := + A * Real.exp (6 * W * i) + +noncomputable def centeredPrimeSupply (E : Finset ℕ) (A W : ℝ) (i : ℕ) : Finset ℕ := + modFivePrimeBand E true (Real.exp (primeSupplyEndpoint A W i)) + (Real.exp (primeSupplyEndpoint A W (i + 1))) + +noncomputable def paddingPrimeSupply (E : Finset ℕ) (L : ℝ) : Finset ℕ := + deletedModFivePrimes E false (Real.exp L) + +lemma primeSupplyEndpoint_zero (A W : ℝ) : primeSupplyEndpoint A W 0 = A := by + simp [primeSupplyEndpoint] + +lemma primeSupplyEndpoint_succ (A W : ℝ) (i : ℕ) : + primeSupplyEndpoint A W (i + 1) = primeSupplyEndpoint A W i * Real.exp (6 * W) := by + unfold primeSupplyEndpoint + rw [Nat.cast_add, Nat.cast_one, mul_add, mul_one, Real.exp_add] + ring + +lemma primeSupplyEndpoint_mono (A W : ℝ) (hA : 0 ≤ A) (hW : 0 ≤ W) : + Monotone (primeSupplyEndpoint A W) := by + intro i j hij + unfold primeSupplyEndpoint + apply mul_le_mul_of_nonneg_left _ hA + apply Real.exp_le_exp.mpr + exact mul_le_mul_of_nonneg_left (by exact_mod_cast hij) (by positivity) + +lemma centeredPrimeSupply_mem {E : Finset ℕ} {A W : ℝ} {i p : ℕ} + (hp : p ∈ centeredPrimeSupply E A W i) : + p.Prime ∧ p % 5 = 1 ∧ p ∉ E ∧ + primeSupplyEndpoint A W i < Real.log p ∧ + Real.log p ≤ primeSupplyEndpoint A W (i + 1) := by + obtain ⟨hlo, hhi, hs, he⟩ := (modFivePrimeBand_mem (Real.exp_pos _).le + (Real.exp_pos _).le).mp hp + have hp0 : (0 : ℝ) < p := by exact_mod_cast hs.1.pos + refine ⟨hs.1, hs.2, he, ?_, ?_⟩ + · simpa only [Real.log_exp] using Real.log_lt_log (Real.exp_pos _) hlo + · simpa only [Real.log_exp] using Real.log_le_log hp0 hhi + +lemma centeredPrimeSupply_pairwise_disjoint (E : Finset ℕ) (A W : ℝ) + (hA : 0 ≤ A) (hW : 0 ≤ W) : + Pairwise (fun i j => Disjoint (centeredPrimeSupply E A W i) (centeredPrimeSupply E A W j)) := by + intro i j hij + apply disjoint_left.mpr + intro p hpi hpj + have hi := centeredPrimeSupply_mem hpi + have hj := centeredPrimeSupply_mem hpj + rcases lt_or_gt_of_ne hij with hlt | hgt + · have hh := primeSupplyEndpoint_mono A W hA hW (Nat.succ_le_of_lt hlt) + linarith [hi.2.2.2.2, hj.2.2.2.1] + · have hh := primeSupplyEndpoint_mono A W hA hW (Nat.succ_le_of_lt hgt) + linarith [hj.2.2.2.2, hi.2.2.2.1] + +lemma centered_padding_disjoint (E : Finset ℕ) (A W L : ℝ) (i : ℕ) : + Disjoint (centeredPrimeSupply E A W i) (paddingPrimeSupply E L) := by + apply disjoint_left.mpr + intro p hp hq + have hpc := (centeredPrimeSupply_mem hp).2.1 + have hqc := (mem_filter.mp (mem_sdiff.mp hq).1).2.2 + exact hqc hpc + +lemma centeredPrimeSupply_global_bounds {E : Finset ℕ} {A W L : ℝ} + (hA : 0 ≤ A) (hW : 0 ≤ W) {J i p : ℕ} (hi : i < J) + (hL : primeSupplyEndpoint A W J ≤ L) (hp : p ∈ centeredPrimeSupply E A W i) : + Real.exp A < (p : ℝ) ∧ (p : ℝ) ≤ Real.exp L := by + have hh := centeredPrimeSupply_mem hp + have hp0 : (0 : ℝ) < p := by exact_mod_cast hh.1.pos + have hlo : A < Real.log p := by + have hmono := primeSupplyEndpoint_mono A W hA hW (Nat.zero_le i) + rw [primeSupplyEndpoint_zero] at hmono + exact hmono.trans_lt hh.2.2.2.1 + have hhi : Real.log p ≤ L := hh.2.2.2.2.trans + ((primeSupplyEndpoint_mono A W hA hW (Nat.succ_le_of_lt hi)).trans hL) + constructor + · simpa only [Real.exp_log hp0] using Real.exp_lt_exp.mpr hlo + · simpa only [Real.exp_log hp0] using Real.exp_le_exp.mpr hhi + +lemma primeSupplyEndpoint_sum_lt (A W : ℝ) (hA : 0 < A) (hW : 1 ≤ W) (J : ℕ) : + (∑ i ∈ range J, primeSupplyEndpoint A W (i + 1)) < 2 * primeSupplyEndpoint A W J := by + have hratio : 2 ≤ Real.exp (6 * W) := by + linarith [Real.add_one_le_exp (6 * W)] + induction J with + | zero => simp [primeSupplyEndpoint, hA] + | succ J ih => + have he : 0 ≤ primeSupplyEndpoint A W J := by unfold primeSupplyEndpoint; positivity + have hstep : 2 * primeSupplyEndpoint A W J ≤ primeSupplyEndpoint A W (J + 1) := by + rw [primeSupplyEndpoint_succ] + nlinarith [mul_le_mul_of_nonneg_right hratio he] + rw [sum_range_succ] + linarith + +lemma centeredPrimeSupply_tuple_log_bound {E : Finset ℕ} {A W L : ℝ} + (hA : 0 < A) (hW : 1 ≤ W) {J : ℕ} (hL : primeSupplyEndpoint A W J ≤ L) + (p : Fin J → ℕ) (hp : ∀ i : Fin J, p i ∈ centeredPrimeSupply E A W i.val) : + Real.log ((∏ i, p i : ℕ) : ℝ) < 2 * L := by + have hlog : Real.log ((∏ i, p i : ℕ) : ℝ) = ∑ i, Real.log (p i : ℝ) := by + rw [Nat.cast_prod, Real.log_prod] + intro i _ + exact_mod_cast (centeredPrimeSupply_mem (hp i)).1.ne_zero + rw [hlog] + calc + _ ≤ ∑ i : Fin J, primeSupplyEndpoint A W (i.val + 1) := + sum_le_sum (fun i _ => (centeredPrimeSupply_mem (hp i)).2.2.2.2) + _ = ∑ i ∈ range J, primeSupplyEndpoint A W (i + 1) := + Fin.sum_univ_eq_sum_range (fun i : ℕ => primeSupplyEndpoint A W (i + 1)) J + _ < 2 * primeSupplyEndpoint A W J := primeSupplyEndpoint_sum_lt A W hA hW J + _ ≤ 2 * L := by linarith + +/-- Every centered supply is nonempty and has the required reciprocal mass. +The threshold is independent of the number of supplies and their indices. -/ +theorem ModFiveThetaInput.centered_supplies (hP : ModFiveThetaInput) + (E : Finset ℕ) (W : ℝ) (hW : 0 < W) : + ∃ A₀ : ℝ, 1 ≤ A₀ ∧ ∀ A : ℝ, A₀ ≤ A → ∀ i : ℕ, + (centeredPrimeSupply E A W i).Nonempty ∧ + W ≤ (∑ p ∈ centeredPrimeSupply E A W i, 1 / (p : ℝ)) ∧ + (∑ p ∈ centeredPrimeSupply E A W i, 1 / (p : ℝ)) ≤ 2 * W := by + obtain ⟨A₀, hA₀, hmass⟩ := hP.centered_band_mass E W hW + refine ⟨A₀, hA₀, fun A hA i => ?_⟩ + have hA0 : 0 ≤ A := (zero_le_one.trans hA₀).trans hA + have hlower : A₀ ≤ primeSupplyEndpoint A W i := by + calc + A₀ ≤ A := hA + _ = primeSupplyEndpoint A W 0 := (primeSupplyEndpoint_zero A W).symm + _ ≤ _ := primeSupplyEndpoint_mono A W hA0 hW.le (Nat.zero_le _) + have hh := hmass (primeSupplyEndpoint A W i) hlower + rw [← primeSupplyEndpoint_succ] at hh + change W ≤ (∑ p ∈ centeredPrimeSupply E A W i, 1 / (p : ℝ)) ∧ + (∑ p ∈ centeredPrimeSupply E A W i, 1 / (p : ℝ)) ≤ 2 * W at hh + refine ⟨?_, hh⟩ + by_contra he + rw [not_nonempty_iff_eq_empty.mp he, sum_empty] at hh + linarith [hh.1] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSupplyScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSupplyScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..5403d03ca6289bd5dca6a00db6bb87fe66950676 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeSupplyScale.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeSupplyGeometry + +namespace OAI + +/-! The literal scale choice of the manuscript satisfies all prime-supply +mass and support hypotheses; no prime-family existence premise remains. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def primeSupplyCount (W L : ℝ) : ℕ := + ⌊((1 / 200 : ℝ) * Real.log L) / (6 * W)⌋₊ + +lemma primeSupplyScale_endpoint (W L : ℝ) (hW : 0 < W) (hL : 1 ≤ L) : + primeSupplyEndpoint (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) ≤ L := by + have hLp : 0 < L := zero_lt_one.trans_le hL + have hl : 0 ≤ Real.log L := Real.log_nonneg hL + have hj : (primeSupplyCount W L : ℝ) ≤ ((1 / 200 : ℝ) * Real.log L) / (6 * W) := + Nat.floor_le (by positivity) + have hj' := (le_div_iff₀ (by positivity : 0 < 6 * W)).mp hj + unfold primeSupplyEndpoint + calc + _ = Real.exp (Real.log L * (199 / 200 : ℝ) + 6 * W * primeSupplyCount W L) := by + rw [Real.rpow_def_of_pos hLp, Real.exp_add] + _ ≤ Real.exp (Real.log L) := Real.exp_le_exp.mpr (by nlinarith) + _ = L := Real.exp_log hLp + +lemma eventually_primeSupplyCount_pos (W : ℝ) (hW : 0 < W) : + ∀ᶠ L : ℝ in atTop, 1 ≤ primeSupplyCount W L := by + filter_upwards [eventually_ge_atTop (Real.exp (1200 * W))] with L hL + have hLp : 0 < L := (Real.exp_pos _).trans_le hL + have hl : 1200 * W ≤ Real.log L := by + simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos _) hL + have hl0 : 0 ≤ Real.log L := le_trans (by positivity : (0 : ℝ) ≤ 1200 * W) hl + unfold primeSupplyCount + apply (Nat.le_floor_iff (by positivity : 0 ≤ ((1 / 200 : ℝ) * Real.log L) / (6 * W))).mpr + norm_num + apply (le_div_iff₀ (by positivity : 0 < 6 * W)).mpr + linarith + +theorem ModFiveThetaInput.eventually_actual_prime_supplies (hP : ModFiveThetaInput) + (E : Finset ℕ) (W : ℝ) (hW : 1 ≤ W) : + ∀ᶠ L : ℝ in atTop, + 1 ≤ primeSupplyCount W L ∧ + primeSupplyEndpoint (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) ≤ L ∧ + ∀ i : ℕ, (centeredPrimeSupply E (L ^ (199 / 200 : ℝ)) W i).Nonempty ∧ + W ≤ (∑ p ∈ centeredPrimeSupply E (L ^ (199 / 200 : ℝ)) W i, 1 / (p : ℝ)) ∧ + (∑ p ∈ centeredPrimeSupply E (L ^ (199 / 200 : ℝ)) W i, 1 / (p : ℝ)) ≤ 2 * W := by + have hWp : 0 < W := zero_lt_one.trans_le hW + obtain ⟨A₀, _, hmass⟩ := hP.centered_supplies E W hWp + have hlarge := (tendsto_rpow_atTop (show 0 < (199 / 200 : ℝ) by norm_num)).eventually + (eventually_ge_atTop A₀) + filter_upwards [eventually_ge_atTop (1 : ℝ), eventually_primeSupplyCount_pos W hWp, + hlarge] with L hL hJ hA + exact ⟨hJ, primeSupplyScale_endpoint W L hWp hL, + hmass (L ^ (199 / 200 : ℝ)) hA⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeTraceParameters.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeTraceParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..97452bf91458f900b0fe23414f3550f591a64866 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeTraceParameters.lean @@ -0,0 +1,38 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualPrimeScale + +namespace OAI + +/-! The canonical prime count and padding degree cap satisfy the numerical +budgets of the trace theorem with an absolute coefficient. -/ + +namespace TwoPointCorrelations + +lemma prime_trace_degree_budget (W L : ℝ) (hW : 1 ≤ W) (hL : 1 ≤ L) : + ((primeSupplyCount W L + ⌊100 * Real.log L⌋₊ : ℕ) : ℝ) ≤ 101 * Real.log L ∧ + (⌊100 * Real.log L⌋₊ : ℝ) ≤ 100 * Real.log L := by + have hlog : 0 ≤ Real.log L := Real.log_nonneg hL + have hcount := primeSupplyCount_mul_bound W L (by linarith) hL + have hprod : (primeSupplyCount W L : ℝ) ≤ primeSupplyCount W L * (6 * W) := by + have hb := mul_le_mul_of_nonneg_left hW (show (0 : ℝ) ≤ primeSupplyCount W L by positivity) + nlinarith + have hj : (primeSupplyCount W L : ℝ) ≤ Real.log L := by + nlinarith + have hm : (⌊100 * Real.log L⌋₊ : ℝ) ≤ 100 * Real.log L := Nat.floor_le (by positivity) + refine ⟨?_, hm⟩ + push_cast + linarith + +lemma prime_trace_endpoints (L : ℝ) (hL : 1 ≤ L) : + 1 ≤ ⌊Real.exp L⌋₊ ∧ + (⌊Real.exp L⌋₊ : ℝ) ≤ Real.exp L ∧ + Real.exp (L ^ (199 / 200 : ℝ)) ≤ ⌈Real.exp (L ^ (199 / 200 : ℝ))⌉₊ ∧ + (⌊Real.exp (100 * L + 1)⌋₊ : ℝ) ≤ Real.exp (100 * L + 1) ∧ + (⌊Real.exp (2 * L)⌋₊ : ℝ) ≤ Real.exp (2 * L) := by + refine ⟨?_, Nat.floor_le (Real.exp_pos _).le, Nat.le_ceil _, + Nat.floor_le (Real.exp_pos _).le, Nat.floor_le (Real.exp_pos _).le⟩ + apply (Nat.le_floor_iff (Real.exp_pos _).le).mpr + simpa only [Nat.cast_one] using Real.one_le_exp (by linarith : 0 ≤ L) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeTupleMass.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeTupleMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb5fc63f427b91554908d4467d652c9777510c16 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeTupleMass.lean @@ -0,0 +1,108 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingBinMassTotal +import OAI.NumberTheory.TwoPoint.Bounds.PrimeSupplyScale +import OAI.NumberTheory.TwoPoint.Walks.TuplePrimeArithmetic + +namespace OAI + +/-! The centered divisor family is the actual image of one prime choice +from each disjoint band. Its harmonic mass has no representation +multiplicity and is exactly the product of the band masses. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def primeTupleDivisors {J : ℕ} (P : Fin J → Finset ℕ) : Finset ℕ := + univ.image (fun x : (j : Fin J) → P j => ∏ j, (x j).val) + +lemma primeTupleDivisors_mass {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) : + (∑ d ∈ primeTupleDivisors P, 1 / (d : ℝ)) = + ∏ j, ∑ p ∈ P j, 1 / (p : ℝ) := by + rw [primeTupleDivisors, sum_image] + · calc + _ = ∑ x : (j : Fin J) → P j, ∏ j, 1 / ((x j).val : ℝ) := by + apply sum_congr rfl + intro x _ + simp only [Nat.cast_prod, one_div, prod_inv_distrib] + _ = ∏ j, ∑ p : P j, 1 / (p.val : ℝ) := + (Fintype.prod_sum (fun j (p : P j) => 1 / (p.val : ℝ))).symm + _ = _ := by + apply prod_congr rfl + intro j _ + exact sum_coe_sort (P j) (fun p : ℕ => 1 / (p : ℝ)) + · intro x _ y _ hxy + exact primeTuple_injective hprime hdisjoint hxy + +lemma centeredPrimeTuple_log_bound {E : Finset ℕ} {A W L : ℝ} + (hA : 0 < A) (hW : 1 ≤ W) {J : ℕ} (hL : primeSupplyEndpoint A W J ≤ L) + {d : ℕ} (hd : d ∈ primeTupleDivisors (fun j : Fin J => centeredPrimeSupply E A W j)) : + 0 < d ∧ Real.log d ≤ 2 * L := by + obtain ⟨x, _, rfl⟩ := mem_image.mp hd + constructor + · exact prod_pos fun j _ => (centeredPrimeSupply_mem (x j).property).1.pos + · exact (centeredPrimeSupply_tuple_log_bound hA hW hL + (fun j => (x j).val) (fun j => (x j).property)).le + +lemma centeredPrimeTuple_mass (E : Finset ℕ) (A W : ℝ) (J : ℕ) + (hA : 0 ≤ A) (hW : 0 ≤ W) : + (∑ d ∈ primeTupleDivisors (fun j : Fin J => centeredPrimeSupply E A W j), + 1 / (d : ℝ)) = + ∏ j : Fin J, ∑ p ∈ centeredPrimeSupply E A W j, 1 / (p : ℝ) := by + apply primeTupleDivisors_mass + · intro j p hp + exact (centeredPrimeSupply_mem hp).1 + · intro j l hne + exact centeredPrimeSupply_pairwise_disjoint E A W hA hW + (fun he => hne (Fin.ext he.symm)) + +lemma primeTupleDivisors_mass_bounds {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (W : ℝ) (hW : 0 ≤ W) + (hmass : ∀ j, W ≤ (∑ p ∈ P j, 1 / (p : ℝ)) ∧ + (∑ p ∈ P j, 1 / (p : ℝ)) ≤ 2 * W) : + W ^ J ≤ (∑ d ∈ primeTupleDivisors P, 1 / (d : ℝ)) ∧ + (∑ d ∈ primeTupleDivisors P, 1 / (d : ℝ)) ≤ (2 * W) ^ J := by + rw [primeTupleDivisors_mass P hprime hdisjoint] + constructor + · calc + _ = ∏ _j : Fin J, W := by simp + _ ≤ _ := prod_le_prod₀ (fun _ _ => hW) (fun j _ => (hmass j).1) + · calc + _ ≤ ∏ _j : Fin J, 2 * W := prod_le_prod₀ + (fun j _ => sum_nonneg (fun p _ => by positivity)) (fun j _ => (hmass j).2) + _ = _ := by simp + +/-- `q:bin-mass` for the actual prime families and the manuscript's scale +choice. The assertion is uniform over the positive bin width. -/ +theorem ModFiveThetaInput.eventually_primeTuple_bin_mass (hP : ModFiveThetaInput) + (E : Finset ℕ) (W : ℝ) (hW : 1 ≤ W) : + ∀ᶠ L : ℝ in atTop, ∀ η : ℝ, 0 < η → + let J := primeSupplyCount W L + let P := fun j : Fin J => centeredPrimeSupply E (L ^ (199 / 200 : ℝ)) W j + let V := ∏ j : Fin J, ∑ p ∈ P j, 1 / (p : ℝ) + (1 / 2 : ℝ) * paddingTiltNormalizer (paddingPrimeSupply E L) * V ≤ + totalPaddingBinMass (primeTupleDivisors P) (paddingPrimeSupply E L) L η ∧ + totalPaddingBinMass (primeTupleDivisors P) (paddingPrimeSupply E L) L η ≤ + paddingTiltNormalizer (paddingPrimeSupply E L) * V := by + filter_upwards [hP.eventually_totalPaddingBinMass E, eventually_ge_atTop (1 : ℝ)] + with L hmass hL + intro η hη + have hLp : 0 < L := zero_lt_one.trans_le hL + have hA : 0 < L ^ (199 / 200 : ℝ) := Real.rpow_pos_of_pos hLp _ + have hWp : 0 < W := zero_lt_one.trans_le hW + have he := primeSupplyScale_endpoint W L hWp hL + have hd := hmass (primeTupleDivisors + (fun j : Fin (primeSupplyCount W L) => centeredPrimeSupply E (L ^ (199 / 200 : ℝ)) W j)) + η hη (fun d hd => centeredPrimeTuple_log_bound hA hW he hd) + dsimp only + rw [centeredPrimeTuple_mass E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) + hA.le hWp.le] at hd + exact hd + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeTuplePool.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeTuplePool.lean new file mode 100644 index 0000000000000000000000000000000000000000..785e772e05e1ed0b9310b0c47a8807509d0891fa --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeTuplePool.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeTupleMass + +namespace OAI + +/-! Arithmetic support of the actual one-prime-per-band tuple family. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def primeTuplePool {J : ℕ} (P : Fin J → Finset ℕ) : Finset ℕ := + univ.biUnion P + +lemma mem_primeTuplePool {J : ℕ} {P : Fin J → Finset ℕ} {p : ℕ} : + p ∈ primeTuplePool P ↔ ∃ j, p ∈ P j := by + simp only [primeTuplePool, mem_biUnion, mem_univ, true_and] + +lemma primeTuplePool_prime {J : ℕ} {P : Fin J → Finset ℕ} + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) {p : ℕ} (hp : p ∈ primeTuplePool P) : + p.Prime := by + obtain ⟨j, hj⟩ := mem_primeTuplePool.mp hp + exact hprime j p hj + +lemma primeHarmonicMass_eq_sum (S : Finset ℕ) : + primeHarmonicMass S = ∑ p ∈ S, 1 / (p : ℝ) := by + unfold primeHarmonicMass + simpa only [one_div] using sum_coe_sort S (fun p : ℕ => 1 / (p : ℝ)) + +lemma primeHarmonicMass_mono {S T : Finset ℕ} (hST : S ⊆ T) : + primeHarmonicMass S ≤ primeHarmonicMass T := by + rw [primeHarmonicMass_eq_sum, primeHarmonicMass_eq_sum] + exact sum_le_sum_of_subset_of_nonneg hST (fun _ _ _ => by positivity) + +lemma primeTuplePool_mass {J : ℕ} (P : Fin J → Finset ℕ) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) : + primeHarmonicMass (primeTuplePool P) = ∑ j, primeHarmonicMass (P j) := by + simp only [primeHarmonicMass_eq_sum, primeTuplePool] + apply sum_biUnion + intro j _ l _ hne + exact hdisjoint j l (Ne.symm hne) + +lemma primeTupleDivisors_arithmetic {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + {d : ℕ} (hd : d ∈ primeTupleDivisors P) : + Squarefree d ∧ d.primeFactors.card = J ∧ d.primeFactors ⊆ primeTuplePool P := by + obtain ⟨x, _, rfl⟩ := mem_image.mp hd + have hf : (∏ j, (x j).val).primeFactors = univ.image (fun j => (x j).val) := + familyTuple_primeFactors (fun j (p : P j) => p.val) + (fun j p => hprime j _ p.property) x (selectedPrimeValues_injective x hdisjoint) + refine ⟨?_, ?_, ?_⟩ + · exact columnTuple_squarefree (fun j (_ : Fin 1) => x j) 0 hprime hdisjoint + · rw [hf, card_image_of_injective _ (selectedPrimeValues_injective x hdisjoint), + card_univ, Fintype.card_fin] + · rw [hf] + intro p hp + obtain ⟨j, _, rfl⟩ := mem_image.mp hp + exact mem_primeTuplePool.mpr ⟨j, (x j).property⟩ + +lemma retainedPrimeDivisor_squarefree (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + {q : ℕ} (hq : q ∈ retainedPrimeDivisors Q) : Squarefree q := by + obtain ⟨U, hU, rfl⟩ := mem_image.mp hq + have hprime (p : ℕ) (hp : p ∈ U) := hQ p ((mem_powerset.mp hU) hp) + apply Finset.squarefree_prod_of_pairwise_isCoprime + · intro p hp r hr hne + change IsRelPrime p r + rw [← Nat.coprime_iff_isRelPrime] + exact (Nat.coprime_primes (hprime p hp) (hprime r hr)).mpr hne + · intro p hp + exact (hprime p hp).squarefree + +noncomputable def boundedPaddingDivisors (Q : Finset ℕ) (M : ℕ) : Finset ℕ := + (retainedPrimeDivisors Q).filter (fun q => q.primeFactors.card ≤ M) + +noncomputable def primeFamilyPairs {J : ℕ} (P : Fin J → Finset ℕ) (Q : Finset ℕ) + (M : ℕ) (eligible : ℕ → ℕ → Prop) : Finset (ℕ × ℕ) := + ((primeTupleDivisors P).product (boundedPaddingDivisors Q M)).filter + (fun dq => eligible dq.1 dq.2) + +lemma mem_primeFamilyPairs {J : ℕ} {P : Fin J → Finset ℕ} {Q : Finset ℕ} + {M : ℕ} {eligible : ℕ → ℕ → Prop} {dq : ℕ × ℕ} : + dq ∈ primeFamilyPairs P Q M eligible ↔ + dq.1 ∈ primeTupleDivisors P ∧ dq.2 ∈ retainedPrimeDivisors Q ∧ + dq.2.primeFactors.card ≤ M ∧ eligible dq.1 dq.2 := by + rcases dq with ⟨d, q⟩ + simp only [primeFamilyPairs, boundedPaddingDivisors, Finset.product_eq_sprod, + mem_filter, Finset.mem_product] + tauto + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeWordEncoding.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeWordEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..6fae7bb27453820e526a5f6b71619a9971a78c2a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/PrimeWordEncoding.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualCodeAssignments + +namespace OAI + +/-! A single finite universe covers all numerical words with bounded prime slots. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +/-- Slot count, complete equality-pattern code, and separate prime-pool assignments. -/ +abbrev PrimeWordEncoding (R T : ℕ) (P Q : Finset ℕ) := + (n : Fin (T + 1)) × (c : CrudeWordCode R n.val R) × + (c.tupleClasses → P) × ({z : c.usedClasses // z ∉ c.tupleClasses} → Q) + +namespace PrimeWordEncoding + +variable {R T : ℕ} {P Q : Finset ℕ} + +def decode (e : PrimeWordEncoding R T P Q) : List SignedStep := + e.2.1.numericalWord (joinCoordinates e.2.1.tupleClasses + (fun z => (e.2.2.1 z).val) (fun z => (e.2.2.2 z).val)) + +noncomputable def weight (e : PrimeWordEncoding R T P Q) : ℝ := + ∏ z : e.2.1.usedClasses, ((joinCoordinates e.2.1.tupleClasses + (fun z => (e.2.2.1 z).val) (fun z => (e.2.2.2 z).val) z : ℕ) : ℝ)⁻¹ + +lemma weight_nonneg (e : PrimeWordEncoding R T P Q) : 0 ≤ e.weight := by + unfold weight + exact prod_nonneg (fun _ _ => by positivity) + +/-- No loss in the reciprocal weight occurs on encoding an actual word. -/ +theorem covers (w : Fin R → SignedStep) + (hT : Fintype.card (ActualPrimeSlot w) ≤ T) + (ht : ∀ i, Squarefree (w i).tuple) (hq : ∀ i, Squarefree (w i).padding) + (hP : ∀ i, (w i).tuple.primeFactors ⊆ P) + (hQ : ∀ i, (w i).padding.primeFactors ⊆ Q) + (hd : ∀ i j, Disjoint (w i).tuple.primeFactors (w j).padding.primeFactors) : + ∃ e : PrimeWordEncoding R T P Q, e.decode = List.ofFn w ∧ + e.2.1.KindConsistent ∧ e.2.1.RowInjective ∧ + Function.Injective (fun z => (e.2.2.1 z).val) ∧ + e.weight = ∏ p ∈ wordDivisorPrimeSupport (List.ofFn w), (p : ℝ)⁻¹ := by + obtain ⟨a, b, hab⟩ := actual_code_pool_assignments w P Q hP hQ + let c := (actualPrimeSlotData w).code + let e : PrimeWordEncoding R T P Q := + ⟨⟨Fintype.card (ActualPrimeSlot w), by omega⟩, c, a, b⟩ + refine ⟨e, ?_, actualPrimeSlotData_code_kindConsistent w hd, + actualPrimeSlotData_code_rowInjective w, ?_, ?_⟩ + · change c.numericalWord (joinCoordinates c.tupleClasses + (fun z => (a z).val) (fun z => (b z).val)) = _ + rw [hab, CrudeWordCode.numericalWord_encode] + exact actualPrimeSlotData_word w ht hq + · have ha (z : c.tupleClasses) : (a z).val = (actualPrimeSlotData w).prime z.val.val := by + have hz := congrFun hab z.val + simpa only [joinCoordinates_mem] using hz + intro u v huv + apply Subtype.ext + apply (actualPrimeSlotData w).code_value_injective + change (actualPrimeSlotData w).prime u.val.val = (actualPrimeSlotData w).prime v.val.val + exact (ha u).symm.trans (huv.trans (ha v)) + · change (∏ z : c.usedClasses, ((joinCoordinates c.tupleClasses + (fun z => (a z).val) (fun z => (b z).val) z : ℕ) : ℝ)⁻¹) = _ + rw [hab] + exact actual_code_reciprocal_weight w (fun i => (ht i).ne_zero) (fun i => (hq i).ne_zero) + +end PrimeWordEncoding + +/-- A finite decoding cover also covers every nonnegative weighted sum. +The chosen representatives are injective because decoding recovers the word. -/ +theorem finite_decoding_weight_bound {W C : Type*} [DecidableEq W] [Fintype C] + (F : Finset W) (decode : C → W) (weight : W → ℝ) (cost : C → ℝ) + (hcost : ∀ c, 0 ≤ cost c) + (hcover : ∀ w ∈ F, ∃ c, decode c = w ∧ weight w ≤ cost c) : + (∑ w ∈ F, weight w) ≤ ∑ c, cost c := by + let choose (w : F) : C := Classical.choose (hcover w.val w.property) + have hchoose (w : F) : decode (choose w) = w.val ∧ weight w.val ≤ cost (choose w) := + Classical.choose_spec (hcover w.val w.property) + have hinj : Function.Injective choose := by + intro u v h + apply Subtype.ext + exact (hchoose u).1.symm.trans ((congrArg decode h).trans (hchoose v).1) + calc + _ = ∑ w : F, weight w.val := (Finset.sum_coe_sort F weight).symm + _ ≤ ∑ c, cost c := sum_le_sum_of_injOn choose + (fun u _ v _ h => hinj h) (subset_univ _) + (fun w _ => (hchoose w).2) (fun c _ _ => hcost c) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionBlockTesting.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionBlockTesting.lean new file mode 100644 index 0000000000000000000000000000000000000000..a252a6c9468b6cad5e5d09ba5037e8579b67a05e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionBlockTesting.lean @@ -0,0 +1,146 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualAffineTesting +import OAI.NumberTheory.TwoPoint.Walks.RetainedBlockIdentity +import OAI.NumberTheory.TwoPoint.Bounds.ProgressionPartition + +namespace OAI + +/-! Combine the residue classes of block origins. The progression gate is +frozen in each class, and every block retains its ambient endpoint cuts. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def ambientLiouvilleBlockForm {J : ℕ} (P : Fin J → Finset ℕ) + (M : ℕ) (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (keep : ℤ → Prop) (t : ℕ) : ℂ := + let c : ℤ := (t + 2 : ℕ) + let v := paddingTestVector Qp L (fun i : Fin M => (i.val : ℤ) + c) integerLiouville + inner ℂ v (primeBlockCompression P M Q u eligible (actualPaddingVertex Qp) + L K W extra h (fun d n m => gate d (n + c) (m + c)) keep c v) + +lemma ambientLiouvilleBlockForm_eq {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (M : ℕ) (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → ℤ → ℤ → Prop) (hgate : ∀ d n m, gate d n m ↔ gate d m n) + (keep : ℤ → Prop) (t : ℕ) : + ambientLiouvilleBlockForm P M Q Qp u eligible L K W extra h gate keep t = + (2 * (L : ℂ)) * edgeBlockSum univ + (fun e : ((j : Fin J) → P j) × Q => h * e.2.val * ∏ j, (e.1 j).val) + (fun e n => retainedPrimeEdge P Q Qp u eligible L K W extra h gate keep e n + ((n : ℤ) + (h * e.2.val * ∏ j, (e.1 j).val : ℕ))) M t := + primeBlockCompression_retained_blocks P hprime hdisjoint M t Q Qp u eligible + L K W extra h gate hgate keep + +lemma ambientLiouvilleBlockForm_progression {J : ℕ} (P : Fin J → Finset ℕ) + (M : ℕ) (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h l b a k : ℕ) (keep : ℤ → Prop) : + ambientLiouvilleBlockForm P M Q Qp u eligible L K W extra h + (progressionEdgeGate h l b) keep (a + l * k) = + let v := paddingTestVector Qp L + (fun i : Fin M => (i.val : ℤ) + (a + 2 + l * k : ℕ)) integerLiouville + inner ℂ v (primeBlockCompression P M Q u eligible (actualPaddingVertex Qp) L K W + extra h (fun d n m => progressionEdgeGate h l b d + (n + (a + 2 : ℕ)) (m + (a + 2 : ℕ))) keep (a + 2 + l * k : ℕ) v) := by + unfold ambientLiouvilleBlockForm + dsimp only + rw [show a + l * k + 2 = a + 2 + l * k by omega] + have hc : ((a + 2 + l * k : ℕ) : ℤ) = (a + 2 : ℕ) + l * k := by + push_cast + ring + rw [hc, primeBlockCompression_progression_freeze] + +theorem ModFiveThetaInput.eventually_progression_block_testing_uniform + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ + ∀ (h l : ℕ) (_hh : 0 < h) (_hl : 0 < l) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (_hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W), + ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + ∀ b N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let M := ⌈Real.exp (103 * L)⌉₊ + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + uniformAverage (fun t : Fin (l * N) => + ‖ambientLiouvilleBlockForm P M Q Qp actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) L K W (fun _ => actualPaddingDegreeCut Qp L) + h (progressionEdgeGate h l b) keep t.val‖) ≤ + (3 * R) * ((l : ℝ) * (2 * M * paddingTiltNormalizer Qp)) + + ((M : ℝ) * (2 * K * (8 * W) ^ J) * (5 : ℝ) ^ (400 * Real.log L)) * + Real.exp (-(2 * ⌊L⌋₊ : ℕ)) := by + obtain ⟨A, hA, hb⟩ := hprime.eventually_actual_affine_testing_uniform hBr + refine ⟨A, hA, ?_⟩ + intro h l hh hl E hE hEl W hW + have hb := hb h l hh hl E hE hEl W hW + filter_upwards [hb] with L hb + intro hL η hη hηone eligible he + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + let M := ⌈Real.exp (103 * L)⌉₊ + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + intro b N hN + apply uniformAverage_le_of_progressions + (fun t => ‖ambientLiouvilleBlockForm P M Q Qp actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) L K W (fun _ => actualPaddingDegreeCut Qp L) + h (progressionEdgeGate h l b) keep t‖) l N hl _ + intro a + have ht := hb hL η hη hηone eligible he + (fun d n m => progressionEdgeGate h l b d (n + (a.val + 2 : ℕ)) (m + (a.val + 2 : ℕ))) + (fun d n m => progressionEdgeGate_symmetric h l b d _ _) + integerLiouville integerLiouville_norm_le_one (a.val + 2) N hN + simpa only [ambientLiouvilleBlockForm_progression] using ht + +theorem ModFiveThetaInput.eventually_progression_block_testing + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) + (h l : ℕ) (hh : 0 < h) (hl : 0 < l) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Qp := paddingPrimeSupply E L + let Q := boundedPaddingDivisors Qp ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL hW hE + let keep := fun z => ¬ProhibitedSite h ⌊L ^ (1 / 10 : ℝ)⌋₊ + (fun d q => (d, q) ∈ data.pairs) z + ∀ b N : ℕ, Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let M := ⌈Real.exp (103 * L)⌉₊ + let K := Real.exp (4 * J) + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + uniformAverage (fun t : Fin (l * N) => + ‖ambientLiouvilleBlockForm P M Q Qp actualPaddingCoefficient + (fun d q => (d, q) ∈ data.pairs) L K W (fun _ => actualPaddingDegreeCut Qp L) + h (progressionEdgeGate h l b) keep t.val‖) ≤ + (3 * R) * ((l : ℝ) * (2 * M * paddingTiltNormalizer Qp)) + + ((M : ℝ) * (2 * K * (8 * W) ^ J) * (5 : ℝ) ^ (400 * Real.log L)) * + Real.exp (-(2 * ⌊L⌋₊ : ℕ)) := by + obtain ⟨A, hA, hbound⟩ := hprime.eventually_progression_block_testing_uniform hBr + exact ⟨A, hA, hbound h l hh hl E hE hEl W hW⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionCompressionGate.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionCompressionGate.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca8ab22e70957f35a81d42d0cdc5b531c996e0d0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionCompressionGate.lean @@ -0,0 +1,32 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualAffineCompression +import OAI.NumberTheory.TwoPoint.Bounds.ProgressionEdgeGate + +namespace OAI + +/-! Freeze the ambient progression condition within each residue class +before applying the affine-origin compression estimate. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +lemma progressionEdgeGate_function (h l b : ℕ) (a : ℤ) (k : ℕ) : + (fun d n m => progressionEdgeGate h l b d (n + (a + l * k)) (m + (a + l * k))) = + (fun d n m => progressionEdgeGate h l b d (n + a) (m + a)) := by + funext d n m + exact propext (progressionEdgeGate_freeze h l b d n m a k) + +lemma primeBlockCompression_progression_freeze {J : ℕ} (P : Fin J → Finset ℕ) + (M : ℕ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h l b : ℕ) + (keep : ℤ → Prop) (a : ℤ) (k : ℕ) : + primeBlockCompression P M Q u eligible g L K W extra h + (fun d n m => progressionEdgeGate h l b d (n + (a + l * k)) (m + (a + l * k))) + keep (a + l * k) = + primeBlockCompression P M Q u eligible g L K W extra h + (fun d n m => progressionEdgeGate h l b d (n + a) (m + a)) keep (a + l * k) := by + rw [progressionEdgeGate_function] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionDeduction.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionDeduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e9337c3df9e33e2446548e92638d92451d21dad --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionDeduction.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResidueExpansion +import OAI.NumberTheory.TwoPoint.AffineDeduction + +namespace OAI + +/-! +# From binary cancellation to every progression and affine forms + +The character expansion treats all residue classes, while +finite-prime stability preserves nonpretentiousness of an original factor. +-/ + +open Filter +open scoped BigOperators ComplexConjugate + +namespace TwoPointCorrelations + +/-- The progression sum is a fixed finite linear combination of ordinary +binary sums, with no coprimality condition on the residue class. -/ +theorem residuePrefix_eq_component_correlations (f g : ℕ → ℂ) (h l b N : ℕ) + (hl : 0 < l) : + residuePrefix (fun n => f n * g (n + h)) l b N = + ((l / b.gcd l).totient : ℂ)⁻¹ * + ∑ χ : DirichletCharacter ℂ (l / b.gcd l), + ∑ E ∈ (b.gcd l).primeFactors.powerset, + (conj (naturalCharacter χ (b / b.gcd l)) * (-1 : ℂ) ^ E.card) * + correlationSum (residueComponent f (b.gcd l) χ E) g 0 h N := by + have hI : Finset.Ioc 0 N = Finset.Icc 1 N := by + ext n + simp only [Finset.mem_Ioc, Finset.mem_Icc] + omega + unfold residuePrefix + calc + _ = ∑ n ∈ Finset.Ioc 0 N, + ((l / b.gcd l).totient : ℂ)⁻¹ * + ∑ χ : DirichletCharacter ℂ (l / b.gcd l), + ∑ E ∈ (b.gcd l).primeFactors.powerset, + (conj (naturalCharacter χ (b / b.gcd l)) * (-1 : ℂ) ^ E.card) * + (residueComponent f (b.gcd l) χ E n * g (n + h)) := by + apply Finset.sum_congr rfl + intro n hn + have hnpos := (Finset.mem_Ioc.mp hn).1 + rw [show (if n % l = b % l then f n * g (n + h) else 0) = + (if n % l = b % l then f n else 0) * g (n + h) by split_ifs <;> simp] + rw [residue_weight_eq_components f l b n hl hnpos, mul_assoc] + congr 1 + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro χ _ + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro E _ + ring + _ = _ := by + rw [← Finset.mul_sum] + congr 1 + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro χ _ + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro E _ + rw [← Finset.mul_sum] + simp only [correlationSum, hI, Nat.add_zero] + +/-- Every-residue progression cancellation follows from the +binary corrected Elliott statement by finite character expansion. -/ +theorem BinaryCorrectedElliott.progression (hbinary : BinaryCorrectedElliott) : + ProgressionCorrectedElliott := by + intro f g hf hg hfb hgb hnp h l b hh hl + let d := b.gcd l + let q := l / d + let c := b / d + have hd : 0 < d := Nat.gcd_pos_of_pos_right b hl + have hq : 0 < q := Nat.div_pos (Nat.le_of_dvd hl (Nat.gcd_dvd_right b l)) hd + have hpiece (χ : DirichletCharacter ℂ q) (E : Finset ℕ) : + Tendsto (fun N : ℕ => correlationSum (residueComponent f d χ E) g 0 h N / + (N : ℂ)) atTop (nhds 0) := by + apply hbinary _ _ (residueComponent_multiplicative f d χ E hf) hg + (residueComponent_oneBounded f d χ E hfb) hgb _ 0 h hh.ne + exact hnp.imp (residueComponent_nonpretentious f d χ E hq hfb) id + have hsum := tendsto_finsetSum (Finset.univ : Finset (DirichletCharacter ℂ q)) + (fun χ _ => tendsto_finsetSum d.primeFactors.powerset (fun E _ => + (tendsto_const_nhds (x := conj (naturalCharacter χ c) * (-1 : ℂ) ^ E.card)).mul + (hpiece χ E))) + have hlimit := (tendsto_const_nhds (x := (q.totient : ℂ)⁻¹)).mul hsum + have heq (N : ℕ) : + residuePrefix (fun n => f n * g (n + h)) l b N / (N : ℂ) = + (q.totient : ℂ)⁻¹ * + ∑ χ : DirichletCharacter ℂ q, ∑ E ∈ d.primeFactors.powerset, + (conj (naturalCharacter χ c) * (-1 : ℂ) ^ E.card) * + (correlationSum (residueComponent f d χ E) g 0 h N / (N : ℂ)) := by + rw [residuePrefix_eq_component_correlations f g h l b N hl] + simp only [d, q, c, mul_div_assoc, Finset.sum_div] + simp_rw [heq] + simpa using hlimit + +/-- The complete qualitative affine reduction, including nonunit slopes and +either original nonpretentious factor, assuming binary cancellation. -/ +theorem BinaryCorrectedElliott.affine (hbinary : BinaryCorrectedElliott) : + AffineCorrectedElliott := hbinary.progression.affine + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionEdgeGate.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionEdgeGate.lean new file mode 100644 index 0000000000000000000000000000000000000000..18609be2285e7228a1bb3fdb69f01e8c33d9f4f8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionEdgeGate.lean @@ -0,0 +1,39 @@ +import OAI.NumberTheory.TwoPoint.Bounds.IntegerEdges +import Mathlib.Data.Int.ModEq + +namespace OAI + +/-! The progression restriction is symmetric in the two endpoints and +is fixed while the block origin moves through one residue class. -/ + +namespace TwoPointCorrelations + +def progressionEdgeGate (h l b d : ℕ) (n m : ℤ) : Prop := + ∃ q : ℕ, + (m = n + (h * q * d : ℕ) ∧ Int.ModEq (l : ℤ) n (b * q * d : ℕ)) ∨ + (n = m + (h * q * d : ℕ) ∧ Int.ModEq (l : ℤ) m (b * q * d : ℕ)) + +lemma progressionEdgeGate_symmetric (h l b d : ℕ) (n m : ℤ) : + progressionEdgeGate h l b d n m ↔ progressionEdgeGate h l b d m n := by + simp only [progressionEdgeGate, or_comm] + +lemma progressionEdgeGate_add_mul (h l b d : ℕ) (n m k : ℤ) : + progressionEdgeGate h l b d (n + l * k) (m + l * k) ↔ + progressionEdgeGate h l b d n m := by + unfold progressionEdgeGate + apply exists_congr + intro q + have he₁ : m + l * k = n + l * k + (h * q * d : ℕ) ↔ + m = n + (h * q * d : ℕ) := by omega + have he₂ : n + l * k = m + l * k + (h * q * d : ℕ) ↔ + n = m + (h * q * d : ℕ) := by omega + simp only [he₁, he₂, Int.add_modulus_mul_modEq_iff] + +lemma progressionEdgeGate_freeze (h l b d : ℕ) (n m a : ℤ) (k : ℕ) : + progressionEdgeGate h l b d (n + (a + l * k)) (m + (a + l * k)) ↔ + progressionEdgeGate h l b d (n + a) (m + a) := by + simpa only [← add_assoc] using progressionEdgeGate_add_mul h l b d (n + a) (m + a) k + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionFourier.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionFourier.lean new file mode 100644 index 0000000000000000000000000000000000000000..49d9adca8436b4558956d78d08ad98e2df2cb479 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionFourier.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.TwoPoint.PublishedInputs +import Mathlib.Analysis.Fourier.ZMod + +namespace OAI + +/-! +# Additive Fourier resolution of every progression class + +The coefficient mass is exactly one. There is no invertibility assumption +on the class, and no frequency supremum is put inside an integral. +-/ + +namespace TwoPointCorrelations + +open scoped BigOperators + +theorem additiveCharacter_add (α β : ℝ) (n : ℕ) : + additiveCharacter (α + β) n = additiveCharacter α n * additiveCharacter β n := by + unfold additiveCharacter + rw [← Complex.exp_add] + congr 1 + push_cast + ring + +theorem stdAddChar_nat_mul (l : ℕ) [NeZero l] (a : ZMod l) (n : ℕ) : + ZMod.stdAddChar (a * (n : ZMod l)) = additiveCharacter ((a.val : ℝ) / l) n := by + conv_lhs => rw [← ZMod.natCast_zmod_val a, ← Nat.cast_mul] + rw [← Int.cast_natCast, ZMod.stdAddChar_coe] + unfold additiveCharacter + congr 1 + push_cast + ring + +theorem zmod_indicator_fourier (l : ℕ) [NeZero l] (n b : ZMod l) : + (if n = b then (1 : ℂ) else 0) = + (l : ℂ)⁻¹ * ∑ a : ZMod l, ZMod.stdAddChar (a * (n - b)) := by + classical + rw [AddChar.sum_mulShift _ (ZMod.isPrimitive_stdAddChar l), ZMod.card] + have hlc : (l : ℂ) ≠ 0 := by exact_mod_cast NeZero.ne l + by_cases h : n = b + · simp [h, hlc] + · simp [h, sub_ne_zero.mpr h] + +theorem progression_fourier_identity (S : Finset ℕ) (v : ℕ → ℂ) + (l : ℕ) [NeZero l] (b : ZMod l) (α : ℝ) : + (∑ n ∈ S, if (n : ZMod l) = b then v n * additiveCharacter α n else 0) = + (l : ℂ)⁻¹ * ∑ a : ZMod l, ZMod.stdAddChar (-(a * b)) * + ∑ n ∈ S, v n * additiveCharacter (α + (a.val : ℝ) / l) n := by + classical + have hi (n : ℕ) : + (if (n : ZMod l) = b then v n * additiveCharacter α n else 0) = + (l : ℂ)⁻¹ * ∑ a : ZMod l, + ZMod.stdAddChar (-(a * b)) * (v n * additiveCharacter (α + (a.val : ℝ) / l) n) := by + have h := congrArg (fun z : ℂ => z * (v n * additiveCharacter α n)) + (zmod_indicator_fourier l (n : ZMod l) b) + simp only [ite_mul, one_mul, zero_mul] at h + rw [h, mul_assoc] + congr 1 + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro a _ + rw [additiveCharacter_add, ← stdAddChar_nat_mul l a n] + have hm : a * ((n : ZMod l) - b) = -(a * b) + a * n := by ring + rw [hm, AddChar.map_add_eq_mul] + ring + simp_rw [hi] + rw [← Finset.mul_sum, Finset.sum_comm] + congr 1 + apply Finset.sum_congr rfl + intro a _ + rw [Finset.mul_sum] + +/-- The progression mask averages `l` shifted frequencies with total +absolute coefficient mass one. -/ +theorem norm_progression_fourier_le (S : Finset ℕ) (v : ℕ → ℂ) + (l : ℕ) [NeZero l] (b : ZMod l) (α : ℝ) : + ‖∑ n ∈ S, if (n : ZMod l) = b then v n * additiveCharacter α n else 0‖ ≤ + (l : ℝ)⁻¹ * ∑ a : ZMod l, + ‖∑ n ∈ S, v n * additiveCharacter (α + (a.val : ℝ) / l) n‖ := by + rw [progression_fourier_identity, norm_mul, norm_inv, Complex.norm_natCast] + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr (Nat.cast_nonneg l)) + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro a _ + simp only [norm_mul, ZMod.stdAddChar_apply, Circle.norm_coe, one_mul, le_refl] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionGateOnEdge.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionGateOnEdge.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d5094657f4268126483823e7c90a15da14c45d8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionGateOnEdge.lean @@ -0,0 +1,29 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ProgressionEdgeGate + +namespace OAI + +/-! On a genuine increasing edge, the symmetric gate is precisely the +original progression restriction for that edge's padding divisor. -/ + +namespace TwoPointCorrelations + +lemma progressionEdgeGate_on_edge (h l b d q : ℕ) (hh : 0 < h) (hd : 0 < d) + (hq : 0 < q) (n : ℤ) : + progressionEdgeGate h l b d n (n + (h * q * d : ℕ)) ↔ + Int.ModEq (l : ℤ) n (b * q * d : ℕ) := by + constructor + · rintro ⟨q', hf | hr⟩ + · have he : h * q * d = h * q' * d := by + exact_mod_cast add_left_cancel hf.1 + have hq' : q = q' := Nat.eq_of_mul_eq_mul_left hh + (Nat.eq_of_mul_eq_mul_right hd he) + simpa only [← hq'] using hf.2 + · have hpos : (0 : ℤ) < (h * q * d : ℕ) := by positivity + have hnneg : (0 : ℤ) ≤ (h * q' * d : ℕ) := by positivity + omega + · intro he + exact ⟨q, Or.inl ⟨rfl, he⟩⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionMeanIdentity.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionMeanIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..20240f1c56dd2d5c61b0c84cfeeec6c9e59f0bb2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionMeanIdentity.lean @@ -0,0 +1,38 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QuantitativeCenteringAssembly +import OAI.NumberTheory.TwoPoint.Bounds.DivisibilityPrefix + +namespace OAI + +/-! Match the analytic real-cutoff mean with the manuscript's ordinary +progression sum, for every residue class. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma progressionLiouvilleMean_eq (h l b : ℕ) [NeZero l] (X : ℝ) : + progressionLiouvilleMean h l b X = + progressionSum liouville liouville h l b ⌊X⌋₊ / (X : ℂ) := by + unfold progressionLiouvilleMean + rw [positivePrefix_eq_Icc] + congr 1 + simp only [progressionSum, sum_filter] + apply sum_congr rfl + intro n _ + simp only [progressionSequence, ZMod.natCast_eq_natCast_iff'] + split_ifs <;> simp only [zero_mul] + +lemma primeFactors_exclusions (h l : ℕ) (hh : 0 < h) (hl : 0 < l) : + (∀ p, p.Prime → p ∣ h → p ∈ (h * l).primeFactors) ∧ + (∀ p, p.Prime → p ∣ l → p ∈ (h * l).primeFactors) := by + have hn : h * l ≠ 0 := (Nat.mul_pos hh hl).ne' + constructor + · intro p hp hph + exact Nat.mem_primeFactors.mpr ⟨hp, dvd_mul_of_dvd_left hph l, hn⟩ + · intro p hp hpl + exact Nat.mem_primeFactors.mpr ⟨hp, dvd_mul_of_dvd_right hpl h, hn⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionPartition.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..956b97ee0d48189f30a38e95da7fcfc90041a90a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProgressionPartition.lean @@ -0,0 +1,42 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteAverages +import Mathlib.Logic.Equiv.Fin.Basic + +namespace OAI + +/-! Averaging all residue classes combines fixed-progression block estimates. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma uniformAverage_swap {α β : Type*} [Fintype α] [Fintype β] (f : α → β → ℝ) : + uniformAverage (fun x => uniformAverage (f x)) = + uniformAverage (fun y => uniformAverage (fun x => f x y)) := by + rw [← uniformAverage_prod, ← uniformAverage_prod] + exact uniformAverage_equiv (Equiv.prodComm α β) (fun x => f x.2 x.1) + +lemma uniformAverage_progression_partition (f : ℕ → ℝ) (l N : ℕ) : + uniformAverage (fun y : Fin (l * N) => f y.val) = + uniformAverage (fun b : Fin l => uniformAverage (fun x : Fin N => f (b.val + l * x.val))) := by + let e : Fin N × Fin l ≃ Fin (l * N) := finProdFinEquiv.trans (finCongr (Nat.mul_comm N l)) + calc + _ = uniformAverage (fun x : Fin N × Fin l => f (x.2.val + l * x.1.val)) := by + exact (uniformAverage_equiv e (fun y : Fin (l * N) => f y.val)).symm + _ = uniformAverage (fun x : Fin N => uniformAverage (fun b : Fin l => f (b.val + l * x.val))) := + uniformAverage_prod (fun (x : Fin N) (b : Fin l) => f (b.val + l * x.val)) + _ = _ := uniformAverage_swap _ + +lemma uniformAverage_le_of_progressions (f : ℕ → ℝ) (l N : ℕ) (hl : 0 < l) + (C : ℝ) (hf : ∀ b : Fin l, uniformAverage (fun x : Fin N => f (b.val + l * x.val)) ≤ C) : + uniformAverage (fun y : Fin (l * N) => f y.val) ≤ C := by + rw [uniformAverage_progression_partition] + let : Nonempty (Fin l) := ⟨⟨0, hl⟩⟩ + calc + _ ≤ uniformAverage (fun _ : Fin l => C) := by + unfold uniformAverage + exact div_le_div_of_nonneg_right (sum_le_sum (fun b _ => hf b)) (Nat.cast_nonneg _) + _ = _ := uniformAverage_const _ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ProjectedGraphTesting.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProjectedGraphTesting.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a2c972f9349f4e6fa38399ac52fda74c63fb7bf --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProjectedGraphTesting.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.TwoPoint.Bounds.GraphTesting +import OAI.NumberTheory.TwoPoint.Walks.BlockTesting + +namespace OAI + +/-! The deterministic bound for the manuscript's actual test vectors, +with both degree cutoffs and the square-root padding weight. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma paddingTestVector_apply_norm_le {V : Type*} (Q : Finset ℕ) (L : ℝ) + (site : V → ℤ) (f : ℤ → ℂ) (hf : ∀ n, ‖f n‖ ≤ 1) (i : V) : + ‖paddingTestVector Q L site f i‖ ≤ actualPaddingVertex Q (site i) := by + by_cases hi : actualPaddingDegreeCut Q L (site i) + · simp only [paddingTestVector, WithLp.ofLp_toLp, ite_eq_left hi, norm_mul, + Complex.norm_real, Real.norm_eq_abs, abs_of_pos (actualPaddingVertex_pos Q _)] + simpa only [mul_one] using mul_le_mul_of_nonneg_left (hf (site i)) + (actualPaddingVertex_pos Q _).le + · simpa [paddingTestVector, hi] using (actualPaddingVertex_pos Q (site i)).le + +lemma projected_paddingTestVector_support {V : Type*} [Fintype V] [DecidableEq V] + (Q : Finset ℕ) (L : ℝ) (site : V → ℤ) (f : ℤ → ℂ) (keep : V → Prop) + (i : V) (hi : coordinateProjection keep (paddingTestVector Q L site f) i ≠ 0) : + keep i ∧ actualPaddingDegreeCut Q L (site i) := by + constructor + · by_contra hk + apply hi + simp only [coordinateProjection_apply, ite_eq_right hk] + · by_contra hq + apply hi + simp [coordinateProjection_apply, paddingTestVector, hq] + +lemma paddingVertex_cut_bound (Q : Finset ℕ) (L : ℝ) (n : ℤ) + (hn : actualPaddingDegreeCut Q L n) : + actualPaddingVertex Q n ^ 2 ≤ (5 : ℝ) ^ (400 * Real.log L) := by + rw [actualPaddingVertex_sq, actualPaddingWeight, ← Real.rpow_natCast] + exact Real.rpow_le_rpow_of_exponent_le (by norm_num) hn + +theorem projected_padding_graph_test {J : ℕ} {V : Type*} [Fintype V] [DecidableEq V] + (P : Fin J → Finset ℕ) (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (site : V → ℤ) (hinj : Function.Injective site) + (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) (gate : ℕ → V → V → Prop) + (hL : 0 < L) (hK : 0 ≤ K) (hW : 0 ≤ W) (hu : ∀ q ∈ Q, 0 ≤ u q) + (hV : ∀ j, primeHarmonicMass (P j) ≤ 2 * W) + (f : ℤ → ℂ) (hf : ∀ n, ‖f n‖ ≤ 1) : + let B := primeFamilyGraphOperator (fun j (p : P j) => p.val) (fun _ _ => 0) + site Q u eligible (actualPaddingVertex Qp) L K extra h gate + let proj := coordinateProjection (fun i : V => + (actualPaddingDegree (univ.biUnion P) (site i) : ℝ) ≤ 6 * W * J) + let v := paddingTestVector Qp L site f + ‖inner ℂ v ((proj * (∑ d, B d) * proj) v)‖ ≤ + Fintype.card V * (2 * K * (8 * W) ^ J) * (5 : ℝ) ^ (400 * Real.log L) := by + dsimp only + let keep := fun i : V => (actualPaddingDegree (univ.biUnion P) (site i) : ℝ) ≤ 6 * W * J + let proj := coordinateProjection keep + let v := paddingTestVector Qp L site f + have hcoord (i : V) : ‖proj v i‖ ≤ actualPaddingVertex Qp (site i) := by + dsimp only [proj] + rw [coordinateProjection_apply] + split_ifs + · exact paddingTestVector_apply_norm_le Qp L site f hf i + · simpa only [norm_zero] using (actualPaddingVertex_pos Qp (site i)).le + have hsupp (i : V) (hi : proj v i ≠ 0) : + keep i ∧ actualPaddingDegreeCut Qp L (site i) := + projected_paddingTestVector_support Qp L site f keep i hi + have hb := prime_graph_test_deterministic P hprime hdisjoint site hinj Q u eligible + (actualPaddingVertex Qp) L K W extra h gate hL hK hW hu + (actualPaddingVertex_pos Qp) hV (proj v) hcoord (fun i hi => (hsupp i hi).1) + ((5 : ℝ) ^ (400 * Real.log L)) (Real.rpow_nonneg (by norm_num) _) + (fun i hi => paddingVertex_cut_bound Qp L (site i) (hsupp i hi).2) + have he := (coordinateProjection_selfAdjoint keep).isSymmetric v + ((∑ d, primeFamilyGraphOperator (fun j (p : P j) => p.val) (fun _ _ => 0) + site Q u eligible (actualPaddingVertex Qp) L K extra h gate d) (proj v)) + change inner ℂ (proj v) _ = inner ℂ v (proj _) at he + exact (le_of_eq (congrArg norm he.symm)).trans hb + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ProjectedLiouvilleVector.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProjectedLiouvilleVector.lean new file mode 100644 index 0000000000000000000000000000000000000000..6fda282d8b3a8d522ff7cb2a2f8cc7fae6dac68e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProjectedLiouvilleVector.lean @@ -0,0 +1,33 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ProjectedGraphTesting +import OAI.NumberTheory.TwoPoint.Walks.RetainedLiouvilleEdges + +namespace OAI + +/-! The actual degree-projected Liouville test is an ambient masked scalar. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +lemma projectedLiouvilleVector_eq {V : Type*} [Fintype V] [DecidableEq V] + (Q : Finset ℕ) (L : ℝ) (site : V → ℤ) (keep : ℤ → Prop) : + coordinateProjection (fun i => keep (site i)) + (paddingTestVector Q L site integerLiouville) = + WithLp.toLp 2 (fun i => retainedLiouvilleScalar (actualPaddingVertex Q) + (fun n => keep n ∧ actualPaddingDegreeCut Q L n) (site i)) := by + ext i + by_cases hp : keep (site i) <;> by_cases hq : actualPaddingDegreeCut Q L (site i) <;> + simp [coordinateProjection_apply, paddingTestVector, retainedLiouvilleScalar, hp, hq] + +lemma projectedLiouvilleVector_star {V : Type*} [Fintype V] [DecidableEq V] + (Q : Finset ℕ) (L : ℝ) (site : V → ℤ) (keep : ℤ → Prop) (i : V) : + star (coordinateProjection (fun i => keep (site i)) + (paddingTestVector Q L site integerLiouville) i) = + coordinateProjection (fun i => keep (site i)) + (paddingTestVector Q L site integerLiouville) i := by + rw [projectedLiouvilleVector_eq] + exact retainedLiouvilleScalar_star _ _ _ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ProjectedPrimeLiouville.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProjectedPrimeLiouville.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee46ca07eede73889661e23c9b85a2bf0f1d358e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ProjectedPrimeLiouville.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeLiouvilleQuadratic +import OAI.NumberTheory.TwoPoint.Bounds.ProjectedLiouvilleVector + +namespace OAI + +/-! The exact retained-edge identity for the projected vector used by +actual block testing, including both degree cutoffs. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem projected_prime_liouville_quadratic {J : ℕ} {V : Type*} + [Fintype V] [DecidableEq V] + (P : Fin J → Finset ℕ) (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (site : V → ℤ) (Q Qp : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (L K W : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) + (gate : ℕ → V → V → Prop) (hgate : ∀ d i j, gate d i j ↔ gate d j i) : + let B := primeFamilyGraphOperator (fun j (p : P j) => p.val) (fun _ _ => 0) + site Q u eligible (actualPaddingVertex Qp) L K extra h gate + let keep := fun n => (actualPaddingDegree (univ.biUnion P) n : ℝ) ≤ 6 * W * J + let proj := coordinateProjection (fun i => keep (site i)) + let v := paddingTestVector Qp L site integerLiouville + inner ℂ v ((proj * (∑ d, B d) * proj) v) = + (2 * (L : ℂ)) * ∑ d : (j : Fin J) → P j, ∑ i, ∑ j, + if gate (∏ k, (d k).val) i j then ∑ q ∈ Q, + retainedLiouvilleEdge Q u (eligible (∏ k, (d k).val)) (actualPaddingVertex Qp) + (centeredTuple (∏ k, (d k).val).primeFactors) L K (extra (∏ k, (d k).val)) + (fun n => keep n ∧ actualPaddingDegreeCut Qp L n) + h (∏ k, (d k).val) q (site i) (site j) + else 0 := by + dsimp only + let keep := fun n => (actualPaddingDegree (univ.biUnion P) n : ℝ) ≤ 6 * W * J + let proj := coordinateProjection (fun i => keep (site i)) + let v := paddingTestVector Qp L site integerLiouville + let B := primeFamilyGraphOperator (fun j (p : P j) => p.val) (fun _ _ => 0) + site Q u eligible (actualPaddingVertex Qp) L K extra h gate + have hq := prime_graph_liouville_quadratic P hprime hdisjoint site Q u eligible + (actualPaddingVertex Qp) L K extra (fun n => keep n ∧ actualPaddingDegreeCut Qp L n) + h gate hgate (actualPaddingVertex_ne_zero Qp) + dsimp only at hq + rw [← projectedLiouvilleVector_eq Qp L site keep] at hq + have he := (coordinateProjection_selfAdjoint (fun i => keep (site i))).isSymmetric + v ((∑ d, B d) (proj v)) + exact he.symm.trans hq + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeCanonicalCentering.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeCanonicalCentering.lean new file mode 100644 index 0000000000000000000000000000000000000000..3dbabd7bd137c858685a6a9133efc22718d56f55 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeCanonicalCentering.lean @@ -0,0 +1,156 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativePartialCentering +import OAI.NumberTheory.TwoPoint.Walks.CanonicalTupleSmooth +import OAI.NumberTheory.TwoPoint.Bounds.ComplexCenteredBridge +import OAI.NumberTheory.TwoPoint.Bounds.PaddingSmoothBound + +namespace OAI + +/-! The actual canonical nonraw complex bins: the cost of every padding +dilation is summed against its exact reciprocal law. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma nonrawComplexBin_real_denominator {J : ℕ} (P : Fin J → Finset ℕ) + (R : Finset ℕ) (eligible : ℕ → ℕ → Prop) (F G : ℕ → ℂ) (h : ℕ) + (T : ℝ) (hT : 1 ≤ T) : + ‖nonrawComplexBin P R eligible F G h T‖ ≤ + ‖∑ q ∈ R, (actualPaddingCoefficient q : ℂ) * + ((positivePrefix (tupleComplexCenteredProfile P q eligible F G h) ⌊T⌋₊ - + positivePrefix (tupleComplexPartialProfile P ∅ q eligible F G h) ⌊T⌋₊) / + (⌊T⌋₊ : ℂ))‖ := by + let A : ℕ → ℂ := fun q => (actualPaddingCoefficient q : ℂ) * + (positivePrefix (tupleComplexCenteredProfile P q eligible F G h) ⌊T⌋₊ - + positivePrefix (tupleComplexPartialProfile P ∅ q eligible F G h) ⌊T⌋₊) + have he (c : ℂ) : (∑ q ∈ R, (actualPaddingCoefficient q : ℂ) * + ((positivePrefix (tupleComplexCenteredProfile P q eligible F G h) ⌊T⌋₊ - + positivePrefix (tupleComplexPartialProfile P ∅ q eligible F G h) ⌊T⌋₊) / c)) = + (∑ q ∈ R, A q) / c := by simp only [A, mul_div_assoc, sum_div] + have hN : (0 : ℝ) < ⌊T⌋₊ := by exact_mod_cast Nat.floor_pos.mpr hT + rw [nonrawComplexBin, he, he, norm_div, norm_div, Complex.norm_real, + Real.norm_eq_abs, abs_of_nonneg (by linarith : 0 ≤ T), Complex.norm_natCast] + exact div_le_div_of_nonneg_left (norm_nonneg _) hN (Nat.floor_le (by linarith)) + +theorem qualitative_canonical_nonraw_bin (hP : ModFiveThetaInput) + (hM : PrimeReciprocalInput) (hMRT : MRTShortExponentialInput) + {F G : ℕ → ℂ} (hFm : Multiplicative F) (hGm : Multiplicative G) + (hF : OneBounded F) (hG : OneBounded G) + (hnp : UniformlyNonpretentious F ∨ UniformlyNonpretentious G) + (h : ℕ) (hh : 0 < h) (E : Finset ℕ) (W : ℝ) (hW : 1 ≤ W) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + ∀ R : Finset ℕ, R ⊆ retainedPrimeDivisors Q → + ∀ η : ℝ, 0 < η → Real.exp (2 * η) < 2 → + ∀ᶠ T : ℝ in atTop, ∀ j ∈ paddingBinIndices L η, + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → actualPaddingBin η (Real.log d) j q) → + ‖nonrawComplexBin P R eligible F G h T‖ ≤ + C * canonicalRoughParameter L ^ (-11 / 10 : ℝ) * (2 : ℝ) ^ J * + paddingTiltNormalizer Q * ∏ i, primeHarmonicMass (P i) := by + obtain ⟨C, hC, hrough⟩ := qualitative_complex_partial_bin hM hMRT hFm hGm hF hG hnp + h hh 100 (by norm_num) + refine ⟨2 * C * paddingSmoothConstant, + mul_pos (mul_pos (by norm_num) hC) paddingSmoothConstant_pos, ?_⟩ + filter_upwards [canonicalRoughParameter_tendsto.eventually hrough, + eventually_canonical_retained_smooth_cost E W hW, + hP.eventually_actual_pool_masses E W hW, eventually_ge_atTop (1 : ℝ)] with + L hrough hcost hmass hL + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + let B := canonicalRoughParameter L + let Is := (univ : Finset (Fin J)).powerset.filter Finset.Nonempty + have hLp : 0 < L := zero_lt_one.trans_le hL + have hB : 0 < B := Real.rpow_pos_of_pos hLp _ + have hp : ∀ i, ∀ p ∈ P i, p.Prime := centeredPrimeBands_prime _ _ _ _ + have hd : ∀ i j, j ≠ i → Disjoint (P i) (P j) := centeredPrimeBands_disjoint _ _ _ _ + (Real.rpow_nonneg hLp.le _) (zero_le_one.trans hW) + have hlarge : ∀ i, ∀ p ∈ P i, Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ (p : ℝ) := by + intro i p hip + rw [canonicalRoughParameter_prime_endpoint L hLp.le] + exact (centeredPrimeSupply_global_bounds (Real.rpow_nonneg hLp.le _) (zero_le_one.trans hW) + i.isLt (primeSupplyScale_endpoint W L (by linarith) hL) hip).1.le + have hQ : ∀ p ∈ Q, p.Prime := fun _ hp => paddingPrimeSupply_prime hp + intro R hR + have hRpos : ∀ q ∈ R, 0 < q := fun q hq => retainedPrimeDivisor_pos Q hQ (hR hq) + have hcop : ∀ q ∈ R, ∀ i, ∀ p ∈ P i, q.Coprime p := by + intro q hq i p hip + exact paddingPrimeDivisor_coprime_centered E _ W L J (hR hq) i hip + have hm : ∀ i, 1 ≤ primeHarmonicMass (P i) := fun i => (hmass.2.1 i).1 + intro η hη hηtwo + let bins := paddingBinIndices L η + let e : ℕ → ℝ := fun q => 2 * C * B ^ (-11 / 10 : ℝ) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) + have he : ∀ q ∈ R, 0 ≤ e q := by + intro q _ + exact mul_nonneg (by positivity) (smoothReciprocalProduct_nonneg _ + (fun _ hp => Nat.prime_of_mem_primeFactors hp) _ (by norm_num)) + have hall : ∀ᶠ N : ℕ in atTop, ∀ j ∈ bins, ∀ q ∈ R, ∀ I ∈ Is, + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → actualPaddingBin η (Real.log d) j q) → + ‖positivePrefix (tupleComplexPartialProfile P I q eligible F G h) N / (N : ℂ)‖ ≤ + e q * ((1 / (q : ℝ)) * ∏ i : {i // i ∉ I}, primeHarmonicMass (P i)) := by + apply (eventually_all_finset bins).mpr + intro j hj + apply (eventually_all_finset R).mpr + intro q hq + apply (eventually_all_finset Is).mpr + intro I hI + have hjbound := (mem_paddingBinIndices_iff L η j hη).mp hj + have hupper : Real.exp ((j : ℝ) * η) ≤ Real.exp (100 * B ^ (2 : ℕ)) := by + apply Real.exp_le_exp.mpr + exact hjbound.2.trans (mul_le_mul_of_nonneg_left (canonicalRoughParameter_square_ge L hL) + (by norm_num)) + exact hrough J P hp hd hlarge I (mem_filter.mp hI).2 q (hRpos q hq) + (hcost I) η hη hηtwo j hupper + have hsum : (∑ q ∈ R, actualPaddingCoefficient q / (q : ℝ) * e q) ≤ + (2 * C * B ^ (-11 / 10 : ℝ)) * + (paddingTiltNormalizer Q * paddingSmoothConstant) := by + calc + _ = (2 * C * B ^ (-11 / 10 : ℝ)) * + ∑ q ∈ R, (4 : ℝ) ^ q.primeFactors.card / (q : ℝ) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + rw [mul_sum] + apply sum_congr rfl + intro q _ + dsimp only [e, actualPaddingCoefficient] + ring + _ ≤ _ := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply le_trans _ (padding_smooth_half_sum_le Q hQ) + exact sum_le_sum_of_subset_of_nonneg hR (fun q _ _ => mul_nonneg (by positivity) + (smoothReciprocalProduct_nonneg _ (fun _ hp => Nat.prime_of_mem_primeFactors hp) + _ (by norm_num))) + have hnat : ∀ᶠ N : ℕ in atTop, ∀ j ∈ bins, ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → actualPaddingBin η (Real.log d) j q) → + ‖∑ q ∈ R, (actualPaddingCoefficient q : ℂ) * + ((positivePrefix (tupleComplexCenteredProfile P q eligible F G h) N - + positivePrefix (tupleComplexPartialProfile P ∅ q eligible F G h) N) / (N : ℂ))‖ ≤ + (2 * C * paddingSmoothConstant) * B ^ (-11 / 10 : ℝ) * (2 : ℝ) ^ J * + paddingTiltNormalizer Q * ∏ i, primeHarmonicMass (P i) := by + filter_upwards [hall] with N hN + intro j hj eligible hel + have hb := complex_partial_centering_sum_bound P hp hd hm R actualPaddingCoefficient + (fun q _ => by unfold actualPaddingCoefficient; positivity) hcop eligible F G h N e he + (fun q hq I hI => hN j hj q hq I hI eligible hel) + apply hb.trans + calc + _ ≤ (2 : ℝ) ^ J * ((2 * C * B ^ (-11 / 10 : ℝ)) * + (paddingTiltNormalizer Q * paddingSmoothConstant)) * ∏ i, primeHarmonicMass (P i) := by + exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hsum (by positivity)) + (prod_nonneg (fun i _ => zero_le_one.trans (hm i))) + _ = _ := by ring + filter_upwards [(tendsto_nat_floor_atTop (α := ℝ)).eventually hnat, + eventually_ge_atTop (1 : ℝ)] with T hT hTone + intro j hj eligible hel + exact (nonrawComplexBin_real_denominator P R eligible F G h T hTone).trans + (hT j hj eligible hel) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeCenteringRate.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeCenteringRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d286c026e04a38a4a4170ce6c02ab4344f7791f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeCenteringRate.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.TwoPoint.Walks.CanonicalRoughScale +import OAI.NumberTheory.TwoPoint.Bounds.PaddingBinCount +import OAI.NumberTheory.TwoPoint.Bounds.ComplexFinalScale + +namespace OAI + +/-! The small loss from summing every logarithmic bin still leaves a +negative power in the canonical qualitative centering estimate. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma primeSupplyCount_small_log (W L : ℝ) (hW : 1 ≤ W) (hL : 1 ≤ L) : + (primeSupplyCount W L : ℝ) ≤ Real.log L / 200 := by + have hb := primeSupplyCount_mul_bound W L (by linarith) hL + have hJ : 0 ≤ (primeSupplyCount W L : ℝ) := Nat.cast_nonneg _ + have hm := mul_nonneg hJ (show 0 ≤ 6 * W - 1 by linarith) + nlinarith + +lemma exp_double_neg_nat_lt_two (J : ℕ) (hJ : 2 ≤ J) : + Real.exp (2 * Real.exp (-(J : ℝ))) < 2 := by + have hj : Real.exp (-(J : ℝ)) ≤ Real.exp (-2) := + Real.exp_le_exp.mpr (by exact_mod_cast (show -(J : ℤ) ≤ -2 by omega)) + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have harg : 2 * Real.exp (-(J : ℝ)) ≤ Real.exp (-1) := by + calc + _ ≤ 2 * Real.exp (-2) := mul_le_mul_of_nonneg_left hj (by norm_num) + _ ≤ Real.exp 1 * Real.exp (-2) := mul_le_mul_of_nonneg_right htwo (Real.exp_pos _).le + _ = Real.exp (-1) := by rw [← Real.exp_add]; norm_num + have hend : Real.exp (Real.exp (-1)) < 2 := by + simpa only [Nat.cast_one] using exp_neg_nat_exp_lt_two 1 (by decide) + exact (Real.exp_le_exp.mpr harg).trans_lt hend + +lemma eventually_primeSupplyCount_two (W : ℝ) (hW : 0 < W) : + ∀ᶠ L : ℝ in atTop, 2 ≤ primeSupplyCount W L := by + filter_upwards [eventually_ge_atTop (Real.exp (2400 * W))] with L hL + have hLp : 0 < L := (Real.exp_pos _).trans_le hL + have hl : 2400 * W ≤ Real.log L := by + simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos _) hL + have hl0 : 0 ≤ Real.log L := le_trans (by positivity : 0 ≤ 2400 * W) hl + unfold primeSupplyCount + apply (Nat.le_floor_iff (by positivity : 0 ≤ ((1 / 200 : ℝ) * Real.log L) / (6 * W))).mpr + norm_num + apply (le_div_iff₀ (by positivity : 0 < 6 * W)).mpr + linarith + +lemma canonical_centering_bin_count_rate (L : ℝ) (J : ℕ) (hL : 1 ≤ L) + (hJ : (J : ℝ) ≤ Real.log L / 200) : + ((paddingBinIndices L (Real.exp (-(J : ℝ)))).card : ℝ) * + (2 : ℝ) ^ J * canonicalRoughParameter L ^ (-11 / 10 : ℝ) ≤ + 101 * L ^ (-3 / 40 : ℝ) := by + have hLp : 0 < L := zero_lt_one.trans_le hL + have hβ : 0 ≤ canonicalRoughParameter L ^ (-11 / 10 : ℝ) := + Real.rpow_nonneg (Real.rpow_nonneg hLp.le _) _ + have hη : Real.exp (-(J : ℝ)) ≤ 1 := + Real.exp_le_one_iff.mpr (neg_nonpos.mpr (Nat.cast_nonneg _)) + have hc := paddingBinIndices_card_linear L (Real.exp (-(J : ℝ))) hL (Real.exp_pos _) hη + have he : Real.exp (J : ℝ) ≤ L ^ (1 / 200 : ℝ) := by + rw [Real.rpow_def_of_pos hLp] + exact Real.exp_le_exp.mpr (by nlinarith) + have hrate := canonical_centering_rate_bound L hL J hJ + calc + _ ≤ (101 * L * Real.exp (J : ℝ)) * (2 : ℝ) ^ J * + canonicalRoughParameter L ^ (-11 / 10 : ℝ) := by + have hc' : ((paddingBinIndices L (Real.exp (-(J : ℝ)))).card : ℝ) ≤ + 101 * L * Real.exp (J : ℝ) := by + simpa only [Real.exp_neg, div_eq_mul_inv, inv_inv] using hc + exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hc' (by positivity)) + hβ + _ = 101 * Real.exp (J : ℝ) * + ((2 : ℝ) ^ J * L * canonicalRoughParameter L ^ (-11 / 10 : ℝ)) := by ring + _ ≤ 101 * L ^ (1 / 200 : ℝ) * L ^ (-2 / 25 : ℝ) := by + exact mul_le_mul (mul_le_mul_of_nonneg_left he (by norm_num)) hrate + (mul_nonneg (mul_nonneg (by positivity) hLp.le) hβ) (by positivity) + _ = 101 * L ^ (-3 / 40 : ℝ) := by + rw [mul_assoc, ← Real.rpow_add hLp] + norm_num + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeCenteringTotal.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeCenteringTotal.lean new file mode 100644 index 0000000000000000000000000000000000000000..14266c32a61c1cdac43cc30666fff79ea29b5be5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeCenteringTotal.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeCanonicalCentering +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeCenteringRate + +namespace OAI + +/-! Sum every actual logarithmic bin, retaining arbitrary unit-disk phase +weights and the exact padding and tuple normalizers. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem qualitative_canonical_nonraw_total (hP : ModFiveThetaInput) + (hM : PrimeReciprocalInput) (hMRT : MRTShortExponentialInput) + {F G : ℕ → ℂ} (hFm : Multiplicative F) (hGm : Multiplicative G) + (hF : OneBounded F) (hG : OneBounded G) + (hnp : UniformlyNonpretentious F ∨ UniformlyNonpretentious G) + (h : ℕ) (hh : 0 < h) (E : Finset ℕ) (W : ℝ) (hW : 1 ≤ W) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + ∀ R : Finset ℕ, R ⊆ retainedPrimeDivisors Q → + let η := Real.exp (-(J : ℝ)) + let bins := paddingBinIndices L η + ∀ᶠ X : ℝ in atTop, ∀ (eligible : ℤ → ℕ → ℕ → Prop) (v : ℤ → ℂ), + (∀ j ∈ bins, ∀ d q, eligible j d q → actualPaddingBin η (Real.log d) j q) → + (∀ j ∈ bins, ‖v j‖ ≤ 1) → + ‖∑ j ∈ bins, v j * nonrawComplexBin P R (eligible j) F G h + (X * Real.exp ((j : ℝ) * η))‖ ≤ + C * L ^ (-3 / 40 : ℝ) * paddingTiltNormalizer Q * ∏ i, primeHarmonicMass (P i) := by + obtain ⟨C, hC, hb⟩ := qualitative_canonical_nonraw_bin hP hM hMRT hFm hGm hF hG hnp + h hh E W hW + refine ⟨101 * C, by positivity, ?_⟩ + filter_upwards [hb, eventually_primeSupplyCount_two W (by linarith), + eventually_ge_atTop (1 : ℝ)] with L hb hJ hL + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + intro R hR + let η := Real.exp (-(J : ℝ)) + let bins := paddingBinIndices L η + let V := paddingTiltNormalizer Q * ∏ i, primeHarmonicMass (P i) + have hη : 0 < η := Real.exp_pos _ + have hV : 0 ≤ V := mul_nonneg (paddingTiltNormalizer_pos Q).le + (prod_nonneg (fun i _ => by unfold primeHarmonicMass; positivity)) + obtain ⟨T₀, hT₀⟩ := eventually_atTop.mp (hb R hR η hη (exp_double_neg_nat_lt_two J hJ)) + filter_upwards [eventually_ge_atTop (max T₀ 1)] with X hX + intro eligible v hel hv + have hXp : 0 ≤ X := by linarith [le_max_right T₀ (1 : ℝ)] + have hterm (j : ℤ) (hj : j ∈ bins) : + ‖v j * nonrawComplexBin P R (eligible j) F G h + (X * Real.exp ((j : ℝ) * η))‖ ≤ + C * canonicalRoughParameter L ^ (-11 / 10 : ℝ) * (2 : ℝ) ^ J * V := by + have hgeom := (mem_paddingBinIndices_iff L η j hη).mp hj + have ht : X ≤ X * Real.exp ((j : ℝ) * η) := by + have hj0 : (0 : ℝ) ≤ j := by exact_mod_cast hgeom.1 + exact le_mul_of_one_le_right hXp (Real.one_le_exp (mul_nonneg hj0 hη.le)) + have hb' := hT₀ (X * Real.exp ((j : ℝ) * η)) + ((le_max_left T₀ (1 : ℝ)).trans (hX.trans ht)) j hj (eligible j) (hel j hj) + rw [norm_mul] + calc + _ ≤ 1 * ‖nonrawComplexBin P R (eligible j) F G h + (X * Real.exp ((j : ℝ) * η))‖ := + mul_le_mul_of_nonneg_right (hv j hj) (norm_nonneg _) + _ ≤ _ := by simpa only [one_mul, V, mul_assoc] using hb' + have hcount := canonical_centering_bin_count_rate L J hL (primeSupplyCount_small_log W L hW hL) + calc + _ ≤ ∑ j ∈ bins, ‖v j * nonrawComplexBin P R (eligible j) F G h + (X * Real.exp ((j : ℝ) * η))‖ := norm_sum_le _ _ + _ ≤ ∑ _j ∈ bins, C * canonicalRoughParameter L ^ (-11 / 10 : ℝ) * (2 : ℝ) ^ J * V := + sum_le_sum hterm + _ = C * (((bins.card : ℝ) * (2 : ℝ) ^ J * + canonicalRoughParameter L ^ (-11 / 10 : ℝ))) * V := by + rw [sum_const, nsmul_eq_mul] + ring + _ ≤ C * (101 * L ^ (-3 / 40 : ℝ)) * V := + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hcount hC.le) hV + _ = _ := by dsimp only [V]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeDivisorTransfer.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeDivisorTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..0373ff6e4bd74f69d632830be2d95415dc1b1ed0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeDivisorTransfer.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeRoughBins +import OAI.NumberTheory.TwoPoint.Bounds.RescaledPrefixSums + +namespace OAI + +/-! Finite assembly of the actual `u*w` expansion at `Y = floor(X/u)`. +The reciprocal weight of each retained divisor is preserved exactly, and +the long-average threshold is uniform over all admissible Fourier twists. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +structure RoughBinData where + left : ℕ → ℂ + right : ℕ → ℂ + support : Finset ℕ + coefficient : ℕ → ℂ + +def RoughBinData.Admissible (d : RoughBinData) (f : ℕ → ℂ) (P : Finset ℕ) + (M τ P₀ : ℝ) : Prop := + Multiplicative d.left ∧ OneBounded d.left ∧ OneBounded d.right ∧ + (∀ p, Nat.Prime p → p ∉ P → d.left p = f p) ∧ + (∀ z ∈ d.support, M < (z : ℝ) ∧ (z : ℝ) ≤ τ * M ∧ HasNoPrimeFactorBelow P₀ z) ∧ + (∀ z ∈ d.support, ‖d.coefficient z‖ ≤ 1) + +/-- Uniform rough-shift cancellation summed over the finite retained- +divisor family, with total weight `sum |a_u|/u`. Functions and coefficients +may be chosen after the common long-average threshold. -/ +theorem qualitative_divisor_transfer (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (U : Finset ℕ) (a : ℕ → ℂ) (H τ : ℝ) (P : ℕ → Finset ℕ) + (l : ℕ) [NeZero l] (residue : ℕ → ZMod l), + 1 < τ → τ < 2 → (∀ u ∈ U, 0 < u) → + (∀ u ∈ U, Real.exp (B ^ (9999 / 10000 : ℝ)) / τ ≤ H / (u : ℝ)) → + (∀ u ∈ U, H / (u : ℝ) ≤ Real.exp (C₀ * B)) → + ∀ᶠ X : ℕ in atTop, ∀ d : ℕ → RoughBinData, + (∀ u ∈ U, (d u).Admissible f (P u) (H / (u : ℝ)) τ + (Real.exp (B ^ (9999 / 10000 : ℝ)))) → + ‖(∑ u ∈ U, a u * positivePrefix + (weightedRoughShiftProfile (progressionSequence (d u).left l (residue u)) + (d u).right (d u).support (d u).coefficient h) (X / u)) / (X : ℂ)‖ ≤ + C * B ^ (-10001 / 10000 : ℝ) * (∑ u ∈ U, ‖a u‖ / (u : ℝ)) := by + obtain ⟨C, hC, hrough⟩ := qualitative_rough_shifts_real_bins hM hMRT hfnp hf h hh C₀ hC₀ + refine ⟨C, hC, ?_⟩ + filter_upwards [hrough, eventually_ge_atTop 1] with B hb hB + intro U a H τ P l _ residue hτ₁ hτ₂ hU hMlower hMupper + have hBpos : 0 < B := zero_lt_one.trans_le hB + let F : ℕ → RoughBinData → ℕ → ℂ := fun u d => + weightedRoughShiftProfile (progressionSequence d.left l (residue u)) + d.right d.support d.coefficient h + let Valid : ℕ → RoughBinData → Prop := fun u d => + d.Admissible f (P u) (H / (u : ℝ)) τ (Real.exp (B ^ (9999 / 10000 : ℝ))) + have hF : ∀ u ∈ U, ∀ᶠ Y : ℕ in atTop, + ∀ d : RoughBinData, Valid u d → ‖positivePrefix (F u d) Y / (Y : ℂ)‖ ≤ + C * B ^ (-10001 / 10000 : ℝ) := by + intro u hu + filter_upwards [hb (P u) (H / (u : ℝ)) τ hτ₁ hτ₂ (hMlower u hu) (hMupper u hu)] + with Y hy + intro d hd + exact hy d.left d.right hd.1 hd.2.1 hd.2.2.1 hd.2.2.2.1 + l (residue u) d.support d.coefficient hd.2.2.2.2.1 hd.2.2.2.2.2 + exact finite_rescaled_prefix_bound U a F Valid + (C * B ^ (-10001 / 10000 : ℝ)) (by positivity) hU hF + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeDivisorTransferRight.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeDivisorTransferRight.lean new file mode 100644 index 0000000000000000000000000000000000000000..f6a600aa5076e22519c52a276637ec051b63d1c1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeDivisorTransferRight.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeDivisorTransfer +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeRightBins + +namespace OAI + +/-! The finite retained-divisor assembly for a nonpretentious second +factor, with the same uniformity in all admissible Fourier twists. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +def RoughBinData.AdmissibleRight (d : RoughBinData) (f : ℕ → ℂ) (P : Finset ℕ) + (M τ P₀ : ℝ) : Prop := + OneBounded d.left ∧ Multiplicative d.right ∧ OneBounded d.right ∧ + (∀ p, Nat.Prime p → p ∉ P → d.right p = f p) ∧ + (∀ z ∈ d.support, M < (z : ℝ) ∧ (z : ℝ) ≤ τ * M ∧ HasNoPrimeFactorBelow P₀ z) ∧ + (∀ z ∈ d.support, ‖d.coefficient z‖ ≤ 1) + +/-- Uniform rough-shift cancellation summed over the finite retained- +divisor family, with total weight `sum |a_u|/u`. Functions and coefficients +may be chosen after the common long-average threshold. -/ +theorem qualitative_divisor_transfer_right (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (U : Finset ℕ) (a : ℕ → ℂ) (H τ : ℝ) (P : ℕ → Finset ℕ) + (l : ℕ) [NeZero l] (residue : ℕ → ZMod l), + 1 < τ → τ < 2 → (∀ u ∈ U, 0 < u) → + (∀ u ∈ U, Real.exp (B ^ (9999 / 10000 : ℝ)) / τ ≤ H / (u : ℝ)) → + (∀ u ∈ U, H / (u : ℝ) ≤ Real.exp (C₀ * B)) → + ∀ᶠ X : ℕ in atTop, ∀ d : ℕ → RoughBinData, + (∀ u ∈ U, (d u).AdmissibleRight f (P u) (H / (u : ℝ)) τ + (Real.exp (B ^ (9999 / 10000 : ℝ)))) → + ‖(∑ u ∈ U, a u * positivePrefix + (weightedRoughShiftProfile (progressionSequence (d u).left l (residue u)) + (d u).right (d u).support (d u).coefficient h) (X / u)) / (X : ℂ)‖ ≤ + C * B ^ (-10001 / 10000 : ℝ) * (∑ u ∈ U, ‖a u‖ / (u : ℝ)) := by + obtain ⟨C, hC, hrough⟩ := qualitative_rough_shifts_real_bins_right hM hMRT hfnp hf h hh C₀ hC₀ + refine ⟨C, hC, ?_⟩ + filter_upwards [hrough, eventually_ge_atTop 1] with B hb hB + intro U a H τ P l _ residue hτ₁ hτ₂ hU hMlower hMupper + have hBpos : 0 < B := zero_lt_one.trans_le hB + let F : ℕ → RoughBinData → ℕ → ℂ := fun u d => + weightedRoughShiftProfile (progressionSequence d.left l (residue u)) + d.right d.support d.coefficient h + let Valid : ℕ → RoughBinData → Prop := fun u d => + d.AdmissibleRight f (P u) (H / (u : ℝ)) τ (Real.exp (B ^ (9999 / 10000 : ℝ))) + have hF : ∀ u ∈ U, ∀ᶠ Y : ℕ in atTop, + ∀ d : RoughBinData, Valid u d → ‖positivePrefix (F u d) Y / (Y : ℂ)‖ ≤ + C * B ^ (-10001 / 10000 : ℝ) := by + intro u hu + filter_upwards [hb (P u) (H / (u : ℝ)) τ hτ₁ hτ₂ (hMlower u hu) (hMupper u hu)] + with Y hy + intro d hd + exact hy d.left d.right hd.1 hd.2.1 hd.2.2.1 hd.2.2.2.1 + l (residue u) d.support d.coefficient hd.2.2.2.2.1 hd.2.2.2.2.2 + exact finite_rescaled_prefix_bound U a F Valid + (C * B ^ (-10001 / 10000 : ℝ)) (by positivity) hU hF + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativePartialCentering.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativePartialCentering.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a8e1d2d439f524c92f8b504e1acf16598810cbb --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativePartialCentering.lean @@ -0,0 +1,142 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DilatedRoughBins +import OAI.NumberTheory.TwoPoint.Bounds.ComplexPartialBounds +import OAI.NumberTheory.TwoPoint.Bounds.ComplexBinWindows +import OAI.NumberTheory.TwoPoint.Walks.TupleSmoothCost + +namespace OAI + +/-! Direct dilation gives qualitative centering for the actual complex +partial-tuple terms. The eventual cutoff is allowed to depend on the fixed +finite prime families, while the analytic constant is independent of them. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma qualitative_dilated_fixed_factors (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {F G : ℕ → ℂ} + (hFm : Multiplicative F) (hGm : Multiplicative G) + (hF : OneBounded F) (hG : OneBounded G) + (hnp : UniformlyNonpretentious F ∨ UniformlyNonpretentious G) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (u : ℕ), 0 < u → ∀ M τ : ℝ, 1 < τ → τ < 2 → + Real.exp (B ^ (9999 / 10000 : ℝ)) / τ ≤ M → + M ≤ Real.exp (C₀ * B ^ (2 : ℕ)) → + ∀ᶠ Y : ℕ in atTop, ∀ Z : Finset ℕ, + (∀ z ∈ Z, M < (z : ℝ) ∧ (z : ℝ) ≤ τ * M ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + ‖weightedRoughShiftAverage (fun n => F (u * n)) (fun n => G (u * n)) + Z (fun _ => 1) h Y‖ ≤ + C * B ^ (-11 / 10 : ℝ) * smoothReciprocalProduct u.primeFactors (1 / 2 : ℝ) := by + rcases hnp with hnp | hnp + · obtain ⟨C, hC, hb⟩ := qualitative_dilated_rough_shifts_real_bins hM hMRT hnp hF h hh C₀ hC₀ + refine ⟨C, hC, ?_⟩ + filter_upwards [hb] with B hb + intro u hu M τ hτ₁ hτ₂ hlow hupp + filter_upwards [hb ∅ M τ hτ₁ hτ₂ hlow hupp u hu] with Y hY + intro Z hZ + exact hY F G hFm hF hG (fun _ _ _ => rfl) Z (fun _ => 1) hZ (by simp) + · obtain ⟨C, hC, hb⟩ := qualitative_dilated_rough_shifts_real_bins_right hM hMRT hnp hG h hh C₀ hC₀ + refine ⟨C, hC, ?_⟩ + filter_upwards [hb] with B hb + intro u hu M τ hτ₁ hτ₂ hlow hupp + filter_upwards [hb ∅ M τ hτ₁ hτ₂ hlow hupp u hu] with Y hY + intro Z hZ + exact hY F G hF hGm hG (fun _ _ _ => rfl) Z (fun _ => 1) hZ (by simp) + +theorem qualitative_complex_partial_bin (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {F G : ℕ → ℂ} + (hFm : Multiplicative F) (hGm : Multiplicative G) + (hF : OneBounded F) (hG : OneBounded G) + (hnp : UniformlyNonpretentious F ∨ UniformlyNonpretentious G) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (J : ℕ) (P : Fin J → Finset ℕ), + (∀ i, ∀ p ∈ P i, p.Prime) → + (∀ i j, j ≠ i → Disjoint (P i) (P j)) → + (∀ i, ∀ p ∈ P i, Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ (p : ℝ)) → + ∀ (I : Finset (Fin J)), I.Nonempty → ∀ q : ℕ, 0 < q → + (∀ y : (i : {i // i ∉ I}) → P i, + smoothReciprocalProduct (∏ i, (y i).val).primeFactors (1 / 2 : ℝ) ≤ 2) → + ∀ (η : ℝ), 0 < η → Real.exp (2 * η) < 2 → ∀ j : ℤ, + Real.exp ((j : ℝ) * η) ≤ Real.exp (C₀ * B ^ (2 : ℕ)) → + ∀ᶠ X : ℕ in atTop, ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → actualPaddingBin η (Real.log d) j q) → + ‖positivePrefix (tupleComplexPartialProfile P I q eligible F G h) X / (X : ℂ)‖ ≤ + (2 * C * B ^ (-11 / 10 : ℝ) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ)) * + ((1 / (q : ℝ)) * ∏ i : {i // i ∉ I}, primeHarmonicMass (P i)) := by + obtain ⟨C, hC, hb⟩ := qualitative_dilated_fixed_factors hM hMRT hFm hGm hF hG hnp h hh C₀ hC₀ + refine ⟨C, hC, ?_⟩ + filter_upwards [hb, eventually_ge_atTop (1 : ℝ)] with B hb hB + intro J P hp hd hlarge I hI q hq hcost η hη hηtwo j hj + let τ := Real.exp (2 * η) + have hτ : 1 < τ := Real.one_lt_exp_iff.mpr (by positivity) + have hτp : 0 < τ := Real.exp_pos _ + let E := 2 * C * B ^ (-11 / 10 : ℝ) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) + have hE : 0 ≤ E := mul_nonneg (by positivity) + (smoothReciprocalProduct_nonneg _ (fun _ hp => Nat.prime_of_mem_primeFactors hp) + _ (by norm_num)) + have hall : ∀ᶠ X : ℕ in atTop, ∀ y : (i : {i // i ∉ I}) → P i, + ∀ eligible : ℕ → ℕ → Prop, + (∀ d q, eligible d q → actualPaddingBin η (Real.log d) j q) → + ‖weightedRoughShiftAverage + (fun n => F ((q * ∏ i, (y i).val) * n)) + (fun n => G ((q * ∏ i, (y i).val) * n)) + ((primeTupleSlice P I).filter (fun z => eligible ((∏ i, (y i).val) * z) q)) + (fun _ => 1) h (X / (q * ∏ i, (y i).val))‖ ≤ E := by + apply Filter.eventually_all.mpr + intro y + let t : ℕ := ∏ i, (y i).val + let u := q * t + let M := enlargedBinStart η j u + have ht : 0 < t := prod_pos fun i _ => (hp i _ (y i).property).pos + have hu : 0 < u := Nat.mul_pos hq ht + have hMupper : M ≤ Real.exp (C₀ * B ^ (2 : ℕ)) := + enlargedBinStart_upper η hη.le j u hu _ hj + by_cases hMlower : Real.exp (B ^ (9999 / 10000 : ℝ)) / τ ≤ M + · have hwin := (tendsto_nat_div_atTop u hu).eventually + (hb u hu M τ hτ hηtwo hMlower hMupper) + filter_upwards [hwin] with X hX + intro eligible hel + have hZ : ∀ z ∈ (primeTupleSlice P I).filter (fun z => eligible (t * z) q), + M < (z : ℝ) ∧ (z : ℝ) ≤ τ * M ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z := by + intro z hz + obtain ⟨hz, he⟩ := mem_filter.mp hz + have hzpos := primeTupleSlice_pos P I hp hz + have hw := enlarged_partial_bin_window q t z hq ht hzpos η hη j (hel _ _ he) + refine ⟨hw.1, hw.2, ?_⟩ + intro p hprime hsmall hdiv + obtain ⟨i, _, hi⟩ := prime_dvd_primeTupleSlice P I hp hz hprime hdiv + exact (not_lt_of_ge (hlarge i p hi)) hsmall + apply (hX _ hZ).trans + have hc := mul_le_mul_of_nonneg_left (dilated_tuple_smooth_cost q t hq ht (hcost y)) + (show 0 ≤ C * B ^ (-11 / 10 : ℝ) by positivity) + exact hc.trans_eq (by dsimp only [E]; ring) + · refine Filter.Eventually.of_forall ?_ + intro X eligible hel + have hempty : (primeTupleSlice P I).filter (fun z => eligible (t * z) q) = ∅ := by + apply eq_empty_iff_forall_notMem.mpr + intro z hz + obtain ⟨hz, he⟩ := mem_filter.mp hz + have hw := enlarged_partial_bin_window q t z hq ht + (primeTupleSlice_pos P I hp hz) η hη j (hel _ _ he) + exact hMlower (rough_bin_forces_start_lower hτp + (primeTupleSlice_lower P I hp _ hlarge hI hz) hw.2) + change ‖weightedRoughShiftAverage (fun n => F (u * n)) (fun n => G (u * n)) + ((primeTupleSlice P I).filter (fun z => eligible (t * z) q)) (fun _ => 1) h (X / u)‖ ≤ E + rw [hempty] + simpa only [weightedRoughShiftAverage, weightedRoughShiftProfile, sum_empty, + positivePrefix, sum_const_zero, zero_div, norm_zero] using hE + filter_upwards [hall, eventually_ge_atTop 1] with X hX hXpos + intro eligible hel + exact complex_partial_tuple_prefix_bound P hp hd I q hq eligible F G h X + (by omega) E hE (fun y => hX y eligible hel) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativePrimeScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativePrimeScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..b21a8c1140313d7320dfc1c596671c0fc3b0b01d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativePrimeScale.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeSieveParameters +import OAI.NumberTheory.TwoPoint.Bounds.RoughSieveProbability + +namespace OAI + +/-! The published Mertens estimate on the smaller qualitative sieve +cutoff, and the exact inclusion of its primes in the roughness condition. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def qualitativeSievePrimes (B : ℝ) : Finset ℕ := + sievePrimesUpTo (Real.exp (qualitativeSieveLogCutoff B)) + +def HasNoPrimeFactorBelow (R : ℝ) (n : ℕ) : Prop := + ∀ p : ℕ, Nat.Prime p → (p : ℝ) < R → ¬p ∣ n + +lemma qualitativeSieveLogCutoff_lt_power (B : ℝ) (hB : 0 < B) : + qualitativeSieveLogCutoff B < B ^ (9999 / 10000 : ℝ) := by + apply div_lt_self (Real.rpow_pos_of_pos hB _) + have hr : (0 : ℝ) ≤ qualitativeSieveHalfOrder B := Nat.cast_nonneg _ + push_cast + nlinarith only [hr] + +lemma HasNoPrimeFactorBelow.qualitativeSieve {B : ℝ} (hB : 0 < B) {n : ℕ} + (hn : HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) n) : + avoidsPrimeSet (qualitativeSievePrimes B) n := by + intro p hp + apply hn p (sievePrimesUpTo_prime _ p hp) + exact (sievePrimesUpTo_le _ (Real.exp_pos _).le p hp).trans_lt + (Real.exp_lt_exp.mpr (qualitativeSieveLogCutoff_lt_power B hB)) + +theorem PrimeReciprocalInput.qualitative_scale (hM : PrimeReciprocalInput) : + ∃ C : ℝ, 0 ≤ C ∧ ∀ᶠ B : ℝ in atTop, + |(∑ p ∈ qualitativeSievePrimes B, 1 / (p : ℝ)) - + Real.log (qualitativeSieveLogCutoff B)| ≤ C ∧ + (∑ p ∈ qualitativeSievePrimes B, 1 / (p : ℝ)) ≤ (5 / 4 : ℝ) * Real.log B := by + obtain ⟨C, hC⟩ := hM + have hC₀ : 0 ≤ C := (abs_nonneg _).trans (hC 2 (by norm_num)) + refine ⟨C, hC₀, ?_⟩ + filter_upwards [eventually_qualitativeSieveParameters, + eventually_ge_atTop (Real.exp (4 * C + 1))] with B hpar hB + have hX : 0 < qualitativeSieveLogCutoff B := zero_lt_one.trans_le hpar.cutoff_one + have hy : 2 ≤ Real.exp (qualitativeSieveLogCutoff B) := by + linarith [Real.add_one_le_exp (qualitativeSieveLogCutoff B), hpar.cutoff_one] + have hm := hC (Real.exp (qualitativeSieveLogCutoff B)) hy + rw [Real.log_exp] at hm + refine ⟨hm, ?_⟩ + have hlogC : 4 * C + 1 ≤ Real.log B := by + rw [← Real.log_exp (4 * C + 1)] + exact Real.log_le_log (Real.exp_pos _) hB + have hlogX := Real.log_le_log hX hpar.cutoff_le + have hu := (abs_le.mp hm).2 + change (∑ p ∈ qualitativeSievePrimes B, 1 / (p : ℝ)) - + Real.log (qualitativeSieveLogCutoff B) ≤ C at hu + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRightBins.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRightBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..09c57795a3be99a822442f8817974ff6907f4108 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRightBins.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeRoughBins +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeRightShifts + +namespace OAI + +/-! Real-bin transfer when the original second factor is nonpretentious. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +/-- The rough estimate for the real bins `(M,τM]` that arise after writing +an expanded divisor as `u*w`. -/ +theorem qualitative_rough_shifts_real_bins_right (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ) (M τ : ℝ), 1 < τ → τ < 2 → + Real.exp (B ^ (9999 / 10000 : ℝ)) / τ ≤ M → + M ≤ Real.exp (C₀ * B) → + ∀ᶠ Y : ℕ in atTop, ∀ b g : ℕ → ℂ, + OneBounded b → Multiplicative g → OneBounded g → + (∀ p, Nat.Prime p → p ∉ P → g p = f p) → + ∀ (l : ℕ) [NeZero l] (a : ZMod l) (Z : Finset ℕ) (c : ℕ → ℂ), + (∀ z ∈ Z, M < (z : ℝ) ∧ (z : ℝ) ≤ τ * M ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + (∀ z ∈ Z, ‖c z‖ ≤ 1) → + ‖weightedRoughShiftAverage (progressionSequence b l a) g Z c h Y‖ ≤ + C * B ^ (-10001 / 10000 : ℝ) := by + obtain ⟨C, hC, hrough⟩ := qualitative_rough_shifts_right hM hMRT hfnp hf h hh + (C₀ + 1) (by linarith) + refine ⟨C, hC, ?_⟩ + filter_upwards [hrough, eventually_ge_atTop 1] with B hb hB + intro P M τ hτ₁ hτ₂ hMlower hMupper + have hτpos : 0 < τ := zero_lt_one.trans hτ₁ + have hMpos : 0 < M := (div_pos (Real.exp_pos _) hτpos).trans_le hMlower + have hMc : M ≤ (Nat.ceil M : ℝ) := Nat.le_ceil M + have hDlower : (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ Nat.ceil M := by + have ht := (div_le_iff₀ hτpos).mp hMlower + nlinarith only [ht, hτ₂, hMpos, hMc] + have hDupper := ceil_exp_scale_bound B C₀ M hB hC₀ hMpos.le hMupper + filter_upwards [hb P (Nat.ceil M) hDlower hDupper] with Y hy + intro b g hbounded hmult hg heq l _ a Z c hZ hc + apply hy b g hbounded hmult hg heq l a Z c _ hc + intro z hz + have hzw := rough_bin_ceil_window M τ hMpos hτ₂ z ⟨(hZ z hz).1, (hZ z hz).2.1⟩ + exact ⟨hzw.1, hzw.2, (hZ z hz).2.2⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRightShifts.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRightShifts.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e95e35b51bbbb742a445fcc703888705dd0d5b5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRightShifts.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeRoughShifts +import OAI.NumberTheory.TwoPoint.Bounds.WeightedShiftRight + +namespace OAI + +/-! The qualitative rough-shift estimate when the original second factor +is uniformly nonpretentious. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma progressionSequence_mod_one (g : ℕ → ℂ) : + progressionSequence g 1 (0 : ZMod 1) = g := by + funext n + simp only [progressionSequence, Subsingleton.elim (n : ZMod 1) 0, ite_true] + +lemma long_window_exp_bound (B C₀ : ℝ) (D h : ℕ) (hB : 1 ≤ B) + (hD : (D : ℝ) ≤ Real.exp (C₀ * B)) : + (((2 * h + 1) * D : ℕ) : ℝ) ≤ + Real.exp ((C₀ + (2 * (h : ℝ) + 1)) * B) := by + have ht : 0 < 2 * (h : ℝ) + 1 := by positivity + have hexp : 2 * (h : ℝ) + 1 ≤ Real.exp ((2 * (h : ℝ) + 1) * B) := by + have he := Real.add_one_le_exp ((2 * (h : ℝ) + 1) * B) + nlinarith only [he, ht, hB] + calc + _ = (2 * (h : ℝ) + 1) * D := by push_cast; rfl + _ ≤ Real.exp ((2 * (h : ℝ) + 1) * B) * Real.exp (C₀ * B) := by gcongr + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +/-- The second-factor counterpart of `qualitative_rough_shifts`, with the +same exponent and uniformity in finite prime changes. -/ +theorem qualitative_rough_shifts_right (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ) (D : ℕ), + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → + (D : ℝ) ≤ Real.exp (C₀ * B) → + ∀ᶠ Y : ℕ in atTop, ∀ b g : ℕ → ℂ, + OneBounded b → Multiplicative g → OneBounded g → + (∀ p, Nat.Prime p → p ∉ P → g p = f p) → + ∀ (l : ℕ) [NeZero l] (a : ZMod l) (Z : Finset ℕ) (c : ℕ → ℂ), + (∀ z ∈ Z, D ≤ z ∧ z < D + D ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + (∀ z ∈ Z, ‖c z‖ ≤ 1) → + ‖weightedRoughShiftAverage (progressionSequence b l a) g Z c h Y‖ ≤ + C * B ^ (-10001 / 10000 : ℝ) := by + obtain ⟨U, V, hU, hV, hfourier⟩ := hM.qualitative_rough_fourier + obtain ⟨K, hK, hwindows⟩ := hMRT.qualitative_window_scale hfnp hf + (C₀ + (2 * (h : ℝ) + 1)) (by + have ht : (0 : ℝ) ≤ h := Nat.cast_nonneg h + linarith only [hC₀, ht]) + let C := 2 + (2 * (h : ℝ) + 1) + (2 * (h : ℝ) + 1) * U * V * K + refine ⟨C, by dsimp [C]; positivity, ?_⟩ + filter_upwards [hfourier, hwindows, eventually_qualitative_frequency_gap, + eventually_qualitative_interval_lower, eventually_ge_atTop (Real.exp 1)] with + B hfour hwin hgap hlower hB + intro P D hDlower hDupper + have hDten : 10 ≤ D := hlower D hDlower + have hDpos : 0 < D := by omega + have hB₁ : 1 ≤ B := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hB + have hBpos : 0 < B := zero_lt_one.trans_le hB₁ + have hlog : 0 ≤ Real.log B := Real.log_nonneg hB₁ + have hη : 0 < B ^ (-10001 / 10000 : ℝ) := Real.rpow_pos_of_pos hBpos _ + let Q := (2 * h + 1) * D + have hDQ : D ≤ Q := Nat.le_mul_of_pos_left D (by omega) + have hQten : 10 ≤ Q := hDten.trans hDQ + have hQlower : (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ Q := + hDlower.trans (by exact_mod_cast hDQ) + have hQupper : (Q : ℝ) ≤ Real.exp ((C₀ + (2 * (h : ℝ) + 1)) * B) := + long_window_exp_bound B C₀ D h hB₁ hDupper + filter_upwards [hwin P Q hQten hQlower hQupper, + eventually_fixed_interval_endpoint D _ hη] with Y hy hend + intro b g hbounded hmult hg heq l _ a Z c hZ hc + have hfourZ := hfour D h hDlower hh Z c hZ hc + have hZinterval : ∀ z ∈ Z, D ≤ z ∧ z < D + D := + fun z hz => ⟨(hZ z hz).1, (hZ z hz).2.1⟩ + have hZend : ∀ z ∈ Z, z ≤ 2 * D := by + intro z hz + have ht := (hZ z hz).2.1 + omega + apply weighted_rough_shift_parameter_bound_right (progressionSequence b l a) g + (hbounded.progressionSequence l a) hg Z c D h Y hDpos hend.1 hZend + (Real.log B / B ^ (9999 / 10000 : ℝ)) (B ^ (-10001 / 10000 : ℝ)) U V K + (by positivity) hη hU.le hV.le hK.le + (rough_coefficient_mass_le_one Z c D hDpos hZinterval hc) + hend.2 hgap hfourZ.1 hfourZ.2 + intro θ + have hG := hy g hmult hg heq 1 (0 : ZMod 1) (-θ) + simp only [progressionSequence_mod_one] at hG + simp_rw [backwardWindowPolynomial_eq_forward_neg] + convert hG using 1 + dsimp [Q] + push_cast + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRoughBins.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRoughBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..559da0dd19f6bc1a96375002c79a8294d3845ba9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRoughBins.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeRoughShifts + +namespace OAI + +/-! The actual real divisor bins in the analytic centering argument are +contained in the natural windows used by the finite Fourier proof. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma rough_bin_ceil_window (M τ : ℝ) (hM : 0 < M) (hτ : τ < 2) + (z : ℕ) (hz : M < (z : ℝ) ∧ (z : ℝ) ≤ τ * M) : + Nat.ceil M ≤ z ∧ z < Nat.ceil M + Nat.ceil M := by + have hc : M ≤ (Nat.ceil M : ℝ) := Nat.le_ceil M + constructor + · exact Nat.ceil_le.mpr hz.1.le + · have ht : (z : ℝ) < (Nat.ceil M : ℝ) + Nat.ceil M := by + nlinarith only [hz.2, hτ, hM, hc] + exact_mod_cast ht + +lemma ceil_exp_scale_bound (B C₀ M : ℝ) (hB : 1 ≤ B) (hC₀ : 1 ≤ C₀) + (hM : 0 ≤ M) (hupper : M ≤ Real.exp (C₀ * B)) : + (Nat.ceil M : ℝ) ≤ Real.exp ((C₀ + 1) * B) := by + have hc : (Nat.ceil M : ℝ) ≤ M + 1 := (Nat.ceil_lt_add_one hM).le + have he : 1 ≤ Real.exp (C₀ * B) := Real.one_le_exp (by nlinarith) + have heB : 2 ≤ Real.exp B := by linarith [Real.add_one_le_exp B] + calc + _ ≤ M + 1 := hc + _ ≤ Real.exp (C₀ * B) + 1 := by linarith only [hupper] + _ ≤ Real.exp (C₀ * B) * Real.exp B := by nlinarith only [he, heB] + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +/-- The rough estimate for the real bins `(M,τM]` that arise after writing +an expanded divisor as `u*w`. -/ +theorem qualitative_rough_shifts_real_bins (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ) (M τ : ℝ), 1 < τ → τ < 2 → + Real.exp (B ^ (9999 / 10000 : ℝ)) / τ ≤ M → + M ≤ Real.exp (C₀ * B) → + ∀ᶠ Y : ℕ in atTop, ∀ b g : ℕ → ℂ, + Multiplicative b → OneBounded b → OneBounded g → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → + ∀ (l : ℕ) [NeZero l] (a : ZMod l) (Z : Finset ℕ) (c : ℕ → ℂ), + (∀ z ∈ Z, M < (z : ℝ) ∧ (z : ℝ) ≤ τ * M ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + (∀ z ∈ Z, ‖c z‖ ≤ 1) → + ‖weightedRoughShiftAverage (progressionSequence b l a) g Z c h Y‖ ≤ + C * B ^ (-10001 / 10000 : ℝ) := by + obtain ⟨C, hC, hrough⟩ := qualitative_rough_shifts hM hMRT hfnp hf h hh + (C₀ + 1) (by linarith) + refine ⟨C, hC, ?_⟩ + filter_upwards [hrough, eventually_ge_atTop 1] with B hb hB + intro P M τ hτ₁ hτ₂ hMlower hMupper + have hτpos : 0 < τ := zero_lt_one.trans hτ₁ + have hMpos : 0 < M := (div_pos (Real.exp_pos _) hτpos).trans_le hMlower + have hMc : M ≤ (Nat.ceil M : ℝ) := Nat.le_ceil M + have hDlower : (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ Nat.ceil M := by + have ht := (div_le_iff₀ hτpos).mp hMlower + nlinarith only [ht, hτ₂, hMpos, hMc] + have hDupper := ceil_exp_scale_bound B C₀ M hB hC₀ hMpos.le hMupper + filter_upwards [hb P (Nat.ceil M) hDlower hDupper] with Y hy + intro b g hmult hbounded hg heq l _ a Z c hZ hc + apply hy b g hmult hbounded hg heq l a Z c _ hc + intro z hz + have hzw := rough_bin_ceil_window M τ hMpos hτ₂ z ⟨(hZ z hz).1, (hZ z hz).2.1⟩ + exact ⟨hzw.1, hzw.2, (hZ z hz).2.2⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRoughFourier.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRoughFourier.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b0184fcd77137419be976a7867cfb347f6f7c89 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRoughFourier.lean @@ -0,0 +1,118 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativePrimeScale +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeSieveBoundary +import OAI.NumberTheory.TwoPoint.Bounds.RoughCutoffProbability +import OAI.NumberTheory.TwoPoint.Bounds.WeightedRoughFourier + +namespace OAI + +/-! The qualitative rough multiplier, with arbitrary bounded complex +coefficients, obtained directly from the finite four-form sieve. -/ + +namespace TwoPointCorrelations + +open Finset Filter MeasureTheory +open scoped Classical + +lemma rpow_neg_hundred_le_qualitative_rate (B : ℝ) (hB : 1 ≤ B) + (hlog : 1 ≤ Real.log B) (k : ℕ) (hk : k ≤ 100) : + B ^ (-100 : ℝ) ≤ (Real.log B / B ^ (9999 / 10000 : ℝ)) ^ k := by + have hBp : 0 < B := zero_lt_one.trans_le hB + have hA : 0 < B ^ (9999 / 10000 : ℝ) := Real.rpow_pos_of_pos hBp _ + have hAB : B ^ (9999 / 10000 : ℝ) ≤ B := by + simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le hB + (show (9999 / 10000 : ℝ) ≤ 1 by norm_num) + have hi : B⁻¹ ≤ Real.log B / B ^ (9999 / 10000 : ℝ) := by + calc + _ ≤ (B ^ (9999 / 10000 : ℝ))⁻¹ := inv_anti₀ hA hAB + _ ≤ _ := by + change (B ^ (9999 / 10000 : ℝ))⁻¹ ≤ + Real.log B * (B ^ (9999 / 10000 : ℝ))⁻¹ + nlinarith only [hlog, inv_pos.mpr hA] + calc + _ ≤ B ^ (-(k : ℝ)) := Real.rpow_le_rpow_of_exponent_le hB (by + have hk' : (k : ℝ) ≤ 100 := by exact_mod_cast hk + linarith only [hk']) + _ = (B⁻¹) ^ k := by + rw [show -(k : ℝ) = (-1 : ℝ) * k by ring, + Real.rpow_mul_natCast hBp.le, Real.rpow_neg_one] + _ ≤ _ := pow_le_pow_left₀ (inv_nonneg.mpr hBp.le) hi k + +/-- The manuscript qualitative multiplier estimate. Its fourth moment +has only four logarithmic factors, which is stronger than the six needed +in the analytic transfer. -/ +theorem PrimeReciprocalInput.qualitative_rough_fourier (hM : PrimeReciprocalInput) : + ∃ U V : ℝ, 0 < U ∧ 0 < V ∧ ∀ᶠ B : ℝ in atTop, + ∀ (D h : ℕ), (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → 0 < h → + ∀ (Z : Finset ℕ) (c : ℕ → ℂ), + (∀ z ∈ Z, D ≤ z ∧ z < D + D ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + (∀ z ∈ Z, ‖c z‖ ≤ 1) → + (∀ θ, ‖weightedRoughFourier Z c h θ‖ ≤ + U * (Real.log B / B ^ (9999 / 10000 : ℝ))) ∧ + (∫ θ, ‖weightedRoughFourier Z c h θ‖ ^ 4 ∂AddCircle.haarAddCircle) ≤ + V / (D : ℝ) * (Real.log B / B ^ (9999 / 10000 : ℝ)) ^ 4 := by + obtain ⟨C, hC, hprime⟩ := hM.qualitative_scale + let U := Real.exp C * 100300 + 2 + let V := Real.exp (4 * C + 6) * 100300 ^ 4 + 2 + refine ⟨U, V, by dsimp [U]; positivity, by dsimp [V]; positivity, ?_⟩ + filter_upwards [hprime, eventually_qualitativeSieveParameters, + eventually_ge_atTop (Real.exp 1)] with B hp hpar hB + intro D h hD hh Z c hZ hc + have hB₁ : 1 ≤ B := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hB + have hBp : 0 < B := zero_lt_one.trans_le hB₁ + have hDp : (0 : ℝ) < D := lt_of_lt_of_le (by positivity) hD + let : NeZero D := ⟨by exact_mod_cast hDp.ne'⟩ + let P := qualitativeSievePrimes B + let X := qualitativeSieveLogCutoff B + let Y := Real.exp X + let r := qualitativeSieveHalfOrder B + let q := Real.log B / B ^ (9999 / 10000 : ℝ) + have hX : 0 < X := zero_lt_one.trans_le hpar.cutoff_one + have hY : 0 ≤ Y := (Real.exp_pos _).le + have hP (p : ℕ) (hp : p ∈ P) : Nat.Prime p := sievePrimesUpTo_prime Y p hp + have hmax (p : ℕ) (hp : p ∈ P) : (p : ℝ) ≤ Y := sievePrimesUpTo_le Y hY p hp + have hcard : (P.card : ℝ) ≤ Y := sievePrimesUpTo_card_le Y hY + have hlo : Real.log X - C ≤ ∑ p ∈ P, 1 / (p : ℝ) := by + have ht := (abs_le.mp hp.1).1 + change -C ≤ (∑ p ∈ P, 1 / (p : ℝ)) - Real.log X at ht + linarith only [ht] + have hup : (∑ p ∈ P, 1 / (p : ℝ)) ≤ 5 * Real.log B := by + have ht := hp.2 + change (∑ p ∈ P, 1 / (p : ℝ)) ≤ (5 / 4 : ℝ) * Real.log B at ht + linarith [hpar.log_one] + have he₁ := qualitative_sieve_boundary_cost B hpar hBp 1 Y P.card D + zero_le_one (by norm_num) hY (Nat.cast_nonneg _) hcard le_rfl hD + have he₃ := qualitative_sieve_boundary_cost B hpar hBp 3 Y P.card D + (by norm_num) le_rfl hY (Nat.cast_nonneg _) hcard le_rfl hD + have hprob₁ := rough_interval_probability_cutoff P hP D D r B C X Y hB₁ hX hY + hmax hlo hup hpar.nextOrder_large + have hprob₄ := rough_cube_probability_cutoff P hP (D, D, D) D r B C X Y hB₁ hX hY + hmax hlo hp.2 hpar.nextOrder_large + have hsmall₁ : B ^ (-100 : ℝ) ≤ q := by + simpa only [pow_one] using rpow_neg_hundred_le_qualitative_rate B hB₁ hpar.log_one 1 (by norm_num) + have hsmall₄ : B ^ (-100 : ℝ) ≤ q ^ 4 := + rpow_neg_hundred_le_qualitative_rate B hB₁ hpar.log_one 4 (by norm_num) + have hinv : 1 / X ≤ 100300 * q := by + calc + _ ≤ 100300 * Real.log B / B ^ (9999 / 10000 : ℝ) := hpar.inverse_cutoff + _ = _ := by dsimp [q]; ring + have hmain₁ : Real.exp C / X ≤ (Real.exp C * 100300) * q := by + convert mul_le_mul_of_nonneg_left hinv (Real.exp_pos C).le using 1 <;> ring + have hmain₄ : Real.exp (4 * C + 6) / X ^ 4 ≤ + (Real.exp (4 * C + 6) * 100300 ^ 4) * q ^ 4 := by + have ht := mul_le_mul_of_nonneg_left + (pow_le_pow_left₀ (by positivity : 0 ≤ 1 / X) hinv 4) (Real.exp_pos (4 * C + 6)).le + convert ht using 1 <;> ring + have hzsmall : ∀ z ∈ Z, D ≤ z ∧ z < D + D ∧ avoidsPrimeSet P z := by + intro z hz + exact ⟨(hZ z hz).1, (hZ z hz).2.1, + (hZ z hz).2.2.qualitativeSieve hBp⟩ + have hb := weightedRoughFourier_bounds_of_sieve P Z c D h hh (U * q) (V * q ^ 4) + hzsmall hc (hprob₁.trans (by dsimp [U]; nlinarith only [hmain₁, he₁, hsmall₁])) + (hprob₄.trans (by dsimp [V]; nlinarith only [hmain₄, he₃, hsmall₄])) + refine ⟨hb.1, hb.2.trans_eq ?_⟩ + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRoughShifts.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRoughShifts.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d378346c3c6c04aee5c3fb2b7a4068bf17e4393 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeRoughShifts.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeRoughFourier +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeWindowScale +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeShiftScale +import OAI.NumberTheory.TwoPoint.Bounds.WeightedShiftParameters + +namespace OAI + +/-! The qualitative rough-shift estimate, uniform over finite-prime +modifications, progression classes, and bounded rough coefficients. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +/-- The rough analytic transfer for a nonpretentious first factor. +All parameters other than the long average length are fixed before its +limit; the bound is uniform over the allowed modified functions. -/ +theorem qualitative_rough_shifts (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ) (D : ℕ), + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → + (D : ℝ) ≤ Real.exp (C₀ * B) → + ∀ᶠ Y : ℕ in atTop, ∀ b g : ℕ → ℂ, + Multiplicative b → OneBounded b → OneBounded g → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → + ∀ (l : ℕ) [NeZero l] (a : ZMod l) (Z : Finset ℕ) (c : ℕ → ℂ), + (∀ z ∈ Z, D ≤ z ∧ z < D + D ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + (∀ z ∈ Z, ‖c z‖ ≤ 1) → + ‖weightedRoughShiftAverage (progressionSequence b l a) g Z c h Y‖ ≤ + C * B ^ (-10001 / 10000 : ℝ) := by + obtain ⟨U, V, hU, hV, hfourier⟩ := hM.qualitative_rough_fourier + obtain ⟨K, hK, hwindows⟩ := hMRT.qualitative_window_scale hfnp hf C₀ hC₀ + let C := 2 + (2 * (h : ℝ) + 1) + (2 * (h : ℝ) + 1) * U * V * K + refine ⟨C, by dsimp [C]; positivity, ?_⟩ + filter_upwards [hfourier, hwindows, eventually_qualitative_frequency_gap, + eventually_qualitative_interval_lower, eventually_ge_atTop (Real.exp 1)] with + B hfour hwin hgap hlower hB + intro P D hDlower hDupper + have hDten : 10 ≤ D := hlower D hDlower + have hDpos : 0 < D := by omega + have hBpos : 0 < B := (Real.exp_pos 1).trans_le hB + have hlog : 0 ≤ Real.log B := Real.log_nonneg + ((Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hB) + have hη : 0 < B ^ (-10001 / 10000 : ℝ) := Real.rpow_pos_of_pos hBpos _ + filter_upwards [hwin P D hDten hDlower hDupper, + eventually_fixed_interval_endpoint D _ hη] with Y hy hend + intro b g hb hbounded hg heq l _ a Z c hZ hc + have hF := hy b hb hbounded heq l a + have hfourZ := hfour D h hDlower hh Z c hZ hc + have hZinterval : ∀ z ∈ Z, D ≤ z ∧ z < D + D := + fun z hz => ⟨(hZ z hz).1, (hZ z hz).2.1⟩ + have hZend : ∀ z ∈ Z, z ≤ 2 * D := by + intro z hz + have ht := (hZ z hz).2.1 + omega + apply weighted_rough_shift_parameter_bound (progressionSequence b l a) g + (hbounded.progressionSequence l a) hg Z c D h Y hDpos hend.1 hZend + (Real.log B / B ^ (9999 / 10000 : ℝ)) (B ^ (-10001 / 10000 : ℝ)) U V K + (by positivity) hη hU.le hV.le hK.le + (rough_coefficient_mass_le_one Z c D hDpos hZinterval hc) + hend.2 hgap hfourZ.1 hfourZ.2 + intro θ + convert hF θ using 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeShiftScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeShiftScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..f235653e30871d4ddeb3788c54aa57b36a78ba75 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeShiftScale.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeSieveParameters + +namespace OAI + +/-! Final scale arithmetic in the qualitative rough-shift estimate. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma eventually_qualitative_frequency_gap : + ∀ᶠ B : ℝ in atTop, + (Real.log B / B ^ (9999 / 10000 : ℝ)) ^ (6 : ℕ) ≤ + (B ^ (-10001 / 10000 : ℝ)) ^ (5 : ℕ) := by + have hs := (isLittleO_log_rpow_atTop + (show 0 < (1 / 10 : ℝ) by norm_num)).bound (show 0 < (1 : ℝ) by norm_num) + filter_upwards [eventually_ge_atTop 1, hs] with B hB hb + have hBp : 0 < B := zero_lt_one.trans_le hB + have hlog : 0 ≤ Real.log B := Real.log_nonneg hB + rw [Real.norm_eq_abs, abs_of_nonneg hlog, Real.norm_eq_abs, + abs_of_pos (Real.rpow_pos_of_pos hBp _), one_mul] at hb + have hq : Real.log B / B ^ (9999 / 10000 : ℝ) ≤ B ^ (-8999 / 10000 : ℝ) := by + calc + _ ≤ B ^ (1 / 10 : ℝ) / B ^ (9999 / 10000 : ℝ) := + div_le_div_of_nonneg_right hb (by positivity) + _ = _ := by rw [← Real.rpow_sub hBp]; norm_num + calc + _ ≤ (B ^ (-8999 / 10000 : ℝ)) ^ (6 : ℕ) := + pow_le_pow_left₀ (by positivity) hq 6 + _ = B ^ (-26997 / 5000 : ℝ) := by + rw [← Real.rpow_natCast, ← Real.rpow_mul hBp.le] + norm_num + _ ≤ B ^ (-10001 / 2000 : ℝ) := + Real.rpow_le_rpow_of_exponent_le hB (by norm_num) + _ = _ := by + rw [← Real.rpow_natCast, ← Real.rpow_mul hBp.le] + norm_num + +lemma eventually_qualitative_interval_lower : + ∀ᶠ B : ℝ in atTop, ∀ D : ℕ, + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → 10 ≤ D := by + have hh := ((Real.tendsto_exp_atTop.comp + (tendsto_rpow_atTop (show 0 < (9999 / 10000 : ℝ) by norm_num))).const_mul_atTop + (show 0 < (1 / 2 : ℝ) by norm_num)).eventually (eventually_ge_atTop 10) + filter_upwards [hh] with B hb + intro D hD + exact_mod_cast hb.trans hD + +lemma eventually_fixed_interval_endpoint (D : ℕ) (η : ℝ) (hη : 0 < η) : + ∀ᶠ Y : ℕ in atTop, 0 < Y ∧ (D : ℝ) / Y ≤ η := by + have hb : ∀ᶠ Y : ℕ in atTop, (D : ℝ) / η ≤ Y := + (tendsto_natCast_atTop_atTop (R := ℝ)).eventually (eventually_ge_atTop _) + filter_upwards [hb, eventually_ge_atTop 1] with Y hy hY + refine ⟨by omega, ?_⟩ + have hYr : (0 : ℝ) < Y := by exact_mod_cast (show 0 < Y by omega) + apply (div_le_iff₀ hYr).mpr + have ht := (div_le_iff₀ hη).mp hy + nlinarith only [ht] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeShortSums.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeShortSums.lean new file mode 100644 index 0000000000000000000000000000000000000000..502676371682a84a13f9a9c34226a9b95ca4c502 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeShortSums.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ModifiedShortSums +import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics +import Mathlib.Analysis.Complex.ExponentialBounds + +namespace OAI + +/-! The published MRT theorem at fixed window length, uniformly over +all finite-prime modifications of the original nonpretentious factor. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical Topology + +lemma loglog_div_log_nonneg (D : ℕ) (hD : 10 ≤ D) : + 0 ≤ Real.log (Real.log (D : ℝ)) / Real.log D := by + have hDr : (10 : ℝ) ≤ D := by exact_mod_cast hD + have hdlog : 1 ≤ Real.log (D : ℝ) := by + rw [← Real.log_exp 1] + exact Real.log_le_log (Real.exp_pos 1) (by linarith [Real.exp_one_lt_three]) + exact div_nonneg (Real.log_nonneg hdlog) (by linarith) + +/-- Fixed-length MRT, with an arbitrarily small residual error. The +supremum over frequencies remains outside the sum over window origins. -/ +theorem MRTShortExponentialInput.modified_fixed_windows + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) : + ∃ C : ℝ, 0 < C ∧ ∀ (P : Finset ℕ) (D : ℕ), 10 ≤ D → ∀ ε : ℝ, 0 < ε → + ∀ᶠ Y : ℕ in atTop, ∀ b : ℕ → ℂ, Multiplicative b → OneBounded b → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → + ∀ (l : ℕ) [NeZero l] (a : ZMod l) (θ : AddCircle (1 : ℝ)), + (∑ v ∈ range Y, + ‖forwardWindowPolynomial (progressionSequence b l a) D (v + 1) θ‖) ≤ + C * D * Y * (Real.log (Real.log (D : ℝ)) / Real.log D + ε) := by + obtain ⟨C, hC, hraw⟩ := hMRT.modified_windows hfnp hf + refine ⟨2 * C, by positivity, ?_⟩ + intro P D hD ε hε + have hehalf : 0 < ε / 2 := by positivity + have ht : Tendsto (fun Y : ℕ => (Real.log (Y + 1 : ℕ)) ^ (-1 / (700 : ℝ))) + atTop (𝓝 0) := by + simpa only [neg_div, Function.comp_def] using + (tendsto_rpow_neg_atTop (show 0 < (1 / (700 : ℝ)) by norm_num)).comp + (Real.tendsto_log_atTop.comp + ((tendsto_natCast_atTop_atTop (R := ℝ)).comp (tendsto_add_atTop_nat 1))) + have hsmall := ht.eventually (gt_mem_nhds hehalf) + filter_upwards [hraw P D hD (-20 * Real.log (ε / 2)), hsmall, + eventually_ge_atTop 1] with Y hy hs hY + intro b hb hbounded heq l _ a θ + have hval := hy b hb hbounded heq l a θ + have he : Real.exp (-(-20 * Real.log (ε / 2)) / 20) = ε / 2 := by + convert Real.exp_log hehalf using 1 + congr 1 + ring + rw [he] at hval + have hfirst := loglog_div_log_nonneg D hD + have hDpos : (0 : ℝ) < D := by exact_mod_cast (show 0 < D by omega) + have hYpos : (0 : ℝ) < (Y + 1 : ℕ) := by positivity + have hbound := (div_le_iff₀ (mul_pos hDpos hYpos)).mp hval + have herror : ε / 2 + mrtShortError (Y + 1) D ≤ + Real.log (Real.log (D : ℝ)) / Real.log D + ε := by + unfold mrtShortError + linarith only [hs] + have hYn : ((Y + 1 : ℕ) : ℝ) ≤ 2 * Y := by exact_mod_cast (show Y + 1 ≤ 2 * Y by omega) + calc + _ ≤ (C * (ε / 2 + mrtShortError (Y + 1) D)) * ((D : ℝ) * (Y + 1 : ℕ)) := hbound + _ ≤ (C * (Real.log (Real.log (D : ℝ)) / Real.log D + ε)) * + ((D : ℝ) * (Y + 1 : ℕ)) := by gcongr + _ ≤ (C * (Real.log (Real.log (D : ℝ)) / Real.log D + ε)) * + ((D : ℝ) * (2 * Y)) := by gcongr + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeSieveBoundary.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeSieveBoundary.lean new file mode 100644 index 0000000000000000000000000000000000000000..4636194bb9e4e6dac8a91752994cf9124474d32d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeSieveBoundary.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeSieveParameters + +namespace OAI + +/-! The literal CRT boundary error at the qualitative sieve cutoff. -/ + +namespace TwoPointCorrelations + +lemma qualitative_sieve_boundary_cost (B : ℝ) (hpar : QualitativeSieveParameters B) + (hB : 0 < B) (C₀ Y n : ℝ) (N : ℕ) + (hC₀ : 0 ≤ C₀) (hC₃ : C₀ ≤ 3) (hY : 0 ≤ Y) (hn : 0 ≤ n) + (hnY : n ≤ Y) (hYexp : Y ≤ Real.exp (qualitativeSieveLogCutoff B)) + (hN : (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ N) : + C₀ / (N : ℝ) * (2 * qualitativeSieveHalfOrder B + 1 : ℕ) * + (n * Y + 1) ^ (2 * qualitativeSieveHalfOrder B) ≤ B ^ (-100 : ℝ) := by + let X := qualitativeSieveLogCutoff B + let A := B ^ (9999 / 10000 : ℝ) + have hA : 0 < A := Real.rpow_pos_of_pos hB _ + have hXT : 1 ≤ X * Real.log B := by + nlinarith only [hpar.cutoff_one, hpar.log_one] + have hdom : 100000 * Real.log B ≤ A := by + have hh := mul_le_mul_of_nonneg_right hpar.cutoff_one + (show 0 ≤ Real.log B by linarith [hpar.log_one]) + nlinarith only [hh, hpar.cutoff_cost] + have hA₄ : 4 ≤ A := by linarith [hpar.log_one] + have hnum := sieve_boundary_numerator X (Real.log B) 1002 C₀ (n * Y + 1) + (2 * qualitativeSieveHalfOrder B) hpar.cutoff_one hpar.log_one (by norm_num) + hC₀ (by positivity) (sieve_base_le_exp X Y n hpar.cutoff_one hY hn hnY hYexp) + hpar.order_small + have hnumexp : Real.exp ((C₀ + 4 * 1002) * X * Real.log B) ≤ Real.exp (A / 4) := by + apply Real.exp_le_exp.mpr + have hcost : X * Real.log B ≤ A / 100000 := hpar.cutoff_cost + have hXT₀ : 0 ≤ X * Real.log B := by linarith + nlinarith only [hC₃, hC₀, hcost, hXT₀, hA] + have hNp : (0 : ℝ) < N := lt_of_lt_of_le (by positivity) hN + have hdiv : 1 / (N : ℝ) ≤ 2 * Real.exp (-A) := by + apply (div_le_iff₀ hNp).mpr + have hh := mul_le_mul_of_nonneg_left hN (show 0 ≤ 2 * Real.exp (-A) by positivity) + have hc : (2 * Real.exp (-A)) * ((1 / 2 : ℝ) * Real.exp A) = 1 := by + calc + _ = Real.exp (-A) * Real.exp A := by ring + _ = 1 := by rw [← Real.exp_add, neg_add_cancel, Real.exp_zero] + change (2 * Real.exp (-A)) * ((1 / 2 : ℝ) * Real.exp A) ≤ _ at hh + rw [hc] at hh + nlinarith only [hh] + have he : 2 ≤ Real.exp (A / 4) := by + linarith [Real.add_one_le_exp (A / 4)] + calc + _ = (C₀ * (2 * qualitativeSieveHalfOrder B + 1 : ℕ) * + (n * Y + 1) ^ (2 * qualitativeSieveHalfOrder B)) * (1 / (N : ℝ)) := by ring + _ ≤ Real.exp (A / 4) * (2 * Real.exp (-A)) := by + exact mul_le_mul (hnum.trans hnumexp) hdiv (by positivity) (Real.exp_pos _).le + _ ≤ Real.exp (A / 4) * (Real.exp (A / 4) * Real.exp (-A)) := by gcongr + _ = Real.exp (-A / 2) := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + _ ≤ Real.exp (-100 * Real.log B) := Real.exp_le_exp.mpr (by linarith only [hdom, hpar.log_one]) + _ = B ^ (-100 : ℝ) := by rw [Real.rpow_def_of_pos hB]; congr 1; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeSieveParameters.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeSieveParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..25f7e0c55ae4a766f65b8e63b5869c599ce344be --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeSieveParameters.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MertensScale +import OAI.NumberTheory.TwoPoint.Bounds.SieveBoundaryScale + +namespace OAI + +/-! A small sieve cutoff for the qualitative multiplier. Truncation uses +the same proved finite four-form sieve; its cutoff is chosen so that the +entire CRT boundary cost lies far below the available interval length. -/ + +namespace TwoPointCorrelations + +open Filter + +noncomputable def qualitativeSieveHalfOrder (B : ℝ) : ℕ := ⌈500 * Real.log B⌉₊ + +noncomputable def qualitativeSieveLogCutoff (B : ℝ) : ℝ := + B ^ (9999 / 10000 : ℝ) / (100 * (2 * qualitativeSieveHalfOrder B + 1 : ℕ)) + +lemma qualitativeSieveLogCutoff_le_power (B : ℝ) (hB : 0 ≤ B) : + qualitativeSieveLogCutoff B ≤ B ^ (9999 / 10000 : ℝ) := by + apply div_le_self (Real.rpow_nonneg hB _) + have hr : (0 : ℝ) ≤ qualitativeSieveHalfOrder B := Nat.cast_nonneg _ + push_cast + nlinarith only [hr] + +structure QualitativeSieveParameters (B : ℝ) : Prop where + log_one : 1 ≤ Real.log B + nextOrder_large : 220 * Real.log B ≤ (2 * qualitativeSieveHalfOrder B + 1 : ℕ) + order_small : (2 * qualitativeSieveHalfOrder B : ℕ) ≤ 1002 * Real.log B + cutoff_one : 1 ≤ qualitativeSieveLogCutoff B + cutoff_le : qualitativeSieveLogCutoff B ≤ B + cutoff_cost : qualitativeSieveLogCutoff B * Real.log B ≤ + B ^ (9999 / 10000 : ℝ) / 100000 + inverse_cutoff : 1 / qualitativeSieveLogCutoff B ≤ + 100300 * Real.log B / B ^ (9999 / 10000 : ℝ) + +theorem eventually_qualitativeSieveParameters : + ∀ᶠ B : ℝ in atTop, QualitativeSieveParameters B := by + have hs := (isLittleO_log_rpow_atTop + (show 0 < (9999 / 10000 : ℝ) by norm_num)).bound + (show 0 < (1 / 100300 : ℝ) by norm_num) + filter_upwards [eventually_ge_atTop (Real.exp 1), hs] with B hB hsB + have hB₁ : 1 ≤ B := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hB + have hBp : 0 < B := zero_lt_one.trans_le hB₁ + have ht : 1 ≤ Real.log B := by + rw [← Real.log_exp 1] + exact Real.log_le_log (Real.exp_pos 1) hB + have hBa : 0 < B ^ (9999 / 10000 : ℝ) := Real.rpow_pos_of_pos hBp _ + have ht₀ : 0 ≤ Real.log B := by linarith + rw [Real.norm_eq_abs, abs_of_nonneg ht₀, Real.norm_eq_abs, abs_of_pos hBa] at hsB + have hdom : 100300 * Real.log B ≤ B ^ (9999 / 10000 : ℝ) := by linarith + let r := qualitativeSieveHalfOrder B + have hrlo : 500 * Real.log B ≤ (r : ℝ) := Nat.le_ceil _ + have hrhi : (r : ℝ) < 500 * Real.log B + 1 := Nat.ceil_lt_add_one (by positivity) + have hJlo : 1000 * Real.log B ≤ (2 * r + 1 : ℕ) := by push_cast; linarith + have hJhi : (2 * r + 1 : ℕ) ≤ 1003 * Real.log B := by push_cast; linarith + have hden : 0 < (100 : ℝ) * (2 * r + 1 : ℕ) := by positivity + have hden₁ : 1 ≤ (100 : ℝ) * (2 * r + 1 : ℕ) := by + have hr₀ : (0 : ℝ) ≤ r := Nat.cast_nonneg r + push_cast + nlinarith only [hr₀] + have hX₁ : 1 ≤ qualitativeSieveLogCutoff B := by + change 1 ≤ B ^ (9999 / 10000 : ℝ) / (100 * (2 * r + 1 : ℕ)) + apply (le_div_iff₀ hden).mpr + nlinarith only [hJhi, hdom] + refine ⟨ht, ?_, ?_, hX₁, ?_, ?_, ?_⟩ + · change 220 * Real.log B ≤ (2 * r + 1 : ℕ) + linarith + · change (2 * r : ℕ) ≤ 1002 * Real.log B + push_cast + linarith + · calc + qualitativeSieveLogCutoff B ≤ B ^ (9999 / 10000 : ℝ) := + div_le_self hBa.le hden₁ + _ ≤ B := by + simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le hB₁ + (show (9999 / 10000 : ℝ) ≤ 1 by norm_num) + · have htdiv : Real.log B / (100 * (2 * r + 1 : ℕ)) ≤ (1 / 100000 : ℝ) := by + apply (div_le_iff₀ hden).mpr + nlinarith only [hJlo] + calc + qualitativeSieveLogCutoff B * Real.log B = + B ^ (9999 / 10000 : ℝ) * (Real.log B / (100 * (2 * r + 1 : ℕ))) := by + unfold qualitativeSieveLogCutoff + dsimp [r] + ring + _ ≤ B ^ (9999 / 10000 : ℝ) * (1 / 100000 : ℝ) := + mul_le_mul_of_nonneg_left htdiv hBa.le + _ = _ := by ring + · calc + 1 / qualitativeSieveLogCutoff B = + (100 * (2 * r + 1 : ℕ)) / B ^ (9999 / 10000 : ℝ) := by + unfold qualitativeSieveLogCutoff + dsimp [r] + field_simp [hBa.ne', hden.ne'] + _ ≤ _ := div_le_div_of_nonneg_right (by nlinarith only [hJhi]) hBa.le + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeSquareWindows.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeSquareWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd25e5c18e0465255b3f3b0a0134ff94358c29e6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeSquareWindows.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeShortSums +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeSieveParameters + +namespace OAI + +/-! The fixed-length MRT error for intervals as large as exp(C B²). Its constants are uniform over the finite set of modified primes. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem eventually_qualitative_square_window_error (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ K : ℝ, 0 < K ∧ ∀ᶠ B : ℝ in atTop, ∀ D : ℕ, + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → + (D : ℝ) ≤ Real.exp (C₀ * B ^ (2 : ℕ)) → + Real.log (Real.log (D : ℝ)) / Real.log D ≤ + K * (Real.log B / B ^ (9999 / 10000 : ℝ)) := by + have hCpos : 0 < C₀ := zero_lt_one.trans_le hC₀ + have hClog : 0 ≤ Real.log C₀ := Real.log_nonneg hC₀ + refine ⟨2 * (Real.log C₀ + 2), by positivity, ?_⟩ + have hlarge := (tendsto_rpow_atTop (show 0 < (9999 / 10000 : ℝ) by norm_num)).eventually + (eventually_ge_atTop (2 * Real.log 2)) + filter_upwards [eventually_ge_atTop (Real.exp 1), hlarge] with B hB hlargeB + intro D hDlower hDupper + have hB₁ : 1 ≤ B := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hB + have hBp : 0 < B := zero_lt_one.trans_le hB₁ + have hlogB : 1 ≤ Real.log B := by + rw [← Real.log_exp 1] + exact Real.log_le_log (Real.exp_pos 1) hB + have hA : 0 < B ^ (9999 / 10000 : ℝ) := Real.rpow_pos_of_pos hBp _ + have hDp : (0 : ℝ) < D := lt_of_lt_of_le (by positivity) hDlower + have hlogDlo : (1 / 2 : ℝ) * B ^ (9999 / 10000 : ℝ) ≤ Real.log D := by + have ht := Real.log_le_log (by positivity : (0 : ℝ) < + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ))) hDlower + rw [Real.log_mul (by norm_num : (1 / 2 : ℝ) ≠ 0) (Real.exp_ne_zero _), + Real.log_exp, one_div, Real.log_inv] at ht + linarith only [ht, hlargeB] + have hlogDpos : 0 < Real.log (D : ℝ) := lt_of_lt_of_le (by positivity) hlogDlo + have hlogDhi : Real.log (D : ℝ) ≤ C₀ * B ^ (2 : ℕ) := by + simpa only [Real.log_exp] using Real.log_le_log hDp hDupper + have hnum : Real.log (Real.log (D : ℝ)) ≤ (Real.log C₀ + 2) * Real.log B := by + have ht := Real.log_le_log hlogDpos hlogDhi + rw [Real.log_mul hCpos.ne' (pow_ne_zero 2 hBp.ne'), Real.log_pow] at ht + norm_num only [Nat.cast_ofNat] at ht + nlinarith [mul_nonneg hClog (sub_nonneg.mpr hlogB)] + calc + _ ≤ ((Real.log C₀ + 2) * Real.log B) / Real.log D := + div_le_div_of_nonneg_right hnum hlogDpos.le + _ ≤ ((Real.log C₀ + 2) * Real.log B) / + ((1 / 2 : ℝ) * B ^ (9999 / 10000 : ℝ)) := + div_le_div_of_nonneg_left (by positivity) (by positivity) hlogDlo + _ = _ := by ring + +/-- The actual progression-window sum, uniformly over every finite-prime +modification, on the manuscript qualitative interval scales. -/ +theorem MRTShortExponentialInput.qualitative_square_window_scale + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ K : ℝ, 0 < K ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ) (D : ℕ), 10 ≤ D → + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → + (D : ℝ) ≤ Real.exp (C₀ * B ^ (2 : ℕ)) → + ∀ᶠ Y : ℕ in atTop, ∀ b : ℕ → ℂ, Multiplicative b → OneBounded b → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → + ∀ (l : ℕ) [NeZero l] (a : ZMod l) (θ : AddCircle (1 : ℝ)), + (∑ v ∈ range Y, + ‖forwardWindowPolynomial (progressionSequence b l a) D (v + 1) θ‖) ≤ + K * D * Y * (Real.log B / B ^ (9999 / 10000 : ℝ)) := by + obtain ⟨C, hC, hfixed⟩ := hMRT.modified_fixed_windows hfnp hf + obtain ⟨K, hK, hscale⟩ := eventually_qualitative_square_window_error C₀ hC₀ + refine ⟨C * (K + 1), by positivity, ?_⟩ + filter_upwards [hscale, eventually_ge_atTop (Real.exp 1)] with B hs hB + intro P D hD hDlower hDupper + have hBpos : 0 < B := (Real.exp_pos 1).trans_le hB + have hlogpos : 0 < Real.log B := by + have ht : 1 ≤ Real.log B := by + rw [← Real.log_exp 1] + exact Real.log_le_log (Real.exp_pos 1) hB + linarith + have hq : 0 < Real.log B / B ^ (9999 / 10000 : ℝ) := by positivity + filter_upwards [hfixed P D hD _ hq] with Y hy + intro b hb hbounded heq l _ a θ + apply (hy b hb hbounded heq l a θ).trans + have he := hs D hDlower hDupper + calc + _ ≤ C * D * Y * + (K * (Real.log B / B ^ (9999 / 10000 : ℝ)) + + Real.log B / B ^ (9999 / 10000 : ℝ)) := by gcongr + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeStrongRight.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeStrongRight.lean new file mode 100644 index 0000000000000000000000000000000000000000..52b26b753d804776ed6b718b51b25e6cc37e628f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeStrongRight.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeStrongRoughShifts +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeRightShifts + +namespace OAI + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +/-- The second-factor counterpart of `qualitative_rough_shifts`, with the +same exponent and uniformity in finite prime changes. -/ +theorem qualitative_strong_rough_shifts_right (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ) (D : ℕ), + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → + (D : ℝ) ≤ Real.exp (C₀ * B ^ (2 : ℕ)) → + ∀ᶠ Y : ℕ in atTop, ∀ b g : ℕ → ℂ, + OneBounded b → Multiplicative g → OneBounded g → + (∀ p, Nat.Prime p → p ∉ P → g p = f p) → + ∀ (l : ℕ) [NeZero l] (a : ZMod l) (Z : Finset ℕ) (c : ℕ → ℂ), + (∀ z ∈ Z, D ≤ z ∧ z < D + D ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + (∀ z ∈ Z, ‖c z‖ ≤ 1) → + ‖weightedRoughShiftAverage (progressionSequence b l a) g Z c h Y‖ ≤ + C * B ^ (-11 / 10 : ℝ) := by + obtain ⟨U, V, hU, hV, hfourier⟩ := hM.qualitative_rough_fourier + obtain ⟨K, hK, hwindows⟩ := hMRT.qualitative_square_window_scale hfnp hf + (C₀ + (2 * (h : ℝ) + 1)) (by + have ht : (0 : ℝ) ≤ h := Nat.cast_nonneg h + linarith only [hC₀, ht]) + let C := 2 + (2 * (h : ℝ) + 1) + (2 * (h : ℝ) + 1) * U * V * K + refine ⟨C, by dsimp [C]; positivity, ?_⟩ + filter_upwards [hfourier, hwindows, eventually_strong_qualitative_frequency_gap, + eventually_qualitative_interval_lower, eventually_ge_atTop (Real.exp 1)] with + B hfour hwin hgap hlower hB + intro P D hDlower hDupper + have hDten : 10 ≤ D := hlower D hDlower + have hDpos : 0 < D := by omega + have hB₁ : 1 ≤ B := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hB + have hBpos : 0 < B := zero_lt_one.trans_le hB₁ + have hlog : 0 ≤ Real.log B := Real.log_nonneg hB₁ + have hη : 0 < B ^ (-11 / 10 : ℝ) := Real.rpow_pos_of_pos hBpos _ + let Q := (2 * h + 1) * D + have hDQ : D ≤ Q := Nat.le_mul_of_pos_left D (by omega) + have hQten : 10 ≤ Q := hDten.trans hDQ + have hQlower : (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ Q := + hDlower.trans (by exact_mod_cast hDQ) + have hQupper : (Q : ℝ) ≤ Real.exp ((C₀ + (2 * (h : ℝ) + 1)) * B ^ (2 : ℕ)) := + long_window_exp_bound (B ^ (2 : ℕ)) C₀ D h (by nlinarith) hDupper + filter_upwards [hwin P Q hQten hQlower hQupper, + eventually_fixed_interval_endpoint D _ hη] with Y hy hend + intro b g hbounded hmult hg heq l _ a Z c hZ hc + have hfourZ := hfour D h hDlower hh Z c hZ hc + have hZinterval : ∀ z ∈ Z, D ≤ z ∧ z < D + D := + fun z hz => ⟨(hZ z hz).1, (hZ z hz).2.1⟩ + have hZend : ∀ z ∈ Z, z ≤ 2 * D := by + intro z hz + have ht := (hZ z hz).2.1 + omega + apply weighted_rough_shift_parameter_bound_right (progressionSequence b l a) g + (hbounded.progressionSequence l a) hg Z c D h Y hDpos hend.1 hZend + (Real.log B / B ^ (9999 / 10000 : ℝ)) (B ^ (-11 / 10 : ℝ)) U V K + (by positivity) hη hU.le hV.le hK.le + (rough_coefficient_mass_le_one Z c D hDpos hZinterval hc) + hend.2 hgap hfourZ.1 hfourZ.2 + intro θ + have hG := hy g hmult hg heq 1 (0 : ZMod 1) (-θ) + simp only [progressionSequence_mod_one] at hG + simp_rw [backwardWindowPolynomial_eq_forward_neg] + convert hG using 1 + dsimp [Q] + push_cast + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeStrongRoughShifts.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeStrongRoughShifts.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c4036aee5f559aee4fcba2092c0b8cebb2bf757 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeStrongRoughShifts.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeRoughFourier +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeSquareWindows +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeStrongScale +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeShiftScale +import OAI.NumberTheory.TwoPoint.Bounds.WeightedShiftParameters + +namespace OAI + +/-! The stronger qualitative rough-shift estimate on exp(C B²) scales, uniform over finite-prime +modifications, progression classes, and bounded rough coefficients. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +/-- The rough analytic transfer for a nonpretentious first factor. +All parameters other than the long average length are fixed before its +limit; the bound is uniform over the allowed modified functions. -/ +theorem qualitative_strong_rough_shifts (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ) (D : ℕ), + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → + (D : ℝ) ≤ Real.exp (C₀ * B ^ (2 : ℕ)) → + ∀ᶠ Y : ℕ in atTop, ∀ b g : ℕ → ℂ, + Multiplicative b → OneBounded b → OneBounded g → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → + ∀ (l : ℕ) [NeZero l] (a : ZMod l) (Z : Finset ℕ) (c : ℕ → ℂ), + (∀ z ∈ Z, D ≤ z ∧ z < D + D ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + (∀ z ∈ Z, ‖c z‖ ≤ 1) → + ‖weightedRoughShiftAverage (progressionSequence b l a) g Z c h Y‖ ≤ + C * B ^ (-11 / 10 : ℝ) := by + obtain ⟨U, V, hU, hV, hfourier⟩ := hM.qualitative_rough_fourier + obtain ⟨K, hK, hwindows⟩ := hMRT.qualitative_square_window_scale hfnp hf C₀ hC₀ + let C := 2 + (2 * (h : ℝ) + 1) + (2 * (h : ℝ) + 1) * U * V * K + refine ⟨C, by dsimp [C]; positivity, ?_⟩ + filter_upwards [hfourier, hwindows, eventually_strong_qualitative_frequency_gap, + eventually_qualitative_interval_lower, eventually_ge_atTop (Real.exp 1)] with + B hfour hwin hgap hlower hB + intro P D hDlower hDupper + have hDten : 10 ≤ D := hlower D hDlower + have hDpos : 0 < D := by omega + have hBpos : 0 < B := (Real.exp_pos 1).trans_le hB + have hlog : 0 ≤ Real.log B := Real.log_nonneg + ((Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hB) + have hη : 0 < B ^ (-11 / 10 : ℝ) := Real.rpow_pos_of_pos hBpos _ + filter_upwards [hwin P D hDten hDlower hDupper, + eventually_fixed_interval_endpoint D _ hη] with Y hy hend + intro b g hb hbounded hg heq l _ a Z c hZ hc + have hF := hy b hb hbounded heq l a + have hfourZ := hfour D h hDlower hh Z c hZ hc + have hZinterval : ∀ z ∈ Z, D ≤ z ∧ z < D + D := + fun z hz => ⟨(hZ z hz).1, (hZ z hz).2.1⟩ + have hZend : ∀ z ∈ Z, z ≤ 2 * D := by + intro z hz + have ht := (hZ z hz).2.1 + omega + apply weighted_rough_shift_parameter_bound (progressionSequence b l a) g + (hbounded.progressionSequence l a) hg Z c D h Y hDpos hend.1 hZend + (Real.log B / B ^ (9999 / 10000 : ℝ)) (B ^ (-11 / 10 : ℝ)) U V K + (by positivity) hη hU.le hV.le hK.le + (rough_coefficient_mass_le_one Z c D hDpos hZinterval hc) + hend.2 hgap hfourZ.1 hfourZ.2 + intro θ + convert hF θ using 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeStrongScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeStrongScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..536e576d08690e4f9234fa63920cd0e820e69bac --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeStrongScale.lean @@ -0,0 +1,41 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeSieveParameters + +namespace OAI + +/-! Final scale arithmetic in the qualitative rough-shift estimate. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma eventually_strong_qualitative_frequency_gap : + ∀ᶠ B : ℝ in atTop, + (Real.log B / B ^ (9999 / 10000 : ℝ)) ^ (6 : ℕ) ≤ + (B ^ (-11 / 10 : ℝ)) ^ (5 : ℕ) := by + have hs := (isLittleO_log_rpow_atTop + (show 0 < (1 / 20 : ℝ) by norm_num)).bound (show 0 < (1 : ℝ) by norm_num) + filter_upwards [eventually_ge_atTop 1, hs] with B hB hb + have hBp : 0 < B := zero_lt_one.trans_le hB + have hlog : 0 ≤ Real.log B := Real.log_nonneg hB + rw [Real.norm_eq_abs, abs_of_nonneg hlog, Real.norm_eq_abs, + abs_of_pos (Real.rpow_pos_of_pos hBp _), one_mul] at hb + have hq : Real.log B / B ^ (9999 / 10000 : ℝ) ≤ B ^ (-9499 / 10000 : ℝ) := by + calc + _ ≤ B ^ (1 / 20 : ℝ) / B ^ (9999 / 10000 : ℝ) := + div_le_div_of_nonneg_right hb (by positivity) + _ = _ := by rw [← Real.rpow_sub hBp]; norm_num + calc + _ ≤ (B ^ (-9499 / 10000 : ℝ)) ^ (6 : ℕ) := + pow_le_pow_left₀ (by positivity) hq 6 + _ = B ^ (-28497 / 5000 : ℝ) := by + rw [← Real.rpow_natCast, ← Real.rpow_mul hBp.le] + norm_num + _ ≤ B ^ (-11 / 2 : ℝ) := + Real.rpow_le_rpow_of_exponent_le hB (by norm_num) + _ = _ := by + rw [← Real.rpow_natCast, ← Real.rpow_mul hBp.le] + norm_num + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeWindowScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeWindowScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c8dc6e4d5bb9d6d7bcb70b0b9311a9cbe9338d6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QualitativeWindowScale.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeShortSums +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeSieveParameters + +namespace OAI + +/-! The fixed-length MRT error on the interval scales of the qualitative +transfer. Its constants are uniform over the finite set of modified primes. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem eventually_qualitative_window_error (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ K : ℝ, 0 < K ∧ ∀ᶠ B : ℝ in atTop, ∀ D : ℕ, + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → + (D : ℝ) ≤ Real.exp (C₀ * B) → + Real.log (Real.log (D : ℝ)) / Real.log D ≤ + K * (Real.log B / B ^ (9999 / 10000 : ℝ)) := by + have hCpos : 0 < C₀ := zero_lt_one.trans_le hC₀ + have hClog : 0 ≤ Real.log C₀ := Real.log_nonneg hC₀ + refine ⟨2 * (Real.log C₀ + 1), by positivity, ?_⟩ + have hlarge := (tendsto_rpow_atTop (show 0 < (9999 / 10000 : ℝ) by norm_num)).eventually + (eventually_ge_atTop (2 * Real.log 2)) + filter_upwards [eventually_ge_atTop (Real.exp 1), hlarge] with B hB hlargeB + intro D hDlower hDupper + have hB₁ : 1 ≤ B := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hB + have hBp : 0 < B := zero_lt_one.trans_le hB₁ + have hlogB : 1 ≤ Real.log B := by + rw [← Real.log_exp 1] + exact Real.log_le_log (Real.exp_pos 1) hB + have hA : 0 < B ^ (9999 / 10000 : ℝ) := Real.rpow_pos_of_pos hBp _ + have hDp : (0 : ℝ) < D := lt_of_lt_of_le (by positivity) hDlower + have hlogDlo : (1 / 2 : ℝ) * B ^ (9999 / 10000 : ℝ) ≤ Real.log D := by + have ht := Real.log_le_log (by positivity : (0 : ℝ) < + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ))) hDlower + rw [Real.log_mul (by norm_num : (1 / 2 : ℝ) ≠ 0) (Real.exp_ne_zero _), + Real.log_exp, one_div, Real.log_inv] at ht + linarith only [ht, hlargeB] + have hlogDpos : 0 < Real.log (D : ℝ) := lt_of_lt_of_le (by positivity) hlogDlo + have hlogDhi : Real.log (D : ℝ) ≤ C₀ * B := by + simpa only [Real.log_exp] using Real.log_le_log hDp hDupper + have hnum : Real.log (Real.log (D : ℝ)) ≤ (Real.log C₀ + 1) * Real.log B := by + have ht := Real.log_le_log hlogDpos hlogDhi + rw [Real.log_mul hCpos.ne' hBp.ne'] at ht + nlinarith only [ht, hClog, hlogB] + calc + _ ≤ ((Real.log C₀ + 1) * Real.log B) / Real.log D := + div_le_div_of_nonneg_right hnum hlogDpos.le + _ ≤ ((Real.log C₀ + 1) * Real.log B) / + ((1 / 2 : ℝ) * B ^ (9999 / 10000 : ℝ)) := + div_le_div_of_nonneg_left (by positivity) (by positivity) hlogDlo + _ = _ := by ring + +/-- The actual progression-window sum, uniformly over every finite-prime +modification, on the manuscript qualitative interval scales. -/ +theorem MRTShortExponentialInput.qualitative_window_scale + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) + (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ K : ℝ, 0 < K ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ) (D : ℕ), 10 ≤ D → + (1 / 2 : ℝ) * Real.exp (B ^ (9999 / 10000 : ℝ)) ≤ D → + (D : ℝ) ≤ Real.exp (C₀ * B) → + ∀ᶠ Y : ℕ in atTop, ∀ b : ℕ → ℂ, Multiplicative b → OneBounded b → + (∀ p, Nat.Prime p → p ∉ P → b p = f p) → + ∀ (l : ℕ) [NeZero l] (a : ZMod l) (θ : AddCircle (1 : ℝ)), + (∑ v ∈ range Y, + ‖forwardWindowPolynomial (progressionSequence b l a) D (v + 1) θ‖) ≤ + K * D * Y * (Real.log B / B ^ (9999 / 10000 : ℝ)) := by + obtain ⟨C, hC, hfixed⟩ := hMRT.modified_fixed_windows hfnp hf + obtain ⟨K, hK, hscale⟩ := eventually_qualitative_window_error C₀ hC₀ + refine ⟨C * (K + 1), by positivity, ?_⟩ + filter_upwards [hscale, eventually_ge_atTop (Real.exp 1)] with B hs hB + intro P D hD hDlower hDupper + have hBpos : 0 < B := (Real.exp_pos 1).trans_le hB + have hlogpos : 0 < Real.log B := by + have ht : 1 ≤ Real.log B := by + rw [← Real.log_exp 1] + exact Real.log_le_log (Real.exp_pos 1) hB + linarith + have hq : 0 < Real.log B / B ^ (9999 / 10000 : ℝ) := by positivity + filter_upwards [hfixed P D hD _ hq] with Y hy + intro b hb hbounded heq l _ a θ + apply (hy b hb hbounded heq l a θ).trans + have he := hs D hDlower hDupper + calc + _ ≤ C * D * Y * + (K * (Real.log B / B ^ (9999 / 10000 : ℝ)) + + Real.log B / B ^ (9999 / 10000 : ℝ)) := by gcongr + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeCenteringAssembly.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeCenteringAssembly.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d2362c94a3179fe93c027c295d34572a8469179 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeCenteringAssembly.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CenteredBinIdentity +import OAI.NumberTheory.TwoPoint.Walks.CanonicalCenteringBins + +namespace OAI + +/-! The quantitative centering estimate for the same numerical bins +used by the spectral and deletion bounds. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def progressionLiouvilleMean (h l b : ℕ) [NeZero l] (X : ℝ) : ℂ := + positivePrefix (fun n => progressionSequence liouville l (b : ZMod l) n * liouville (n + h)) + ⌊X⌋₊ / (X : ℂ) + +noncomputable def canonicalRawBin (h l b : ℕ) (E : Finset ℕ) (W L η X : ℝ) (j : ℤ) : ℂ := + let T := X * Real.exp ((j : ℝ) * η) + ((⌊T⌋₊ : ℂ) / (T : ℂ)) * + canonicalUncutPrefix h l b E W L (numericalBinEligible L η j) ⌊T⌋₊ + +theorem quantitative_centering_assembly (hP : ModFiveThetaInput) + (hM : PrimeReciprocalInput) (hMRT : MRTLiouvilleShortInput) + (h : ℕ) (hh : 0 < h) (l : ℕ) [NeZero l] (E : Finset ℕ) + (hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, ∀ _hL : 1 ≤ L, + ∀ X : ℝ, Real.exp (L ^ (1000 : ℝ)) ≤ X → + ∀ η : ℝ, 0 < η → η < Real.log 2 → ∀ b : ℕ, + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + let S₀ := totalPaddingBinMass (primeTupleDivisors P) Q L η + ‖(∑ j ∈ paddingBinIndices L η, canonicalRawBin h l b E W L η X j) - + (S₀ : ℂ) * progressionLiouvilleMean h l b X‖ ≤ + C * η⁻¹ * (2 : ℝ) ^ J * L ^ (-1 / 20 : ℝ) * paddingTiltNormalizer Q * + (∏ i, primeHarmonicMass (P i)) + S₀ * (2 * η + 1 / X) := by + obtain ⟨C, hC, hb⟩ := quantitative_canonical_centering_bins hP hM hMRT h hh l E hEl W hW + refine ⟨C, hC, ?_⟩ + filter_upwards [hb] with L hb + intro hL X hX η hη hηlog b + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + let R := boundedPaddingDivisors Q ⌊100 * Real.log L⌋₊ + let D := primeTupleDivisors P + let S₀ := totalPaddingBinMass D Q L η + let bins := paddingBinIndices L η + let T := fun j : ℤ => X * Real.exp ((j : ℝ) * η) + let F := progressionLiouvilleMean h l b X + let raw := fun j => canonicalRawBin h l b E W L η X j + let full := fun j => fullNumericalBin D R L η j l (b : ZMod l) h (T j) + let err := fun j => tupleNonrawBin P R actualPaddingCoefficient (numericalBinEligible L η j) + l (b : ZMod l) h (T j) + have hp : ∀ i, ∀ p ∈ P i, p.Prime := centeredPrimeBands_prime _ _ _ _ + have hd : ∀ i k, k ≠ i → Disjoint (P i) (P k) := centeredPrimeBands_disjoint _ _ _ _ + (Real.rpow_nonneg (zero_le_one.trans hL) _) (zero_le_one.trans hW) + have hq : ∀ p ∈ Q, p.Prime := fun _ hp => paddingPrimeSupply_prime hp + have hR : ∀ q ∈ R, 0 < q := fun q hq' => + retainedPrimeDivisor_pos Q hq (mem_filter.mp hq').1 + have hD : ∀ d ∈ D, 0 < d := by + intro d hd' + obtain ⟨x, _, rfl⟩ := mem_image.mp hd' + exact prod_pos fun i _ => (hp i _ (x i).property).pos + have hunit : ∀ d ∈ D, ∀ q ∈ R, IsUnit ((q * d : ℕ) : ZMod l) := by + intro d hd' q hq' + obtain ⟨x, _, rfl⟩ := mem_image.mp hd' + apply (ZMod.isUnit_iff_coprime _ l).mpr + exact Nat.coprime_mul_iff_left.mpr + ⟨paddingPrimeDivisor_coprime E L l hEl (mem_filter.mp hq').1, + Nat.coprime_prod_left_iff.mpr (fun i _ => + centeredPrimeBands_coprime E _ W J l hEl i (x i).property)⟩ + have hident (j : ℤ) : raw j - full j = err j := + weighted_uncut_sub_full_bin P hp hd R hR L η j h l b hh (T j) + have hsum : (∑ j ∈ bins, raw j) - (∑ j ∈ bins, full j) = ∑ j ∈ bins, err j := by + rw [← sum_sub_distrib] + exact sum_congr rfl (fun j _ => hident j) + have he := hb X hX η hη hηlog (numericalBinEligible L η) + (fun j d q he => numericalBinEligible_bin L η j d q he) (b : ZMod l) + have hf := fullNumericalBins_error D Q hD hq L η X hL + ((Real.exp_pos _).trans_le hX) hη.le l (b : ZMod l) h hunit + change ‖(∑ j ∈ bins, raw j) - (S₀ : ℂ) * F‖ ≤ _ + have ht := norm_add_le ((∑ j ∈ bins, raw j) - (∑ j ∈ bins, full j)) + ((∑ j ∈ bins, full j) - (S₀ : ℂ) * F) + rw [sub_add_sub_cancel, hsum] at ht + exact ht.trans (add_le_add ((norm_sum_le _ _).trans he) hf) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeDivisorBins.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeDivisorBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a48bfe7e4cb90f4d1c94790d29e6bc80c507b96 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeDivisorBins.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QuantitativeResidueBins +import OAI.NumberTheory.TwoPoint.Bounds.RescaledPrefixSums + +namespace OAI + +/-! Quantitative finite extraction at Y=floor(X/u), with the exact +reciprocal mass of u and the absolute exponent 1000 retained. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma finite_rescaled_prefix_bound_at (U : Finset ℕ) (a : ℕ → ℂ) + (F : ℕ → ℕ → ℂ) (X : ℕ) (E : ℝ) (hX : 0 < X) (hE : 0 ≤ E) + (hU : ∀ u ∈ U, 0 < u) + (hF : ∀ u ∈ U, ‖positivePrefix (F u) (X / u) / ((X / u : ℕ) : ℂ)‖ ≤ E) : + ‖(∑ u ∈ U, a u * positivePrefix (F u) (X / u)) / (X : ℂ)‖ ≤ + E * ∑ u ∈ U, ‖a u‖ / (u : ℝ) := by + have hXp : (0 : ℝ) < X := by exact_mod_cast hX + rw [sum_div] + calc + _ ≤ ∑ u ∈ U, ‖a u * positivePrefix (F u) (X / u) / (X : ℂ)‖ := norm_sum_le _ _ + _ ≤ ∑ u ∈ U, E * (‖a u‖ / (u : ℝ)) := by + apply sum_le_sum + intro u hu + have hup : (0 : ℝ) < u := by exact_mod_cast hU u hu + have hb := prefix_norm_of_average_bound (F u) (X / u) E (hF u hu) + have hratio : ((X / u : ℕ) : ℝ) ≤ (X : ℝ) / u := Nat.cast_div_le + have hprefix : ‖positivePrefix (F u) (X / u)‖ ≤ ((X : ℝ) / u) * E := + hb.trans (mul_le_mul_of_nonneg_right hratio hE) + rw [norm_div, norm_mul, Complex.norm_natCast] + calc + _ ≤ (‖a u‖ * (((X : ℝ) / u) * E)) / X := by gcongr + _ = _ := by field_simp + _ = _ := by rw [mul_sum] + +theorem quantitative_residue_bin_family (hM : PrimeReciprocalInput) + (hMRT : MRTLiouvilleShortInput) (h : ℕ) (hh : 0 < h) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, + ∀ (X l : ℕ) [NeZero l], 0 < X → + ∀ (U : Finset ℕ) (a : ℕ → ℂ) (b : ℕ → ZMod l) + (M : ℕ → ℝ) (τ : ℝ) (Z : ℕ → Finset ℕ), + 0 < τ → τ < 2 → (∀ u ∈ U, 0 < u) → + (∀ u ∈ U, Real.exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ)) ≤ ((X / u : ℕ) : ℝ)) → + (∀ u ∈ U, ∀ z ∈ Z u, M u ≤ (z : ℝ) ∧ (z : ℝ) ≤ τ * M u ∧ + Real.exp (L ^ (199 / 200 : ℝ)) ≤ (z : ℝ) ∧ (z : ℝ) ≤ Real.exp (2 * L) ∧ + avoidsPrimeSet (sievePrimesUpTo (Real.exp (L ^ (99 / 100 : ℝ)))) z) → + ‖(∑ u ∈ U, a u * positivePrefix (residueScaledRoughProfile l (b u) (Z u) h) (X / u)) / + (X : ℂ)‖ ≤ + ((l : ℝ) * C * L ^ (-21 / 20 : ℝ)) * (∑ u ∈ U, ‖a u‖ / (u : ℝ)) := by + obtain ⟨C, hC, hb⟩ := quantitative_residue_bin hM hMRT h hh + refine ⟨C, hC, ?_⟩ + filter_upwards [hb, eventually_ge_atTop (1 : ℝ)] with L hb hL + intro X l _ hX U a b M τ Z hτ hτtwo hU hY hZ + exact finite_rescaled_prefix_bound_at U a + (fun u => residueScaledRoughProfile l (b u) (Z u) h) X _ hX (by positivity) hU + (fun u hu => hb (X / u) l (hY u hu) (b u) (M u) τ hτ hτtwo (Z u) (hZ u hu)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeFinalWindows.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeFinalWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..35d5a896e1b81b0a74256d427d5ea9de01923266 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeFinalWindows.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.TwoPoint.Walks.CanonicalCenteringBins + +namespace OAI + +/-! The final logarithmic bins meet both the analytic and spectral +long-window hypotheses, uniformly in the absolute exponent A. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma exp_neg_nat_lt_log_two (J : ℕ) (hJ : 1 ≤ J) : + Real.exp (-(J : ℝ)) < Real.log 2 := by + have hJ' : (1 : ℝ) ≤ J := by exact_mod_cast hJ + have he : 2 < Real.exp 1 := by + linarith [Real.add_one_lt_exp (by norm_num : (1 : ℝ) ≠ 0)] + have hi : (Real.exp 1)⁻¹ < (1 / 2 : ℝ) := by + rw [inv_eq_one_div] + apply (div_lt_iff₀ (Real.exp_pos 1)).mpr + linarith + 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 + linarith + calc + _ ≤ Real.exp (-1) := Real.exp_le_exp.mpr (by linarith) + _ < (1 / 2 : ℝ) := by simpa only [Real.exp_neg] using hi + _ ≤ _ := hl + +lemma floor_exp_half_bound (Y T : ℝ) (hY : 2 ≤ Y) (hT : Real.exp Y ≤ T) : + Real.exp (Y / 2) ≤ (⌊T⌋₊ : ℝ) := by + let E := Real.exp (Y / 2) + have hE : 2 ≤ E := by + have he := Real.add_one_le_exp (Y / 2) + dsimp only [E] + linarith + have hsq : E * E ≤ T := by + calc + _ = Real.exp Y := by + dsimp only [E] + rw [← Real.exp_add] + congr 1 + ring + _ ≤ T := hT + have hf := Nat.lt_floor_add_one T + change E ≤ _ + nlinarith + +lemma final_bin_windows (L X η : ℝ) (A : ℕ) (hL : 2 ≤ L) + (hA : 1000 ≤ A) (hX : Real.exp (L ^ A) ≤ X) (hη : 0 < η) + (j : ℤ) (hj : j ∈ paddingBinIndices L η) : + Real.exp (L ^ (1000 : ℝ)) ≤ X ∧ + Real.exp (L ^ A / 2) ≤ (⌊X * Real.exp ((j : ℝ) * η)⌋₊ : ℝ) := by + have hLone : 1 ≤ L := by linarith + have hAp : A ≠ 0 := by omega + have hpow : L ^ (1000 : ℝ) ≤ L ^ A := by + rw [Real.rpow_ofNat] + exact pow_le_pow_right₀ hLone hA + have hY : 2 ≤ L ^ A := hL.trans (le_self_pow₀ hLone hAp) + have hXp : 0 < X := (Real.exp_pos _).trans_le hX + exact ⟨(Real.exp_le_exp.mpr hpow).trans hX, + floor_exp_half_bound _ _ hY + (hX.trans (bin_cutoff_ge L η X hη hXp.le j hj))⟩ + +theorem eventually_quantitative_final_windows (W : ℝ) (hW : 0 < W) : + ∀ᶠ L : ℝ in atTop, + 2 ≤ L ∧ 1 ≤ primeSupplyCount W L ∧ + 0 < Real.exp (-(primeSupplyCount W L : ℝ)) ∧ + Real.exp (-(primeSupplyCount W L : ℝ)) < Real.log 2 ∧ + ∀ (A : ℕ), 1000 ≤ A → ∀ (X : ℝ), Real.exp (L ^ A) ≤ X → + Real.exp (L ^ (1000 : ℝ)) ≤ X ∧ + ∀ j ∈ paddingBinIndices L (Real.exp (-(primeSupplyCount W L : ℝ))), + Real.exp (L ^ A / 2) ≤ + (⌊X * Real.exp ((j : ℝ) * Real.exp (-(primeSupplyCount W L : ℝ)))⌋₊ : ℝ) := by + filter_upwards [eventually_primeSupplyCount_pos W hW, eventually_ge_atTop (2 : ℝ)] + with L hJ hL + refine ⟨hL, hJ, Real.exp_pos _, exp_neg_nat_lt_log_two _ hJ, ?_⟩ + intro A hA X hX + have hLone : 1 ≤ L := by linarith + have hpow : L ^ (1000 : ℝ) ≤ L ^ A := by + rw [Real.rpow_ofNat] + exact pow_le_pow_right₀ hLone hA + refine ⟨(Real.exp_le_exp.mpr hpow).trans hX, ?_⟩ + intro j hj + exact (final_bin_windows L X _ A hL hA hX (Real.exp_pos _) j hj).2 + +lemma final_log_scale_exact (X : ℝ) (A : ℕ) (hX : 1 ≤ X) (hA : A ≠ 0) : + Real.exp (((Real.log X) ^ (1 / (A : ℝ))) ^ A) = X := by + have hp : ((Real.log X) ^ (1 / (A : ℝ))) ^ A = Real.log X := by + simpa only [one_div] using Real.rpow_inv_natCast_pow (Real.log_nonneg hX) hA + rw [hp, Real.exp_log (zero_lt_one.trans_le hX)] + +lemma final_log_scale_tendsto (A : ℕ) (hA : 0 < A) : + Tendsto (fun X : ℝ => (Real.log X) ^ (1 / (A : ℝ))) atTop atTop := by + have hAp : (0 : ℝ) < A := by exact_mod_cast hA + exact (tendsto_rpow_atTop (one_div_pos.mpr hAp)).comp Real.tendsto_log_atTop + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeFixedScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeFixedScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..99b4e7cc03476b33470c7cdfe79c295e936f3cc9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeFixedScale.lean @@ -0,0 +1,134 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FinalCorrelationBound +import OAI.NumberTheory.TwoPoint.Walks.RetainedFinalScale +import OAI.NumberTheory.TwoPoint.Bounds.QuantitativeFinalWindows + +namespace OAI + +/-! Assembly of the actual graph, deletion and centering estimates. +The interval exponent and prime-band width are absolute: they are chosen +before the shift, modulus, or residue class. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem quantitative_fixed_scale (hP : ModFiveThetaInput) + (hBr : BravermanDepth22Input) (hM : PrimeReciprocalInput) + (hMRT : MRTLiouvilleShortInput) : + ∃ (A : ℕ) (W : ℝ), 1000 ≤ A ∧ 10 ≤ W ∧ + ∀ (h l : ℕ) [NeZero l], 0 < h → + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, + ∀ X : ℝ, Real.exp (L ^ A) ≤ X → ∀ b : ℕ, + ‖progressionLiouvilleMean h l b X‖ ≤ + C * Real.exp (-(primeSupplyCount W L : ℝ)) := by + obtain ⟨As, W, hAs, hW, hs⟩ := + hP.eventually_canonical_retained_weighted_saving hBr + obtain ⟨Ad, hAd, hd⟩ := hBr.eventually_canonical_shifted_source_deletion_uniform hP + let A := As + Ad + have hA : 1000 ≤ A := by dsimp only [A]; omega + have hWone : 1 ≤ W := by linarith + refine ⟨A, W, hA, hW, ?_⟩ + intro h l _ hh + have hl : 0 < l := NeZero.pos l + let E := (h * l).primeFactors + have hE : ∀ p, p.Prime → p ∣ h → p ∈ E := by + intro p hp hph + exact Nat.mem_primeFactors.mpr + ⟨hp, dvd_mul_of_dvd_left hph l, (Nat.mul_pos hh hl).ne'⟩ + have hEl : ∀ p, p.Prime → p ∣ l → p ∈ E := by + intro p hp hpl + exact Nat.mem_primeFactors.mpr + ⟨hp, dvd_mul_of_dvd_right hpl h, (Nat.mul_pos hh hl).ne'⟩ + obtain ⟨Cd, hCd, hd⟩ := hd h E hE W 3 hW (by norm_num) + obtain ⟨Cc, hCc, hc⟩ := quantitative_centering_assembly hP hM hMRT h hh l E hEl W hWone + let Cs : ℝ := 1212 * Real.exp 1 * (l : ℝ) ^ 2 + 606 + refine ⟨Cs + 4 * Cd + 2 * Cc + 19, by dsimp only [Cs]; positivity, ?_⟩ + filter_upwards [hs h l hh hl E hE hEl, hd, hc, + hP.eventually_canonical_retained_mass E W hWone, + eventually_quantitative_final_windows W (by linarith), + eventually_rare_error_saving W hWone, + eventually_ge_atTop (101 : ℝ)] with L hs hd hc hm hw hr hlarge + intro X hX b + have hL : 1 ≤ L := by linarith + let J := primeSupplyCount W L + let η := Real.exp (-(J : ℝ)) + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + let S := paddingTiltNormalizer Q + let V := ∏ i, primeHarmonicMass (P i) + let M := S * V + let S₀ := totalPaddingBinMass (primeTupleDivisors P) Q L η + let bins := paddingBinIndices L η + let eligible := numericalBinEligible L η + let T := fun j : ℤ => X * Real.exp ((j : ℝ) * η) + let N := fun j : ℤ => ⌊T j⌋₊ + let v := fun j : ℤ => (N j : ℂ) / (T j : ℂ) + let raw := ∑ j ∈ bins, v j * canonicalUncutPrefix h l b E W L (eligible j) (N j) + let retained := ∑ j ∈ bins, + v j * canonicalRetainedPrefix h l b E W L (eligible j) hL hWone hE (N j) + let cost := fun site => canonicalShiftedSourceDeletion h E W L η (Real.exp (4 * J)) + hL hWone hE bins (fun d => Real.log d) eligible site (fun _ => 1) N + have hη : 0 < η := Real.exp_pos _ + have hηone : η ≤ 1 := Real.exp_le_one_iff.mpr (neg_nonpos.mpr (Nat.cast_nonneg J)) + have hXpos : 0 < X := (Real.exp_pos _).trans_le hX + have hwindow := hw.2.2.2.2 A hA X hX + have hN (A' : ℕ) (hA' : A' ≤ A) (j : ℤ) (hj : j ∈ bins) : + Real.exp (L ^ A' / 2) ≤ (N j : ℝ) := + (Real.exp_le_exp.mpr (div_le_div_of_nonneg_right + (pow_le_pow_right₀ hL hA') (by norm_num))).trans (hwindow.2 j hj) + have hv : ∀ j ∈ bins, ‖v j‖ ≤ 1 := by + intro j _ + exact floor_cutoff_weight_norm_le (T j) (mul_pos hXpos (Real.exp_pos _)) + have he : ∀ j ∈ bins, ∀ d q, eligible j d q → PaddingPairEligible L η d q := by + intro j hj d q hdq + exact numericalBinEligible_pair L η hη j hj d q hdq + have hb : ∀ j ∈ bins, ∀ d q, eligible j d q → + actualPaddingBin η (Real.log d) j q := by + intro j _ d q hdq + exact numericalBinEligible_bin L η j d q hdq + have hbins : (bins.card : ℝ) ≤ Real.exp (3 * Real.log L) := + paddingBinIndices_card_polynomial L W hlarge hWone + have hm' := hm hL η hη + have hV : 1 ≤ V := (one_le_pow₀ hWone).trans hm'.1 + have hM : 0 < M := mul_pos (paddingTiltNormalizer_pos Q) (by linarith) + have hmass : M / 2 ≤ S₀ := hm'.2 + have hS₀ : 0 < S₀ := (half_pos hM).trans_le hmass + have hret : ‖retained‖ / S₀ ≤ Cs * η := + hs hL eligible he b N v (hN As (by dsimp only [A]; omega)) hv + have hdelete : ‖raw - retained‖ ≤ cost (fun _ _ _ => 0) + + cost (fun _ d q => (h * q * d : ℕ)) := + canonical_weighted_correlation_deletion h l b E W L η hL hWone hE bins + (fun d => Real.log d) eligible N v hb hv + have hd' (site : ℤ → ℕ → ℕ → ℤ) : cost site / M ≤ (Cd + 4) * η := by + have hx := hd hL η (Real.exp (4 * J)) hη hηone (Real.exp_pos _) bins + (fun d => Real.log d) eligible hbins he hb site (fun _ => 1) N + (hN Ad (by dsimp only [A]; omega)) + exact hx.trans (quantitative_deletion_small L W Cd J hL hWone hCd.le + (primeSupplyCount_final_budget L W hL hWone) hr) + have hdel : ‖raw - retained‖ ≤ 2 * M * ((Cd + 4) * η) := by + have h₁ := (div_le_iff₀ hM).mp (hd' (fun _ _ _ => 0)) + have h₂ := (div_le_iff₀ hM).mp (hd' (fun _ d q => (h * q * d : ℕ))) + nlinarith + have hcenter : ‖raw - (S₀ : ℂ) * progressionLiouvilleMean h l b X‖ ≤ + Cc * η * M + S₀ * (2 * η + 1 / X) := by + have hx := hc hL X hwindow.1 η hη hw.2.2.2.1 b + change ‖raw - (S₀ : ℂ) * progressionLiouvilleMean h l b X‖ ≤ _ at hx + have hsmall := (quantitative_small_terms L W J hL hWone + (primeSupplyCount_final_budget L W hL hWone)).1 + have hinv : η⁻¹ = Real.exp (J : ℝ) := by + dsimp only [η] + rw [Real.exp_neg, inv_inv] + rw [← hinv] at hsmall + have hcsmall := mul_le_mul_of_nonneg_left hsmall hCc.le + have hcsmall' := mul_le_mul_of_nonneg_right hcsmall hM.le + dsimp only [M] at hcsmall' + nlinarith + exact correlation_normalized_bound raw retained (progressionLiouvilleMean h l b X) + S₀ M η Cs Cd Cc (1 / X) hS₀ hM.le hη.le (by dsimp only [Cs]; positivity) + hCd.le hCc.le hmass (reciprocal_cutoff_saving L W X A hL hWone (by omega) hX) + hret hdel hcenter + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeParameterChoice.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeParameterChoice.lean new file mode 100644 index 0000000000000000000000000000000000000000..391ee01c1c9e021e9d3a4046f3abe49faeec59f3 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeParameterChoice.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.TwoPoint.Walks.RetainedRowScale + +namespace OAI + +/-! The manuscript's final exponential savings at eta = exp(-J), +K = exp(4J), and a fixed sufficiently large W. -/ + +namespace TwoPointCorrelations + +lemma two_pow_eq_exp (J : ℕ) : (2 : ℝ) ^ J = Real.exp ((J : ℝ) * Real.log 2) := by + rw [← Real.rpow_natCast, Real.rpow_def_of_pos (by norm_num)] + congr 1 + ring + +lemma quantitative_small_terms (L W : ℝ) (J : ℕ) (hL : 1 ≤ L) (hW : 1 ≤ W) + (hJ : 60 * (J : ℝ) ≤ Real.log L) : + Real.exp J * (2 : ℝ) ^ J * L ^ (-1 / 20 : ℝ) ≤ Real.exp (-(J : ℝ)) ∧ + (2 : ℝ) ^ J * Real.exp (-4 * (J : ℝ)) ≤ Real.exp (-(J : ℝ)) ∧ + (2 : ℝ) ^ J * L ^ (-100 : ℝ) ≤ Real.exp (-(J : ℝ)) ∧ + (2 : ℝ) ^ J * Real.exp (-2 * W * J) ≤ Real.exp (-(J : ℝ)) := by + have hLp : 0 < L := by linarith + have hJ0 : (0 : ℝ) ≤ J := Nat.cast_nonneg _ + have hlog : 0 ≤ Real.log L := Real.log_nonneg hL + have hlogtwo : Real.log 2 ≤ 1 := by + have ht := Real.log_le_sub_one_of_pos (show (0 : ℝ) < 2 by norm_num) + linarith + have htwo : (J : ℝ) * Real.log 2 ≤ J := by nlinarith + have hWJ : (J : ℝ) ≤ W * J := by nlinarith + rw [two_pow_eq_exp] + simp only [Real.rpow_def_of_pos hLp] + repeat rw [← Real.exp_add] + refine ⟨?_, ?_, ?_, ?_⟩ <;> apply Real.exp_le_exp.mpr <;> nlinarith + +lemma quantitative_spectral_term (C W : ℝ) (J : ℕ) (hC : 0 ≤ C) (hW : 0 < W) + (hchoice : Real.exp 5 * (C / Real.sqrt W) ≤ Real.exp (-1)) : + Real.exp (5 * (J : ℝ)) * (C / Real.sqrt W) ^ J ≤ Real.exp (-(J : ℝ)) := by + have he : Real.exp (5 * (J : ℝ)) = (Real.exp 5) ^ J := by + rw [mul_comm, Real.exp_nat_mul] + rw [he, ← mul_pow] + have hp := pow_le_pow_left₀ (mul_nonneg (Real.exp_pos _).le (by positivity)) hchoice J + calc + _ ≤ (Real.exp (-1)) ^ J := hp + _ = _ := by rw [← Real.exp_nat_mul]; congr 1; ring + +lemma primeSupplyCount_final_budget (L W : ℝ) (hL : 1 ≤ L) (hW : 1 ≤ W) : + 60 * (primeSupplyCount W L : ℝ) ≤ Real.log L := by + have hj := primeSupplyCount_mul_bound W L (by linarith) hL + have hJ0 : (0 : ℝ) ≤ primeSupplyCount W L := Nat.cast_nonneg _ + nlinarith + +lemma primeSupplyCount_saving (L W : ℝ) (hL : 1 ≤ L) (_hW : 0 < W) : + Real.exp (-(primeSupplyCount W L : ℝ)) ≤ + Real.exp 1 * L ^ (-(1 / (1200 * W)) : ℝ) := by + have hLp : 0 < L := by linarith + have hf := Nat.lt_floor_add_one (((1 / 200 : ℝ) * Real.log L) / (6 * W)) + have he : ((1 / 200 : ℝ) * Real.log L) / (6 * W) = Real.log L / (1200 * W) := by ring + change ((1 / 200 : ℝ) * Real.log L) / (6 * W) < (primeSupplyCount W L : ℝ) + 1 at hf + rw [he] at hf + rw [Real.rpow_def_of_pos hLp, ← Real.exp_add] + apply Real.exp_le_exp.mpr + have hz : Real.log L * (-(1 / (1200 * W))) = -(Real.log L / (1200 * W)) := by ring + rw [hz] + linarith + +lemma exists_fixed_spectral_parameter (C : ℝ) (hC : 0 ≤ C) : + ∃ W : ℝ, 10 ≤ W ∧ Real.exp 5 * (C / Real.sqrt W) ≤ Real.exp (-1) := by + let a := Real.exp 6 * C + 4 + have ha : 4 ≤ a := by + have hp := mul_nonneg (Real.exp_pos (6 : ℝ)).le hC + dsimp only [a] + linarith + have hap : 0 < a := by linarith + refine ⟨a ^ 2, by nlinarith, ?_⟩ + rw [Real.sqrt_sq hap.le, ← mul_div_assoc] + apply (div_le_iff₀ hap).mpr + have he : Real.exp (-1) * Real.exp 6 = Real.exp 5 := by + rw [← Real.exp_add] + norm_num + dsimp [a] + rw [mul_add, ← mul_assoc, he] + linarith [Real.exp_pos (-1)] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeResidueBins.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeResidueBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..471d1982dcc876575137a611c50202c41e190201 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeResidueBins.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QuantitativeRoughBins + +namespace OAI + +/-! The progression class in a partial centering term depends on the +rough shift. Splitting by its residue costs exactly the fixed modulus. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma sum_modulus_fibres (l : ℕ) [NeZero l] (Z : Finset ℕ) + (F : ZMod l → ℕ → ℂ) : + (∑ r : ZMod l, ∑ z ∈ Z.filter (fun z : ℕ => (z : ZMod l) = r), F r z) = + ∑ z ∈ Z, F (z : ZMod l) z := by + simp only [sum_filter] + rw [sum_comm] + apply sum_congr rfl + intro z _ + simp + +noncomputable def residueScaledRoughProfile (l : ℕ) [NeZero l] (b : ZMod l) + (Z : Finset ℕ) (h n : ℕ) : ℂ := + ∑ z ∈ Z, (z : ℂ)⁻¹ * + (progressionSequence liouville l (b * (z : ZMod l)) n * liouville (n + h * z)) + +noncomputable def residueScaledRoughAverage (l : ℕ) [NeZero l] (b : ZMod l) + (Z : Finset ℕ) (h Y : ℕ) : ℂ := + positivePrefix (residueScaledRoughProfile l b Z h) Y / (Y : ℂ) + +lemma residueScaledRoughProfile_partition (l : ℕ) [NeZero l] (b : ZMod l) + (Z : Finset ℕ) (h n : ℕ) : + residueScaledRoughProfile l b Z h n = + ∑ r : ZMod l, roughShiftProfile (progressionSequence liouville l (b * r)) + liouville (Z.filter (fun z : ℕ => (z : ZMod l) = r)) h n := by + exact (sum_modulus_fibres l Z (fun r z => (z : ℂ)⁻¹ * + (progressionSequence liouville l (b * r) n * liouville (n + h * z)))).symm + +lemma residueScaledRoughAverage_partition (l : ℕ) [NeZero l] (b : ZMod l) + (Z : Finset ℕ) (h Y : ℕ) : + residueScaledRoughAverage l b Z h Y = + ∑ r : ZMod l, roughShiftAverage (progressionSequence liouville l (b * r)) + liouville (Z.filter (fun z : ℕ => (z : ZMod l) = r)) h Y := by + simp only [residueScaledRoughAverage, positivePrefix, residueScaledRoughProfile_partition, + roughShiftAverage] + rw [sum_comm, sum_div] + +theorem quantitative_residue_bin (hM : PrimeReciprocalInput) + (hMRT : MRTLiouvilleShortInput) (h : ℕ) (hh : 0 < h) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, + ∀ (Y l : ℕ), Real.exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ)) ≤ (Y : ℝ) → + ∀ [NeZero l] (b : ZMod l) (M τ : ℝ), 0 < τ → τ < 2 → + ∀ Z : Finset ℕ, + (∀ z ∈ Z, M ≤ (z : ℝ) ∧ (z : ℝ) ≤ τ * M ∧ + Real.exp (L ^ (199 / 200 : ℝ)) ≤ (z : ℝ) ∧ (z : ℝ) ≤ Real.exp (2 * L) ∧ + avoidsPrimeSet (sievePrimesUpTo (Real.exp (L ^ (99 / 100 : ℝ)))) z) → + ‖residueScaledRoughAverage l b Z h Y‖ ≤ (l : ℝ) * C * L ^ (-21 / 20 : ℝ) := by + obtain ⟨C, hC, hb⟩ := quantitative_rough_real_bin hM hMRT h hh + refine ⟨C, hC, ?_⟩ + filter_upwards [hb] with L hb + intro Y l hY _ b M τ hτ hτtwo Z hZ + rw [residueScaledRoughAverage_partition] + calc + _ ≤ ∑ r : ZMod l, ‖roughShiftAverage (progressionSequence liouville l (b * r)) + liouville (Z.filter (fun z : ℕ => (z : ZMod l) = r)) h Y‖ := norm_sum_le _ _ + _ ≤ ∑ _r : ZMod l, C * L ^ (-21 / 20 : ℝ) := by + apply sum_le_sum + intro r _ + exact hb Y l hY (b * r) M τ hτ hτtwo _ (fun z hz => hZ z (mem_filter.mp hz).1) + _ = _ := by simp only [sum_const, card_univ, ZMod.card, nsmul_eq_mul]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeRoughBins.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeRoughBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..3efd48bb7716f1622c0df4ce2eae18347e63e0e4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeRoughBins.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughLiouvilleShifts +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeRoughBins + +namespace OAI + +/-! The quantitative rough-shift estimate on the actual logarithmic +bins, retaining the absolute long-interval exponent 1000. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem quantitative_rough_real_bin (hM : PrimeReciprocalInput) + (hMRT : MRTLiouvilleShortInput) (h : ℕ) (hh : 0 < h) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, + ∀ (Y l : ℕ), Real.exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ)) ≤ (Y : ℝ) → + ∀ [NeZero l] (a : ZMod l) (M τ : ℝ), 0 < τ → τ < 2 → + ∀ Z : Finset ℕ, + (∀ z ∈ Z, M ≤ (z : ℝ) ∧ (z : ℝ) ≤ τ * M ∧ + Real.exp (L ^ (199 / 200 : ℝ)) ≤ (z : ℝ) ∧ (z : ℝ) ≤ Real.exp (2 * L) ∧ + avoidsPrimeSet (sievePrimesUpTo (Real.exp (L ^ (99 / 100 : ℝ)))) z) → + ‖roughShiftAverage (progressionSequence liouville l a) liouville Z h Y‖ ≤ + C * L ^ (-21 / 20 : ℝ) := by + obtain ⟨C, hC, hb⟩ := rough_liouville_shifts hM hMRT h hh + refine ⟨C, hC, ?_⟩ + filter_upwards [hb, eventually_ge_atTop (1 : ℝ)] with L hb hL + intro Y l hY _ a M τ hτ hτtwo Z hZ + by_cases hz : Z.Nonempty + · obtain ⟨z, hz⟩ := hz + have hzdata := hZ z hz + have hzm : 0 < τ * M := (Real.exp_pos _).trans_le (hzdata.2.2.1.trans hzdata.2.1) + have hMpos : 0 < M := by + rcases mul_pos_iff.mp hzm with hpos | hneg + · exact hpos.2 + · linarith [hneg.1] + have hceil : (Nat.ceil M : ℝ) ≤ z := by exact_mod_cast Nat.ceil_le.mpr hzdata.1 + have hlow : (1 / 2 : ℝ) * Real.exp (L ^ (199 / 200 : ℝ)) ≤ Nat.ceil M := by + have hMc : M ≤ (Nat.ceil M : ℝ) := Nat.le_ceil M + nlinarith [hzdata.2.1, hzdata.2.2.1] + have hupp : (Nat.ceil M : ℝ) ≤ Real.exp (2 * L) := hceil.trans hzdata.2.2.2.1 + apply hb Y (Nat.ceil M) l hlow hupp hY a Z + intro z hz + have hzD : Nat.ceil M ≤ z := Nat.ceil_le.mpr (hZ z hz).1 + have hMceil : M ≤ (Nat.ceil M : ℝ) := Nat.le_ceil M + have hzupper : (z : ℝ) < 2 * (Nat.ceil M : ℝ) := by + nlinarith [(hZ z hz).2.1] + have hzupperNat : z < Nat.ceil M + Nat.ceil M := by + have ht : z < 2 * Nat.ceil M := by exact_mod_cast hzupper + omega + exact ⟨hzD, hzupperNat, (hZ z hz).2.2.2.2⟩ + · have he : Z = ∅ := not_nonempty_iff_eq_empty.mp hz + subst Z + simp only [roughShiftAverage, roughShiftProfile, sum_empty, positivePrefix, sum_const_zero, + zero_div, norm_zero] + exact mul_nonneg hC.le (Real.rpow_nonneg (zero_le_one.trans hL) _) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeTupleBins.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeTupleBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b0abfcb38c66b56fc25272a27d4f0e62aeffa88 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuantitativeTupleBins.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.TwoPoint.Walks.PartialTupleProfiles +import OAI.NumberTheory.TwoPoint.Walks.TupleSliceSupport + +namespace OAI + +/-! A partial-centering bin saves L^(-21/20) with exactly the reciprocal +mass of the retained supply products. The scale exponent is absolute. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma indexed_rescaled_prefix_bound {α : Type*} [Fintype α] + (u : α → ℕ) (F : α → ℕ → ℂ) (X : ℕ) (E : ℝ) + (hX : 0 < X) (hE : 0 ≤ E) (hu : ∀ a, 0 < u a) + (hF : ∀ a, ‖positivePrefix (F a) (X / u a) / ((X / u a : ℕ) : ℂ)‖ ≤ E) : + ‖(∑ a, positivePrefix (F a) (X / u a)) / (X : ℂ)‖ ≤ + E * ∑ a, 1 / (u a : ℝ) := by + have hXp : (0 : ℝ) < X := by exact_mod_cast hX + rw [sum_div] + calc + _ ≤ ∑ a, ‖positivePrefix (F a) (X / u a) / (X : ℂ)‖ := norm_sum_le _ _ + _ ≤ ∑ a, E * (1 / (u a : ℝ)) := by + apply sum_le_sum + intro a _ + have hup : (0 : ℝ) < u a := by exact_mod_cast hu a + have hb := prefix_norm_of_average_bound (F a) (X / u a) E (hF a) + have hratio : ((X / u a : ℕ) : ℝ) ≤ (X : ℝ) / u a := Nat.cast_div_le + have hp := hb.trans (mul_le_mul_of_nonneg_right hratio hE) + rw [norm_div, Complex.norm_natCast] + calc + _ ≤ (((X : ℝ) / u a) * E) / X := div_le_div_of_nonneg_right hp hXp.le + _ = _ := by field_simp + _ = _ := by rw [mul_sum] + +lemma retained_tuple_reciprocal_sum {J : ℕ} (P : Fin J → Finset ℕ) + (I : Finset (Fin J)) (q : ℕ) : + (∑ y : (j : {j // j ∉ I}) → P j, + 1 / ((q : ℝ) * ∏ j, ((y j).val : ℝ))) = + (1 / (q : ℝ)) * ∏ j : {j // j ∉ I}, primeHarmonicMass (P j) := by + calc + _ = (1 / (q : ℝ)) * + ∑ y : (j : {j // j ∉ I}) → P j, ∏ j, ((y j).val : ℝ)⁻¹ := by + rw [mul_sum] + apply sum_congr rfl + intro y _ + simp only [one_div, mul_inv_rev, prod_inv_distrib] + ring + _ = _ := by + congr 1 + exact (Fintype.prod_sum (fun j : {j // j ∉ I} => + fun p : P j => (p.val : ℝ)⁻¹)).symm + +theorem quantitative_partial_tuple_bin (hM : PrimeReciprocalInput) + (hMRT : MRTLiouvilleShortInput) (h : ℕ) (hh : 0 < h) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, + ∀ (J : ℕ) (P : Fin J → Finset ℕ), + (∀ j, ∀ p ∈ P j, p.Prime) → + (∀ j k, k ≠ j → Disjoint (P j) (P k)) → + ∀ (I : Finset (Fin J)) (q X l : ℕ) [NeZero l], + 0 < q → 0 < X → + ∀ (eligible : ℕ → ℕ → Prop) (b : ZMod l) (M : ℝ) (τ : ℝ), + 0 < τ → τ < 2 → + (∀ y : (j : {j // j ∉ I}) → P j, + IsUnit ((q * ∏ j, (y j).val : ℕ) : ZMod l)) → + (∀ y : (j : {j // j ∉ I}) → P j, + Real.exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ)) ≤ + ((X / (q * ∏ j, (y j).val) : ℕ) : ℝ)) → + (∀ y : (j : {j // j ∉ I}) → P j, ∀ z ∈ primeTupleSlice P I, + eligible ((∏ j, (y j).val) * z) q → + M / (q * ∏ j, ((y j).val : ℝ)) ≤ (z : ℝ) ∧ + (z : ℝ) ≤ τ * (M / (q * ∏ j, ((y j).val : ℝ))) ∧ + Real.exp (L ^ (199 / 200 : ℝ)) ≤ (z : ℝ) ∧ + (z : ℝ) ≤ Real.exp (2 * L) ∧ + avoidsPrimeSet (sievePrimesUpTo (Real.exp (L ^ (99 / 100 : ℝ)))) z) → + ‖positivePrefix (tuplePartialProfile P I q eligible l b h) X / (X : ℂ)‖ ≤ + ((l : ℝ) * C * L ^ (-21 / 20 : ℝ)) * + ((1 / (q : ℝ)) * ∏ j : {j // j ∉ I}, primeHarmonicMass (P j)) := by + obtain ⟨C, hC, hb⟩ := quantitative_residue_bin hM hMRT h hh + refine ⟨C, hC, ?_⟩ + filter_upwards [hb, eventually_ge_atTop (1 : ℝ)] with L hb hL + intro J P hp hd I q X l _ hq hX eligible b M τ hτ hτtwo hunit hY hZ + rw [tuplePartialProfile_prefix P hp hd I q hq eligible l b h X hunit] + have hu (y : (j : {j // j ∉ I}) → P j) : 0 < q * ∏ j, (y j).val := + Nat.mul_pos hq (prod_pos fun j _ => (hp j _ (y j).property).pos) + have he := indexed_rescaled_prefix_bound + (fun y : (j : {j // j ∉ I}) → P j => q * ∏ j, (y j).val) + (fun y => residueScaledRoughProfile l b + ((primeTupleSlice P I).filter (fun z => eligible ((∏ j, (y j).val) * z) q)) h) + X ((l : ℝ) * C * L ^ (-21 / 20 : ℝ)) hX (by positivity) hu + (fun y => hb _ l (hY y) b (M / (q * ∏ j, ((y j).val : ℝ))) τ hτ hτtwo _ + (fun z hz => hZ y z (mem_filter.mp hz).1 (mem_filter.mp hz).2)) + simpa only [Nat.cast_mul, Nat.cast_prod, retained_tuple_reciprocal_sum] using he + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QuotientLines.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuotientLines.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c85ac3d0adf9e939a464dc2eab413d30c9c29b7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuotientLines.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.TwoPoint.Bounds.LinearPivots +import Mathlib.LinearAlgebra.Dimension.Constructions +import Mathlib.LinearAlgebra.Dimension.DivisionRing + +namespace OAI + +/-! +# Quotient coordinates in the forest code + +The quotient keeps a basis chosen from the original coordinate directions. +Failure to extend an independent family by a direction and a departure +difference forces that difference onto the corresponding quotient line. +-/ + +namespace TwoPointCorrelations + +open Finset Submodule + +variable {K ι κ V : Type*} [Field K] [AddCommGroup V] [Module K V] + +/-- The exact maximality consequence used for a regular label. -/ +theorem quotient_line_of_nonextendable_pair (v : κ → V) (hv : LinearIndependent K v) + (x y : V) (hx : (span K (Set.range v)).mkQ x ≠ 0) + (hmax : ¬LinearIndependent K (Sum.elim v ![y, x])) : + ∃ c : K, (span K (Set.range v)).mkQ y = c • (span K (Set.range v)).mkQ x := by + classical + let D := span K (Set.range v) + let vlift : κ → D := fun i => ⟨v i, subset_span ⟨i, rfl⟩⟩ + have hvlift : LinearIndependent K vlift := by + apply LinearIndependent.of_comp D.subtype + exact hv + have hq : ¬LinearIndependent K (D.mkQ ∘ ![y, x]) := by + intro h + apply hmax + exact hvlift.sumElim_of_quotient ![y, x] h + have heq : ∃ c : K, c • D.mkQ x = D.mkQ y := by + by_contra! hc + apply hq + apply linearIndependent_fin2.mpr + exact ⟨hx, hc⟩ + obtain ⟨c, hc⟩ := heq + exact ⟨c, hc.symm⟩ + +/-- All designated departures for a regular label lie on one quotient line. -/ +theorem quotient_departures_on_line (v : κ → V) (hv : LinearIndependent K v) + (direction : V) (departure : ι → V) (base : ι) + (hx : (span K (Set.range v)).mkQ direction ≠ 0) + (hmax : ∀ i, ¬LinearIndependent K + (Sum.elim v ![departure i - departure base, direction])) : + ∀ i, ∃ c : K, (span K (Set.range v)).mkQ (departure i) = + (span K (Set.range v)).mkQ (departure base) + + c • (span K (Set.range v)).mkQ direction := by + intro i + obtain ⟨c, hc⟩ := quotient_line_of_nonextendable_pair v hv direction + (departure i - departure base) hx (hmax i) + refine ⟨c, ?_⟩ + rw [map_sub] at hc + exact sub_eq_iff_eq_add'.mp hc + +/-- A coordinate basis survives the quotient after exactly `dim D` labels +are omitted. This fixes the count, even when the subspace is not spanned by +coordinate vectors. -/ +theorem exists_coordinate_quotient_basis [Fintype ι] [DecidableEq ι] + (D : Submodule K (ι → K)) : + ∃ S : Finset ι, Sᶜ.card = Module.finrank K D ∧ + LinearIndependent K (fun i : S => D.mkQ (Pi.basisFun K ι i)) ∧ + span K (Set.range (fun i : S => D.mkQ (Pi.basisFun K ι i))) = ⊤ := by + classical + let v : ι → ((ι → K) ⧸ D) := fun i => D.mkQ (Pi.basisFun K ι i) + have hv : span K (Set.range v) = ⊤ := by + change span K (Set.range (D.mkQ ∘ Pi.basisFun K ι)) = ⊤ + rw [Set.range_comp, ← Submodule.map_span, (Pi.basisFun K ι).span_eq, + Submodule.map_top, LinearMap.range_eq_top.mpr D.mkQ_surjective] + obtain ⟨η, a, ha, hspan, hind⟩ := exists_linearIndependent' K v + let : Finite η := Finite.of_injective a ha + let : Fintype η := Fintype.ofFinite η + let b : Module.Basis η K ((ι → K) ⧸ D) := Module.Basis.mk hind (by rw [hspan, hv]) + let S : Finset ι := univ.image a + let e : η ≃ S := Equiv.ofBijective (fun j => ⟨a j, mem_image.mpr ⟨j, mem_univ _, rfl⟩⟩) + ⟨fun j k h => ha (congrArg Subtype.val h), by + intro i + obtain ⟨j, _, hj⟩ := mem_image.mp i.property + exact ⟨j, Subtype.ext hj⟩⟩ + let bs := b.reindex e + have hbs (i : S) : bs i = v i := by + rw [show bs = b.reindex e from rfl, Module.Basis.reindex_apply] + simp only [b, Module.Basis.mk_apply, Function.comp_apply] + have hi : a (e.symm i) = i := congrArg Subtype.val (e.apply_symm_apply i) + rw [hi] + have heq : (bs : S → ((ι → K) ⧸ D)) = (fun i : S => D.mkQ (Pi.basisFun K ι i)) := + funext hbs + have hcard : S.card = Module.finrank K ((ι → K) ⧸ D) := by + simpa only [Fintype.card_coe] using (Module.finrank_eq_card_basis bs).symm + have hdim := D.finrank_quotient_add_finrank + rw [Module.finrank_pi] at hdim + refine ⟨S, ?_, ?_, ?_⟩ + · rw [card_compl, hcard] + omega + · rw [← heq] + exact bs.linearIndependent + · rw [← heq] + exact bs.span_eq + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QuotientPathNumbering.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuotientPathNumbering.lean new file mode 100644 index 0000000000000000000000000000000000000000..ffd4e45e334f19371d121582c0fc00ab2626cd68 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuotientPathNumbering.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.TwoPoint.Walks.IndexedQuotientPaths +import OAI.NumberTheory.TwoPoint.Bounds.FiniteWalkNumbering + +namespace OAI + +/-! One bounded numbering for the regular lines in all actual quotient paths. -/ + +namespace TwoPointCorrelations + +open Finset SimpleGraph + +private theorem inl_mem_incidenceVertices {ι V : Type*} (i j : ι) (steps : List (V × ι)) : + Sum.inl j ∈ incidenceVertices i steps ↔ j ∈ i :: steps.map Prod.snd := by + induction steps generalizing i with + | nil => simp [incidenceVertices] + | cons step rest ih => + rcases step with ⟨x, k⟩ + simp [incidenceVertices, ih] + +variable {K α ι : Type*} [Field K] [Fintype α] [DecidableEq ι] + +/-- The same forest numbering is used for every regular segment. Equal line +numbers therefore identify exactly equal regular labels across all blocks. -/ +theorem quotient_run_family_numbering {S N : ℕ} + (D : Submodule K (α → K)) (anchor : ι → (α → K) ⧸ D) + (regularLabel : ι → α) (label : ℕ → α) (coefficient : ℕ → K) + (hind : LinearIndependent K (fun j => D.mkQ (Pi.basisFun K α (regularLabel j)))) + (start : Fin S → ℕ) (first : Fin S → ι) (steps : Fin S → List (ℕ × ι)) + (hstart : ∀ i, ∃ c : K, D.mkQ (formalDeparture label coefficient (start i)) = + anchor (first i) + c • D.mkQ (Pi.basisFun K α (regularLabel (first i)))) + (hdata : ∀ i, QuotientRunData D anchor regularLabel label coefficient (start i) (first i) (steps i)) + (hsize : (∑ i, (2 * (steps i).length + 1)) ≤ N) : + ∃ (number : ι → ℕ) (code : ForestPathData.Code N S), + (∀ i j, j ∈ first i :: (steps i).map Prod.snd → number j < N) ∧ + (∀ i j, j ∈ first i :: (steps i).map Prod.snd → + ∀ k l, l ∈ first k :: (steps k).map Prod.snd → number j = number l → j = l) ∧ + ∀ i, evenEntries (decodeForestPaths code i) = + (first i :: (steps i).map Prod.snd).map number := by + classical + let direction := fun j => D.mkQ (Pi.basisFun K α (regularLabel j)) + let G := affineIncidenceGraph (K := K) anchor direction + let vertices := fun i => incidenceVertices (first i) (quotientRunSteps D label coefficient (steps i)) + have hne : ∀ i, vertices i ≠ [] := fun i => incidenceVertices_ne_nil _ _ + have hchain : ∀ i, (vertices i).IsChain G.Adj := fun i => + incidenceVertices_isChain anchor direction (first i) _ + (quotientRunData_incidenceChain D anchor regularLabel label coefficient + (start i) (first i) (steps i) (hstart i) (hdata i)) + let starts := fun i => (vertices i).head (hne i) + let finishes := fun i => (vertices i).getLast (hne i) + let walk : ∀ i, G.Walk (starts i) (finishes i) := fun i => + Walk.ofSupport (vertices i) (hne i) (hchain i) + have hsupport (i : Fin S) : (walk i).support = vertices i := + Walk.support_ofSupport (G := G) (hne i) (hchain i) + have hG : G.IsAcyclic := affineIncidenceGraph_isAcyclic anchor direction hind + have hred : ∀ i, List.IsChain (· ≠ ·) (walk i).edges := by + intro i + apply (hG.isPath_iff_isChain _).mp + exact quotientRunData_simple D anchor regularLabel label coefficient hind + (start i) (first i) (steps i) (hstart i) (hdata i) + have hsize' : (∑ i, (walk i).support.length) ≤ N := by + simp_rw [hsupport] + simpa only [vertices, incidenceVertices_length, quotientRunSteps, List.length_map] using hsize + obtain ⟨number, code, hinj, hbound, hdecode⟩ := + finite_walk_family_numbering starts finishes walk hG hred hsize' + (Sum.elim (fun _ => true) (fun _ => false)) + have hmem : ∀ i j, j ∈ first i :: (steps i).map Prod.snd → + Sum.inl j ∈ walkFamilySupport starts finishes walk := by + intro i j hj + apply mem_walkFamilySupport starts finishes walk i + rw [hsupport] + apply (inl_mem_incidenceVertices _ _ _).mpr + simpa only [quotientRunSteps, List.map_map, Function.comp_def] using hj + refine ⟨fun j => number (.inl j), code, ?_, ?_, ?_⟩ + · intro i j hj + exact hbound _ (hmem i j hj) + · intro i j hj k l hl heq + exact Sum.inl.inj (hinj (hmem i j hj) (hmem k l hl) heq) + · intro i + rw [hdecode] + rw [hsupport] + rw [evenEntries_incidenceVertices] + simp only [quotientRunSteps, List.map_map, Function.comp_def] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/QuotientRunPaths.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuotientRunPaths.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4068aa09d27e4bc8f8ea6ce37b6d62cb9b5cb24 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/QuotientRunPaths.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FormalDepartures +import OAI.NumberTheory.TwoPoint.Walks.IncidenceDecoding + +namespace OAI + +/-! Constant perfect runs give the concrete reduced paths used by column coding. -/ + +namespace TwoPointCorrelations + +open Finset SimpleGraph + +variable {K α ι : Type*} [Field K] [Fintype α] + +/-- Each transition ends a nonzero constant run and starts the next regular +label on its common quotient line. These are local conditions on departures. -/ +def QuotientRunData (D : Submodule K (α → K)) + (anchor : ι → (α → K) ⧸ D) (regularLabel : ι → α) + (label : ℕ → α) (coefficient : ℕ → K) (a : ℕ) (i : ι) : + List (ℕ × ι) → Prop + | [] => True + | (b, j) :: rest => + a ≤ b ∧ (∀ t ∈ Ico a b, label t = regularLabel i) ∧ + (∑ t ∈ Ico a b, coefficient t) ≠ 0 ∧ i ≠ j ∧ + (∃ c : K, D.mkQ (formalDeparture label coefficient b) = anchor j + + c • D.mkQ (Pi.basisFun K α (regularLabel j))) ∧ + QuotientRunData D anchor regularLabel label coefficient b j rest + +noncomputable def quotientRunSteps (D : Submodule K (α → K)) (label : ℕ → α) + (coefficient : ℕ → K) (steps : List (ℕ × ι)) : List (((α → K) ⧸ D) × ι) := + steps.map (fun p => (D.mkQ (formalDeparture label coefficient p.1), p.2)) + +/-- Both adjacent lines contain the exact common departure at a transition. -/ +theorem quotientRunData_incidenceChain (D : Submodule K (α → K)) + (anchor : ι → (α → K) ⧸ D) (regularLabel : ι → α) + (label : ℕ → α) (coefficient : ℕ → K) (a : ℕ) (i : ι) (steps : List (ℕ × ι)) + (hstart : ∃ c : K, D.mkQ (formalDeparture label coefficient a) = anchor i + + c • D.mkQ (Pi.basisFun K α (regularLabel i))) + (hdata : QuotientRunData D anchor regularLabel label coefficient a i steps) : + IncidenceChain (K := K) anchor (fun j => D.mkQ (Pi.basisFun K α (regularLabel j))) i + (quotientRunSteps D label coefficient steps) := by + induction steps generalizing a i with + | nil => trivial + | cons step rest ih => + rcases step with ⟨b, j⟩ + rcases hdata with ⟨hab, hconst, _, _, hnext, hrest⟩ + refine ⟨?_, hnext, ih b j hnext hrest⟩ + exact affine_line_successor _ _ _ _ hstart _ + (quotient_departure_const_run D label coefficient a b hab (regularLabel i) hconst) + +/-- Nonzero numerical runs prohibit point--line--point reversal; distinct +adjacent run labels prohibit line--point--line reversal. -/ +theorem quotientRunData_reduced (D : Submodule K (α → K)) + (anchor : ι → (α → K) ⧸ D) (regularLabel : ι → α) + (label : ℕ → α) (coefficient : ℕ → K) + (hdir : ∀ j, D.mkQ (Pi.basisFun K α (regularLabel j)) ≠ 0) + (a : ℕ) (i : ι) (steps : List (ℕ × ι)) + (hdata : QuotientRunData D anchor regularLabel label coefficient a i steps) : + IncidenceReduced i (quotientRunSteps D label coefficient steps) := by + induction steps generalizing a i with + | nil => trivial + | cons step rest ih => + rcases step with ⟨b, j⟩ + rcases hdata with ⟨_, _, _, hij, _, hrest⟩ + refine ⟨hij, ?_, ih b j hrest⟩ + intro y k hhead + cases rest with + | nil => simp at hhead + | cons step rest => + rcases step with ⟨c, l⟩ + simp only [List.map_cons, List.head?_cons, Option.some.injEq, + Prod.mk.injEq] at hhead + rcases hhead with ⟨rfl, rfl⟩ + rcases hrest with ⟨hbc, hconst, hnonzero, _, _, _⟩ + exact quotient_run_endpoints_ne D label coefficient b c hbc (regularLabel j) + hconst (hdir j) hnonzero + +/-- The path support consists of exactly the canonical regular run lines +alternating with their actual transition departures. -/ +theorem quotientRunData_simple (D : Submodule K (α → K)) + (anchor : ι → (α → K) ⧸ D) (regularLabel : ι → α) + (label : ℕ → α) (coefficient : ℕ → K) + (hind : LinearIndependent K (fun j => D.mkQ (Pi.basisFun K α (regularLabel j)))) + (a : ℕ) (i : ι) (steps : List (ℕ × ι)) + (hstart : ∃ c : K, D.mkQ (formalDeparture label coefficient a) = anchor i + + c • D.mkQ (Pi.basisFun K α (regularLabel i))) + (hdata : QuotientRunData D anchor regularLabel label coefficient a i steps) : + (Walk.ofSupport (incidenceVertices i (quotientRunSteps D label coefficient steps)) + (incidenceVertices_ne_nil _ _) + (incidenceVertices_isChain anchor _ _ _ + (quotientRunData_incidenceChain D anchor regularLabel label coefficient a i steps hstart hdata))).IsPath := by + exact incidence_vertices_simple anchor _ hind i _ + (quotientRunData_incidenceChain D anchor regularLabel label coefficient a i steps hstart hdata) + (quotientRunData_reduced D anchor regularLabel label coefficient + (fun j => hind.ne_zero j) a i steps hdata) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RandomPrimeRank.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RandomPrimeRank.lean new file mode 100644 index 0000000000000000000000000000000000000000..c9f911dcd198a5b8c2692b78115a08f35016e7d5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RandomPrimeRank.lean @@ -0,0 +1,123 @@ +import OAI.NumberTheory.TwoPoint.Walks.RankProbability +import OAI.NumberTheory.TwoPoint.Bounds.ZeroRows +import Mathlib.Analysis.SpecialFunctions.Sqrt + +namespace OAI + +/-! The finite random-prime rank estimate, manuscript `q:rank-probability`. -/ + +namespace TwoPointCorrelations + +open Finset Matrix + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def primeDifference (P : Finset ℕ) (B : Matrix ι ι ℤ) + (y z : ι → P) : ι → ℤ := + B *ᵥ ((fun j => ((y j).val : ℤ)) - (fun j => ((z j).val : ℤ))) + +lemma average_probability_comm {A C : Type*} [Fintype A] [Fintype C] + (μ : FiniteLaw A) (ν : FiniteLaw C) (E : A → C → Prop) : + μ.average (fun x => ν.probability (E x)) = + ν.average (fun y => μ.probability (fun x => E x y)) := by + simp only [FiniteLaw.probability, FiniteLaw.average, mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro y _ + apply sum_congr rfl + intro x _ + ring + +theorem random_prime_rank_squared + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (μ : FiniteLaw P) + (B : Matrix ι ι ℤ) (hB : B.det ≠ 0) (f : (ι → P) → ι → ℤ) + (M : ℕ) (α : ℝ) (hα : 0 ≤ α) (hatom : ∀ p, μ.weight p ≤ α) + (hsize : ∀ y z : ι → P, ∀ i, (primeDifference P B y z i).natAbs ≤ M) : + let ν := FiniteLaw.independent (fun _ : ι => μ) + (ν.average (fun c => ν.probability (fun y => + ∀ i, ((c i).val : ℤ) ∣ (B *ᵥ (fun j => ((y j).val : ℤ)) + f c) i))) ^ 2 ≤ + (α * (1 + (Nat.log 2 M : ℝ))) ^ Fintype.card ι := by + classical + dsimp only + let ν := FiniteLaw.independent (fun _ : ι => μ) + let E (c y : ι → P) : Prop := + ∀ i, ((c i).val : ℤ) ∣ (B *ᵥ (fun j => ((y j).val : ℤ)) + f c) i + let D (c y z : ι → P) : Prop := ∀ i, ((c i).val : ℤ) ∣ primeDifference P B y z i + have hd (c y z : ι → P) (hy : E c y) (hz : E c z) : D c y z := by + intro i + have h := dvd_sub (hy i) (hz i) + simpa only [Pi.add_apply, add_sub_add_right_eq_sub, primeDifference, Matrix.mulVec_sub, + Pi.sub_apply] using h + have hs := FiniteLaw.two_sample_bound ν ν E D hd + have hreorder : ν.average (fun c => ν.average (fun y => ν.probability (D c y))) = + (ν.product ν).average (fun yz => ν.probability (fun c => D c yz.1 yz.2)) := by + rw [FiniteLaw.average_product, ν.average_comm] + apply congrArg (ν.average) + funext y + exact average_probability_comm ν ν (fun c z => D c y z) + rw [hreorder] at hs + let β := α * (Nat.log 2 M : ℝ) + have hβ : 0 ≤ β := mul_nonneg hα (Nat.cast_nonneg _) + have hcontrols (y z : ι → P) : + ν.probability (fun c => D c y z) ≤ + ∏ i, if primeDifference P B y z i = 0 then (1 : ℝ) else β := by + rw [show ν.probability (fun c => D c y z) = + ∏ i, μ.probability (fun p => (p.val : ℤ) ∣ primeDifference P B y z i) from + FiniteLaw.independent_probability_all (fun _ : ι => μ) + (fun i p => (p.val : ℤ) ∣ primeDifference P B y z i)] + apply prod_le_prod₀ + · intro i _ + exact μ.probability_nonneg _ + · intro i _ + by_cases hi : primeDifference P B y z i = 0 + · simp [hi, FiniteLaw.probability] + · rw [ite_eq_right hi] + apply (FiniteLaw.prime_divisibility_probability P hP μ α hα hatom _ hi).trans + exact mul_le_mul_of_nonneg_left (by exact_mod_cast Nat.log_mono_right (hsize y z i)) hα + have hzero (S : Finset ι) : + (ν.product ν).average (fun yz => + ∏ i ∈ S, if primeDifference P B yz.1 yz.2 i = 0 then (1 : ℝ) else 0) ≤ α ^ S.card := by + rw [FiniteLaw.average_product, ν.average_comm] + apply (ν.average_mono (g := fun _ => α ^ S.card) ?_).trans_eq (ν.average_const _) + intro z + have heq : ν.average (fun x => + ∏ i ∈ S, if primeDifference P B x z i = 0 then (1 : ℝ) else 0) = + ν.probability (fun x => ∀ i ∈ S, primeDifference P B x z i = 0) := by + unfold FiniteLaw.probability + apply congrArg ν.average + funext x + by_cases hx : ∀ i ∈ S, primeDifference P B x z i = 0 <;> + simp [Finset.prod_boole, hx] + rw [heq] + have hv : Function.Injective (fun p : P => (p.val : ℤ)) := by + intro p q hpq + apply Subtype.ext + exact Int.ofNat_inj.mp hpq + exact FiniteLaw.zero_rows_probability (fun _ : ι => μ) + (fun p : P => (p.val : ℤ)) hv + B hB S z α hα (fun _ => hatom) + calc + _ ≤ (ν.product ν).average (fun yz => ν.probability (fun c => D c yz.1 yz.2)) := hs + _ ≤ (ν.product ν).average (fun yz => + ∏ i, if primeDifference P B yz.1 yz.2 i = 0 then (1 : ℝ) else β) := + (ν.product ν).average_mono (fun yz => hcontrols yz.1 yz.2) + _ ≤ (α + β) ^ Fintype.card ι := + FiniteLaw.zero_set_product_bound (ν.product ν) (fun yz => primeDifference P B yz.1 yz.2) + α β hβ hzero + _ = _ := by congr 1; dsimp [β]; ring + +/-- The square-root form of the rank bound. -/ +theorem random_prime_rank_bound + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (μ : FiniteLaw P) + (B : Matrix ι ι ℤ) (hB : B.det ≠ 0) (f : (ι → P) → ι → ℤ) + (M : ℕ) (α : ℝ) (hα : 0 ≤ α) (hatom : ∀ p, μ.weight p ≤ α) + (hsize : ∀ y z : ι → P, ∀ i, (primeDifference P B y z i).natAbs ≤ M) : + let ν := FiniteLaw.independent (fun _ : ι => μ) + ν.average (fun c => ν.probability (fun y => + ∀ i, ((c i).val : ℤ) ∣ (B *ᵥ (fun j => ((y j).val : ℤ)) + f c) i)) ≤ + Real.sqrt ((α * (1 + (Nat.log 2 M : ℝ))) ^ Fintype.card ι) := by + exact Real.le_sqrt_of_sq_le (random_prime_rank_squared P hP μ B hB f M α hα hatom hsize) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RareRowDecay.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RareRowDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..dfad325e40a188de10ad50260c2275b2d544efe9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RareRowDecay.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeRowMomentScale + +namespace OAI + +/-! Polynomially many rare-site row costs are absorbed by the +stretched-exponential forbidden-site probability. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma eventually_rare_row_exponent (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, + (2 * C + 25) * Real.log L + 2 * L ^ (9 / 10 : ℝ) ≤ + (1 / 2 : ℝ) * L ^ (199 / 200 : ℝ) := by + have hlog := (isLittleO_log_rpow_atTop (show 0 < (199 / 200 : ℝ) by norm_num)).bound + (show 0 < 1 / (8 * (2 * C + 26)) by positivity) + have hpower := (tendsto_rpow_atTop (y := (19 / 200 : ℝ)) (by norm_num)).eventually + (eventually_ge_atTop (8 : ℝ)) + filter_upwards [hlog, hpower, eventually_ge_atTop (1 : ℝ)] with L hl hp hL + have hLp : 0 < L := zero_lt_one.trans_le hL + have hln : 0 ≤ Real.log L := Real.log_nonneg hL + have hR : 0 ≤ L ^ (199 / 200 : ℝ) := Real.rpow_nonneg hLp.le _ + rw [Real.norm_eq_abs, abs_of_nonneg hln, Real.norm_eq_abs, abs_of_nonneg hR] at hl + have hc : (2 * C + 25) * Real.log L ≤ (1 / 8 : ℝ) * L ^ (199 / 200 : ℝ) := by + calc + _ ≤ (2 * C + 26) * Real.log L := by nlinarith + _ ≤ (2 * C + 26) * ((1 / (8 * (2 * C + 26))) * L ^ (199 / 200 : ℝ)) := + mul_le_mul_of_nonneg_left hl (by positivity) + _ = _ := by field_simp + have hh := mul_le_mul_of_nonneg_left hp (Real.rpow_nonneg hLp.le (9 / 10 : ℝ)) + have he : L ^ (9 / 10 : ℝ) * L ^ (19 / 200 : ℝ) = L ^ (199 / 200 : ℝ) := by + rw [← Real.rpow_add hLp] + norm_num + rw [he] at hh + nlinarith + +theorem eventually_rare_row_decay (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ A x : ℝ, 0 ≤ A → 0 ≤ x → + A ≤ Real.exp (C * Real.log L) → + x ^ 2 ≤ L ^ (25 : ℕ) * Real.exp (-(1 / 2 : ℝ) * L ^ (199 / 200 : ℝ)) → + A * x ≤ Real.exp (-L ^ (9 / 10 : ℝ)) := by + filter_upwards [eventually_rare_row_exponent C hC, eventually_ge_atTop (1 : ℝ)] + with L hscale hL + intro A x hA hx hAbound hxbound + have hLp : 0 < L := zero_lt_one.trans_le hL + have hA2 := pow_le_pow_left₀ hA hAbound 2 + have hh := mul_le_mul hA2 hxbound (sq_nonneg x) + (sq_nonneg (Real.exp (C * Real.log L))) + have hL25 : Real.exp ((25 : ℕ) * Real.log L) = L ^ (25 : ℕ) := by + rw [Real.exp_nat_mul, Real.exp_log hLp] + have he : (Real.exp (C * Real.log L)) ^ 2 * + (L ^ (25 : ℕ) * Real.exp (-(1 / 2 : ℝ) * L ^ (199 / 200 : ℝ))) = + Real.exp ((2 * C + 25) * Real.log L - + (1 / 2 : ℝ) * L ^ (199 / 200 : ℝ)) := by + rw [← Real.exp_nat_mul, ← hL25, ← Real.exp_add, ← Real.exp_add] + congr 1 + ring + rw [he] at hh + have hexp := Real.exp_le_exp.mpr + (show (2 * C + 25) * Real.log L - (1 / 2 : ℝ) * L ^ (199 / 200 : ℝ) ≤ + -(2 * L ^ (9 / 10 : ℝ)) by linarith) + have hsq : (A * x) ^ 2 ≤ (Real.exp (-L ^ (9 / 10 : ℝ))) ^ 2 := by + calc + _ = A ^ 2 * x ^ 2 := mul_pow _ _ _ + _ ≤ Real.exp ((2 * C + 25) * Real.log L - + (1 / 2 : ℝ) * L ^ (199 / 200 : ℝ)) := hh + _ ≤ Real.exp (-(2 * L ^ (9 / 10 : ℝ))) := hexp + _ = _ := by rw [← Real.exp_nat_mul]; congr 1; ring + have hAx : 0 ≤ A * x := mul_nonneg hA hx + have hpos := Real.exp_pos (-L ^ (9 / 10 : ℝ)) + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RareRowSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RareRowSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd426b18ba9506a6a5fb06d99ff3c79ec63afe72 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RareRowSum.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ActualRareRow +import OAI.NumberTheory.TwoPoint.Bounds.PositiveRowMajorant + +namespace OAI + +/-! Sum the rare-site estimate over the polynomially many bins. The +row bound is applied in the product model before integer transfer. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma positive_rare_row_bound {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (Q D : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) (hD : D ⊆ primeTupleDivisors P) + (padding : ℕ → Finset ℕ) (hpadding : ∀ d ∈ D, padding d ⊆ retainedPrimeDivisors Q) + (n : ℤ) (bad : Prop) : + (∑ d ∈ D, ∑ q ∈ padding d, + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors n * + if (q : ℤ) ∣ n ∧ bad then 1 else 0) ≤ + primeRowMajorant P Q n * if bad then 1 else 0 := by + by_cases hb : bad + · simp only [hb, and_true, ite_true, mul_one] + exact positive_tuple_padding_row_bound P hprime hdisjoint Q D hQ hD padding hpadding n + · simp only [hb, and_false, ite_false, mul_zero, sum_const_zero, le_refl] + +theorem ModFiveThetaInput.eventually_actual_rare_row_sum (hP : ModFiveThetaInput) + (E : Finset ℕ) (W C : ℝ) (hW : 10 ≤ W) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ (h M B : ℕ) + (data : ProhibitedPrimeFamily h (primeSupplyCount W L) M), + data.P = centeredPrimePool E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) → + data.Q = paddingPrimeSupply E L → + ∀ (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) (site : ℤ) (bins : Finset ℤ), + (bins.card : ℝ) ≤ Real.exp (C * Real.log L) → + ∀ (bad : ℤ → (↥(data.P ∪ data.Q) → Fin B) → Prop), + (∀ j ∈ bins, (data.residueLaw B hB).probability (bad j) ≤ + Real.exp (-(1 / 2 : ℝ) * L ^ (199 / 200 : ℝ))) → + (∑ j ∈ bins, (data.residueLaw B hB).average (fun x => + primeRowMajorant (centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L)) + data.Q (data.residueOrigin x + site) * if bad j x then 1 else 0)) ≤ + Real.exp (-L ^ (9 / 10 : ℝ)) := by + filter_upwards [hP.eventually_actual_rare_row E W C hW hC] with L hb + intro h M B data hp hq hB site bins hbins bad hbad + by_cases hempty : bins = ∅ + · subst bins + simp only [sum_empty] + exact (Real.exp_pos _).le + have hcard : 0 < (bins.card : ℝ) := by + exact_mod_cast card_pos.mpr (nonempty_iff_ne_empty.mpr hempty) + have hs : (bins.card : ℝ) * + (∑ j ∈ bins, (data.residueLaw B hB).average (fun x => + primeRowMajorant (centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L)) + data.Q (data.residueOrigin x + site) * if bad j x then 1 else 0)) ≤ + (bins.card : ℝ) * Real.exp (-L ^ (9 / 10 : ℝ)) := by + rw [mul_sum] + calc + _ ≤ ∑ _j ∈ bins, Real.exp (-L ^ (9 / 10 : ℝ)) := by + apply sum_le_sum + intro j hj + exact hb h M B data hp hq hB site (bad j) (hbad j hj) bins.card hcard.le hbins + _ = _ := by simp only [sum_const, nsmul_eq_mul] + exact le_of_mul_le_mul_left hs hcard + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RawPairSelection.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RawPairSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e43323a32bd097db9484b650ac15743552b4ba3 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RawPairSelection.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeDefectPhase +import OAI.NumberTheory.TwoPoint.Walks.SelectedRawLowerBound + +namespace OAI + +/-! One selection simultaneously retains raw complex mass and keeps the +coprimality error small. The hypotheses are the actual prime-tail moments. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem select_raw_pair_family {J : ℕ} {f g : ℕ → ℂ} + (hfm : Multiplicative f) (hgm : Multiplicative g) + (hf1 : f 1 = 1) (hg1 : g 1 = 1) (hf : OneBounded f) (hg : OneBounded g) + (P : Fin J → Finset ℕ) (Q : Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (hQ : ∀ p ∈ Q, p.Prime) (hPQ : Disjoint (primeTuplePool P) Q) + (W L η γ : ℝ) (hW : 1 ≤ W) (hη : 0 < η) (hγ : 0 ≤ γ) + (hmass : ∀ j, W ≤ primeHarmonicMass (P j)) + (htotal : paddingTiltNormalizer Q * (∏ j, primeHarmonicMass (P j)) / 2 ≤ + totalPaddingBinMass (primeTupleDivisors P) Q L η) + (hdD : (∑ p ∈ primeTuplePool P, (1 - ‖f p * g p‖) / (p : ℝ)) ≤ 1 / 100) + (hdQ : (∑ p ∈ Q, (1 - ‖f p * g p‖) / (p : ℝ)) ≤ 1 / 100) + (hrD : (∑ p ∈ primeTuplePool P, 1 / (p : ℝ) ^ 2) ≤ γ / 1280) + (hrQ : (∑ p ∈ Q, 1 / (p : ℝ) ^ 2) ≤ γ / 1280) : + ∃ A ⊆ eligibleComplexPairs (primeTupleDivisors P) Q (PaddingPairEligible L η), + totalPaddingBinMass (primeTupleDivisors P) Q L η / 8 ≤ ‖selectedRawCoefficient A f g‖ ∧ + (∑ dq ∈ A, complexPairWeight dq) ≤ totalPaddingBinMass (primeTupleDivisors P) Q L η ∧ + (∑ dq ∈ A, complexPairWeight dq * + ∑ p ∈ (dq.1 * dq.2).primeFactors, 1 / (p : ℝ)) ≤ + γ * totalPaddingBinMass (primeTupleDivisors P) Q L η / 128 := by + have hWp : 0 < W := zero_lt_one.trans_le hW + have hdD0 : 0 ≤ ∑ p ∈ primeTuplePool P, (1 - ‖f p * g p‖) / (p : ℝ) := by + apply sum_nonneg + intro p hp + have hpp := primeTuplePool_prime hprime hp + apply div_nonneg _ (Nat.cast_nonneg p) + rw [norm_mul] + exact sub_nonneg.mpr ((mul_le_mul (hf p hpp.pos) (hg p hpp.pos) + (norm_nonneg _) zero_le_one).trans (by norm_num)) + have hdsmall : (∑ p ∈ primeTuplePool P, (1 - ‖f p * g p‖) / (p : ℝ)) / W + + 4 * (∑ p ∈ Q, (1 - ‖f p * g p‖) / (p : ℝ)) ≤ 1 / 4 := by + have hdiv := div_le_self hdD0 hW + linarith + obtain ⟨A, hA, hphase⟩ := exists_pair_phase_of_prime_defect hfm hgm hf1 hg1 hf hg + P Q hprime hdisjoint hQ hPQ W L η hWp hη hmass htotal hdsmall + refine ⟨A, hA, hphase, selected_pair_mass_le _ _ A L η hη hA, ?_⟩ + have hA' : A ⊆ primeTupleDivisors P ×ˢ retainedPrimeDivisors Q := + hA.trans (filter_subset _ _) + have hb := selected_pair_reciprocal_cost_le P Q hprime hdisjoint hQ hPQ W hWp hmass A hA' + have hdiv : (∑ p ∈ primeTuplePool P, 1 / (p : ℝ) ^ 2) / W ≤ γ / 1280 := + (div_le_self (sum_nonneg (fun _ _ => by positivity)) hW).trans hrD + have hsmall : (∑ p ∈ primeTuplePool P, 1 / (p : ℝ) ^ 2) / W + + 4 * (∑ p ∈ Q, 1 / (p : ℝ) ^ 2) ≤ γ / 256 := by linarith + have hV : 0 ≤ paddingTiltNormalizer Q * ∏ j, primeHarmonicMass (P j) := + mul_nonneg (paddingTiltNormalizer_pos Q).le + (prod_nonneg (fun j _ => (hWp.trans_le (hmass j)).le)) + have hs := mul_le_mul_of_nonneg_left hsmall hV + have ht := mul_le_mul_of_nonneg_left htotal hγ + exact hb.trans (hs.trans (by nlinarith)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalColumnRank.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalColumnRank.lean new file mode 100644 index 0000000000000000000000000000000000000000..551380d84ec1f0eba562447d1504a9e5fa5e7772 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalColumnRank.lean @@ -0,0 +1,47 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FixedColumnWords +import OAI.NumberTheory.TwoPoint.Bounds.PrimeReciprocalLaw + +namespace OAI + +/-! The finite positive reciprocal majorant for one high-rank column. -/ + +namespace TwoPointCorrelations.ColumnWordPattern + +open Finset +open scoped Classical + +variable {α ρ : Type*} [Fintype α] [DecidableEq α] [Fintype ρ] [DecidableEq ρ] + +/-- A single reciprocal factor is retained for each abstract label. The +sum permits numerical collisions and is uniform in all fixed other-column +data and the starting point of the word. -/ +theorem reciprocal_high_rank_bound + (w : ColumnWordPattern α) (h Q D B H : ℕ) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (hV : 0 < primeHarmonicMass P) (hH : 0 < H) + (hlo : ∀ p ∈ P, H ≤ p) (hbound : ∀ p ∈ P, p ≤ B) + (hq : ∀ j < w.length, w.padding j ≤ Q) + (hd : ∀ j < w.length, w.otherColumns j ≤ D) + (left right : ρ → ℕ) (control : ρ → α) + (hl : ∀ i, left i ≤ w.length) (hr : ∀ i, right i ≤ w.length) + (hind : LinearIndependent ℝ (Sum.elim + (fun i => formalDeparture w.label (fun j => (w.coefficient h j : ℝ)) (left i) - + formalDeparture w.label (fun j => (w.coefficient h j : ℝ)) (right i)) + (fun i => Pi.basisFun ℝ α (control i)))) + (base : (α → P) → ℤ) (E : (α → P) → Prop) + (hlit : ∀ x, E x → ∀ i, ((x (control i)).val : ℤ) ∣ base x + + wordDisplacement h ((w.word (fun z => (x z).val)).take (left i))) + (hrit : ∀ x, E x → ∀ i, ((x (control i)).val : ℤ) ∣ base x + + wordDisplacement h ((w.word (fun z => (x z).val)).take (right i))) : + (∑ x : α → P, if E x then ∏ z, ((x z).val : ℝ)⁻¹ else 0) ≤ + primeHarmonicMass P ^ Fintype.card α * + Real.sqrt (((primeHarmonicMass P * H)⁻¹ * + (1 + (Nat.log 2 (2 * w.length * (h * Q * D) * B) : ℝ))) ^ Fintype.card ρ) := by + apply primeReciprocalLaw_restore_bound P hV E + exact w.high_rank_event_bound h Q D B P hP (primeReciprocalLaw P hV) + hbound hq hd left right control hl hr hind (primeHarmonicMass P * H)⁻¹ + (by positivity) (primeReciprocalLaw_atom_le P hV H hH hlo) base E hlit hrit + +end TwoPointCorrelations.ColumnWordPattern + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalPaddingLaw.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalPaddingLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..c9a6093a428547122b59f975af02829bed4af3ec --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalPaddingLaw.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingDivisorEncoding +import OAI.NumberTheory.TwoPoint.Bounds.BernoulliTail + +namespace OAI + +/-! The harmonic divisor law `4^omega(q)/(q S)` is an actual finite +independent prime-selection law with inclusion probabilities `4/(p+4)`. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def reciprocalPaddingPrimeLaw (p : ℕ) : FiniteLaw Bool := + booleanLaw (4 / ((p : ℝ) + 4)) (by positivity) (by + apply (div_le_one (by positivity)).mpr + exact le_add_of_nonneg_left (Nat.cast_nonneg p)) + +noncomputable def reciprocalPaddingLaw (Q : Finset ℕ) : FiniteLaw (Q → Bool) := + FiniteLaw.independent (fun p : Q => reciprocalPaddingPrimeLaw p) + +lemma reciprocal_padding_atom (p : ℕ) (hp : 0 < p) (b : Bool) : + (reciprocalPaddingPrimeLaw p).weight b * (1 + 4 / (p : ℝ)) = + if b then 4 / (p : ℝ) else 1 := by + have hp0 : (p : ℝ) ≠ 0 := by exact_mod_cast hp.ne' + have hp4 : (p : ℝ) + 4 ≠ 0 := by positivity + cases b <;> simp only [reciprocalPaddingPrimeLaw, booleanLaw, Bool.false_eq_true, ↓reduceIte] + all_goals field_simp <;> ring + +lemma paddingSelectedDivisor_cast (Q : Finset ℕ) (b : Q → Bool) : + (paddingSelectedDivisor Q b : ℝ) = ∏ p : Q, if b p then (p.val : ℝ) else 1 := by + rw [paddingSelectedDivisor, Nat.cast_prod] + simp only [selectedCoordinates, prod_filter] + +lemma reciprocal_padding_weight (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) (b : Q → Bool) : + (reciprocalPaddingLaw Q).weight b * paddingTiltNormalizer Q = + paddingDivisorCoefficient Q b / (paddingSelectedDivisor Q b : ℝ) := by + simp only [reciprocalPaddingLaw, FiniteLaw.independent, paddingTiltNormalizer, + ← prod_mul_distrib] + rw [paddingDivisorCoefficient, paddingSelectedDivisor_cast, ← prod_div_distrib] + apply prod_congr rfl + intro p _ + rw [reciprocal_padding_atom p (hQ p p.property).pos] + cases b p <;> simp + +lemma reciprocal_padding_average (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) (F : ℕ → ℝ) : + (reciprocalPaddingLaw Q).average (fun b => F (paddingSelectedDivisor Q b)) = + (paddingTiltNormalizer Q)⁻¹ * + ∑ q ∈ retainedPrimeDivisors Q, ((4 : ℝ) ^ q.primeFactors.card / (q : ℝ)) * F q := by + have hS := paddingTiltNormalizer_pos Q + let G (q : retainedPrimeDivisors Q) : ℝ := + ((4 : ℝ) ^ q.val.primeFactors.card / (q.val : ℝ)) * F q.val + have hatom (b : Q → Bool) : + (reciprocalPaddingLaw Q).weight b * F (paddingSelectedDivisor Q b) = + (paddingTiltNormalizer Q)⁻¹ * G (paddingDivisorEquiv Q hQ b) := by + have hw := reciprocal_padding_weight Q hQ b + change _ = (paddingTiltNormalizer Q)⁻¹ * + ((4 : ℝ) ^ (paddingSelectedDivisor Q b).primeFactors.card / + (paddingSelectedDivisor Q b : ℝ) * F (paddingSelectedDivisor Q b)) + rw [paddingSelectedDivisor_primeFactors Q hQ b, paddingAvailablePrimes_card, + ← paddingDivisorCoefficient_eq_four_pow] + calc + _ = (paddingTiltNormalizer Q)⁻¹ * + (((reciprocalPaddingLaw Q).weight b * paddingTiltNormalizer Q) * + F (paddingSelectedDivisor Q b)) := by field_simp [hS.ne'] + _ = _ := by rw [hw] + unfold FiniteLaw.average + simp_rw [hatom] + rw [← mul_sum, (paddingDivisorEquiv Q hQ).sum_comp G] + congr 1 + exact sum_coe_sort (retainedPrimeDivisors Q) + (fun q : ℕ => ((4 : ℝ) ^ q.primeFactors.card / (q : ℝ)) * F q) + +lemma FiniteLaw.independent_average_coordinate {ι A : Type*} [Fintype ι] [DecidableEq ι] + [Fintype A] (μ : ι → FiniteLaw A) (i : ι) (f : A → ℝ) : + (FiniteLaw.independent μ).average (fun x => f (x i)) = (μ i).average f := by + have hh := FiniteLaw.independent_average_product μ (fun j x => if j = i then f x else 1) + have he (j : ι) : (μ j).average (fun x => if j = i then f x else 1) = + if j = i then (μ i).average f else 1 := by + by_cases hj : j = i + · subst j + simp + · simp [hj] + simpa only [he, prod_ite_eq', mem_univ, ite_true] using hh + +lemma reciprocal_padding_count_average (Q : Finset ℕ) : + (reciprocalPaddingLaw Q).average booleanCount = ∑ p : Q, 4 / ((p.val : ℝ) + 4) := by + change (FiniteLaw.independent (fun p : Q => reciprocalPaddingPrimeLaw p)).average + (fun b : Q → Bool => ∑ p : Q, if b p then 1 else 0) = _ + rw [FiniteLaw.average_sum] + apply sum_congr rfl + intro p _ + rw [FiniteLaw.independent_average_coordinate (fun p : Q => reciprocalPaddingPrimeLaw p) p + (fun b : Bool => if b then 1 else 0)] + simp [reciprocalPaddingPrimeLaw, booleanLaw, FiniteLaw.average] + +lemma reciprocal_padding_log_average (Q : Finset ℕ) : + (reciprocalPaddingLaw Q).average (paddingLog Q) = + ∑ p : Q, (4 / ((p.val : ℝ) + 4)) * Real.log p.val := by + change (FiniteLaw.independent (fun p : Q => reciprocalPaddingPrimeLaw p)).average + (fun b : Q → Bool => ∑ p : Q, if b p then Real.log p.val else 0) = _ + rw [FiniteLaw.average_sum] + apply sum_congr rfl + intro p _ + rw [FiniteLaw.independent_average_coordinate (fun p : Q => reciprocalPaddingPrimeLaw p) p + (fun b : Bool => if b then Real.log p.val else 0)] + simp [reciprocalPaddingPrimeLaw, booleanLaw, FiniteLaw.average] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalPrimeBands.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalPrimeBands.lean new file mode 100644 index 0000000000000000000000000000000000000000..2859bd160d211d9244f73c0df0f2ece850c08c06 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalPrimeBands.lean @@ -0,0 +1,129 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimePartialSummation +import OAI.NumberTheory.TwoPoint.Bounds.ThetaLogError +import Mathlib.Analysis.SpecialFunctions.Integrals.Basic + +namespace OAI + +/-! Quantitative reciprocal-prime bands from the actual theta error. +Partial summation gives the reciprocal-prime estimates. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +noncomputable def reciprocalLog (x : ℝ) : ℝ := x⁻¹ / Real.log x + +lemma reciprocalLog_hasDerivAt {x : ℝ} (hx : 1 < x) : + HasDerivAt reciprocalLog + (-(Real.log x + 1) / (x ^ 2 * Real.log x ^ 2)) x := by + have hx0 : x ≠ 0 := (zero_lt_one.trans hx).ne' + have hl0 : Real.log x ≠ 0 := (Real.log_pos hx).ne' + have hh := (hasDerivAt_inv hx0).div (Real.hasDerivAt_log hx0) hl0 + convert hh using 1 + · rfl + · field_simp + ring + +lemma reciprocalLog_error_le (K x E : ℝ) (hK : 0 ≤ K) + (hx : 0 < x) (hl : 1 ≤ Real.log x) + (hE : |E| ≤ K * x / Real.log x ^ 2) : + |reciprocalLog x * E| ≤ K / Real.log x := by + have hlp : 0 < Real.log x := zero_lt_one.trans_le hl + rw [abs_mul, abs_of_nonneg (by unfold reciprocalLog; positivity)] + calc + _ ≤ reciprocalLog x * (K * x / Real.log x ^ 2) := + mul_le_mul_of_nonneg_left hE (by unfold reciprocalLog; positivity) + _ = K / Real.log x ^ 3 := by unfold reciprocalLog; field_simp + _ ≤ K / Real.log x := by + apply div_le_div_of_nonneg_left hK hlp + nlinarith [sq_nonneg (Real.log x - 1)] + +lemma reciprocalLog_deriv_error_le (K x E : ℝ) (hK : 0 ≤ K) + (hx : 1 < x) (hl : 1 ≤ Real.log x) + (hE : |E| ≤ K * x / Real.log x ^ 2) : + |deriv reciprocalLog x * E| ≤ 2 * K * (x⁻¹ / Real.log x ^ 2) := by + have hx0 : 0 < x := zero_lt_one.trans hx + have hlp : 0 < Real.log x := zero_lt_one.trans_le hl + rw [(reciprocalLog_hasDerivAt hx).deriv, abs_mul, abs_div, abs_neg, + abs_of_pos (by positivity : 0 < Real.log x + 1), + abs_of_pos (by positivity : 0 < x ^ 2 * Real.log x ^ 2)] + calc + _ ≤ ((Real.log x + 1) / (x ^ 2 * Real.log x ^ 2)) * + (K * x / Real.log x ^ 2) := mul_le_mul_of_nonneg_left hE (by positivity) + _ ≤ 2 * K * (x⁻¹ / Real.log x ^ 2) := by + apply (mul_le_mul_iff_of_pos_right (by positivity : 0 < x * Real.log x ^ 4)).mp + field_simp + nlinarith [sq_nonneg (Real.log x - 1), mul_nonneg hK (sq_nonneg (Real.log x - 1))] + +/-- A uniform band error. The upper endpoint is arbitrary, so this applies +simultaneously to all the logarithmically spaced supplies in the manuscript. -/ +theorem reciprocal_band_error (c : ℕ → ℝ) (α K a b : ℝ) (hK : 0 ≤ K) + (ha : Real.exp 1 ≤ a) (hab : a ≤ b) + (hE : ∀ x ∈ Set.Icc a b, + |partialCoefficientSum c x - α * x| ≤ K * x / Real.log x ^ 2) : + |(∑ n ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, reciprocalLog n * c n) - + α * (Real.log (Real.log b) - Real.log (Real.log a))| ≤ 4 * K / Real.log a := by + have ha1 : 1 < a := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le ha + have hb1 : 1 < b := ha1.trans_le hab + have ha0 : 0 < a := zero_lt_one.trans ha1 + have hla : 1 ≤ Real.log a := by + simpa using Real.log_le_log (Real.exp_pos 1) ha + have hlap : 0 < Real.log a := Real.log_pos ha1 + have hx1 (x : ℝ) (hx : x ∈ Set.Icc a b) : 1 < x := ha1.trans_le hx.1 + have hlx (x : ℝ) (hx : x ∈ Set.Icc a b) : 1 ≤ Real.log x := + hla.trans (Real.log_le_log ha0 hx.1) + have hf : ∀ x ∈ Set.Icc a b, DifferentiableAt ℝ reciprocalLog x := + fun x hx => (reciprocalLog_hasDerivAt (hx1 x hx)).differentiableAt + have hxn : ∀ x ∈ Set.Icc a b, x ≠ 0 := + fun x hx => (zero_lt_one.trans (hx1 x hx)).ne' + have hln : ∀ x ∈ Set.Icc a b, Real.log x ≠ 0 := + fun x hx => (Real.log_pos (hx1 x hx)).ne' + have hclog : ContinuousOn Real.log (Set.Icc a b) := + fun x hx => (Real.continuousAt_log (hxn x hx)).continuousWithinAt + have hdf : ContinuousOn (deriv reciprocalLog) (Set.Icc a b) := by + apply ContinuousOn.congr (f := fun x => -(Real.log x + 1) / (x ^ 2 * Real.log x ^ 2)) + · exact (hclog.add continuousOn_const).neg.div + ((continuousOn_id.pow 2).mul (hclog.pow 2)) + (fun x hx => mul_ne_zero (pow_ne_zero 2 (hxn x hx)) (pow_ne_zero 2 (hln x hx))) + · intro x hx + exact (reciprocalLog_hasDerivAt (hx1 x hx)).deriv + have hAbel := centered_partial_summation c α a b ha0.le hab reciprocalLog hf hdf + rw [show (∫ t in a..b, reciprocalLog t) = + Real.log (Real.log b) - Real.log (Real.log a) from + integral_inv_div_log ha1 hb1] at hAbel + have hg : IntervalIntegrable (fun x : ℝ => 2 * K * (x⁻¹ / Real.log x ^ 2)) volume a b := by + apply ContinuousOn.intervalIntegrable_of_Icc (h := hab) + exact ((continuousOn_id.inv₀ hxn).div (hclog.pow 2) + (fun x hx => pow_ne_zero 2 (hln x hx))).const_mul (2 * K) + have hi : |∫ x in a..b, deriv reciprocalLog x * (partialCoefficientSum c x - α * x)| ≤ + 2 * K / Real.log a := by + have hbound := intervalIntegral.norm_integral_le_of_norm_le hab + (Filter.Eventually.of_forall (fun x hx => by + rw [Real.norm_eq_abs] + exact reciprocalLog_deriv_error_le K x _ hK (hx1 x ⟨hx.1.le, hx.2⟩) + (hlx x ⟨hx.1.le, hx.2⟩) (hE x ⟨hx.1.le, hx.2⟩))) hg + rw [Real.norm_eq_abs, intervalIntegral.integral_const_mul, + integral_inv_div_log_sq ha1 hb1] at hbound + apply hbound.trans + have hbnonneg : 0 ≤ (Real.log b)⁻¹ := inv_nonneg.mpr (Real.log_pos hb1).le + simp only [div_eq_mul_inv] + nlinarith [mul_nonneg (by positivity : 0 ≤ 2 * K) hbnonneg] + have hA := reciprocalLog_error_le K a _ hK ha0 hla (hE a ⟨le_rfl, hab⟩) + have hB := reciprocalLog_error_le K b _ hK (zero_lt_one.trans hb1) + (hlx b ⟨hab, le_rfl⟩) (hE b ⟨hab, le_rfl⟩) + have hBA : K / Real.log b ≤ K / Real.log a := + div_le_div_of_nonneg_left hK hlap (Real.log_le_log ha0 hab) + rw [hAbel] + calc + _ ≤ |reciprocalLog b * (partialCoefficientSum c b - α * b)| + + |reciprocalLog a * (partialCoefficientSum c a - α * a)| + + |∫ t in a..b, deriv reciprocalLog t * (partialCoefficientSum c t - α * t)| := + (abs_sub _ _).trans (add_le_add (abs_sub _ _) (le_refl _)) + _ ≤ K / Real.log a + K / Real.log a + 2 * K / Real.log a := + add_le_add (add_le_add (hB.trans hBA) hA) hi + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalProgressions.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalProgressions.lean new file mode 100644 index 0000000000000000000000000000000000000000..d16bfa8c2994f77372c266e18f56da231f88235c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalProgressions.lean @@ -0,0 +1,112 @@ +import Mathlib.NumberTheory.Harmonic.Bounds +import Mathlib.Data.Nat.ModEq +import Mathlib.Data.Nat.Prime.Int +import Mathlib.Tactic + +namespace OAI + +/-! Reciprocal savings for one prime variable in a nondegenerate congruence. -/ + +namespace TwoPointCorrelations + +open Finset + +/-- A finite subset of one residue class has at most one exceptional initial +term; every subsequent reciprocal is bounded by a harmonic term divided by +the modulus. The set may consist only of primes or satisfy extra restrictions. -/ +theorem reciprocal_congruence_sum (S : Finset ℕ) (H N p : ℕ) + (hH : 0 < H) (hN : 1 ≤ N) (hp : 0 < p) + (hlower : ∀ x ∈ S, H ≤ x) (hupper : ∀ x ∈ S, x ≤ N) + (hcongruent : ∀ x ∈ S, ∀ y ∈ S, Nat.ModEq p x y) : + ∑ x ∈ S, (x : ℝ)⁻¹ ≤ (H : ℝ)⁻¹ + (1 + Real.log N) / p := by + classical + have hlog : 0 ≤ Real.log (N : ℝ) := Real.log_nonneg (by exact_mod_cast hN) + by_cases hS : S.Nonempty + · let a := S.min' hS + have ha : a ∈ S := min'_mem S hS + let R := S.erase a + let k : ℕ → ℕ := fun x => (x - a) / p + have hkprod (x : ℕ) (hx : x ∈ R) : p * k x = x - a := by + exact Nat.mul_div_cancel' ((hcongruent a ha x (mem_erase.mp hx).2).dvd') + have hkpositive (x : ℕ) (hx : x ∈ R) : 0 < k x := by + have hax := min'_le S x (mem_erase.mp hx).2 + have hne := (mem_erase.mp hx).1 + have hprod := hkprod x hx + by_contra hn + have hz : k x = 0 := by omega + rw [hz, mul_zero] at hprod + omega + have hkupper (x : ℕ) (hx : x ∈ R) : k x ≤ N := + (Nat.div_le_self (x - a) p).trans ((Nat.sub_le x a).trans (hupper x (mem_erase.mp hx).2)) + have hkinj : Set.InjOn k R := by + intro x hx y hy heq + have hxprod := hkprod x hx + have hyprod := hkprod y hy + have hax := min'_le S x (mem_erase.mp hx).2 + have hay := min'_le S y (mem_erase.mp hy).2 + rw [heq] at hxprod + omega + have hweight (x : ℕ) (hx : x ∈ R) : + (x : ℝ)⁻¹ ≤ (p : ℝ)⁻¹ * (k x : ℝ)⁻¹ := by + have hprod : (p : ℝ) * (k x : ℝ) ≤ x := by + exact_mod_cast (show p * k x ≤ x by rw [hkprod x hx]; exact Nat.sub_le _ _) + have hpos : 0 < (p : ℝ) * (k x : ℝ) := by + exact mul_pos (by exact_mod_cast hp) (by exact_mod_cast hkpositive x hx) + simpa only [mul_inv] using ((inv_le_inv₀ (lt_of_lt_of_le hpos hprod) hpos).mpr hprod) + have hsubset : R.image k ⊆ Icc 1 N := by + intro j hj + obtain ⟨x, hx, rfl⟩ := mem_image.mp hj + exact mem_Icc.mpr ⟨hkpositive x hx, hkupper x hx⟩ + have hrest : ∑ x ∈ R, (x : ℝ)⁻¹ ≤ (1 + Real.log N) / p := by + calc + _ ≤ ∑ x ∈ R, (p : ℝ)⁻¹ * (k x : ℝ)⁻¹ := sum_le_sum hweight + _ = ∑ j ∈ R.image k, (p : ℝ)⁻¹ * (j : ℝ)⁻¹ := by + rw [sum_image hkinj] + _ ≤ ∑ j ∈ Icc 1 N, (p : ℝ)⁻¹ * (j : ℝ)⁻¹ := by + apply sum_le_sum_of_subset_of_nonneg hsubset + intro j _ _ + positivity + _ = (p : ℝ)⁻¹ * (harmonic N : ℝ) := by + simp only [← mul_sum, harmonic_eq_sum_Icc, Rat.cast_sum, Rat.cast_inv, Rat.cast_natCast] + _ ≤ (p : ℝ)⁻¹ * (1 + Real.log N) := + mul_le_mul_of_nonneg_left (harmonic_le_one_add_log N) (by positivity) + _ = (1 + Real.log N) / p := by rw [div_eq_mul_inv]; ring + have hHreal : (0 : ℝ) < H := by exact_mod_cast hH + have hHale : (H : ℝ) ≤ a := by exact_mod_cast hlower a ha + have hfirst : (a : ℝ)⁻¹ ≤ (H : ℝ)⁻¹ := + (inv_le_inv₀ (lt_of_lt_of_le hHreal hHale) hHreal).mpr hHale + calc + _ = (a : ℝ)⁻¹ + ∑ x ∈ R, (x : ℝ)⁻¹ := by + rw [← sum_erase_add S (fun x : ℕ => (x : ℝ)⁻¹) ha] + simp only [R] + ring + _ ≤ _ := add_le_add hfirst hrest + · have hzero : S = ∅ := not_nonempty_iff_eq_empty.mp hS + simp only [hzero, sum_empty] + positivity + +/-- A congruence with a nonzero coefficient modulo a prime admits only one +residue class, without any assumption that a larger matrix is invertible. -/ +lemma congruence_same_residue {p x y : ℕ} (hp : p.Prime) {A B : ℤ} + (hA : ¬(p : ℤ) ∣ A) + (hx : (p : ℤ) ∣ A * x + B) (hy : (p : ℤ) ∣ A * y + B) : + Nat.ModEq p x y := by + have hprime : Prime (p : ℤ) := Int.prime_ofNat_iff.mpr hp + have hdiff : (p : ℤ) ∣ A * ((y : ℤ) - x) := by + convert hy.sub hx using 1 + ring + exact Nat.modEq_iff_dvd.mpr ((hprime.dvd_mul.mp hdiff).resolve_left hA) + +/-- The reciprocal saving used for each selected triangular relation. -/ +theorem reciprocal_linear_congruence_sum (S : Finset ℕ) (H N p : ℕ) (A B : ℤ) + (hH : 0 < H) (hN : 1 ≤ N) (hp : p.Prime) (hA : ¬(p : ℤ) ∣ A) + (hlower : ∀ x ∈ S, H ≤ x) (hupper : ∀ x ∈ S, x ≤ N) + (hcongruence : ∀ x ∈ S, (p : ℤ) ∣ A * x + B) : + ∑ x ∈ S, (x : ℝ)⁻¹ ≤ (H : ℝ)⁻¹ + (1 + Real.log N) / p := by + apply reciprocal_congruence_sum S H N p hH hN hp.pos hlower hupper + intro x hx y hy + exact congruence_same_residue hp hA (hcongruence x hx) (hcongruence y hy) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalSampling.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalSampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..9658d4942d9877dcefa729c1708e62494ca15661 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ReciprocalSampling.lean @@ -0,0 +1,160 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ReciprocalProgressions +import OAI.NumberTheory.TwoPoint.Bounds.PrimeRelations + +namespace OAI + +/-! Reciprocal-weighted prime sampling and concrete triangular relation bounds. -/ + +namespace TwoPointCorrelations + +open Finset + +namespace FiniteLaw + +variable {A : Type*} [Fintype A] + +/-- A reciprocal atom majorant transfers the finite progression bound to +sampling probability. For the normalized law `1/(Vp)`, it suffices that +`V ≥ 1`, exactly as in the singleton argument. -/ +theorem reciprocal_probability_bound (μ : FiniteLaw A) (value : A → ℕ) + (hinj : Function.Injective value) (H N p : ℕ) (C D : ℤ) + (hH : 0 < H) (hN : 1 ≤ N) (hp : p.Prime) (hC : ¬(p : ℤ) ∣ C) + (hlo : ∀ a, H ≤ value a) (hhi : ∀ a, value a ≤ N) + (hweight : ∀ a, μ.weight a ≤ (value a : ℝ)⁻¹) + (E : A → Prop) (hE : ∀ a, E a → (p : ℤ) ∣ C * value a + D) : + μ.probability E ≤ (H : ℝ)⁻¹ + (1 + Real.log N) / p := by + classical + let S : Finset A := univ.filter E + let T : Finset ℕ := S.image value + have hprob : μ.probability E = ∑ a ∈ S, μ.weight a := by + simp only [probability, average, S, sum_filter, mul_ite, mul_one, mul_zero] + have himage : (∑ a ∈ S, (value a : ℝ)⁻¹) = ∑ x ∈ T, (x : ℝ)⁻¹ := by + dsimp [T] + rw [sum_image (fun a _ b _ hab => hinj hab)] + rw [hprob] + apply (sum_le_sum (fun a _ => hweight a)).trans + rw [himage] + apply reciprocal_linear_congruence_sum T H N p C D hH hN hp hC + · intro x hx + obtain ⟨a, _, rfl⟩ := mem_image.mp hx + exact hlo a + · intro x hx + obtain ⟨a, _, rfl⟩ := mem_image.mp hx + exact hhi a + · intro x hx + obtain ⟨a, ha, rfl⟩ := mem_image.mp hx + exact hE a (mem_filter.mp ha).2 + +/-- Retain the coefficient test during summation. A vanishing coefficient +makes the event empty and costs zero, so no case is lost by resampling. -/ +theorem nondegenerate_reciprocal_probability_bound (μ : FiniteLaw A) (value : A → ℕ) + (hinj : Function.Injective value) (H N p : ℕ) (C D : ℤ) + (hH : 0 < H) (hN : 1 ≤ N) (hp : p.Prime) + (hlo : ∀ a, H ≤ value a) (hhi : ∀ a, value a ≤ N) + (hweight : ∀ a, μ.weight a ≤ (value a : ℝ)⁻¹) : + μ.probability (fun a => (p : ℤ) ∣ C * value a + D ∧ ¬(p : ℤ) ∣ C) ≤ + (H : ℝ)⁻¹ + (1 + Real.log N) / p := by + by_cases hC : (p : ℤ) ∣ C + · have hzero : μ.probability (fun a => (p : ℤ) ∣ C * value a + D ∧ ¬(p : ℤ) ∣ C) = 0 := by + simp [probability, average, hC] + rw [hzero] + have hlog : 0 ≤ Real.log (N : ℝ) := Real.log_nonneg (by exact_mod_cast hN) + positivity + · exact reciprocal_probability_bound μ value hinj H N p C D hH hN hp hC hlo hhi hweight + _ (fun _ ha => ha.1) + +end FiniteLaw + +variable {ι A : Type*} [DecidableEq ι] + +def integerPrimeAssignment (value : A → ℕ) (x : ι → A) : ι → ℤ := fun i => value (x i) + +lemma integerPrimeAssignment_update (value : A → ℕ) (x : ι → A) (i : ι) (a : A) : + integerPrimeAssignment value (Function.update x i a) = + Function.update (integerPrimeAssignment value x) i (value a) := by + funext j + by_cases hji : j = i <;> simp [integerPrimeAssignment, hji] + +/-- At a selected coordinate, the concrete monomial event is precisely a +single nondegenerate linear congruence with all remaining variables fixed. -/ +lemma primeRelationEvent_update_selected {τ : Type*} [Fintype τ] + (m : τ → PrimeMonomial ι) (selected control : ι) (hne : control ≠ selected) + (value : A → ℕ) (x : ι → A) (a : A) : + primeRelationEvent m selected control + (integerPrimeAssignment value (Function.update x selected a)) ↔ + (value (x control) : ℤ) ∣ + primeRelationCoefficient m selected (integerPrimeAssignment value x) * value a + + primeRelationConstant m selected (integerPrimeAssignment value x) ∧ + ¬(value (x control) : ℤ) ∣ + primeRelationCoefficient m selected (integerPrimeAssignment value x) := by + rw [integerPrimeAssignment_update] + unfold primeRelationEvent + rw [Function.update_of_ne hne, primeRelation_update_affine, + primeRelation_coefficient_update_self] + simp only [integerPrimeAssignment] + rw [mul_comm (value a : ℤ)] + +/-- The pointwise support exclusion proved for the witness ordering is the +exact update invariance required by finite triangular elimination. -/ +lemma primeRelationEvent_update_irrelevant {τ : Type*} [Fintype τ] + (m : τ → PrimeMonomial ι) (selected control j : ι) + (value : A → ℕ) (x : ι → A) (a : A) + (hj : j ∉ primeRelationSupport m) (hjc : control ≠ j) : + primeRelationEvent m selected control (integerPrimeAssignment value (Function.update x j a)) ↔ + primeRelationEvent m selected control (integerPrimeAssignment value x) := by + rw [integerPrimeAssignment_update] + exact primeRelationEvent_update m selected control j _ _ hj hjc + +namespace FiniteLaw + +/-- Fully finite singleton saving for an explicitly triangular family of +prime-monomial relations. Later variables occur neither in earlier +relations nor in their controlling primes. -/ +theorem triangular_prime_relation_probability {τ : Type*} [Fintype τ] + [Fintype ι] [LinearOrder ι] [Fintype A] [Nonempty A] + (μ : ι → FiniteLaw A) (value : A → ℕ) (hinj : Function.Injective value) + (H N : ℕ) (hH : 0 < H) (hN : 1 ≤ N) + (hprime : ∀ a, (value a).Prime) + (hlo : ∀ a, H ≤ value a) (hhi : ∀ a, value a ≤ N) + (hweight : ∀ i a, (μ i).weight a ≤ (value a : ℝ)⁻¹) + (m : ι → τ → PrimeMonomial ι) (control : ι → ι) + (R : Finset ι) + (hcontrol : ∀ i ∈ R, control i ≠ i) + (htriangular : ∀ i ∈ R, ∀ j ∈ R, i < j → + j ∉ primeRelationSupport (m i) ∧ control i ≠ j) : + (independent μ).probability (fun x => ∀ i ∈ R, + primeRelationEvent (m i) i (control i) (integerPrimeAssignment value x)) ≤ + ((H : ℝ)⁻¹ + (1 + Real.log N) / H) ^ R.card := by + classical + let E : ι → (ι → A) → Prop := fun i x => + primeRelationEvent (m i) i (control i) (integerPrimeAssignment value x) + have hlog : 0 ≤ Real.log (N : ℝ) := Real.log_nonneg (by exact_mod_cast hN) + apply triangular_probability_bound μ E _ (by positivity) R ?_ ?_ + · intro i hi j hj hij x a + exact primeRelationEvent_update_irrelevant (m i) i (control i) j value x a + (htriangular i hi j hj hij).1 (htriangular i hi j hj hij).2 + · intro i hi x + have hlinear := nondegenerate_reciprocal_probability_bound (μ i) value hinj + H N (value (x (control i))) + (primeRelationCoefficient (m i) i (integerPrimeAssignment value x)) + (primeRelationConstant (m i) i (integerPrimeAssignment value x)) + hH hN (hprime _) hlo hhi (hweight i) + have hevent : (fun a => E i (Function.update x i a)) = + (fun a => (value (x (control i)) : ℤ) ∣ + primeRelationCoefficient (m i) i (integerPrimeAssignment value x) * value a + + primeRelationConstant (m i) i (integerPrimeAssignment value x) ∧ + ¬(value (x (control i)) : ℤ) ∣ + primeRelationCoefficient (m i) i (integerPrimeAssignment value x)) := by + funext a + exact propext (primeRelationEvent_update_selected (m i) i (control i) (hcontrol i hi) value x a) + rw [hevent] + apply hlinear.trans + apply add_le_add le_rfl + exact div_le_div_of_nonneg_left (by linarith) (by exact_mod_cast hH) + (by exact_mod_cast hlo (x (control i))) + +end FiniteLaw + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RecordedWitnessSegments.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RecordedWitnessSegments.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f48509db7f7e66067d64564cbbd187e331165e5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RecordedWitnessSegments.lean @@ -0,0 +1,40 @@ +import OAI.NumberTheory.TwoPoint.Walks.WitnessSegmentation + +namespace OAI + +/-! Every actual main/witness family is represented in the finite segment catalog. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +def recordedWitnessWord {n : ℕ} (main : List SignedStep) (word : Fin n → List SignedStep) : + List SignedStep := main ++ (List.ofFn word).flatten + +theorem recorded_witness_segments {n : ℕ} (main : List SignedStep) + (word : Fin n → List SignedStep) : + ∃ d : WitnessSegmentation n (recordedWitnessWord main word).length, + (recordedWitnessWord main word).take d.1.val = main ∧ + ∀ i, ((recordedWitnessWord main word).drop (d.2.1 i).val).take (d.2.2 i).val = word i := by + let v := recordedWitnessWord main word + have hmain : main.length ≤ v.length := by simp [v, recordedWitnessWord] + have hseg (i : Fin n) : ∃ start len : Fin (v.length + 1), + (v.drop start.val).take len.val = word i := by + obtain ⟨before, after, he⟩ := List.mem_iff_append.mp + (List.mem_ofFn.mpr ⟨i, rfl⟩ : word i ∈ List.ofFn word) + let preword := main ++ before.flatten + have hv : v = preword ++ (word i ++ after.flatten) := by + simp only [v, recordedWitnessWord, he, List.flatten_append, List.flatten_cons, + preword, List.append_assoc] + have hs : preword.length ≤ v.length := by rw [hv]; simp + have hl : (word i).length ≤ v.length := by rw [hv]; simp; omega + refine ⟨⟨preword.length, by omega⟩, ⟨(word i).length, by omega⟩, ?_⟩ + change (v.drop preword.length).take (word i).length = word i + rw [hv, List.drop_left, List.take_left] + choose start len hsegments using hseg + refine ⟨(⟨main.length, Nat.lt_succ_of_le hmain⟩, start, len), ?_, hsegments⟩ + exact List.take_left + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularColumnNames.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularColumnNames.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca485af2b599638cad564c319702e2901942d023 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularColumnNames.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.TwoPoint.Walks.CanonicalColumnNames + +namespace OAI + +/-! Name regular perfect classes by forest vertices and omitted classes by occurrences. -/ + +namespace TwoPointCorrelations + +variable {α : Type*} [DecidableEq α] {n : ℕ} + +/-- Omitted classes use bounded occurrence indices. Regular classes use +exactly the line-vertex numbers shared across the path family. -/ +def forestPerfectName (label : Fin n → α) (perfect : Finset (Fin n)) + (regular : Finset α) (number : regular → ℕ) (i : Fin n) : ℕ ⊕ ℕ := + if hi : label i ∈ regular then .inl (number ⟨label i, hi⟩) + else .inr (columnRepresentative label perfect i).val + +theorem forestPerfectName_of_label_eq (label : Fin n → α) (perfect : Finset (Fin n)) + (regular : Finset α) (number : regular → ℕ) (i j : Fin n) (h : label i = label j) : + forestPerfectName label perfect regular number i = forestPerfectName label perfect regular number j := by + by_cases hi : label i ∈ regular <;> by_cases hj : label j ∈ regular + · have he : (⟨label i, hi⟩ : regular) = ⟨label j, hj⟩ := Subtype.ext h + simp only [forestPerfectName, dite_eq_left hi, dite_eq_left hj, he] + · exact (hj (h ▸ hi)).elim + · exact (hi (h.symm ▸ hj)).elim + · simp only [forestPerfectName, dite_eq_right hi, dite_eq_right hj, + (columnRepresentative_eq_iff label perfect i j).mpr h] + +/-- Injectivity is needed only for lines observed at perfect positions. +No numbering requirement is imposed on unused regular labels. -/ +theorem forestPerfectName_eq_iff (label : Fin n → α) (perfect : Finset (Fin n)) + (regular : Finset α) (number : regular → ℕ) + (hinj : ∀ i ∈ perfect, ∀ j ∈ perfect, ∀ (hi : label i ∈ regular) (hj : label j ∈ regular), + number ⟨label i, hi⟩ = number ⟨label j, hj⟩ → label i = label j) + (i : Fin n) (hi : i ∈ perfect) (j : Fin n) (hj : j ∈ perfect) : + forestPerfectName label perfect regular number i = forestPerfectName label perfect regular number j ↔ + label i = label j := by + constructor + · intro heq + by_cases hir : label i ∈ regular <;> by_cases hjr : label j ∈ regular + · simp only [forestPerfectName, dite_eq_left hir, dite_eq_left hjr, Sum.inl.injEq] at heq + exact hinj i hi j hj hir hjr heq + · simp only [forestPerfectName, dite_eq_left hir, dite_eq_right hjr, Sum.inl_ne_inr] at heq + · simp only [forestPerfectName, dite_eq_right hir, dite_eq_left hjr, Sum.inr_ne_inl] at heq + · simp only [forestPerfectName, dite_eq_right hir, dite_eq_right hjr, Sum.inr.injEq] at heq + exact (columnRepresentative_eq_iff label perfect i j).mp (Fin.ext heq) + · exact forestPerfectName_of_label_eq label perfect regular number i j + +/-- The completed names represent the full equality pattern, including +classes having no perfect occurrence. -/ +theorem canonical_forest_name_eq_iff (label : Fin n → α) (perfect : Finset (Fin n)) + (regular : Finset α) (number : regular → ℕ) + (hinj : ∀ i ∈ perfect, ∀ j ∈ perfect, ∀ (hi : label i ∈ regular) (hj : label j ∈ regular), + number ⟨label i, hi⟩ = number ⟨label j, hj⟩ → label i = label j) + (i j : Fin n) : + canonicalColumnName label perfect (forestPerfectName label perfect regular number) i = + canonicalColumnName label perfect (forestPerfectName label perfect regular number) j ↔ label i = label j := by + apply canonicalColumnName_eq_iff + exact forestPerfectName_eq_iff label perfect regular number hinj + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularFamilyNames.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularFamilyNames.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b37ef904602083039f6aa4ea1e2a62c77d3b041 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularFamilyNames.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TwoPoint.Walks.BlockFamilyDecoding +import OAI.NumberTheory.TwoPoint.Bounds.ObservedColumnNames + +namespace OAI + +/-! Every regular perfect class inherits the bounds and injectivity of its forest line. -/ + +namespace TwoPointCorrelations + +variable {α : Type*} [DecidableEq α] {n N : ℕ} + +omit [DecidableEq α] in +theorem perfect_label_entry (label : Fin n → α) (perfect : Finset (Fin n)) + (chunks : List (List α ⊕ α)) + (hentries : columnChunkEntries chunks = + (columnPositionEntries perfect).map (fun p => (label p.1, p.2))) + (i : Fin n) (hi : i ∈ perfect) : (label i, true) ∈ columnChunkEntries chunks := by + rw [hentries] + simp only [columnPositionEntries, List.map_ofFn, Function.comp_def] + apply List.mem_ofFn.mpr + exact ⟨i, by simp [hi]⟩ + +omit [DecidableEq α] in +theorem perfect_label_position (label : Fin n → α) (perfect : Finset (Fin n)) + (chunks : List (List α ⊕ α)) + (hentries : columnChunkEntries chunks = + (columnPositionEntries perfect).map (fun p => (label p.1, p.2))) + (a : α) (ha : (a, true) ∈ columnChunkEntries chunks) : + ∃ i ∈ perfect, label i = a := by + rw [hentries] at ha + simp only [columnPositionEntries, List.map_ofFn, Function.comp_def, List.mem_ofFn] at ha + obtain ⟨i, he⟩ := ha + have hlabel : label i = a := congrArg Prod.fst he + have hperfect : decide (i ∈ perfect) = true := congrArg Prod.snd he + exact ⟨i, of_decide_eq_true hperfect, hlabel⟩ + +/-- Coverage makes the shared forest bounds and injectivity apply to every +perfect regular occurrence, including those suppressed by run compression. -/ +theorem regular_family_name_properties (label : Fin n → α) (perfect : Finset (Fin n)) + (regular : Finset α) (number : regular → ℕ) (lineNumber : α → ℕ) + (hnumber : ∀ z (hz : z ∈ regular), lineNumber z = number ⟨z, hz⟩) + (labelNat : ℕ → α) + (chunks : List (List α ⊕ α)) (blocks : List (ℕ × ℕ)) + (hentries : columnChunkEntries chunks = + (columnPositionEntries perfect).map (fun p => (label p.1, p.2))) + (hblocks : chunks.filterMap (Sum.elim some (fun _ => none)) = + blocks.map (fun b => blockLabelList labelNat b.1 b.2)) + (hbound : ∀ segment ∈ indexedRegularSegments labelNat (fun z => decide (z ∉ regular)) blocks, + ∀ p ∈ segment, lineNumber p.2 < N) + (hinj : ∀ segment ∈ indexedRegularSegments labelNat (fun z => decide (z ∉ regular)) blocks, + ∀ p ∈ segment, + ∀ other ∈ indexedRegularSegments labelNat (fun z => decide (z ∉ regular)) blocks, + ∀ q ∈ other, lineNumber p.2 = lineNumber q.2 → p.2 = q.2) : + (∀ i ∈ perfect, ∀ hi : label i ∈ regular, number ⟨label i, hi⟩ < N) ∧ + (∀ i ∈ perfect, ∀ j ∈ perfect, ∀ (hi : label i ∈ regular) (hj : label j ∈ regular), + number ⟨label i, hi⟩ = number ⟨label j, hj⟩ → label i = label j) := by + have hcover (i : Fin n) (hi : i ∈ perfect) (hr : label i ∈ regular) : + ∃ segment ∈ indexedRegularSegments labelNat (fun z => decide (z ∉ regular)) blocks, + ∃ p ∈ segment, p.2 = label i := by + exact perfect_regular_entry_covered labelNat (fun z => decide (z ∉ regular)) chunks blocks + hblocks (label i) (perfect_label_entry label perfect chunks hentries i hi) (by simp [hr]) + have hnamed (i : Fin n) (hi : label i ∈ regular) (p : ℕ × α) (hp : p.2 = label i) : + lineNumber p.2 = number ⟨label i, hi⟩ := by + rw [hp] + exact hnumber (label i) hi + constructor + · intro i hi hr + obtain ⟨segment, hs, p, hp, he⟩ := hcover i hi hr + simpa only [hnamed i hr p he] using hbound segment hs p hp + · intro i hi j hj hri hrj heq + obtain ⟨segment, hs, p, hp, hpi⟩ := hcover i hi hri + obtain ⟨other, ho, q, hq, hqj⟩ := hcover j hj hrj + have he : lineNumber p.2 = lineNumber q.2 := by + simpa only [hnamed i hri p hpi, hnamed j hrj q hqj] using heq + exact hpi.symm.trans ((hinj segment hs p hp other ho q hq he).trans hqj) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularLineAnchors.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularLineAnchors.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a635d3f65e2c4d36bfa354aea455d7a1026ae0f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularLineAnchors.lean @@ -0,0 +1,37 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RegularQuotient + +namespace OAI + +/-! Choosing one common affine line for all lit occurrences of each regular label. -/ + +namespace TwoPointCorrelations + +open Finset Submodule + +variable {K α ι : Type*} [Field K] [Fintype α] [Fintype ι] + [DecidableEq α] [DecidableEq ι] + +/-- A low-rank family gives independent regular directions and one anchor +per label, shared by every lit departure in every perfect block. -/ +theorem exists_regular_line_anchors (label : ι → α) (offset : ι → α → K) (r : ℕ) + (hno : ∀ S : Finset (EqualLabelPairs label), S.card = r → + ¬LinearIndependent K (pairFamily (labelPairVectors label offset) S)) : + ∃ (D : Submodule K (α → K)) (R : Finset α) + (anchor : R → (α → K) ⧸ D), Rᶜ.card < 2 * r ∧ + LinearIndependent K (fun z : R => D.mkQ (Pi.basisFun K α z)) ∧ + ∀ (z : R) i, label i = z → + ∃ c : K, D.mkQ (offset i) = anchor z + c • D.mkQ (Pi.basisFun K α z) := by + classical + obtain ⟨D, R, hcard, hind, _, hline⟩ := exists_regular_quotient label offset r hno + let anchor : R → (α → K) ⧸ D := fun z => + if h : ∃ i, label i = z then D.mkQ (offset h.choose) else 0 + refine ⟨D, R, anchor, hcard, hind, ?_⟩ + intro z i hi + have hex : ∃ j, label j = z := ⟨i, hi⟩ + obtain ⟨c, hc⟩ := hline z i hex.choose hi hex.choose_spec + refine ⟨c, ?_⟩ + simpa only [anchor, dite_eq_left hex] using hc + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularQuotient.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularQuotient.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4e6fc41b327937b16bd698821c1ee912d4d2733 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularQuotient.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MaximalPairs +import OAI.NumberTheory.TwoPoint.Walks.IncidenceForest + +namespace OAI + +/-! The low-rank hypothesis produces the regular quotient directions used in forest coding. -/ + +namespace TwoPointCorrelations + +open Finset Submodule + +variable {K α ι : Type*} [Field K] [Fintype α] [Fintype ι] + [DecidableEq α] [DecidableEq ι] + +/-- All pairs of departures carrying the same label. A caller may restrict +`ι` to the lit occurrences before applying this construction. -/ +def EqualLabelPairs (label : ι → α) := + {p : α × ι × ι // label p.2.1 = p.1 ∧ label p.2.2 = p.1} + +instance equalLabelPairsFintype (label : ι → α) : Fintype (EqualLabelPairs label) := + inferInstanceAs (Fintype {p : α × ι × ι // label p.2.1 = p.1 ∧ label p.2.2 = p.1}) + +instance equalLabelPairsDecidableEq (label : ι → α) : DecidableEq (EqualLabelPairs label) := + inferInstanceAs (DecidableEq {p : α × ι × ι // label p.2.1 = p.1 ∧ label p.2.2 = p.1}) + +/-- Difference first, coordinate direction second, so the generic maximal +pair theorem applies without reordering the joint independent family. -/ +noncomputable def labelPairVectors (label : ι → α) (offset : ι → α → K) + (p : EqualLabelPairs label) : Fin 2 → (α → K) := + ![offset p.val.2.1 - offset p.val.2.2, Pi.basisFun K α p.val.1] + +/-- The algebraic part of forest coding: fewer than `r` independent pairs +leave fewer than `2r` omitted labels; all remaining departures for a label +lie along its independent coordinate direction in the quotient. -/ +theorem exists_regular_quotient (label : ι → α) (offset : ι → α → K) (r : ℕ) + (hno : ∀ S : Finset (EqualLabelPairs label), S.card = r → + ¬LinearIndependent K (pairFamily (labelPairVectors label offset) S)) : + ∃ (D : Submodule K (α → K)) (R : Finset α), Rᶜ.card < 2 * r ∧ + LinearIndependent K (fun z : R => D.mkQ (Pi.basisFun K α z)) ∧ + span K (Set.range (fun z : R => D.mkQ (Pi.basisFun K α z))) = ⊤ ∧ + ∀ (z : R) i j, label i = z → label j = z → + ∃ c : K, D.mkQ (offset i) = D.mkQ (offset j) + + c • D.mkQ (Pi.basisFun K α z) := by + classical + let v := labelPairVectors label offset + obtain ⟨S, hcard, hind, hdim, hmax⟩ := exists_small_maximal_independent_pairs v r hno + let D := span K (Set.range (pairFamily v S)) + obtain ⟨R, hRcard, hRind, hRspan⟩ := exists_coordinate_quotient_basis D + refine ⟨D, R, ?_, hRind, hRspan, ?_⟩ + · rw [hRcard, hdim] + omega + · intro z i j hi hj + let p : EqualLabelPairs label := ⟨(z, i, j), hi, hj⟩ + have hx : D.mkQ (v p 1) ≠ 0 := by + exact hRind.ne_zero z + have hpS : p ∉ S := by + intro hp + apply hx + rw [Submodule.mkQ_apply, Submodule.Quotient.mk_eq_zero] + exact subset_span ⟨(⟨p, hp⟩, 1), rfl⟩ + have hpv : v p = ![offset i - offset j, Pi.basisFun K α z] := rfl + obtain ⟨c, hc⟩ := quotient_line_of_nonextendable_pair (pairFamily v S) hind + (Pi.basisFun K α z) (offset i - offset j) hx + (by simpa only [← hpv] using hmax p hpS) + refine ⟨c, ?_⟩ + rw [map_sub] at hc + exact sub_eq_iff_eq_add'.mp hc + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularSegmentCoding.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularSegmentCoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..676de74c715777315d876dcf679956782c705052 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RegularSegmentCoding.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QuotientPathNumbering +import OAI.NumberTheory.TwoPoint.Walks.ColumnChunkBudgets + +namespace OAI + +/-! Assemble all actual regular segments into one shared forest code. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {K α ι : Type*} [Field K] [Fintype α] [DecidableEq ι] + +/-- Enumerating nonempty segments does not require separate choices of line +names for each block. Their common quotient forest supplies one numbering. -/ +theorem regular_segment_list_numbering {N : ℕ} + (D : Submodule K (α → K)) (anchor : ι → (α → K) ⧸ D) + (regularLabel : ι → α) (label : ℕ → α) (coefficient : ℕ → K) + (hind : LinearIndependent K (fun j => D.mkQ (Pi.basisFun K α (regularLabel j)))) + (segments : List (List (ℕ × ι))) + (hne : ∀ segment ∈ segments, segment ≠ []) + (hstart : ∀ first rest, first :: rest ∈ segments → ∃ c : K, + D.mkQ (formalDeparture label coefficient first.1) = + anchor first.2 + c • D.mkQ (Pi.basisFun K α (regularLabel first.2))) + (hdata : ∀ first rest, first :: rest ∈ segments → + QuotientRunData D anchor regularLabel label coefficient first.1 first.2 rest) + (hsize : 2 * (segments.map List.length).sum ≤ N) : + ∃ (number : ι → ℕ) (code : ForestPathData.Code N segments.length), + (∀ segment ∈ segments, ∀ p ∈ segment, number p.2 < N) ∧ + (∀ segment ∈ segments, ∀ p ∈ segment, ∀ other ∈ segments, ∀ q ∈ other, + number p.2 = number q.2 → p.2 = q.2) ∧ + List.ofFn (fun i => evenEntries (decodeForestPaths code i)) = + segments.map (fun segment => segment.map (fun p => number p.2)) := by + let seg : Fin segments.length → List (ℕ × ι) := segments.get + have hseg (i : Fin segments.length) : seg i ∈ segments := List.get_mem _ _ + let first := fun i => (seg i).head (hne _ (hseg i)) + let rest := fun i => (seg i).tail + have hsplit (i : Fin segments.length) : first i :: rest i = seg i := + List.cons_head_tail (hne _ (hseg i)) + have hmem (i : Fin segments.length) : first i :: rest i ∈ segments := by + rw [hsplit]; exact hseg i + have hs : (∑ i, (2 * (rest i).length + 1)) ≤ N := by + apply le_trans (sum_le_sum (fun i _ => ?_)) + ((show (∑ i, 2 * (seg i).length) = 2 * (segments.map List.length).sum by + rw [← mul_sum] + congr 1 + rw [← List.sum_ofFn] + change (List.ofFn (List.length ∘ segments.get)).sum = _ + rw [← List.map_ofFn, List.ofFn_get]).le.trans hsize) + have hl := congrArg List.length (hsplit i) + simp only [List.length_cons] at hl + omega + obtain ⟨number, code, hbound, hinj, hdecode⟩ := + quotient_run_family_numbering D anchor regularLabel label coefficient hind + (fun i => (first i).1) (fun i => (first i).2) rest + (fun i => hstart _ _ (hmem i)) (fun i => hdata _ _ (hmem i)) hs + have hlabels (i : Fin segments.length) : + (first i).2 :: (rest i).map Prod.snd = (seg i).map Prod.snd := by + rw [← hsplit i]; rfl + refine ⟨number, code, ?_, ?_, ?_⟩ + · intro segment hm p hp + obtain ⟨i, rfl⟩ := List.mem_iff_get.mp hm + apply hbound i p.2 + rw [hlabels] + exact List.mem_map.mpr ⟨p, hp, rfl⟩ + · intro segment hm p hp other ho q hq heq + obtain ⟨i, rfl⟩ := List.mem_iff_get.mp hm + obtain ⟨j, rfl⟩ := List.mem_iff_get.mp ho + apply hinj i p.2 _ j q.2 _ heq + · rw [hlabels]; exact List.mem_map.mpr ⟨p, hp, rfl⟩ + · rw [hlabels]; exact List.mem_map.mpr ⟨q, hq, rfl⟩ + · calc + _ = List.ofFn (fun i => (seg i).map (fun p => number p.2)) := by + congr 1 + funext i + rw [hdecode, hlabels, List.map_map] + rfl + _ = _ := by + change List.ofFn ((fun segment => segment.map (fun p => number p.2)) ∘ segments.get) = _ + rw [← List.map_ofFn, List.ofFn_get] + +omit [Field K] [Fintype α] [DecidableEq ι] in +/-- Removing omitted runs cannot increase the total number of regular +vertices, even when a label is repeated in separate blocks. -/ +theorem regular_pieces_total_length_le (pieces : List (List α ⊕ α)) : + ((pieces.filterMap (Sum.elim some (fun _ => none))).map List.length).sum ≤ + (pieces.flatMap (Sum.elim id List.singleton)).length := by + induction pieces with + | nil => rfl + | cons piece pieces ih => + cases piece with + | inl segment => simpa using Nat.add_le_add_left ih segment.length + | inr a => + simp only [List.filterMap_cons, Sum.elim_inr, List.flatMap_cons, List.length_append] + simpa only [List.singleton, List.length_cons, List.length_nil, Nat.add_zero] using + (ih.trans (Nat.le_add_left _ 1)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RelationReindex.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RelationReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..088a56a0c7aff60684b003aa871afc96b521021e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RelationReindex.lean @@ -0,0 +1,49 @@ +import OAI.NumberTheory.TwoPoint.Walks.WordRelations + +namespace OAI + +/-! Reindexing finite monomial relations preserves their events and supports. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι τ σ : Type*} [DecidableEq ι] [Fintype τ] [Fintype σ] + +omit [DecidableEq ι] in +lemma primeRelationEval_reindex (e : τ ≃ σ) (m : τ → PrimeMonomial ι) + (n : σ → PrimeMonomial ι) (hm : ∀ i, n (e i) = m i) (x : ι → ℤ) : + primeRelationEval n x = primeRelationEval m x := by + unfold primeRelationEval + rw [← e.sum_comp (fun i => (n i).eval x)] + exact sum_congr rfl (fun i _ => by rw [hm]) + +lemma primeRelationCoefficient_reindex (e : τ ≃ σ) (m : τ → PrimeMonomial ι) + (n : σ → PrimeMonomial ι) (hm : ∀ i, n (e i) = m i) (y : ι) (x : ι → ℤ) : + primeRelationCoefficient n y x = primeRelationCoefficient m y x := by + unfold primeRelationCoefficient + rw [← e.sum_comp (fun i => (n i).coefficientAt y x)] + exact sum_congr rfl (fun i _ => by rw [hm]) + +lemma primeRelationSupport_reindex (e : τ ≃ σ) (m : τ → PrimeMonomial ι) + (n : σ → PrimeMonomial ι) (hm : ∀ i, n (e i) = m i) : + primeRelationSupport n = primeRelationSupport m := by + ext y + simp only [primeRelationSupport, mem_biUnion, mem_univ, true_and] + constructor + · rintro ⟨i, hi⟩ + obtain ⟨j, rfl⟩ := e.surjective i + exact ⟨j, by simpa only [hm] using hi⟩ + · rintro ⟨i, hi⟩ + exact ⟨e i, by simpa only [hm] using hi⟩ + +lemma primeRelationEvent_reindex (e : τ ≃ σ) (m : τ → PrimeMonomial ι) + (n : σ → PrimeMonomial ι) (hm : ∀ i, n (e i) = m i) + (selected control : ι) (x : ι → ℤ) : + primeRelationEvent n selected control x ↔ primeRelationEvent m selected control x := by + unfold primeRelationEvent + rw [primeRelationEval_reindex e m n hm, primeRelationCoefficient_reindex e m n hm] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResampledWitnesses.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResampledWitnesses.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8c62d6427ab5ce1fc3d35de14b33e2dd75193af --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResampledWitnesses.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.TwoPoint.Walks.WitnessMetadata +import OAI.NumberTheory.TwoPoint.Walks.WitnessMetadataBounds +import OAI.NumberTheory.TwoPoint.Walks.WordResampling + +namespace OAI + +/-! Actual positive minimal witnesses enter the fixed symbolic metadata union. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +/-- Conditions on an actual numerical assignment, before enlarging its event +into the finite union of symbolic relation systems. -/ +def ResampledWitnessEvent {n : ℕ} {ι : Type*} [DecidableEq ι] + (main : LabeledPrimeWord ι) (word : Fin n → LabeledPrimeWord ι) + (h s J : ℕ) (supply : ℕ → ℕ → Prop) + (mark : Fin n → ι) (attachment position : Fin n → ℕ) (value : ι → ℕ) : Prop := + Function.Injective value ∧ + (∀ j, (value j).Prime) ∧ + (∀ i, MinimalWord (ForwardProhibited h s supply) ((word i).resample value).word) ∧ + (∀ i t, t ∈ ((word i).resample value).word → Squarefree t.tuple) ∧ + (∀ i t, t ∈ ((word i).resample value).word → t.tuple.primeFactors.card = J) ∧ + (∀ i p j, TuplePrimeAt ((word i).resample value).word p j → + ¬p ∣ h ∧ ∀ t ∈ ((word i).resample value).word, ¬p ∣ t.padding) ∧ + (∀ i, value (mark i) ∈ wordPrimeSupport ((word i).resample value).word) ∧ + (∀ i j, j ≠ i → value (mark i) ∉ wordPrimeSupport ((word j).resample value).word) ∧ + (∀ i v, TuplePrimeAt (main.resample value).word (value (mark i)) v → v = position i) ∧ + ∃ x : ℤ, ∀ i, PositiveWord h + (x + wordDisplacement h ((main.resample value).word.take (attachment i))) + ((word i).resample value).word + +lemma resampled_witness_metadata {n K h s J N : ℕ} {supply : ℕ → ℕ → Prop} + {ι : Type*} [DecidableEq ι] + (main : LabeledPrimeWord ι) (word : Fin n → LabeledPrimeWord ι) + (mark : Fin n → ι) (attachment position : Fin n → ℕ) + (hsize : 8 * K ≤ n) (horder : Monotone attachment) + (hbound : ∀ i, attachment i ≤ main.word.length) + (hmainLength : main.word.length ≤ N) (hwordLength : ∀ i, (word i).word.length ≤ N) + (value : ι → ℕ) (hevent : ResampledWitnessEvent main word h s J supply mark attachment position value) : + ∃ d : WitnessSystemData n N ι, K ≤ d.chosen.card ∧ d.Triangular main word h ∧ + d.Holds main word h (fun z => (value z : ℤ)) := by + rcases hevent with ⟨hinj, hprime, hminimal, hsq, hcard, hsupport, hmark, hprivate, hmain, x, hpositive⟩ + obtain ⟨d, hd, ht, hh⟩ := witness_system_metadata + (main.resample value) (fun i => (word i).resample value) value hinj hprime + (main.resample_realizes value) (fun i => (word i).resample_realizes value) + mark attachment position hsize hminimal hsq hcard hsupport hmark hprivate horder + (by simpa only [LabeledPrimeWord.resample_length] using hbound) hmain + (by simpa only [LabeledPrimeWord.resample_length] using hmainLength) + (by simpa only [LabeledPrimeWord.resample_length] using hwordLength) x hpositive + exact ⟨d, hd, + (d.triangular_pattern (main.resamplePattern value) (fun i => (word i).resamplePattern value) h).mp ht, + (d.holds_pattern (main.resamplePattern value) (fun i => (word i).resamplePattern value) h _).mp hh⟩ + +/-- The actual witness event has the same prime-power saving as the metadata +union. Coincident prime assignments are allowed in the enlarged union. -/ +theorem resampled_witness_reciprocal_bound {n K h s J N : ℕ} {supply : ℕ → ℕ → Prop} + {ι : Type*} [Fintype ι] [DecidableEq ι] + (main : LabeledPrimeWord ι) (word : Fin n → LabeledPrimeWord ι) + (mark : Fin n → ι) (attachment position : Fin n → ℕ) + (hsize : 8 * K ≤ n) (horder : Monotone attachment) + (hbound : ∀ i, attachment i ≤ main.word.length) + (hmainLength : main.word.length ≤ N) (hwordLength : ∀ i, (word i).word.length ≤ N) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hV : 1 ≤ primeHarmonicMass P) + (H B : ℕ) (hH : 0 < H) (hB : 1 ≤ B) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ B) + (hdelta : (H : ℝ)⁻¹ + (1 + Real.log B) / H ≤ 1) : + (∑ a : ι → P, if ResampledWitnessEvent main word h s J supply mark attachment position + (fun z => (a z).val) then ∏ z, ((a z).val : ℝ)⁻¹ else 0) ≤ + (Fintype.card (WitnessSystemData n N ι) : ℝ) * primeHarmonicMass P ^ Fintype.card ι * + ((H : ℝ)⁻¹ + (1 + Real.log B) / H) ^ K := by + apply le_trans _ (witness_metadata_reciprocal_bound n N K h main word P hP hV H B hH hB hlo hhi hdelta) + apply sum_le_sum + intro a _ + by_cases he : ResampledWitnessEvent main word h s J supply mark attachment position (fun z => (a z).val) + · have hd := resampled_witness_metadata main word mark attachment position hsize horder hbound + hmainLength hwordLength (fun z => (a z).val) he + have hd' : ∃ d : WitnessSystemData n N ι, K ≤ d.chosen.card ∧ d.Triangular main word h ∧ + d.Holds main word h (integerPrimeAssignment Subtype.val a) := hd + rw [ite_eq_left he, ite_eq_left hd'] + · simp only [he, ite_false] + split_ifs <;> positivity + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RescaledPrefixSums.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RescaledPrefixSums.lean new file mode 100644 index 0000000000000000000000000000000000000000..a1a1e5dd47987ae1d1d157635394ef3da2a7b2d0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RescaledPrefixSums.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftBoundary +import Mathlib.Algebra.BigOperators.Field +import Mathlib.Data.Nat.Cast.Order.Field +import Mathlib.Order.Filter.AtTopBot.Basic +import Mathlib.Order.Filter.Finite + +namespace OAI + +/-! Finite weighted assembly at the actual divisor scale `Y = X/u`. +The factor `1/u` is retained exactly, including floor cutoffs. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma tendsto_nat_div_atTop (u : ℕ) (hu : 0 < u) : + Tendsto (fun X : ℕ => X / u) atTop atTop := by + apply tendsto_atTop.2 + intro N + filter_upwards [eventually_ge_atTop (N * u)] with X hX + exact (Nat.le_div_iff_mul_le hu).mpr hX + +lemma prefix_norm_of_average_bound (F : ℕ → ℂ) (N : ℕ) (E : ℝ) + (hF : ‖positivePrefix F N / (N : ℂ)‖ ≤ E) : + ‖positivePrefix F N‖ ≤ (N : ℝ) * E := by + by_cases hN : N = 0 + · simp [hN, positivePrefix] + have hNp : (0 : ℝ) < N := by exact_mod_cast Nat.pos_of_ne_zero hN + rw [norm_div, Complex.norm_natCast] at hF + have ht := (div_le_iff₀ hNp).mp hF + nlinarith only [ht] + +/-- Each profile may have its own parameter. The resulting long-average +threshold is common to the finite divisor family and all parameter choices. -/ +theorem finite_rescaled_prefix_bound {ι : Type*} (U : Finset ℕ) + (a : ℕ → ℂ) (F : ℕ → ι → ℕ → ℂ) (Valid : ℕ → ι → Prop) (E : ℝ) (hE : 0 ≤ E) + (hU : ∀ u ∈ U, 0 < u) + (hF : ∀ u ∈ U, ∀ᶠ Y : ℕ in atTop, + ∀ t : ι, Valid u t → ‖positivePrefix (F u t) Y / (Y : ℂ)‖ ≤ E) : + ∀ᶠ X : ℕ in atTop, ∀ t : ℕ → ι, (∀ u ∈ U, Valid u (t u)) → + ‖(∑ u ∈ U, a u * positivePrefix (F u (t u)) (X / u)) / (X : ℂ)‖ ≤ + E * ∑ u ∈ U, ‖a u‖ / (u : ℝ) := by + have hall : ∀ᶠ X : ℕ in atTop, ∀ u ∈ U, + ∀ t : ι, Valid u t → ‖positivePrefix (F u t) (X / u) / ((X / u : ℕ) : ℂ)‖ ≤ E := by + apply (eventually_all_finset U).mpr + intro u hu + exact (tendsto_nat_div_atTop u (hU u hu)).eventually (hF u hu) + filter_upwards [hall, eventually_ge_atTop 1] with X hX hX₁ + intro t ht + have hXp : (0 : ℝ) < X := by exact_mod_cast (show 0 < X by omega) + rw [sum_div] + calc + _ ≤ ∑ u ∈ U, ‖a u * positivePrefix (F u (t u)) (X / u) / (X : ℂ)‖ := + norm_sum_le _ _ + _ ≤ ∑ u ∈ U, E * (‖a u‖ / (u : ℝ)) := by + apply sum_le_sum + intro u hu + have hup : (0 : ℝ) < u := by exact_mod_cast hU u hu + have hb := prefix_norm_of_average_bound (F u (t u)) (X / u) E (hX u hu (t u) (ht u hu)) + have hratio : ((X / u : ℕ) : ℝ) ≤ (X : ℝ) / u := Nat.cast_div_le + have hprefix : ‖positivePrefix (F u (t u)) (X / u)‖ ≤ ((X : ℝ) / u) * E := + hb.trans (mul_le_mul_of_nonneg_right hratio hE) + rw [norm_div, norm_mul, Complex.norm_natCast] + calc + _ ≤ (‖a u‖ * (((X : ℝ) / u) * E)) / X := by gcongr + _ = _ := by field_simp + _ = _ := by rw [mul_sum] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueBox.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueBox.lean new file mode 100644 index 0000000000000000000000000000000000000000..66e997daa0d3c07d2ffa52770d340f6c114f0c25 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueBox.lean @@ -0,0 +1,129 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CRTComparison +import OAI.NumberTheory.TwoPoint.Bounds.FiniteProbability + +namespace OAI + +/-! Exact residue laws for one interval and three independent intervals. +The box discrepancy is derived by tensoring the one-dimensional count, +without estimating each individual three-dimensional residue atom. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma finiteTotalVariation_product {α β : Type*} [Fintype α] [Fintype β] + (μ₁ ν₁ : FiniteLaw α) (μ₂ ν₂ : FiniteLaw β) : + finiteTotalVariation (μ₁.product μ₂).weight (ν₁.product ν₂).weight ≤ + finiteTotalVariation μ₁.weight ν₁.weight + finiteTotalVariation μ₂.weight ν₂.weight := by + have hpoint (x : α) (y : β) : + |μ₁.weight x * μ₂.weight y - ν₁.weight x * ν₂.weight y| ≤ + |μ₁.weight x - ν₁.weight x| * μ₂.weight y + + ν₁.weight x * |μ₂.weight y - ν₂.weight y| := by + calc + _ = |(μ₁.weight x - ν₁.weight x) * μ₂.weight y + + ν₁.weight x * (μ₂.weight y - ν₂.weight y)| := by congr 1; ring + _ ≤ |(μ₁.weight x - ν₁.weight x) * μ₂.weight y| + + |ν₁.weight x * (μ₂.weight y - ν₂.weight y)| := abs_add_le _ _ + _ = _ := by rw [abs_mul, abs_mul, abs_of_nonneg (μ₂.nonneg y), + abs_of_nonneg (ν₁.nonneg x)] + have hsum := sum_le_sum (fun x (_ : x ∈ (univ : Finset α)) => + sum_le_sum (fun y (_ : y ∈ (univ : Finset β)) => hpoint x y)) + have heq : (∑ x : α, ∑ y : β, + (|μ₁.weight x - ν₁.weight x| * μ₂.weight y + + ν₁.weight x * |μ₂.weight y - ν₂.weight y|)) = + (∑ x, |μ₁.weight x - ν₁.weight x|) + + ∑ y, |μ₂.weight y - ν₂.weight y| := by + simp only [sum_add_distrib, ← mul_sum, μ₂.total, mul_one] + rw [← sum_mul, ν₁.total, one_mul] + rw [heq] at hsum + unfold finiteTotalVariation + simp only [FiniteLaw.product, Fintype.sum_prod_type] + exact (div_le_div_of_nonneg_right hsum (by norm_num)).trans_eq (add_div _ _ 2) + +noncomputable def uniformZModLaw (D : ℕ) [NeZero D] : FiniteLaw (ZMod D) where + weight _ := 1 / D + nonneg _ := by positivity + total := by simp [ZMod.card, nsmul_eq_mul, NeZero.ne D] + +noncomputable def intervalResidueLaw {D : ℕ} [NeZero D] + (A : ZMod D) (N : ℕ) (hN : 0 < N) : FiniteLaw (ZMod D) where + weight := residueProbability A N + nonneg _ := by unfold residueProbability; positivity + total := residueProbability_sum A N hN + +lemma intervalResidueLaw_totalVariation {D : ℕ} [NeZero D] + (A : ZMod D) (N : ℕ) (hN : 0 < N) : + finiteTotalVariation (intervalResidueLaw A N hN).weight (uniformZModLaw D).weight ≤ + (D : ℝ) / (2 * N) := + residueTotalVariation_le A N hN + +/-- The residue mass is the exact pushforward of uniform interval sampling. -/ +lemma intervalResidueLaw_average {D : ℕ} [NeZero D] + (A : ZMod D) (N : ℕ) (hN : 0 < N) (f : ZMod D → ℝ) : + (intervalResidueLaw A N hN).average f = + (∑ j ∈ range N, f (A + (j : ZMod D))) / N := by + unfold FiniteLaw.average intervalResidueLaw residueProbability residueCount + simp only [div_mul_eq_mul_div, ← sum_div, Nat.cast_sum, Nat.cast_ite, + Nat.cast_one, Nat.cast_zero, sum_mul] + congr 1 + rw [sum_comm] + apply sum_congr rfl + intro j _ + simp only [ite_mul, one_mul, zero_mul] + simp + +noncomputable def residueCubeLaw {D : ℕ} [NeZero D] + (A : ZMod D × ZMod D × ZMod D) (N : ℕ) (hN : 0 < N) : + FiniteLaw (ZMod D × ZMod D × ZMod D) := + (intervalResidueLaw A.1 N hN).product + ((intervalResidueLaw A.2.1 N hN).product (intervalResidueLaw A.2.2 N hN)) + +noncomputable def uniformResidueCubeLaw (D : ℕ) [NeZero D] : + FiniteLaw (ZMod D × ZMod D × ZMod D) := + (uniformZModLaw D).product ((uniformZModLaw D).product (uniformZModLaw D)) + +theorem residueCube_totalVariation {D : ℕ} [NeZero D] + (A : ZMod D × ZMod D × ZMod D) (N : ℕ) (hN : 0 < N) : + finiteTotalVariation (residueCubeLaw A N hN).weight (uniformResidueCubeLaw D).weight ≤ + 3 * D / (2 * (N : ℝ)) := by + have h₁ := intervalResidueLaw_totalVariation A.1 N hN + have h₂ := intervalResidueLaw_totalVariation A.2.1 N hN + have h₃ := intervalResidueLaw_totalVariation A.2.2 N hN + have h₂₃ := finiteTotalVariation_product + (intervalResidueLaw A.2.1 N hN) (uniformZModLaw D) + (intervalResidueLaw A.2.2 N hN) (uniformZModLaw D) + have h₁₂₃ := finiteTotalVariation_product + (intervalResidueLaw A.1 N hN) (uniformZModLaw D) + ((intervalResidueLaw A.2.1 N hN).product (intervalResidueLaw A.2.2 N hN)) + ((uniformZModLaw D).product (uniformZModLaw D)) + change finiteTotalVariation + ((intervalResidueLaw A.1 N hN).product + ((intervalResidueLaw A.2.1 N hN).product (intervalResidueLaw A.2.2 N hN))).weight + ((uniformZModLaw D).product ((uniformZModLaw D).product (uniformZModLaw D))).weight ≤ _ + calc + _ ≤ 3 * ((D : ℝ) / (2 * N)) := by linarith + _ = _ := by ring + +/-- Any simultaneous collection of congruence conditions has the same +`3D/N` box error; the number of allowed residue vectors is irrelevant. -/ +theorem residueCube_probability_discrepancy {D : ℕ} [NeZero D] + (A : ZMod D × ZMod D × ZMod D) (N : ℕ) (hN : 0 < N) + (E : (ZMod D × ZMod D × ZMod D) → Prop) : + |(residueCubeLaw A N hN).probability E - (uniformResidueCubeLaw D).probability E| ≤ + 3 * D / (N : ℝ) := by + have hb := finite_observable_difference (residueCubeLaw A N hN).weight + (uniformResidueCubeLaw D).weight (fun x => if E x then 1 else 0) + (fun x => by split_ifs <;> norm_num) + have hv := residueCube_totalVariation A N hN + change |(residueCubeLaw A N hN).probability E - + (uniformResidueCubeLaw D).probability E| ≤ _ at hb + calc + _ ≤ 2 * finiteTotalVariation (residueCubeLaw A N hN).weight + (uniformResidueCubeLaw D).weight := hb + _ ≤ 2 * (3 * D / (2 * (N : ℝ))) := mul_le_mul_of_nonneg_left hv (by norm_num) + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueCentering.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueCentering.lean new file mode 100644 index 0000000000000000000000000000000000000000..b149afb46d98070a82fa55ea91f3db36f2bbb91d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueCentering.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ObservedDesignationWeights +import OAI.NumberTheory.TwoPoint.Bounds.CommonResidueLift +import OAI.NumberTheory.TwoPoint.Bounds.PrimeFamilyWeights +import OAI.NumberTheory.TwoPoint.Walks.ColumnHarmonicSum + +namespace OAI + +/-! Exact passage from divisibility centers to the common-carrier singleton formula. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma FiniteLaw.average_congr_on_support {A : Type*} [Fintype A] + (μ : FiniteLaw A) {f g : A → ℝ} (h : ∀ x, μ.weight x ≠ 0 → f x = g x) : + μ.average f = μ.average g := by + apply sum_congr rfl + intro x _ + by_cases hx : μ.weight x = 0 + · simp [hx] + · rw [h x hx] + +noncomputable def forcedResidue (B p : ℕ) (hp : 0 < p) (hpB : p ≤ B) (offset : ℤ) : Fin B := + letI : NeZero p := ⟨hp.ne'⟩ + ⟨(- (offset : ZMod p)).val, (ZMod.val_lt _).trans_le hpB⟩ + +lemma forcedResidue_lt (B p : ℕ) (hp : 0 < p) (hpB : p ≤ B) (offset : ℤ) : + (forcedResidue B p hp hpB offset).val < p := by + let : NeZero p := ⟨hp.ne'⟩ + exact ZMod.val_lt _ + +lemma divisor_test_iff_forcedResidue (B p : ℕ) (hp : 0 < p) (hpB : p ≤ B) + (offset : ℤ) (z : Fin B) (hz : z.val < p) : + (p : ℤ) ∣ (z.val : ℤ) + offset ↔ z = forcedResidue B p hp hpB offset := by + let : NeZero p := ⟨hp.ne'⟩ + have he : (p : ℤ) ∣ (z.val : ℤ) + offset ↔ + (z.val : ZMod p) = -(offset : ZMod p) := + residue_offset_divisibility (z.val : ZMod p) (z.val : ℤ) offset (by simp) + rw [he] + constructor + · intro h + apply Fin.ext + have hv := congrArg ZMod.val h + simpa only [ZMod.val_natCast_of_lt hz, forcedResidue] using hv + · intro h + subst z + exact ZMod.natCast_zmod_val _ + +/-- The equality is needed only on the support of the product law. Values +in the common carrier above a coordinate's modulus have zero mass. -/ +theorem uniform_divisor_word_average {ι τ : Type*} [Fintype ι] [Fintype τ] + [DecidableEq ι] (B : ℕ) (p : ι → ℕ) (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (label : τ → ι) (offset : τ → ℤ) (R : ℝ) (G : (ι → Fin B) → ℝ) : + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun z => R * (∏ t, + ((if (p (label t) : ℤ) ∣ (z (label t)).val + offset t then (1 : ℝ) else 0) - + (p (label t) : ℝ)⁻¹)) * G z) = + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun z => R * (∏ t, + ((if z (label t) = forcedResidue B (p (label t)) (hp _) (hpB _) (offset t) + then (1 : ℝ) else 0) - (p (label t) : ℝ)⁻¹)) * G z) := by + apply FiniteLaw.average_congr_on_support + intro z hz + have hs := (uniformResidueLaw_independent_support B p hp hpB z).mp hz + have he (t : τ) := divisor_test_iff_forcedResidue B (p (label t)) (hp _) (hpB _) + (offset t) (z (label t)) (hs (label t)) + simp only [he] + +abbrev ColumnPrimeCoordinate {J : ℕ} (P : Fin J → Finset ℕ) := Σ j, P j + +def tupleSlotLabel {J R : ℕ} {P : Fin J → Finset ℕ} + (w : ColumnPrimeAssignment J R P) (t : Fin R × Fin J) : ColumnPrimeCoordinate P := + ⟨t.2, w t.2 t.1⟩ + +/-- Flatten the actual product of family centers without changing either +the numerical prime labels or their repeated residue coordinates. -/ +lemma familyCenter_word_product {J R B : ℕ} {P : Fin J → Finset ℕ} + (w : ColumnPrimeAssignment J R P) (offset : Fin R → ℤ) + (z : ColumnPrimeCoordinate P → Fin B) : + (∏ i, familyCenter (fun _ p => p.val) + (fun j p => ((z ⟨j, p⟩).val : ℤ)) (fun j => w j i) (offset i)) = + ∏ t : Fin R × Fin J, + ((if ((tupleSlotLabel w t).2.val : ℤ) ∣ + ((z (tupleSlotLabel w t)).val : ℤ) + offset t.1 then (1 : ℝ) else 0) - + ((tupleSlotLabel w t).2.val : ℝ)⁻¹) := by + rw [Fintype.prod_prod_type] + rfl + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueCounts.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueCounts.lean new file mode 100644 index 0000000000000000000000000000000000000000..0dc10ace73d0ceb30d351913abed6a23598833c5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueCounts.lean @@ -0,0 +1,162 @@ +import Mathlib.Data.ZMod.Basic +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Tactic + +namespace OAI + +/-! +# Residue counts on arbitrary finite consecutive intervals + +An interval is represented by its starting residue `A` and its length `N`. +Thus this includes arbitrary translates, including intervals starting at +negative integers. We prove the exact quotient-and-remainder count, the +one-count discrepancy, and the total-variation estimate used by the finite +residue comparison in the manuscript. +-/ + +namespace TwoPointCorrelations + +open Finset + +/-- Number of offsets `0 ≤ j < N` whose translated residue equals `r`. -/ +def residueCount {D : ℕ} [NeZero D] (A : ZMod D) (N : ℕ) (r : ZMod D) : ℕ := + ∑ j ∈ Finset.range N, if A + (j : ZMod D) = r then 1 else 0 + +lemma residueCount_add {D : ℕ} [NeZero D] (A : ZMod D) (M N : ℕ) (r : ZMod D) : + residueCount A (M + N) r = residueCount A M r + residueCount (A + (M : ZMod D)) N r := by + unfold residueCount + rw [Finset.sum_range_add] + congr 1 + apply Finset.sum_congr rfl + intro j hj + simp only [Nat.cast_add, add_assoc] + +lemma residueCount_period {D : ℕ} [NeZero D] (A r : ZMod D) : + residueCount A D r = 1 := by + unfold residueCount + rw [← Fin.sum_univ_eq_sum_range] + let e : Fin D ≃ ZMod D := + { toFun := fun i => (i.val : ZMod D) + invFun := fun z => ⟨z.val, z.val_lt⟩ + left_inv := fun i => Fin.ext (ZMod.val_natCast_of_lt i.isLt) + right_inv := fun z => ZMod.natCast_zmod_val z } + change (∑ i : Fin D, (fun z : ZMod D => if A + z = r then (1 : ℕ) else 0) (e i)) = 1 + rw [e.sum_comp (fun z : ZMod D => if A + z = r then (1 : ℕ) else 0)] + have htest (j : ZMod D) : A + j = r ↔ j = r - A := by + constructor + · intro h + apply eq_sub_iff_add_eq.mpr + simpa [add_comm] using h + · intro h + rw [h] + ring + simp_rw [htest] + simp + +lemma residueCount_multiple {D : ℕ} [NeZero D] (A r : ZMod D) (k : ℕ) : + residueCount A (D * k) r = k := by + induction k with + | zero => simp [residueCount] + | succ k ih => + rw [Nat.mul_succ, residueCount_add, ih, residueCount_period] + +lemma residueCount_short {D : ℕ} [NeZero D] (A r : ZMod D) (N : ℕ) + (hN : N ≤ D) : residueCount A N r = if (r - A).val < N then 1 else 0 := by + unfold residueCount + have htest (j : ℕ) (hj : j ∈ Finset.range N) : + A + (j : ZMod D) = r ↔ j = (r - A).val := by + have hjD : j < D := (Finset.mem_range.mp hj).trans_le hN + constructor + · intro h + have heq : (j : ZMod D) = r - A := by + apply eq_sub_iff_add_eq.mpr + simpa [add_comm] using h + have hv := congrArg ZMod.val heq + simpa [ZMod.val_natCast, Nat.mod_eq_of_lt hjD] using hv + · intro h + rw [h, ZMod.natCast_zmod_val] + ring + calc + (∑ j ∈ Finset.range N, if A + (j : ZMod D) = r then 1 else 0) = + ∑ j ∈ Finset.range N, if j = (r - A).val then 1 else 0 := by + apply Finset.sum_congr rfl + intro j hj + simp only [htest j hj] + _ = if (r - A).val < N then 1 else 0 := by simp + +/-- Exact residue count on an arbitrary translated interval. -/ +theorem residueCount_exact {D : ℕ} [NeZero D] (A r : ZMod D) (N : ℕ) : + residueCount A N r = N / D + if (r - A).val < N % D then 1 else 0 := by + have hsplit := residueCount_add A (D * (N / D)) (N % D) r + have hN : D * (N / D) + N % D = N := Nat.div_add_mod N D + rw [hN, residueCount_multiple] at hsplit + simpa only [Nat.cast_mul, ZMod.natCast_self, zero_mul, add_zero, + residueCount_short A r (N % D) (Nat.le_of_lt (Nat.mod_lt N (NeZero.pos D)))] using hsplit + +/-- The count differs from interval length divided by modulus by at most one. -/ +theorem residueCount_discrepancy {D : ℕ} [NeZero D] (A r : ZMod D) (N : ℕ) : + |(residueCount A N r : ℝ) - (N : ℝ) / D| ≤ 1 := by + have hD : (0 : ℝ) < D := by exact_mod_cast NeZero.pos D + have hrem₀ : (0 : ℝ) ≤ ((N % D : ℕ) : ℝ) := by positivity + have hrem₁ : ((N % D : ℕ) : ℝ) < D := by exact_mod_cast Nat.mod_lt N (NeZero.pos D) + have hdiv₀ : (0 : ℝ) ≤ ((N % D : ℕ) : ℝ) / D := div_nonneg hrem₀ hD.le + have hdiv₁ : ((N % D : ℕ) : ℝ) / D < 1 := (div_lt_one hD).mpr hrem₁ + have hquot : (N : ℝ) / D = (N / D : ℕ) + ((N % D : ℕ) : ℝ) / D := by + have hN : (N : ℝ) = (D : ℝ) * (N / D : ℕ) + (N % D : ℕ) := by + exact_mod_cast (Nat.div_add_mod N D).symm + apply (div_eq_iff hD.ne').mpr + field_simp + nlinarith [hN] + rw [residueCount_exact, Nat.cast_add, hquot] + split_ifs <;> simp only [Nat.cast_one, Nat.cast_zero] <;> rw [abs_le] <;> + constructor <;> linarith + +/-- The residue law of a uniformly selected origin from an interval. -/ +noncomputable def residueProbability {D : ℕ} [NeZero D] (A : ZMod D) + (N : ℕ) (r : ZMod D) : ℝ := (residueCount A N r : ℝ) / N + +lemma residueCount_sum {D : ℕ} [NeZero D] (A : ZMod D) (N : ℕ) : + ∑ r : ZMod D, residueCount A N r = N := by + unfold residueCount + rw [Finset.sum_comm] + simp + +lemma residueProbability_sum {D : ℕ} [NeZero D] (A : ZMod D) (N : ℕ) (hN : 0 < N) : + ∑ r : ZMod D, residueProbability A N r = 1 := by + have hN' : (N : ℝ) ≠ 0 := by exact_mod_cast Nat.ne_of_gt hN + simp only [residueProbability, ← Finset.sum_div, ← Nat.cast_sum, residueCount_sum] + exact div_self hN' + +lemma residueProbability_discrepancy {D : ℕ} [NeZero D] (A r : ZMod D) + (N : ℕ) (hN : 0 < N) : |residueProbability A N r - 1 / (D : ℝ)| ≤ 1 / (N : ℝ) := by + have hN' : (0 : ℝ) < N := by exact_mod_cast hN + have hD' : (D : ℝ) ≠ 0 := by exact_mod_cast NeZero.ne D + have heq : residueProbability A N r - 1 / (D : ℝ) = + ((residueCount A N r : ℝ) - (N : ℝ) / D) / N := by + unfold residueProbability + field_simp + rw [heq, abs_div, abs_of_pos hN'] + exact div_le_div_of_nonneg_right (residueCount_discrepancy A r N) hN'.le + +/-- Half the ℓ¹ difference from the uniform residue law. -/ +noncomputable def residueTotalVariation {D : ℕ} [NeZero D] (A : ZMod D) (N : ℕ) : ℝ := + (∑ r : ZMod D, |residueProbability A N r - 1 / (D : ℝ)|) / 2 + +/-- The stronger `D/(2N)` bound implies the `D/N` estimate used in the paper. -/ +theorem residueTotalVariation_le {D : ℕ} [NeZero D] (A : ZMod D) + (N : ℕ) (hN : 0 < N) : residueTotalVariation A N ≤ (D : ℝ) / (2 * N) := by + unfold residueTotalVariation + have hsum : (∑ r : ZMod D, |residueProbability A N r - 1 / (D : ℝ)|) ≤ + (D : ℝ) / N := by + calc + (∑ r : ZMod D, |residueProbability A N r - 1 / (D : ℝ)|) ≤ + ∑ _r : ZMod D, 1 / (N : ℝ) := + Finset.sum_le_sum (fun r _ => residueProbability_discrepancy A r N hN) + _ = (D : ℝ) / N := by simp [ZMod.card, nsmul_eq_mul, div_eq_mul_inv] + have := div_le_div_of_nonneg_right hsum (by norm_num : (0 : ℝ) ≤ 2) + convert this using 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueExpansion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae40bf5c70bc3cd19ec5b2af48e41a78ffcb66c6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueExpansion.lean @@ -0,0 +1,203 @@ +import OAI.NumberTheory.TwoPoint.Bounds.Dilation +import OAI.NumberTheory.TwoPoint.Bounds.CharacterTwists +import Mathlib.NumberTheory.DirichletCharacter.Orthogonality +import Mathlib.NumberTheory.MulChar.Lemmas +import Mathlib.Analysis.Complex.Polynomial.Basic +import Mathlib.RingTheory.RootsOfUnity.AlgebraicallyClosed + +namespace OAI + +/-! +# Residue classes as finite multiplicative expansions + +The character identity in manuscript Lemma `lem:affine-residue` includes +nonunit residue classes. Dividing by the gcd reduces to a unit class, so the +standard character orthogonality relation applies even when the reduced +modulus is one. Each resulting dilation has the finite expansion already +proved in `Dilation`. +-/ + +open scoped BigOperators ComplexConjugate + +namespace TwoPointCorrelations + +/-- A character evaluated on the natural numbers, with its usual zeros. -/ +noncomputable def naturalCharacter {q : ℕ} (χ : DirichletCharacter ℂ q) (n : ℕ) : ℂ := + χ (n : ZMod q) + +lemma naturalCharacter_multiplicative {q : ℕ} (χ : DirichletCharacter ℂ q) : + Multiplicative (naturalCharacter χ) := by + intro m n _ _ _ + simp [naturalCharacter, map_mul] + +lemma naturalCharacter_oneBounded {q : ℕ} (χ : DirichletCharacter ℂ q) : + OneBounded (naturalCharacter χ) := by + intro n _ + exact χ.norm_le_one _ + +@[simp] lemma naturalCharacter_one {q : ℕ} (χ : DirichletCharacter ℂ q) : + naturalCharacter χ 1 = 1 := by simp [naturalCharacter] + +/-- The inverse-value form of conjugation on a unit residue. -/ +lemma character_conj_unit {q : ℕ} [NeZero q] (χ : DirichletCharacter ℂ q) + {a : ZMod q} (ha : IsUnit a) : conj (χ a) = χ a⁻¹ := by + rw [show conj (χ a) = χ⁻¹ a from MulChar.star_apply' χ a, MulChar.inv_apply] + obtain ⟨u, rfl⟩ := ha + rw [Ring.inverse_unit, ZMod.inv_coe_unit] + +lemma residue_character_orthogonality {q c k : ℕ} (hq : 0 < q) + (hc : c.Coprime q) : + (if k % q = c % q then (1 : ℂ) else 0) = + (q.totient : ℂ)⁻¹ * + ∑ χ : DirichletCharacter ℂ q, conj (naturalCharacter χ c) * naturalCharacter χ k := by + let : NeZero q := ⟨hq.ne'⟩ + have hcunit : IsUnit (c : ZMod q) := (ZMod.isUnit_iff_coprime c q).mpr hc + have hs := DirichletCharacter.sum_char_inv_mul_char_eq ℂ hcunit (k : ZMod q) + have htot : (q.totient : ℂ) ≠ 0 := by + exact_mod_cast (Nat.totient_pos.mpr hq).ne' + have heq : ((c : ZMod q) = (k : ZMod q)) ↔ k % q = c % q := by + rw [ZMod.natCast_eq_natCast_iff] + exact eq_comm + simp_rw [naturalCharacter, character_conj_unit _ hcunit] + simp only [hs, heq] + split_ifs <;> simp_all + +lemma scaled_residue_iff {d q c n : ℕ} (hd : 0 < d) (hn : d ∣ n) : + n % (d * q) = (d * c) % (d * q) ↔ (n / d) % q = c % q := by + obtain ⟨k, rfl⟩ := hn + rw [Nat.mul_div_cancel_left k hd, Nat.mul_mod_mul_left, Nat.mul_mod_mul_left] + exact Nat.mul_left_cancel_iff hd + +lemma dvd_of_scaled_residue {d q c n : ℕ} + (h : n % (d * q) = (d * c) % (d * q)) : d ∣ n := by + have hr : d ∣ n % (d * q) := by + rw [h, Nat.mul_mod_mul_left] + exact dvd_mul_right d _ + have ht : d ∣ (d * q) * (n / (d * q)) := dvd_mul_of_dvd_left (dvd_mul_right d q) _ + simpa only [Nat.mod_add_div] using dvd_add hr ht + +/-- Gcd reduction followed by character orthogonality, valid also for `b = 0` +and for reduced modulus one. No assumption that the original class is a unit +is present. -/ +theorem residue_indicator_eq_character_dilations (l b n : ℕ) (hl : 0 < l) : + (if n % l = b % l then (1 : ℂ) else 0) = + ((l / b.gcd l).totient : ℂ)⁻¹ * + ∑ χ : DirichletCharacter ℂ (l / b.gcd l), + conj (naturalCharacter χ (b / b.gcd l)) * + dilate (b.gcd l) (naturalCharacter χ) n := by + let d := b.gcd l + let q := l / d + let c := b / d + have hd : 0 < d := Nat.gcd_pos_of_pos_right b hl + have hdl : d ∣ l := Nat.gcd_dvd_right b l + have hdb : d ∣ b := Nat.gcd_dvd_left b l + have hlq : l = d * q := (Nat.mul_div_cancel' hdl).symm + have hbc : b = d * c := (Nat.mul_div_cancel' hdb).symm + have hq : 0 < q := Nat.div_pos (Nat.le_of_dvd hl hdl) hd + have hc : c.Coprime q := Nat.coprime_div_gcd_div_gcd hd + change (if n % l = b % l then (1 : ℂ) else 0) = + (q.totient : ℂ)⁻¹ * ∑ χ : DirichletCharacter ℂ q, + conj (naturalCharacter χ c) * dilate d (naturalCharacter χ) n + by_cases hn : d ∣ n + · simp only [dilate, ite_eq_left hn] + rw [hlq, hbc] + simp only [scaled_residue_iff hd hn] + exact residue_character_orthogonality hq hc + · have hnres : n % l ≠ b % l := by + intro h + apply hn + apply dvd_of_scaled_residue (q := q) (c := c) + simpa only [← hlq, ← hbc] using h + simp [hnres, dilate, hn] + +/-- Every residue indicator is an explicit finite sum of bounded normalized +multiplicative functions. -/ +theorem residue_indicator_eq_components (l b n : ℕ) (hl : 0 < l) (hn : 0 < n) : + (if n % l = b % l then (1 : ℂ) else 0) = + ((l / b.gcd l).totient : ℂ)⁻¹ * + ∑ χ : DirichletCharacter ℂ (l / b.gcd l), + ∑ E ∈ (b.gcd l).primeFactors.powerset, + (conj (naturalCharacter χ (b / b.gcd l)) * (-1 : ℂ) ^ E.card) * + dilationComponent (b.gcd l) (naturalCharacter χ) E n := by + rw [residue_indicator_eq_character_dilations l b n hl] + congr 1 + apply Finset.sum_congr rfl + intro χ _ + rw [dilate_eq_sum_components (b.gcd l) (naturalCharacter χ) + (Nat.gcd_pos_of_pos_right b hl) (naturalCharacter_multiplicative χ) + (naturalCharacter_one χ) hn, Finset.mul_sum] + apply Finset.sum_congr rfl + intro E _ + ring + +lemma Multiplicative.mul {f g : ℕ → ℂ} (hf : Multiplicative f) (hg : Multiplicative g) : + Multiplicative (fun n => f n * g n) := by + intro m n hm hn hcop + dsimp only + rw [hf m n hm hn hcop, hg m n hm hn hcop] + ring + +lemma OneBounded.mul {f g : ℕ → ℂ} (hf : OneBounded f) (hg : OneBounded g) : + OneBounded (fun n => f n * g n) := by + intro n hn + rw [norm_mul] + exact (mul_le_mul (hf n hn) (hg n hn) (norm_nonneg _) zero_le_one).trans_eq + (by norm_num) + +/-- The multiplicative pieces of a function restricted to a residue class. -/ +noncomputable def residueComponent {q : ℕ} (f : ℕ → ℂ) (d : ℕ) + (χ : DirichletCharacter ℂ q) (E : Finset ℕ) (n : ℕ) : ℂ := + f n * dilationComponent d (naturalCharacter χ) E n + +lemma residueComponent_multiplicative {q : ℕ} (f : ℕ → ℂ) (d : ℕ) + (χ : DirichletCharacter ℂ q) (E : Finset ℕ) (hf : Multiplicative f) : + Multiplicative (residueComponent f d χ E) := + hf.mul (dilationComponent_multiplicative d (naturalCharacter χ) E) + +lemma residueComponent_oneBounded {q : ℕ} (f : ℕ → ℂ) (d : ℕ) + (χ : DirichletCharacter ℂ q) (E : Finset ℕ) (hf : OneBounded f) : + OneBounded (residueComponent f d χ E) := + hf.mul (dilationComponent_oneBounded d (naturalCharacter χ) E + (naturalCharacter_oneBounded χ)) + +/-- Restriction to a nonunit progression modifies the character twist only at +primes dividing the fixed gcd. Hence every multiplicative piece preserves the +original uniformly nonpretentious factor. -/ +lemma residueComponent_nonpretentious {q : ℕ} (f : ℕ → ℂ) (d : ℕ) + (χ : DirichletCharacter ℂ q) (E : Finset ℕ) (hq : 0 < q) + (hf : OneBounded f) (hfnp : UniformlyNonpretentious f) : + UniformlyNonpretentious (residueComponent f d χ E) := by + apply (hfnp.twistByCharacter χ hq).finite_prime_change d.primeFactors + (hf.twistByCharacter χ) (residueComponent_oneBounded f d χ E hf) + intro p hp hpD + unfold residueComponent TwoPointCorrelations.twistByCharacter + congr 1 + simpa only [pow_one, naturalCharacter] using + dilationComponent_prime_pow d (naturalCharacter χ) E (naturalCharacter_one χ) hp hpD 1 + +/-- An explicit expansion after multiplication by the original first factor. -/ +theorem residue_weight_eq_components (f : ℕ → ℂ) (l b n : ℕ) + (hl : 0 < l) (hn : 0 < n) : + (if n % l = b % l then f n else 0) = + ((l / b.gcd l).totient : ℂ)⁻¹ * + ∑ χ : DirichletCharacter ℂ (l / b.gcd l), + ∑ E ∈ (b.gcd l).primeFactors.powerset, + (conj (naturalCharacter χ (b / b.gcd l)) * (-1 : ℂ) ^ E.card) * + residueComponent f (b.gcd l) χ E n := by + calc + _ = f n * (if n % l = b % l then (1 : ℂ) else 0) := by split_ifs <;> simp + _ = _ := by + rw [residue_indicator_eq_components l b n hl hn, mul_left_comm] + congr 1 + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro χ _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro E _ + unfold residueComponent + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueLawUniform.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueLawUniform.lean new file mode 100644 index 0000000000000000000000000000000000000000..1dad315b295ada7e3984374bcdb0b2e99eff78a4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueLawUniform.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteLawMapping +import OAI.NumberTheory.TwoPoint.Bounds.PrimeResidueLift +import OAI.NumberTheory.TwoPoint.Bounds.FiniteAverages + +namespace OAI + +/-! The common padded carrier law pushes forward to the genuine uniform +product of prime residue fields. Padding points contribute zero mass. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem uniformResidue_product_average {ι : Type*} [Fintype ι] [DecidableEq ι] + (B : ℕ) (p : ι → ℕ) [∀ i, NeZero (p i)] + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (F : (∀ i, ZMod (p i)) → ℝ) : + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => F (fun i => (x i).val)) = uniformAverage F := by + let μ := FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i)) + rw [μ.average_fibers (fun x i => ((x i).val : ZMod (p i))) F] + have hprob (y : ∀ i, ZMod (p i)) : + μ.probability (fun x => (fun i => ((x i).val : ZMod (p i))) = y) = + ∏ i, (p i : ℝ)⁻¹ := by + have he : (fun x : ι → Fin B => (fun i => ((x i).val : ZMod (p i))) = y) = + (fun x => ∀ i, ((x i).val : ZMod (p i)) = y i) := by + funext x + exact propext funext_iff + rw [he] + dsimp only [μ] + rw [FiniteLaw.independent_probability_all + (fun i => uniformResidueLaw B (p i) (hp i) (hpB i)) + (fun i (x : Fin B) => (x.val : ZMod (p i)) = y i)] + apply prod_congr rfl + intro i _ + exact uniformResidueLaw_mod_eq B (p i) (hp i) (hpB i) (y i) + simp only [hprob, uniformAverage, Fintype.card_pi, ZMod.card, Nat.cast_prod, + div_eq_mul_inv, ← prod_inv_distrib, ← mul_sum] + ring + +local instance residuePrime_neZero {h J M : ℕ} (data : ProhibitedPrimeFamily h J M) + (p : ↥(data.P ∪ data.Q)) : NeZero p.val := ⟨(data.prime p).ne_zero⟩ + +theorem ProhibitedPrimeFamily.residue_average_uniform {h J M B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (F : (∀ p : ↥(data.P ∪ data.Q), ZMod p.val) → ℝ) : + (data.residueLaw B hB).average (fun x => F (fun p => (x p).val)) = uniformAverage F := by + exact uniformResidue_product_average B (fun p : ↥(data.P ∪ data.Q) => p.val) + (fun p => (data.prime p).pos) (fun p => hB _ p.property) F + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueMatrixMoment.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueMatrixMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4217b1f6d70ae032f5d2e82fe851cc2734c2b75 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueMatrixMoment.lean @@ -0,0 +1,119 @@ +import OAI.NumberTheory.TwoPoint.Bounds.UniformResidueTranslation +import OAI.NumberTheory.TwoPoint.Bounds.MaskedWeightPeriodicity +import OAI.NumberTheory.TwoPoint.Bounds.ShiftTraceComparison + +namespace OAI + +/-! Reduce the actual translated matrix moment to signed closed-word expectations. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {D V : Type*} [DecidableEq D] [Fintype V] + +theorem physicalClosedPair_average_abs_le {h J M B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (embed : V → D × ℤ) (Q : Finset ℕ) (tuple : D → ℕ) + (gate : D → ℤ → ℤ → Prop) (weight : SignedStep → ℤ → ℝ) + (hflip : ∀ t n, weight t.flip (n + t.displacement h) = weight t n) + {k : ℕ} (x : D × ℤ) (a b : Fin k → D × (Q × Bool)) + (hend : shiftWordEnd (integerShiftNext Q tuple h) x a = + shiftWordEnd (integerShiftNext Q tuple h) x b) + (hperiod : ∀ t ∈ integerClosedWordCode Q tuple (a, b), ∀ n m : ℤ, + (∀ p : ↥(data.P ∪ data.Q), (n : ZMod p.val) = (m : ZMod p.val)) → + weight t n = weight t m) : + |(data.residueLaw B hB).average (fun r => + shiftWordWeight embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate + (fun t n => weight t (n + data.residueOrigin r))) x a * + shiftWordWeight embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate + (fun t n => weight t (n + data.residueOrigin r))) x b)| ≤ + |(data.residueLaw B hB).average (fun r => + scalarWalkProduct h weight (data.residueOrigin r) (integerClosedWordCode Q tuple (a, b)))| := by + have htrans := data.residue_average_translate hB + (fun n => scalarWalkProduct h weight n (integerClosedWordCode Q tuple (a, b))) + (fun n m hnm => scalarWalkProduct_residue_congr (data.P ∪ data.Q) h weight _ + (fun t ht z z' hz => hperiod t ht z z' (fun p => hz p.val p.property)) n m + (fun p hp => hnm ⟨p, hp⟩)) x.2 + have hpair : (data.residueLaw B hB).average (fun r => + shiftWordWeight embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate + (fun t n => weight t (n + data.residueOrigin r))) x a * + shiftWordWeight embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate + (fun t n => weight t (n + data.residueOrigin r))) x b) = + (integerPathMask embed Q tuple h gate x a * integerPathMask embed Q tuple h gate x b) * + (data.residueLaw B hB).average (fun r => + scalarWalkProduct h weight (data.residueOrigin r) (integerClosedWordCode Q tuple (a, b))) := by + calc + _ = (data.residueLaw B hB).average (fun r => + (integerPathMask embed Q tuple h gate x a * integerPathMask embed Q tuple h gate x b) * + scalarWalkProduct h weight (data.residueOrigin r + x.2) + (integerClosedWordCode Q tuple (a, b))) := by + apply congrArg (data.residueLaw B hB).average + funext r + rw [physicalShiftWord_closed_pair embed Q tuple h gate weight hflip _ x a b hend, + add_comm x.2] + _ = _ := by + rw [← htrans] + simp only [FiniteLaw.average, mul_sum] + apply sum_congr rfl + intro r _ + ring + rw [hpair] + rcases integerPathMask_zero_or_one embed Q tuple h gate x a with ha | ha <;> + rcases integerPathMask_zero_or_one embed Q tuple h gate x b with hb | hb <;> + simp [ha, hb] + +variable [Fintype D] [DecidableEq V] + +theorem physicalResidueMatrix_moment_le {h J M B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (embed : V → D × ℤ) (hinj : Function.Injective embed) + (Q : Finset ℕ) (tuple : D → ℕ) (gate : D → ℤ → ℤ → Prop) + (weight : SignedStep → ℤ → ℝ) + (hflip : ∀ t n, weight t.flip (n + t.displacement h) = weight t n) (k : ℕ) + (hperiod : ∀ (a b : Fin k → D × (Q × Bool)), + ∀ t ∈ integerClosedWordCode Q tuple (a, b), ∀ n m : ℤ, + (∀ p : ↥(data.P ∪ data.Q), (n : ZMod p.val) = (m : ZMod p.val)) → + weight t n = weight t m) : + (data.residueLaw B hB).average (fun r => + matrixFrobeniusSq (shiftMatrix embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate (fun t n => weight t (n + data.residueOrigin r))) ^ k)) ≤ + ∑ i : V, ∑ a : Fin k → D × (Q × Bool), ∑ b : Fin k → D × (Q × Bool), + if shiftWordEnd (integerShiftNext Q tuple h) (embed i) a = + shiftWordEnd (integerShiftNext Q tuple h) (embed i) b ∧ + integerPathMask embed Q tuple h gate (embed i) a ≠ 0 ∧ + integerPathMask embed Q tuple h gate (embed i) b ≠ 0 then + |(data.residueLaw B hB).average (fun r => scalarWalkProduct h weight + (data.residueOrigin r) (integerClosedWordCode Q tuple (a, b)))| else 0 := by + rw [average_shiftMatrix_moment embed hinj] + apply sum_le_sum + intro i _ + apply sum_le_sum + intro a _ + apply sum_le_sum + intro b _ + by_cases hend : shiftWordEnd (integerShiftNext Q tuple h) (embed i) a = + shiftWordEnd (integerShiftNext Q tuple h) (embed i) b + · by_cases ha : integerPathMask embed Q tuple h gate (embed i) a = 0 + · simp only [shiftClosedWeight, hend, ite_true, physicalShiftWord_product, ha, + zero_mul, ne_eq, not_true_eq_false, false_and, and_false, ite_false, + FiniteLaw.average_const, le_refl] + · by_cases hb : integerPathMask embed Q tuple h gate (embed i) b = 0 + · simp only [shiftClosedWeight, hend, ite_true, physicalShiftWord_product, hb, + zero_mul, mul_zero, ne_eq, not_true_eq_false, and_false, ite_false, + FiniteLaw.average_const, le_refl] + · simp only [shiftClosedWeight, hend, ha, hb, ne_eq, not_false_eq_true, + and_self, ite_true] + exact (le_abs_self _).trans + (physicalClosedPair_average_abs_le data hB embed Q tuple gate weight hflip + (embed i) a b hend (hperiod a b)) + · simp [shiftClosedWeight, hend] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueNumericalWitnesses.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueNumericalWitnesses.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b14c1485712b7c764962d94c5c65133d48e66f6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueNumericalWitnesses.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Walks.AttachedResidueLift +import OAI.NumberTheory.TwoPoint.Bounds.NumericalWitnessEvent + +namespace OAI + +/-! Nonzero singleton centering produces the numerical event counted by witness metadata. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem selected_residue_numerical_witnesses {ι W : Type*} + [Fintype ι] [DecidableEq ι] [Fintype W] [DecidableEq W] + (S : Finset ι) (p : ι → ℕ) (hprime : ∀ i, (p i).Prime) (hinj : Function.Injective p) + (B h s J T : ℕ) (supply : ℕ → ℕ → Prop) + (main : List SignedStep) (word : W → List SignedStep) (attachment : W → ℕ) + (a x : ι → Fin B) + (hatt : ∀ w, attachment w ≤ main.length) + (hminimal : ∀ w, MinimalWord (ForwardProhibited h s supply) (word w)) + (hlen : ∀ w, (word w).length ≤ s) + (hsq : ∀ w t, t ∈ word w → Squarefree t.tuple) + (hdivsq : ∀ w t, t ∈ word w → Squarefree (t.padding * t.tuple)) + (hcard : ∀ w t, t ∈ word w → t.tuple.primeFactors.card = J) + (hsupport : ∀ w q j, TuplePrimeAt (word w) q j → + ¬q ∣ h ∧ ∀ t ∈ word w, ¬q ∣ t.padding) + (hpad : ∀ i ∈ S, ∀ w t, t ∈ word w → ¬p i ∣ t.padding) + (hcover : ∀ w q, q ∈ wordDivisorPrimeSupport (word w) → ∃ i, p i = q) + (position : S → ℕ) + (hmain : ∀ i : S, ∀ v, TuplePrimeAt main (p i) v → v = position i) + (hnonzero : selectedMixedDifference S a + (witnessAvoidance (fun w z => decide (AttachedResiduePositiveWord p h (word w) + (wordDisplacement h (main.take (attachment w))) B z))) x ≠ 0) + (hT : T * (s * J) < S.card) : + ∃ index : Fin T → W, Function.Injective index ∧ + NumericalWitnessEvent main (fun i => word (index i)) p h s J supply := by + let I : W → (S → Fin B) → Bool := fun w z => decide + (AttachedResiduePositiveWord p h (word w) + (wordDisplacement h (main.take (attachment w))) B + (joinCoordinates S z (fun i => x i))) + have hdepends (w) : DependsOn (wordCoordinateSupport (fun i : S => p i) (word w)) (I w) := + attached_residue_test_depends S p h B (word w) _ (hsq w) + (fun i _ => hprime i) (fun i hi => hpad i hi w) _ + have hn : mixedDifference (fun i : S => a i) (witnessAvoidance I) (fun i : S => x i) ≠ 0 := + hnonzero + obtain ⟨index, hindex, horder, H, hI, mark, _hmark, hprivate⟩ := + ordered_numerical_witness_cover (fun i : S => p i) (hinj.comp Subtype.val_injective) + word attachment I (fun i : S => a i) (fun i : S => x i) hdepends hn s J T hlen hsq + (fun w t ht => (hcard w t ht).le) (by simpa only [Fintype.card_coe] using hT) + let hybrid := joinCoordinates S (forceCoordinates H (fun i : S => a i) (fun i : S => x i)) + (fun i => x i) + have htests (i : Fin T) : AttachedResiduePositiveWord p h (word (index i)) + (wordDisplacement h (main.take (attachment (index i)))) B hybrid := by + have hi := hI i + exact of_decide_eq_true hi + obtain ⟨origin, horigin⟩ := attached_residue_words_common_origin T B h p hprime hinj hybrid + (fun i => word (index i)) (fun i => wordDisplacement h (main.take (attachment (index i)))) + (fun i => hdivsq (index i)) (fun i => hcover (index i)) htests + refine ⟨index, hindex, (fun i => (mark i).val), (fun i => attachment (index i)), + (fun i => position (mark i)), horder, (fun i => hatt (index i)), hinj, hprime, + (fun i => hminimal (index i)), (fun i => hsq (index i)), (fun i => hcard (index i)), + (fun i => hsupport (index i)), ?_, ?_, ?_, origin, horigin⟩ + · intro i + exact (mem_wordPrimeSupport_iff _ _ (hsq (index i))).mpr (hprivate i).1 + · intro i j hji hmem + exact (hprivate i).2 j hji ((mem_wordPrimeSupport_iff _ _ (hsq (index j))).mp hmem) + · intro i v hv + exact hmain (mark i) v hv + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueRestriction.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..e71e01ae13062404a2d23ce150ce11f67a7d33ca --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueRestriction.lean @@ -0,0 +1,140 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PrimeResidueLift +import OAI.NumberTheory.TwoPoint.Bounds.IndependentSampling + +namespace OAI + +/-! Restriction of a product law to selected prime coordinates. The +coordinate laws may depend on the prime; no common-modulus uniformity is +assumed. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace FiniteLaw + +lemma independent_average_reindex {ι κ A : Type*} [Fintype ι] [Fintype κ] + [DecidableEq ι] [DecidableEq κ] [Fintype A] + (e : ι ≃ κ) (μ : κ → FiniteLaw A) (f : (κ → A) → ℝ) : + (independent μ).average f = + (independent (fun i => μ (e i))).average (fun x => f (fun k => x (e.symm k))) := by + let E : (ι → A) ≃ (κ → A) := Equiv.arrowCongr e (Equiv.refl A) + calc + _ = ∑ x : ι → A, (independent μ).weight (E x) * f (E x) := + (E.sum_comp (fun x => (independent μ).weight x * f x)).symm + _ = _ := by + apply sum_congr rfl + intro x _ + change (∏ k, (μ k).weight (x (e.symm k))) * f (fun k => x (e.symm k)) = + (∏ i, (μ (e i)).weight (x i)) * f (fun k => x (e.symm k)) + congr 1 + simpa only [e.apply_symm_apply] using + e.symm.prod_comp (fun i => (μ (e i)).weight (x i)) + +lemma independent_average_restrict {ι A : Type*} [Fintype ι] + [DecidableEq ι] [Fintype A] + (μ : ι → FiniteLaw A) (S : Finset ι) (f : (S → A) → ℝ) : + (independent μ).average (fun x => f (fun i : S => x i)) = + (independent (fun i : S => μ i)).average f := by + rw [independent_average_split μ S] + simp only [joinCoordinates_mem, average_const] + +/-- Independent coordinates retain their individual laws under an +injective change of the index set. -/ +lemma independent_average_embedding {ι κ A : Type*} [Fintype ι] [Fintype κ] + [DecidableEq ι] [DecidableEq κ] [Fintype A] + (e : κ → ι) (he : Function.Injective e) (μ : ι → FiniteLaw A) + (f : (κ → A) → ℝ) : + (independent μ).average (fun x => f (fun k => x (e k))) = + (independent (fun k => μ (e k))).average f := by + let S : Finset ι := univ.image e + let E : κ ≃ S := Equiv.ofBijective + (fun k => ⟨e k, mem_image.mpr ⟨k, mem_univ _, rfl⟩⟩) (by + constructor + · intro x y hxy + exact he (congrArg Subtype.val hxy) + · intro y + obtain ⟨k, _, hk⟩ := mem_image.mp y.property + exact ⟨k, Subtype.ext hk⟩) + calc + _ = (independent (fun i : S => μ i)).average + (fun x => f (fun k => x (E k))) := + independent_average_restrict μ S (fun x => f (fun k => x (E k))) + _ = _ := by + rw [independent_average_reindex E] + simp only [E.symm_apply_apply] + rfl + +end FiniteLaw + +namespace ProhibitedPrimeFamily + +variable {h J M B : ℕ} (data : ProhibitedPrimeFamily h J M) + +def paddingCoordinate (p : data.Q) : ↥(data.P ∪ data.Q) := + ⟨p.val, mem_union_right _ p.property⟩ + +def paddingRestriction (x : ↥(data.P ∪ data.Q) → Fin B) : data.Q → Fin B := + fun p => x (data.paddingCoordinate p) + +noncomputable def paddingResidueLaw (B : ℕ) + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) : FiniteLaw (data.Q → Fin B) := + FiniteLaw.independent (fun p : data.Q => + uniformResidueLaw B p.val (data.primeQ _ p.property).pos + (hB _ (mem_union_right _ p.property))) + +lemma residue_average_padding (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (f : (data.Q → Fin B) → ℝ) : + (data.residueLaw B hB).average (fun x => f (data.paddingRestriction x)) = + (data.paddingResidueLaw B hB).average f := by + have hi : Function.Injective data.paddingCoordinate := by + intro p q hpq + apply Subtype.ext + exact congrArg (fun z : ↥(data.P ∪ data.Q) => z.val) hpq + exact FiniteLaw.independent_average_embedding data.paddingCoordinate hi + (fun p => uniformResidueLaw B p.val (data.prime p).pos (hB _ p.property)) f + +lemma exists_padding_residue_origin (x : data.Q → Fin B) : + ∃ n : ℤ, ∀ p : data.Q, (n : ZMod p.val) = ((x p).val : ZMod p.val) := by + let (p : data.Q) : NeZero p.val := ⟨(data.primeQ _ p.property).ne_zero⟩ + apply exists_common_integer_residue (fun p : data.Q => p.val) + intro p q hpq + exact (Nat.coprime_primes (data.primeQ _ p.property) (data.primeQ _ q.property)).mpr + (fun he => hpq (Subtype.ext he)) + +noncomputable def paddingResidueOrigin (x : data.Q → Fin B) : ℤ := + (data.exists_padding_residue_origin x).choose + +lemma paddingResidueOrigin_spec (x : data.Q → Fin B) (p : data.Q) : + (data.paddingResidueOrigin x : ZMod p.val) = ((x p).val : ZMod p.val) := + (data.exists_padding_residue_origin x).choose_spec p + +/-- Padding-periodic observables at the full CRT lift depend only on the +independent padding coordinates, including after a fixed integer shift. -/ +lemma residue_average_padding_shift (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (site : ℤ) (f : ℤ → ℝ) + (hf : ∀ n m : ℤ, (∀ q ∈ data.Q, (n : ZMod q) = (m : ZMod q)) → f n = f m) : + (data.residueLaw B hB).average (fun x => f (data.residueOrigin x + site)) = + (data.paddingResidueLaw B hB).average (fun x => + f (data.paddingResidueOrigin x + site)) := by + calc + _ = (data.residueLaw B hB).average (fun x => + f (data.paddingResidueOrigin (data.paddingRestriction x) + site)) := by + apply congrArg (data.residueLaw B hB).average + funext x + apply hf + intro q hq + let p : data.Q := ⟨q, hq⟩ + rw [Int.cast_add, Int.cast_add] + exact congrArg (fun z : ZMod q => z + (site : ZMod q)) + ((data.residueOrigin_spec x (data.paddingCoordinate p)).trans + (data.paddingResidueOrigin_spec (data.paddingRestriction x) p).symm) + _ = _ := data.residue_average_padding hB + (fun x => f (data.paddingResidueOrigin x + site)) + +end ProhibitedPrimeFamily + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueSampling.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueSampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b3d5836ff6fbe53fceed39d4babfcd60822056c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueSampling.lean @@ -0,0 +1,142 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveCRT +import OAI.NumberTheory.TwoPoint.Bounds.FiniteAverages + +namespace OAI + +/-! A fixed finite interval sample space for every sieve intersection. +The modulus may vary with the selected primes, but the actual sample law +in these identities never changes. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def uniformFiniteLaw (α : Type*) [Fintype α] [Nonempty α] : FiniteLaw α where + weight _ := 1 / Fintype.card α + nonneg _ := by positivity + total := by simp [Fintype.card_ne_zero] + +lemma uniformFiniteLaw_average {α : Type*} [Fintype α] [Nonempty α] (f : α → ℝ) : + (uniformFiniteLaw α).average f = uniformAverage f := by + simp only [FiniteLaw.average, uniformFiniteLaw, ← mul_sum, uniformAverage] + ring + +lemma intervalResidueLaw_average_uniform {D : ℕ} [NeZero D] + (A : ZMod D) (N : ℕ) (hN : 0 < N) (f : ZMod D → ℝ) : + (intervalResidueLaw A N hN).average f = + uniformAverage (fun j : Fin N => f (A + (j.val : ZMod D))) := by + rw [intervalResidueLaw_average] + unfold uniformAverage + rw [Fintype.card_fin] + congr 1 + exact (Fin.sum_univ_eq_sum_range (fun j : ℕ => f (A + (j : ZMod D))) N).symm + +lemma uniformCube_average_residues {D N : ℕ} [NeZero D] [NeZero N] + (A : ZMod D × ZMod D × ZMod D) + (f : (ZMod D × ZMod D × ZMod D) → ℝ) : + (uniformFiniteLaw (Fin N × Fin N × Fin N)).average + (fun j => f (A.1 + (j.1.val : ZMod D), + A.2.1 + (j.2.1.val : ZMod D), A.2.2 + (j.2.2.val : ZMod D))) = + (residueCubeLaw A N (NeZero.pos N)).average f := by + let μ₁ := intervalResidueLaw A.1 N (NeZero.pos N) + let μ₂ := intervalResidueLaw A.2.1 N (NeZero.pos N) + let μ₃ := intervalResidueLaw A.2.2 N (NeZero.pos N) + have h₃ (i j : Fin N) : + uniformAverage (fun k : Fin N => f (A.1 + (i.val : ZMod D), + A.2.1 + (j.val : ZMod D), A.2.2 + (k.val : ZMod D))) = + μ₃.average (fun z => f (A.1 + (i.val : ZMod D), A.2.1 + (j.val : ZMod D), z)) := + (intervalResidueLaw_average_uniform A.2.2 N (NeZero.pos N) + (fun z => f (A.1 + (i.val : ZMod D), A.2.1 + (j.val : ZMod D), z))).symm + have h₂ (i : Fin N) : + uniformAverage (fun j : Fin N => + μ₃.average (fun z => f (A.1 + (i.val : ZMod D), A.2.1 + (j.val : ZMod D), z))) = + μ₂.average (fun y => μ₃.average (fun z => f (A.1 + (i.val : ZMod D), y, z))) := + (intervalResidueLaw_average_uniform A.2.1 N (NeZero.pos N) + (fun y => μ₃.average (fun z => f (A.1 + (i.val : ZMod D), y, z)))).symm + have hprod (i : Fin N) := uniformAverage_prod + (fun (j k : Fin N) => f (A.1 + (i.val : ZMod D), + A.2.1 + (j.val : ZMod D), A.2.2 + (k.val : ZMod D))) + rw [uniformFiniteLaw_average, uniformAverage_prod + (fun (i : Fin N) (jk : Fin N × Fin N) => f (A.1 + (i.val : ZMod D), + A.2.1 + (jk.1.val : ZMod D), A.2.2 + (jk.2.val : ZMod D)))] + simp_rw [hprod, h₃, h₂] + change _ = (μ₁.product (μ₂.product μ₃)).average f + rw [FiniteLaw.average_product] + simp_rw [FiniteLaw.average_product] + exact (intervalResidueLaw_average_uniform A.1 N (NeZero.pos N) + (fun x => μ₂.average (fun y => μ₃.average (fun z => f (x, y, z))))).symm + +lemma uniformCube_probability_residues {D N : ℕ} [NeZero D] [NeZero N] + (A : ZMod D × ZMod D × ZMod D) + (E : (ZMod D × ZMod D × ZMod D) → Prop) : + (uniformFiniteLaw (Fin N × Fin N × Fin N)).probability + (fun j => E (A.1 + (j.1.val : ZMod D), + A.2.1 + (j.2.1.val : ZMod D), A.2.2 + (j.2.2.val : ZMod D))) = + (residueCubeLaw A N (NeZero.pos N)).probability E := + uniformCube_average_residues A (fun z => if E z then 1 else 0) + +/-- Exact CRT intersections on a fixed uniform interval cube, with their +complete finite boundary error. -/ +theorem sieveCRT_cube_sample_discrepancy {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ZMod (∏ i, s i) × ZMod (∏ i, s i) × ZMod (∏ i, s i)) + (N : ℕ) [NeZero N] + (E : ∀ i, (ZMod (s i) × ZMod (s i) × ZMod (s i)) → Prop) : + |(uniformFiniteLaw (Fin N × Fin N × Fin N)).probability + (fun j => ∀ i, E i (sieveCubeCRT s hcop + (A.1 + (j.1.val : ZMod (∏ i, s i)), + A.2.1 + (j.2.1.val : ZMod (∏ i, s i)), + A.2.2 + (j.2.2.val : ZMod (∏ i, s i))) i)) - + ∏ i, (uniformResidueCubeLaw (s i)).probability (E i)| ≤ + 3 * (∏ i, s i : ℕ) / (N : ℝ) := by + rw [uniformCube_probability_residues A (fun x => ∀ i, E i (sieveCubeCRT s hcop x i)), + ← sieveCRT_cube_probability s hcop E] + exact residueCube_probability_discrepancy A N (NeZero.pos N) _ + +lemma uniformInterval_probability_residues {D N : ℕ} [NeZero D] [NeZero N] + (A : ZMod D) (E : ZMod D → Prop) : + (uniformFiniteLaw (Fin N)).probability (fun j => E (A + (j.val : ZMod D))) = + (intervalResidueLaw A N (NeZero.pos N)).probability E := by + unfold FiniteLaw.probability + rw [uniformFiniteLaw_average, intervalResidueLaw_average_uniform] + +lemma interval_probability_discrepancy {D : ℕ} [NeZero D] + (A : ZMod D) (N : ℕ) (hN : 0 < N) (E : ZMod D → Prop) : + |(intervalResidueLaw A N hN).probability E - (uniformZModLaw D).probability E| ≤ + (D : ℝ) / N := by + have hd := finite_observable_difference (intervalResidueLaw A N hN).weight + (uniformZModLaw D).weight (fun x => if E x then 1 else 0) + (fun x => by split_ifs <;> norm_num) + have hv := intervalResidueLaw_totalVariation A N hN + change |(intervalResidueLaw A N hN).probability E - + (uniformZModLaw D).probability E| ≤ _ at hd + calc + _ ≤ 2 * finiteTotalVariation (intervalResidueLaw A N hN).weight + (uniformZModLaw D).weight := hd + _ ≤ 2 * ((D : ℝ) / (2 * N)) := mul_le_mul_of_nonneg_left hv (by norm_num) + _ = _ := by ring + +theorem sieveCRT_one_sample_discrepancy {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ZMod (∏ i, s i)) (N : ℕ) [NeZero N] (E : ∀ i, ZMod (s i) → Prop) : + |(uniformFiniteLaw (Fin N)).probability + (fun j => ∀ i, E i (ZMod.prodEquivPi s hcop (A + (j.val : ZMod (∏ i, s i))) i)) - + ∏ i, (uniformZModLaw (s i)).probability (E i)| ≤ (∏ i, s i : ℕ) / (N : ℝ) := by + rw [uniformInterval_probability_residues A + (fun x => ∀ i, E i (ZMod.prodEquivPi s hcop x i)), ← sieveCRT_one_probability s hcop E] + exact interval_probability_discrepancy A N (NeZero.pos N) _ + +lemma sieveCubeCRT_natCast {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) (a b c : ℕ) (i : ι) : + sieveCubeCRT s hcop (a, b, c) i = + ((a : ZMod (s i)), (b : ZMod (s i)), (c : ZMod (s i))) := by + simp [sieveCubeCRT, ZMod.prodEquivPi_apply, + ZMod.cast_natCast (dvd_prod_of_mem s (mem_univ i))] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueTraceBound.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueTraceBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..40b9ead4abcab3fc8ced2ffd0aca5db4f26f4329 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueTraceBound.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Bounds.UniformResidues +import OAI.NumberTheory.TwoPoint.Bounds.DesignationWeights + +namespace OAI + +/-! The manuscript's designated-term majorant for actual uniform residues. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι τ : Type*} [Fintype ι] [DecidableEq ι] + +omit [Fintype ι] in +/-- The exact reciprocal coefficient of one lit/unlit designation, +including the singleton atoms. -/ +noncomputable def designatedReciprocal (p : ι → ℕ) (S : Finset ι) + (L U : Finset τ) (label : τ → ι) : ℝ := + (∏ t ∈ U, (p (label t) : ℝ)⁻¹) * + (∏ i ∈ L.image label, (p i : ℝ)⁻¹) * (∏ i ∈ S, (p i : ℝ)⁻¹) + +/-- Singleton integration and lit forcing are carried out on one common +residue sample. The unlit slots impose no further residue condition. -/ +theorem uniform_designated_trace_bound (B : ℕ) (p : ι → ℕ) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (S : Finset ι) (L U : Finset τ) (label : τ → ι) (target : τ → Fin B) + (a base : ι → Fin B) (R : ℝ) (G : (ι → Fin B) → ℝ) + (hR : 0 ≤ R) (hL : LitConsistent L label target) + (hSL : Disjoint S (L.image label)) + (ha : ∀ i ∈ S, (a i).val < p i) + (htarget : ∀ t ∈ L, (target t).val < p (label t)) : + |(FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => (R * ((-1 : ℝ) ^ U.card * ∏ t ∈ U, (p (label t) : ℝ)⁻¹)) * + ((∏ t ∈ L, if x (label t) = target t then (1 : ℝ) else 0) * + ((∏ i ∈ S, ((if x i = a i then (1 : ℝ) else 0) - (p i : ℝ)⁻¹)) * G x)))| ≤ + R * designatedReciprocal p S L U label * + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => |selectedMixedDifference S a + (fun x => G (forceCoordinates (L.image label) + (litForcedTarget L label target base) x)) x|) := by + let μ := fun i => uniformResidueLaw B (p i) (hp i) (hpB i) + have hs : ∀ x : ι → Fin B, + (∏ i ∈ S, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i))) = + ∏ i ∈ S, ((if x i = a i then (1 : ℝ) else 0) - (p i : ℝ)⁻¹) := by + intro x + apply prod_congr rfl + intro i hi + rw [uniformResidueLaw_weight B (p i) (hp i) (hpB i) (a i) (ha i hi)] + have hsp : (∏ i ∈ S, (μ i).weight (a i)) = ∏ i ∈ S, (p i : ℝ)⁻¹ := by + apply prod_congr rfl + intro i hi + exact uniformResidueLaw_weight B (p i) (hp i) (hpB i) (a i) (ha i hi) + have hlp : (∏ i ∈ L.image label, (μ i).weight (litForcedTarget L label target base i)) = + ∏ i ∈ L.image label, (p i : ℝ)⁻¹ := by + apply prod_congr rfl + intro i hi + obtain ⟨t, ht, rfl⟩ := mem_image.mp hi + rw [litForcedTarget_at L label target base hL t ht] + exact uniformResidueLaw_weight B (p (label t)) (hp _) (hpB _) _ (htarget t ht) + have hc : |R * ((-1 : ℝ) ^ U.card * ∏ t ∈ U, (p (label t) : ℝ)⁻¹)| = + R * ∏ t ∈ U, (p (label t) : ℝ)⁻¹ := by + rw [abs_mul, abs_of_nonneg hR, + absolute_unlit_coefficient U label (fun i => (p i : ℝ)⁻¹) + (fun _ => inv_nonneg.mpr (Nat.cast_nonneg _))] + have hb := designated_residue_bound μ S L label target a base + (R * ((-1 : ℝ) ^ U.card * ∏ t ∈ U, (p (label t) : ℝ)⁻¹)) G hL hSL + simp only [hs, hc, hsp, hlp] at hb + simpa only [designatedReciprocal, mul_assoc] using hb + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueWitnessHybrid.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueWitnessHybrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..6907fd865a81279d3042fc0c3a354a2c8dfaf693 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueWitnessHybrid.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResidueNumericalWitnesses + +namespace OAI + +/-! Keep the same common hybrid that supplies the numerical witnesses. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem selected_residue_witnesses_and_hybrid {ι W : Type*} + [Fintype ι] [DecidableEq ι] [Fintype W] [DecidableEq W] + (S : Finset ι) (p : ι → ℕ) (hprime : ∀ i, (p i).Prime) (hinj : Function.Injective p) + (B h s J T : ℕ) (supply : ℕ → ℕ → Prop) + (main : List SignedStep) (word : W → List SignedStep) (attachment : W → ℕ) + (a x : ι → Fin B) + (hatt : ∀ w, attachment w ≤ main.length) + (hminimal : ∀ w, MinimalWord (ForwardProhibited h s supply) (word w)) + (hlen : ∀ w, (word w).length ≤ s) + (hsq : ∀ w t, t ∈ word w → Squarefree t.tuple) + (hdivsq : ∀ w t, t ∈ word w → Squarefree (t.padding * t.tuple)) + (hcard : ∀ w t, t ∈ word w → t.tuple.primeFactors.card = J) + (hsupport : ∀ w q j, TuplePrimeAt (word w) q j → + ¬q ∣ h ∧ ∀ t ∈ word w, ¬q ∣ t.padding) + (hpad : ∀ i ∈ S, ∀ w t, t ∈ word w → ¬p i ∣ t.padding) + (hcover : ∀ w q, q ∈ wordDivisorPrimeSupport (word w) → ∃ i, p i = q) + (position : S → ℕ) + (hmain : ∀ i : S, ∀ v, TuplePrimeAt main (p i) v → v = position i) + (hnonzero : selectedMixedDifference S a + (witnessAvoidance (fun w z => decide (AttachedResiduePositiveWord p h (word w) + (wordDisplacement h (main.take (attachment w))) B z))) x ≠ 0) + (hT : T * (s * J) < S.card) : + ∃ index : Fin T → W, Function.Injective index ∧ + NumericalWitnessEvent main (fun i => word (index i)) p h s J supply ∧ + ∃ y : ι → Fin B, (∀ i, i ∉ S → y i = x i) ∧ + ∀ i, AttachedResiduePositiveWord p h (word (index i)) + (wordDisplacement h (main.take (attachment (index i)))) B y := by + let I : W → (S → Fin B) → Bool := fun w z => decide + (AttachedResiduePositiveWord p h (word w) + (wordDisplacement h (main.take (attachment w))) B + (joinCoordinates S z (fun i => x i))) + have hdepends (w) : DependsOn (wordCoordinateSupport (fun i : S => p i) (word w)) (I w) := + attached_residue_test_depends S p h B (word w) _ (hsq w) + (fun i _ => hprime i) (fun i hi => hpad i hi w) _ + have hn : mixedDifference (fun i : S => a i) (witnessAvoidance I) (fun i : S => x i) ≠ 0 := + hnonzero + obtain ⟨index, hindex, horder, H, hI, mark, _hmark, hprivate⟩ := + ordered_numerical_witness_cover (fun i : S => p i) (hinj.comp Subtype.val_injective) + word attachment I (fun i : S => a i) (fun i : S => x i) hdepends hn s J T hlen hsq + (fun w t ht => (hcard w t ht).le) (by simpa only [Fintype.card_coe] using hT) + let hybrid := joinCoordinates S (forceCoordinates H (fun i : S => a i) (fun i : S => x i)) + (fun i => x i) + have htests (i : Fin T) : AttachedResiduePositiveWord p h (word (index i)) + (wordDisplacement h (main.take (attachment (index i)))) B hybrid := by + have hi := hI i + exact of_decide_eq_true hi + obtain ⟨origin, horigin⟩ := attached_residue_words_common_origin T B h p hprime hinj hybrid + (fun i => word (index i)) (fun i => wordDisplacement h (main.take (attachment (index i)))) + (fun i => hdivsq (index i)) (fun i => hcover (index i)) htests + refine ⟨index, hindex, ?_, hybrid, ?_, htests⟩ + · refine ⟨(fun i => (mark i).val), (fun i => attachment (index i)), + (fun i => position (mark i)), horder, (fun i => hatt (index i)), hinj, hprime, + (fun i => hminimal (index i)), (fun i => hsq (index i)), (fun i => hcard (index i)), + (fun i => hsupport (index i)), ?_, ?_, ?_, origin, horigin⟩ + · intro i + exact (mem_wordPrimeSupport_iff _ _ (hsq (index i))).mpr (hprivate i).1 + · intro i j hji hmem + exact (hprivate i).2 j hji ((mem_wordPrimeSupport_iff _ _ (hsq (index j))).mp hmem) + · intro i v hv + exact hmain (mark i) v hv + · intro i hi + simp only [hybrid, joinCoordinates, hi, dite_false] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueWordDependence.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueWordDependence.lean new file mode 100644 index 0000000000000000000000000000000000000000..6449fa6c0541e146c47791f9d966fff24c9197c4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResidueWordDependence.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PositiveWordProbability +import OAI.NumberTheory.TwoPoint.Walks.SelectedWitnesses + +namespace OAI + +/-! The actual attached-word residue tests depend only on their tuple singleton primes. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +/-- Positivity for a word attached at a fixed displacement from the main origin. -/ +def AttachedResiduePositiveWord {ι : Type*} (p : ι → ℕ) (h : ℕ) + (w : List SignedStep) (attachment : ℤ) (B : ℕ) (x : ι → Fin B) : Prop := + ∀ (k : Fin w.length) (i : ι), + p i ∈ ((w.get k).padding * (w.get k).tuple).primeFactors → + ((x i).val : ZMod (p i)) = + -((attachment + wordDisplacement h (w.take k.val) : ℤ) : ZMod (p i)) + +lemma divisor_prime_in_word_support (w : List SignedStep) (p : ℕ) (hp : p.Prime) + (hsq : ∀ t ∈ w, Squarefree t.tuple) (hpad : ∀ t ∈ w, ¬p ∣ t.padding) + (k : Fin w.length) (hk : p ∈ ((w.get k).padding * (w.get k).tuple).primeFactors) : + p ∈ wordPrimeSupport w := by + have ht : w.get k ∈ w := List.get_mem w k + have hd := (Nat.mem_primeFactors.mp hk).2.1 + have hdt : p ∣ (w.get k).tuple := (hp.dvd_mul.mp hd).resolve_left (hpad _ ht) + exact (mem_wordPrimeSupport p w).mpr + ⟨w.get k, ht, Nat.mem_primeFactors.mpr ⟨hp, hdt, (hsq _ ht).ne_zero⟩⟩ + +/-- Freeze all other coordinates, including every padding prime. -/ +lemma attached_residue_test_depends {ι : Type*} [Fintype ι] [DecidableEq ι] + (S : Finset ι) (p : ι → ℕ) (h B : ℕ) (w : List SignedStep) (attachment : ℤ) + (hsq : ∀ t ∈ w, Squarefree t.tuple) + (hprime : ∀ i ∈ S, (p i).Prime) (hpad : ∀ i ∈ S, ∀ t ∈ w, ¬p i ∣ t.padding) + (outside : {i // i ∉ S} → Fin B) : + DependsOn (wordCoordinateSupport (fun i : S => p i) w) + (fun z : S → Fin B => decide (AttachedResiduePositiveWord p h w attachment B + (joinCoordinates S z outside))) := by + intro z z' hzz + apply decide_eq_decide.mpr + have he (k : Fin w.length) (i : ι) + (hi : p i ∈ ((w.get k).padding * (w.get k).tuple).primeFactors) : + joinCoordinates S z outside i = joinCoordinates S z' outside i := by + by_cases his : i ∈ S + · have hpw := divisor_prime_in_word_support w (p i) (hprime i his) hsq (hpad i his) k hi + have hz := hzz ⟨i, his⟩ (mem_filter.mpr ⟨mem_univ _, hpw⟩) + simpa only [joinCoordinates, his, dite_true] using hz + · simp only [joinCoordinates, his, dite_false] + constructor + · intro hz k i hi + rw [← he k i hi] + exact hz k i hi + · intro hz k i hi + rw [he k i hi] + exact hz k i hi + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResolventBounds.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResolventBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..289f71ed5e1487ac99cfc473b485079f9a49aa32 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResolventBounds.lean @@ -0,0 +1,138 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResolventTransfer + +namespace OAI + +/-! +# Quadratic-form bounds for the noncommuting resolvent + +The correction is estimated using the norm of each individual resolvent. +This avoids imposing any commutation relation between distinct edges. +-/ + +open scoped BigOperators + +namespace TwoPointCorrelations + +variable {ι E : Type*} [Fintype ι] [DecidableEq ι] + [NormedAddCommGroup E] [InnerProductSpace ℂ E] [FiniteDimensional ℂ E] + +theorem transferResolvent_positive_abs [Nontrivial E] (B : ι → E →L[ℂ] E) + (hB : ∀ i, IsSelfAdjoint (B i)) (t : ℝ) + (hsmall : ∀ u : ℝ, |u| ≤ |t| → ∀ i, ‖u • B i‖ < 1) + (hH : ∀ u : ℝ, |u| ≤ |t| → + IsUnit (1 - (u : ℂ) • nonbacktrackingContinuous B)) : + ∀ v : E, v ≠ 0 → 0 < (inner ℂ (transferResolvent B t v) v).re := by + have hu (u : ℝ) (h : |u| ≤ |t|) (i : ι) : IsUnit (1 + u • B i) := + isUnit_edge_shift _ _ (hsmall u h i) + have hmul (s : ℝ) (hs : s ∈ Set.Icc (0 : ℝ) 1) : |s * t| ≤ |t| := by + rw [abs_mul, abs_of_nonneg hs.1] + exact mul_le_of_le_one_left (abs_nonneg t) hs.2 + have hc := transferResolvent_continuousOn B (-|t|) |t| + (fun u hu' i => hu u (abs_le.mpr hu') i) + have hpath : ContinuousOn (fun s : ℝ => transferResolvent B (s * t)) + (Set.Icc 0 1) := hc.comp (by fun_prop) (fun s hs => abs_le.mp (hmul s hs)) + have h := selfAdjoint_path_positive (fun s : ℝ => transferResolvent B (s * t)) 0 1 + zero_le_one hpath (by ext v; simp [transferResolvent]) + (fun s hs => (transferResolvent_selfAdjoint B hB (s * t) + (hu (s * t) (hmul s hs))).isSymmetric) + (fun s hs => transferResolvent_injective B (s * t) + (hu (s * t) (hmul s hs)) (hH (s * t) (hmul s hs))) + simpa only [one_mul] using h + +omit [DecidableEq ι] [FiniteDimensional ℂ E] in +theorem transferResolvent_apply_expansion (B : ι → E →L[ℂ] E) (u : ℝ) + (hunit : ∀ i, IsUnit (1 + u • B i)) (v : E) : + transferResolvent B u v = v - u • (∑ i, B i v) + + u ^ 2 • (∑ i, B i (B i (edgeResolvent (B i) u v))) := by + have hi (i : ι) : u • B i (edgeResolvent (B i) u v) = + u • B i v - u ^ 2 • B i (B i (edgeResolvent (B i) u v)) := by + have hR := congrArg (fun T : E →L[ℂ] E => T v) (edgeResolvent_mul (B i) u (hunit i)) + have h := congrArg (fun z : E => u • B i z) hR + simp only [add_apply, one_apply_eq_self, smul_apply, mul_apply_eq_comp, + map_add, ContinuousLinearMap.map_smul_of_tower, smul_add, smul_smul, ← pow_two] at h + exact eq_sub_of_add_eq h + simp only [transferResolvent, sub_apply, one_apply_eq_self, sum_apply, + smul_apply, mul_apply_eq_comp] + simp_rw [hi] + rw [Finset.sum_sub_distrib, ← Finset.smul_sum, ← Finset.smul_sum] + abel + +omit [DecidableEq ι] in +theorem resolventCorrection_bound [Nontrivial E] (B : ι → E →L[ℂ] E) + (hB : ∀ i, IsSelfAdjoint (B i)) (u : ℝ) + (hsmall : ∀ i, ‖u • B i‖ ≤ 1 / 2) (v : E) : + |(inner ℂ (∑ i, B i (B i (edgeResolvent (B i) u v))) v).re| ≤ + 2 * ∑ i, ‖B i v‖ ^ 2 := by + have hi (i : ι) : |(inner ℂ (B i (B i (edgeResolvent (B i) u v))) v).re| ≤ + 2 * ‖B i v‖ ^ 2 := by + have hu := isUnit_edge_shift (B i) u ((hsmall i).trans_lt (by norm_num)) + have hc := congrArg (fun T : E →L[ℂ] E => T v) (edgeResolvent_commute (B i) u hu) + have heq : inner ℂ (B i (B i (edgeResolvent (B i) u v))) v = + inner ℂ (edgeResolvent (B i) u (B i v)) (B i v) := by + calc + _ = inner ℂ (B i (edgeResolvent (B i) u v)) (B i v) := (hB i).isSymmetric _ _ + _ = _ := by + simpa only [mul_apply_eq_comp] using congrArg (fun w => inner ℂ w (B i v)) hc + rw [heq] + calc + |(inner ℂ (edgeResolvent (B i) u (B i v)) (B i v)).re| ≤ + ‖inner ℂ (edgeResolvent (B i) u (B i v)) (B i v)‖ := Complex.abs_re_le_norm _ + _ ≤ ‖edgeResolvent (B i) u (B i v)‖ * ‖B i v‖ := norm_inner_le_norm _ _ + _ ≤ (2 * ‖B i v‖) * ‖B i v‖ := by + apply mul_le_mul_of_nonneg_right _ (norm_nonneg _) + exact (ContinuousLinearMap.le_opNorm _ _).trans + (mul_le_mul_of_nonneg_right (edgeResolvent_norm_le_two (B i) u (hsmall i)) + (norm_nonneg _)) + _ = 2 * ‖B i v‖ ^ 2 := by ring + simp only [sum_inner, Complex.re_sum] + calc + |∑ i, (inner ℂ (B i (B i (edgeResolvent (B i) u v))) v).re| ≤ + ∑ i, |(inner ℂ (B i (B i (edgeResolvent (B i) u v))) v).re| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ i, 2 * ‖B i v‖ ^ 2 := Finset.sum_le_sum (fun i _ => hi i) + _ = _ := (Finset.mul_sum ..).symm + +omit [DecidableEq ι] [FiniteDimensional ℂ E] in +theorem transferResolvent_inner_expansion (B : ι → E →L[ℂ] E) (u : ℝ) + (hunit : ∀ i, IsUnit (1 + u • B i)) (v : E) : + (inner ℂ (transferResolvent B u v) v).re = ‖v‖ ^ 2 - + u * (inner ℂ (∑ i, B i v) v).re + + u ^ 2 * (inner ℂ (∑ i, B i (B i (edgeResolvent (B i) u v))) v).re := by + rw [transferResolvent_apply_expansion B u hunit v] + simp only [inner_add_left, inner_sub_left, inner_smul_left_eq_star_smul, + Complex.add_re, Complex.sub_re, inner_self_eq_norm_sq_to_K] + simp [← Complex.ofReal_pow] + +omit [DecidableEq ι] in +/-- Positivity of the resolvent at both endpoints controls the quadratic +form of the edge sum on each vector satisfying the square-function bound. -/ +theorem edge_sum_quadratic_bound [Nontrivial E] (B : ι → E →L[ℂ] E) + (hB : ∀ i, IsSelfAdjoint (B i)) (t b : ℝ) (ht : 0 < t) + (hsmall : ∀ i, ‖t • B i‖ ≤ 1 / 2) + (hplus : ∀ v : E, 0 ≤ (inner ℂ (transferResolvent B t v) v).re) + (hminus : ∀ v : E, 0 ≤ (inner ℂ (transferResolvent B (-t) v) v).re) + (v : E) (hsq : ∑ i, ‖B i v‖ ^ 2 ≤ b ^ 2 * ‖v‖ ^ 2) : + |(inner ℂ (∑ i, B i v) v).re| ≤ ((1 + 2 * t ^ 2 * b ^ 2) / t) * ‖v‖ ^ 2 := by + have hsmallNeg (i : ι) : ‖(-t) • B i‖ ≤ 1 / 2 := by simpa using hsmall i + have hup := (resolventCorrection_bound B hB t hsmall v).trans (mul_le_mul_of_nonneg_left hsq (by norm_num)) + have hum := (resolventCorrection_bound B hB (-t) hsmallNeg v).trans (mul_le_mul_of_nonneg_left hsq (by norm_num)) + have hp := hplus v + have hm := hminus v + rw [transferResolvent_inner_expansion B t + (fun i => isUnit_edge_shift _ _ ((hsmall i).trans_lt (by norm_num)))] at hp + rw [transferResolvent_inner_expansion B (-t) + (fun i => isUnit_edge_shift _ _ ((hsmallNeg i).trans_lt (by norm_num)))] at hm + rw [abs_le] at hup hum ⊢ + have hup' := mul_le_mul_of_nonneg_left hup.2 (sq_nonneg t) + have hum' := mul_le_mul_of_nonneg_left hum.2 (sq_nonneg t) + rw [div_mul_eq_mul_div] + constructor + · rw [← neg_div] + apply (div_le_iff₀ ht).mpr + nlinarith only [hm, hum'] + · apply (le_div_iff₀ ht).mpr + nlinarith only [hp, hup'] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ResolventTransfer.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResolventTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..17a37b2ac6145c474ced04266ca88cf3825adaad --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ResolventTransfer.lean @@ -0,0 +1,167 @@ +import OAI.NumberTheory.TwoPoint.Bounds.Nonbacktracking +import OAI.NumberTheory.TwoPoint.Bounds.SelfAdjointPath +import Mathlib.Analysis.InnerProductSpace.StarOrder +import Mathlib.Analysis.Normed.Ring.Units +import Mathlib.Analysis.Normed.Algebra.Spectrum +import Mathlib.Algebra.Star.BigOperators + +namespace OAI + +/-! +# The resolvent path for noncommuting edge operators + +The definitions and lemmas here implement the path used in manuscript +Lemma `q:noncommuting`. The only products that are commuted are an edge +operator and its own resolvent. +-/ + +open scoped BigOperators NNReal ENNReal + +namespace TwoPointCorrelations + +variable {ι E : Type*} [Fintype ι] [DecidableEq ι] + [NormedAddCommGroup E] [InnerProductSpace ℂ E] [FiniteDimensional ℂ E] + +noncomputable def edgeResolvent (B : E →L[ℂ] E) (u : ℝ) : E →L[ℂ] E := + Ring.inverse (1 + u • B) + +noncomputable def transferResolvent (B : ι → E →L[ℂ] E) (u : ℝ) : E →L[ℂ] E := + 1 - ∑ i, u • (B i * edgeResolvent (B i) u) + +noncomputable def nonbacktrackingContinuous (B : ι → E →L[ℂ] E) : + (ι → E) →L[ℂ] (ι → E) := + (nonbacktracking (fun i => (B i).toLinearMap)).toContinuousLinearMap + +lemma isUnit_edge_shift (B : E →L[ℂ] E) (u : ℝ) (h : ‖u • B‖ < 1) : + IsUnit (1 + u • B) := by + simpa only [norm_neg, sub_neg_eq_add] using + (isUnit_one_sub_of_norm_lt_one (x := -(u • B)) (by simpa using h)) + +omit [FiniteDimensional ℂ E] in +lemma edgeResolvent_mul (B : E →L[ℂ] E) (u : ℝ) (h : IsUnit (1 + u • B)) : + (1 + u • B) * edgeResolvent B u = 1 := + Ring.mul_inverse_cancel _ h + +omit [FiniteDimensional ℂ E] in +lemma edgeResolvent_commute (B : E →L[ℂ] E) (u : ℝ) (h : IsUnit (1 + u • B)) : + B * edgeResolvent B u = edgeResolvent B u * B := by + let A := 1 + u • B + let R := edgeResolvent B u + have hAR : A * R = 1 := Ring.mul_inverse_cancel _ h + have hRA : R * A = 1 := Ring.inverse_mul_cancel _ h + have hAB : A * B = B * A := by + simp [A, add_mul, mul_add] + calc + B * R = (R * A) * (B * R) := by rw [hRA, one_mul] + _ = R * (A * B) * R := by simp only [mul_assoc] + _ = R * (B * A) * R := by rw [hAB] + _ = (R * B) * (A * R) := by simp only [mul_assoc] + _ = R * B := by rw [hAR, mul_one] + +omit [DecidableEq ι] in +lemma transferResolvent_selfAdjoint (B : ι → E →L[ℂ] E) + (hB : ∀ i, IsSelfAdjoint (B i)) (u : ℝ) + (hunit : ∀ i, IsUnit (1 + u • B i)) : IsSelfAdjoint (transferResolvent B u) := by + unfold transferResolvent + apply IsSelfAdjoint.sub (by simp) + apply isSelfAdjoint_sum + intro i _ + apply (isSelfAdjoint_iff.mpr (by rfl) : IsSelfAdjoint u).smul + have hR : IsSelfAdjoint (edgeResolvent (B i) u) := + ((IsSelfAdjoint.one (E →L[ℂ] E)).add ((isSelfAdjoint_iff.mpr (by rfl) : IsSelfAdjoint u).smul + (hB i))).ringInverse + change star (B i * edgeResolvent (B i) u) = B i * edgeResolvent (B i) u + rw [star_mul, hR.star_eq, (hB i).star_eq] + exact (edgeResolvent_commute (B i) u (hunit i)).symm + +lemma clm_injective_of_isUnit {V : Type*} [AddCommGroup V] [Module ℂ V] [TopologicalSpace V] + (T : V →L[ℂ] V) (h : IsUnit T) : Function.Injective T := by + obtain ⟨v, rfl⟩ := h + exact (ContinuousLinearEquiv.ofUnit v).injective + +theorem transferResolvent_injective (B : ι → E →L[ℂ] E) (u : ℝ) + (hunit : ∀ i, IsUnit (1 + u • B i)) + (hH : IsUnit (1 - (u : ℂ) • nonbacktrackingContinuous B)) : + Function.Injective (transferResolvent B u) := by + have hR (i : ι) (v : E) : edgeResolvent (B i) u v + + (u : ℂ) • B i (edgeResolvent (B i) u v) = v := by + have h := congrArg (fun T : E →L[ℂ] E => T v) (edgeResolvent_mul (B i) u (hunit i)) + simpa using h + have h := resolvent_transfer_injective (fun i => (B i).toLinearMap) (u : ℂ) + (fun i => (edgeResolvent (B i) u).toLinearMap) hR + (clm_injective_of_isUnit (1 - (u : ℂ) • nonbacktrackingContinuous B) hH) + intro v w hvw + apply h + change v - ∑ i, u • B i (edgeResolvent (B i) u v) = + w - ∑ i, u • B i (edgeResolvent (B i) u w) + simpa only [transferResolvent, sub_apply, one_apply_eq_self, sum_apply, + smul_apply, mul_apply_eq_comp] using hvw + +omit [DecidableEq ι] in +theorem transferResolvent_continuousOn (B : ι → E →L[ℂ] E) (a b : ℝ) + (hunit : ∀ u ∈ Set.Icc a b, ∀ i, IsUnit (1 + u • B i)) : + ContinuousOn (transferResolvent B) (Set.Icc a b) := by + apply continuousOn_const.sub + apply continuousOn_finsetSum + intro i _ + apply continuousOn_id.smul + apply continuousOn_const.mul + intro u hu + obtain ⟨v, hv⟩ := hunit u hu i + have hi := NormedRing.inverse_continuousAt v + rw [hv] at hi + have hc : ContinuousWithinAt (fun s : ℝ => (1 : E →L[ℂ] E) + s • B i) + (Set.Icc a b) u := by fun_prop + change ContinuousWithinAt (fun s : ℝ => Ring.inverse ((1 : E →L[ℂ] E) + s • B i)) + (Set.Icc a b) u + exact ContinuousAt.comp_continuousWithinAt (g := Ring.inverse) hi hc + +/-- The positivity step of the nonbacktracking spectral transfer. -/ +theorem transferResolvent_positive [Nontrivial E] (B : ι → E →L[ℂ] E) + (hB : ∀ i, IsSelfAdjoint (B i)) (t : ℝ) (ht : 0 ≤ t) + (hsmall : ∀ u ∈ Set.Icc 0 t, ∀ i, ‖u • B i‖ < 1) + (hH : ∀ u ∈ Set.Icc 0 t, + IsUnit (1 - (u : ℂ) • nonbacktrackingContinuous B)) : + ∀ v : E, v ≠ 0 → 0 < (inner ℂ (transferResolvent B t v) v).re := by + have hu : ∀ u ∈ Set.Icc 0 t, ∀ i, IsUnit (1 + u • B i) := + fun u hu i => isUnit_edge_shift _ _ (hsmall u hu i) + apply selfAdjoint_path_positive (transferResolvent B) 0 t ht + (transferResolvent_continuousOn B 0 t hu) + · ext v + simp [transferResolvent] + · intro u hu' + exact (transferResolvent_selfAdjoint B hB u (hu u hu')).isSymmetric + · intro u hu' + exact transferResolvent_injective B u (hu u hu') (hH u hu') + +lemma edgeResolvent_norm_le_two [Nontrivial E] (B : E →L[ℂ] E) (u : ℝ) + (hnorm : ‖u • B‖ ≤ 1 / 2) : ‖edgeResolvent B u‖ ≤ 2 := by + let x : E →L[ℂ] E := -(u • B) + have hx : ‖x‖ < 1 := by simpa [x] using hnorm.trans_lt (by norm_num : (1 / 2 : ℝ) < 1) + have hbound := tsum_geometric_le_of_norm_lt_one x hx + have hinv : (1 - ‖x‖)⁻¹ ≤ 2 := by + apply (inv_le_iff_one_le_mul₀ (by linarith : 0 < 1 - ‖x‖)).mpr + have : ‖x‖ ≤ 1 / 2 := by simpa [x] using hnorm + linarith + have heq : edgeResolvent B u = ↑(Units.oneSub x hx)⁻¹ := by + simpa [edgeResolvent, x] using NormedRing.inverse_one_sub x hx + rw [heq] + change ‖∑' n : ℕ, x ^ n‖ ≤ 2 + simpa only [norm_one, sub_self, zero_add] using hbound.trans + (show ‖(1 : E →L[ℂ] E)‖ - 1 + (1 - ‖x‖)⁻¹ ≤ 2 by simpa using hinv) + +lemma nonbacktracking_resolvent_isUnit (B : ι → E →L[ℂ] E) (m : ℝ≥0) + (hm : 0 < m) (hrad : spectralRadius ℂ (nonbacktrackingContinuous B) ≤ (m : ℝ≥0∞)) + (u : ℝ) (hu : |u| < (m : ℝ)⁻¹) : + IsUnit (1 - (u : ℂ) • nonbacktrackingContinuous B) := by + apply spectrum.isUnit_one_sub_smul_of_lt_inv_radius (𝕜 := ℂ) + (a := nonbacktrackingContinuous B) (z := (u : ℂ)) + apply lt_of_lt_of_le _ (ENNReal.inv_le_inv.mpr hrad) + have hnn : ‖(u : ℂ)‖₊ < m⁻¹ := by + exact_mod_cast (by simpa using hu : ‖(u : ℂ)‖ < ((m⁻¹ : ℝ≥0) : ℝ)) + rw [← ENNReal.coe_inv hm.ne'] + exact_mod_cast hnn + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughCutoffAverage.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughCutoffAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad6857bd68d129e9cf9468694cb8f104e00a8f42 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughCutoffAverage.lean @@ -0,0 +1,149 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QualitativeDivisorTransferRight +import OAI.NumberTheory.TwoPoint.Bounds.FourierPrimeCutoff + +namespace OAI + +/-! The actual two-cutoff rough correlation is a finite Fourier average of +the already bounded rough correlations. Both original-factor choices are +supported, with every cutoff parameter uniform after the long threshold. -/ + +namespace TwoPointCorrelations + +open Finset Filter MeasureTheory +open scoped Classical FourierTransform + +noncomputable def roughPairCoefficient (c : ℕ → ℂ) (l : ℕ) [NeZero l] + (a : ZMod l) (Y : ℕ) (i : ℕ × ℕ) : ℂ := + if ((i.1 + 1 : ℕ) : ZMod l) = a then (c i.2 / (i.2 : ℂ)) / (Y : ℂ) else 0 + +lemma weightedRoughShiftAverage_eq_pairSum (f g : ℕ → ℂ) (l : ℕ) [NeZero l] + (a : ZMod l) (Z : Finset ℕ) (c : ℕ → ℂ) (h Y : ℕ) : + weightedRoughShiftAverage (progressionSequence f l a) g Z c h Y = + ∑ i ∈ (range Y).product Z, + roughPairCoefficient c l a Y i * f (i.1 + 1) * g (i.1 + 1 + h * i.2) := by + unfold weightedRoughShiftAverage positivePrefix weightedRoughShiftProfile + rw [sum_div] + calc + _ = ∑ n ∈ range Y, ∑ z ∈ Z, + roughPairCoefficient c l a Y (n, z) * f (n + 1) * g (n + 1 + h * z) := by + apply sum_congr rfl + intro n _ + rw [sum_div] + apply sum_congr rfl + intro z _ + unfold roughPairCoefficient progressionSequence + by_cases hn : ((n + 1 : ℕ) : ZMod l) = a + · simp only [hn, ite_true] + ring + · simp only [hn, ite_false, zero_mul, mul_zero, zero_div] + _ = _ := (Finset.sum_product (range Y) Z + (fun i => roughPairCoefficient c l a Y i * f (i.1 + 1) * g (i.1 + 1 + h * i.2))).symm + +noncomputable def cutoffRoughAverage (f g : ℕ → ℂ) (l : ℕ) [NeZero l] + (a : ZMod l) (P Q : Finset ℕ) (μ σ ν τ : ℝ) (w₁ w₂ : ℝ → ℂ) + (Z : Finset ℕ) (c : ℕ → ℂ) (h Y : ℕ) : ℂ := + weightedRoughShiftAverage + (progressionSequence (fun n => f n * primeCountCutoff P μ σ w₁ n) l a) + (fun n => g n * primeCountCutoff Q ν τ w₂ n) Z c h Y + +lemma cutoffRoughAverage_fourier (f g : ℕ → ℂ) (l : ℕ) [NeZero l] + (a : ZMod l) (P Q : Finset ℕ) (μ σ ν τ : ℝ) (φ₁ φ₂ : ℝ → ℂ) + (hc₁ : Continuous φ₁) (hc₂ : Continuous φ₂) + (hi₁ : Integrable φ₁) (hi₂ : Integrable φ₂) + (hF₁ : Integrable (𝓕 φ₁)) (hF₂ : Integrable (𝓕 φ₂)) + (Z : Finset ℕ) (c : ℕ → ℂ) (h Y : ℕ) : + cutoffRoughAverage f g l a P Q μ σ ν τ (𝓕 φ₁) (𝓕 φ₂) Z c h Y = + weightedRoughShiftAverage + (progressionSequence (fun n => f n * φ₁ (((finitePrimeDivisorCount P n : ℝ) - μ) / σ)) l a) + (fun n => g n * φ₂ (((finitePrimeDivisorCount Q n : ℝ) - ν) / τ)) Z c h Y := by + simp only [cutoffRoughAverage, primeCountCutoff_fourier P μ σ φ₁ hc₁ hi₁ hF₁, + primeCountCutoff_fourier Q ν τ φ₂ hc₂ hi₂ hF₂] + +theorem norm_cutoffRoughAverage_le (f g : ℕ → ℂ) (l : ℕ) [NeZero l] + (a : ZMod l) (P Q : Finset ℕ) (μ σ ν τ : ℝ) (w₁ w₂ : ℝ → ℂ) + (hw₁ : Integrable w₁) (hw₂ : Integrable w₂) + (Z : Finset ℕ) (c : ℕ → ℂ) (h Y : ℕ) (E : ℝ) + (hbound : ∀ t s, ‖weightedRoughShiftAverage + (progressionSequence (twistByPrimePhase f P (t / σ)) l a) + (twistByPrimePhase g Q (s / τ)) Z c h Y‖ ≤ E) : + ‖cutoffRoughAverage f g l a P Q μ σ ν τ w₁ w₂ Z c h Y‖ ≤ + E * (∫ t, ‖w₁ t‖) * (∫ s, ‖w₂ s‖) := by + have heq : cutoffRoughAverage f g l a P Q μ σ ν τ w₁ w₂ Z c h Y = + ∑ i ∈ (range Y).product Z, + (roughPairCoefficient c l a Y i * f (i.1 + 1) * g (i.1 + 1 + h * i.2)) * + primeCountCutoff P μ σ w₁ (i.1 + 1) * + primeCountCutoff Q ν τ w₂ (i.1 + 1 + h * i.2) := by + rw [cutoffRoughAverage, weightedRoughShiftAverage_eq_pairSum] + apply sum_congr rfl + intro i _ + ring + rw [heq] + apply norm_primeCountCutoff_pair_sum_le ((range Y).product Z) + (roughPairCoefficient c l a Y) (fun i => i.1 + 1) (fun i => i.1 + 1 + h * i.2) + f g P Q μ σ ν τ w₁ w₂ hw₁ hw₂ E + intro t s + simpa only [weightedRoughShiftAverage_eq_pairSum] using hbound t s + +theorem qualitative_cutoff_rough_shifts (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {f : ℕ → ℂ} + (hfnp : UniformlyNonpretentious f) (hf : OneBounded f) (hfm : Multiplicative f) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (P : Finset ℕ), (∀ p ∈ P, Nat.Prime p) → + ∀ (M τ : ℝ), 1 < τ → τ < 2 → + Real.exp (B ^ (9999 / 10000 : ℝ)) / τ ≤ M → M ≤ Real.exp (C₀ * B) → + ∀ᶠ Y : ℕ in atTop, ∀ g : ℕ → ℂ, OneBounded g → + ∀ (l : ℕ) [NeZero l] (a : ZMod l) (Q : Finset ℕ) (μ σ ν ρ : ℝ) + (w₁ w₂ : ℝ → ℂ), Integrable w₁ → Integrable w₂ → + ∀ (Z : Finset ℕ) (c : ℕ → ℂ), + (∀ z ∈ Z, M < (z : ℝ) ∧ (z : ℝ) ≤ τ * M ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + (∀ z ∈ Z, ‖c z‖ ≤ 1) → + ‖cutoffRoughAverage f g l a P Q μ σ ν ρ w₁ w₂ Z c h Y‖ ≤ + (C * B ^ (-10001 / 10000 : ℝ)) * (∫ t, ‖w₁ t‖) * (∫ s, ‖w₂ s‖) := by + obtain ⟨C, hC, hrough⟩ := qualitative_rough_shifts_real_bins hM hMRT hfnp hf h hh C₀ hC₀ + refine ⟨C, hC, ?_⟩ + filter_upwards [hrough] with B hb + intro P hP M τ hτ₁ hτ₂ hMlower hMupper + filter_upwards [hb P M τ hτ₁ hτ₂ hMlower hMupper] with Y hy + intro g hg l _ a Q μ σ ν ρ w₁ w₂ hw₁ hw₂ Z c hZ hc + apply norm_cutoffRoughAverage_le f g l a P Q μ σ ν ρ w₁ w₂ hw₁ hw₂ Z c h Y + intro t s + exact hy (twistByPrimePhase f P (t / σ)) (twistByPrimePhase g Q (s / ρ)) + (hfm.twistByPrimePhase P hP _) (hf.twistByPrimePhase P _) + (hg.twistByPrimePhase Q _) (fun p hp hout => twistByPrimePhase_prime_outside f P hP _ hp hout) + l a Z c hZ hc + +theorem qualitative_cutoff_rough_shifts_right (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) {g : ℕ → ℂ} + (hgnp : UniformlyNonpretentious g) (hg : OneBounded g) (hgm : Multiplicative g) + (h : ℕ) (hh : 0 < h) (C₀ : ℝ) (hC₀ : 1 ≤ C₀) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ B : ℝ in atTop, + ∀ (Q : Finset ℕ), (∀ p ∈ Q, Nat.Prime p) → + ∀ (M τ : ℝ), 1 < τ → τ < 2 → + Real.exp (B ^ (9999 / 10000 : ℝ)) / τ ≤ M → M ≤ Real.exp (C₀ * B) → + ∀ᶠ Y : ℕ in atTop, ∀ f : ℕ → ℂ, OneBounded f → + ∀ (l : ℕ) [NeZero l] (a : ZMod l) (P : Finset ℕ) (μ σ ν ρ : ℝ) + (w₁ w₂ : ℝ → ℂ), Integrable w₁ → Integrable w₂ → + ∀ (Z : Finset ℕ) (c : ℕ → ℂ), + (∀ z ∈ Z, M < (z : ℝ) ∧ (z : ℝ) ≤ τ * M ∧ + HasNoPrimeFactorBelow (Real.exp (B ^ (9999 / 10000 : ℝ))) z) → + (∀ z ∈ Z, ‖c z‖ ≤ 1) → + ‖cutoffRoughAverage f g l a P Q μ σ ν ρ w₁ w₂ Z c h Y‖ ≤ + (C * B ^ (-10001 / 10000 : ℝ)) * (∫ t, ‖w₁ t‖) * (∫ s, ‖w₂ s‖) := by + obtain ⟨C, hC, hrough⟩ := qualitative_rough_shifts_real_bins_right hM hMRT hgnp hg h hh C₀ hC₀ + refine ⟨C, hC, ?_⟩ + filter_upwards [hrough] with B hb + intro Q hQ M τ hτ₁ hτ₂ hMlower hMupper + filter_upwards [hb Q M τ hτ₁ hτ₂ hMlower hMupper] with Y hy + intro f hf l _ a P μ σ ν ρ w₁ w₂ hw₁ hw₂ Z c hZ hc + apply norm_cutoffRoughAverage_le f g l a P Q μ σ ν ρ w₁ w₂ hw₁ hw₂ Z c h Y + intro t s + exact hy (twistByPrimePhase f P (t / σ)) (twistByPrimePhase g Q (s / ρ)) + (hf.twistByPrimePhase P _) (hgm.twistByPrimePhase Q hQ _) + (hg.twistByPrimePhase Q _) (fun p hp hout => twistByPrimePhase_prime_outside g Q hQ _ hp hout) + l a Z c hZ hc + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughCutoffProbability.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughCutoffProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..1106193da425845642b8048f9a99e08285874194 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughCutoffProbability.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughSieveProbability + +namespace OAI + +/-! The finite rough sieve with its cutoff left explicit, for both one +linear form and the additive four-form system. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem rough_interval_probability_cutoff (P : Finset ℕ) (hP : ∀ p ∈ P, Nat.Prime p) + (A N : ℕ) [NeZero N] (r : ℕ) (B C X Y : ℝ) (hB : 1 ≤ B) (hX : 0 < X) + (hY : 0 ≤ Y) (hmax : ∀ p ∈ P, (p : ℝ) ≤ Y) + (hlower : Real.log X - C ≤ ∑ p ∈ P, 1 / (p : ℝ)) + (hupper : (∑ p ∈ P, 1 / (p : ℝ)) ≤ 5 * Real.log B) + (hr : 220 * Real.log B ≤ (2 * r + 1 : ℕ)) : + (uniformFiniteLaw (Fin N)).probability (fun j => avoidsPrimeSet P (A + j.val)) ≤ + Real.exp C / X + B ^ (-100 : ℝ) + + 1 / (N : ℝ) * (2 * r + 1 : ℕ) * ((P.card : ℝ) * Y + 1) ^ (2 * r) := by + let (p : P) : NeZero (p : ℕ) := ⟨(hP p p.property).ne_zero⟩ + have hh := finite_interval_sieve (fun p : P => (p : ℕ)) (primeSet_pairwise_coprime P hP) + A N (fun _ x => x = 0) r Y hY (fun p => hmax p p.property) + have he : avoidsEvents univ (fun p : P => fun j : Fin N => + ((A + j.val : ℕ) : ZMod (p : ℕ)) = 0) = + (fun j => avoidsPrimeSet P (A + j.val)) := by + funext j + simp only [avoidsEvents, mem_univ, forall_true_left, avoidsPrimeSet_iff_residues] + simp only [he, oneFormBadDensity, Fintype.card_coe] at hh + have hsum : (∑ p : P, 1 / (p : ℝ)) ≤ 5 * Real.log B := by + rw [← sum_subtype (p := fun p : ℕ => p ∈ P) P (fun _ => Iff.rfl) + (fun p => 1 / (p : ℝ))] + exact hupper + have ht := elementarySymmetric_log_tail (univ : Finset P) + (fun p => 1 / (p : ℝ)) (fun p _ => by positivity) (2 * r + 1) B hB hsum hr + have hp : (∏ p ∈ P, (1 - 1 / (p : ℝ))) ≤ Real.exp C / X := by + apply (oneForm_product_bound P (fun p hp => (hP p hp).two_le)).trans + calc + _ ≤ Real.exp (C - Real.log X) := Real.exp_le_exp.mpr (by linarith only [hlower]) + _ = _ := by rw [Real.exp_sub, Real.exp_log hX] + rw [prod_subtype (p := fun p : ℕ => p ∈ P) P (fun _ => Iff.rfl)] at hp + exact hh.trans (by gcongr) + +theorem rough_cube_probability_cutoff (P : Finset ℕ) (hP : ∀ p ∈ P, Nat.Prime p) + (A : ℕ × ℕ × ℕ) (N : ℕ) [NeZero N] (r : ℕ) (B C X Y : ℝ) + (hB : 1 ≤ B) (hX : 0 < X) (hY : 0 ≤ Y) (hmax : ∀ p ∈ P, (p : ℝ) ≤ Y) + (hlower : Real.log X - C ≤ ∑ p ∈ P, 1 / (p : ℝ)) + (hupper : (∑ p ∈ P, 1 / (p : ℝ)) ≤ (5 / 4 : ℝ) * Real.log B) + (hr : 220 * Real.log B ≤ (2 * r + 1 : ℕ)) : + (uniformFiniteLaw (Fin N × Fin N × Fin N)).probability (fun j => + fourFormsAvoidPrimeSet P (A.1 + j.1.val, A.2.1 + j.2.1.val, A.2.2 + j.2.2.val)) ≤ + Real.exp (4 * C + 6) / X ^ 4 + B ^ (-100 : ℝ) + + 3 / (N : ℝ) * (2 * r + 1 : ℕ) * ((P.card : ℝ) * Y + 1) ^ (2 * r) := by + let (p : P) : NeZero (p : ℕ) := ⟨(hP p p.property).ne_zero⟩ + have hh := finite_cube_sieve (fun p : P => (p : ℕ)) (primeSet_pairwise_coprime P hP) + A N (fun _ => fourFormBad) r Y hY (fun p => hmax p p.property) + have he : avoidsEvents univ (fun p : P => fun j : Fin N × Fin N × Fin N => + fourFormBad (((A.1 + j.1.val : ℕ) : ZMod (p : ℕ)), + ((A.2.1 + j.2.1.val : ℕ) : ZMod (p : ℕ)), + ((A.2.2 + j.2.2.val : ℕ) : ZMod (p : ℕ)))) = + (fun j => fourFormsAvoidPrimeSet P + (A.1 + j.1.val, A.2.1 + j.2.1.val, A.2.2 + j.2.2.val)) := by + funext j + simp only [avoidsEvents, mem_univ, forall_true_left, fourFormsAvoidPrimeSet_iff_residues] + change _ ≤ (∏ p : P, (1 - fourFormBadDensity (p : ℕ))) + + elementarySymmetric univ (fun p : P => fourFormBadDensity (p : ℕ)) (2 * r + 1) + _ at hh + rw [he] at hh + simp only [Fintype.card_coe] at hh + have hsum : (∑ p : P, fourFormBadDensity (p : ℕ)) ≤ 5 * Real.log B := by + calc + _ ≤ ∑ p : P, 4 / (p : ℝ) := + sum_le_sum (fun p _ => (fourFormBadDensity_bounds (p : ℕ)).2) + _ = 4 * ∑ p ∈ P, 1 / (p : ℝ) := by + rw [← sum_subtype (p := fun p : ℕ => p ∈ P) P (fun _ => Iff.rfl) + (fun p => 4 / (p : ℝ))] + simp only [div_eq_mul_inv, one_mul, ← mul_sum] + _ ≤ _ := by linarith + have ht := elementarySymmetric_log_tail (univ : Finset P) + (fun p => fourFormBadDensity (p : ℕ)) (fun p _ => fourFormBadDensity_nonneg _) + (2 * r + 1) B hB hsum hr + have hp : (∏ p : P, (1 - fourFormBadDensity (p : ℕ))) ≤ + Real.exp (4 * C + 6) / X ^ 4 := by + apply (fourForm_product_bound P (fun p hp => (hP p hp).two_le)).trans + calc + _ = Real.exp (6 - 4 * ∑ p ∈ P, 1 / (p : ℝ)) := by + rw [← Real.exp_add]; congr 1; ring + _ ≤ Real.exp (4 * C + 6 - 4 * Real.log X) := + Real.exp_le_exp.mpr (by linarith only [hlower]) + _ = _ := by + rw [Real.exp_sub] + have he : Real.exp (4 * Real.log X) = X ^ 4 := by + calc + _ = (Real.exp (Real.log X)) ^ (4 : ℕ) := Real.exp_nat_mul (Real.log X) 4 + _ = _ := by rw [Real.exp_log hX] + rw [he] + exact hh.trans (by gcongr) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughFourier.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughFourier.lean new file mode 100644 index 0000000000000000000000000000000000000000..323afe6570f23e8bd8bdfcfdc0c242eaddc0100c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughFourier.lean @@ -0,0 +1,196 @@ +import OAI.NumberTheory.TwoPoint.PublishedInputs +import Mathlib.Analysis.Fourier.AddCircle + +namespace OAI + +/-! +# Exact finite Fourier identities for rough shifts + +Orthogonality, convolution and the fourth moment are proved for arbitrary +finite coefficients. The sieve bounds on the number of rough integers are +not hypotheses of these identities. Haar measure on `AddCircle (1 : ℝ)` is the +ordinary integral over one period. +-/ + +namespace TwoPointCorrelations + +open scoped BigOperators ComplexConjugate +open MeasureTheory + +noncomputable def fourierPolynomial {ι : Type*} (S : Finset ι) + (frequency : ι → ℤ) (coefficient : ι → ℂ) (θ : AddCircle (1 : ℝ)) : ℂ := + ∑ i ∈ S, coefficient i * fourier (frequency i) θ + +theorem continuous_fourierPolynomial {ι : Type*} (S : Finset ι) + (frequency : ι → ℤ) (coefficient : ι → ℂ) : + Continuous (fourierPolynomial S frequency coefficient) := by + unfold fourierPolynomial + exact continuous_finsetSum S (fun i _ => + continuous_const.mul (fourier (frequency i)).continuous) + +theorem integral_circle_eq_period (F : AddCircle (1 : ℝ) → ℂ) : + (∫ θ, F θ ∂AddCircle.haarAddCircle) = ∫ x in (0 : ℝ)..1, F (x : AddCircle (1 : ℝ)) := by + have h := fourierCoeff_eq_intervalIntegral F 0 0 + simpa only [fourierCoeff, fourier_zero, one_smul, + neg_zero, one_div_one, zero_add] using h + +theorem integral_fourier_character (n : ℤ) : + (∫ θ : AddCircle (1 : ℝ), fourier n θ ∂AddCircle.haarAddCircle) = + if n = 0 then 1 else 0 := by + have h := congrFun (fourierCoeff_fourier (T := 1) n) 0 + simpa [fourierCoeff, Pi.single_apply, eq_comm] using h + +theorem integrable_fourier_character (n : ℤ) : + Integrable (fun θ : AddCircle (1 : ℝ) => fourier n θ) + AddCircle.haarAddCircle := by + simpa only [smul_eq_mul, mul_one] using + (integrable_const (1 : ℂ) (μ := (AddCircle.haarAddCircle : Measure (AddCircle (1 : ℝ))))).fourier_smul n + +theorem integral_fourierPolynomial {ι : Type*} (S : Finset ι) + (frequency : ι → ℤ) (coefficient : ι → ℂ) : + (∫ θ, fourierPolynomial S frequency coefficient θ ∂AddCircle.haarAddCircle) = + ∑ i ∈ S, if frequency i = 0 then coefficient i else 0 := by + classical + unfold fourierPolynomial + rw [integral_finsetSum S (fun i _ => + (integrable_fourier_character (frequency i)).const_mul (coefficient i))] + apply Finset.sum_congr rfl + intro i _ + rw [integral_const_mul, integral_fourier_character] + split_ifs <;> simp_all + +theorem norm_fourierPolynomial_le {ι : Type*} (S : Finset ι) + (frequency : ι → ℤ) (coefficient : ι → ℂ) (θ : AddCircle (1 : ℝ)) : + ‖fourierPolynomial S frequency coefficient θ‖ ≤ ∑ i ∈ S, ‖coefficient i‖ := by + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro i _ + simp only [norm_mul, fourier_apply, Circle.norm_coe, mul_one, le_refl] + +theorem fourierPolynomial_mul {ι κ : Type*} (S : Finset ι) (T : Finset κ) + (f : ι → ℤ) (g : κ → ℤ) (a : ι → ℂ) (b : κ → ℂ) (θ : AddCircle (1 : ℝ)) : + fourierPolynomial S f a θ * fourierPolynomial T g b θ = + fourierPolynomial (S ×ˢ T) (fun i => f i.1 + g i.2) + (fun i => a i.1 * b i.2) θ := by + classical + simp only [fourierPolynomial, Finset.sum_product, Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + rw [fourier_add] + ring + +theorem fourierPolynomial_conj {ι : Type*} (S : Finset ι) + (f : ι → ℤ) (a : ι → ℂ) (θ : AddCircle (1 : ℝ)) : + conj (fourierPolynomial S f a θ) = + fourierPolynomial S (fun i => -f i) (fun i => conj (a i)) θ := by + simp only [fourierPolynomial, map_sum, map_mul, fourier_neg] + +/-- Exact Fourier selection of all frequency-zero terms in a product. -/ +theorem integral_fourier_product {ι κ : Type*} (S : Finset ι) (T : Finset κ) + (f : ι → ℤ) (g : κ → ℤ) (a : ι → ℂ) (b : κ → ℂ) : + (∫ θ, fourierPolynomial S f a θ * fourierPolynomial T g b θ + ∂AddCircle.haarAddCircle) = + ∑ i ∈ S ×ˢ T, if f i.1 + g i.2 = 0 then a i.1 * b i.2 else 0 := by + simp_rw [fourierPolynomial_mul] + exact integral_fourierPolynomial _ _ _ + +/-- Parseval for finite polynomials, retaining collisions of frequencies. -/ +theorem integral_norm_fourierPolynomial_sq {ι : Type*} (S : Finset ι) + (f : ι → ℤ) (a : ι → ℂ) : + (∫ θ, ‖fourierPolynomial S f a θ‖ ^ 2 ∂AddCircle.haarAddCircle) = + ∑ i ∈ S ×ˢ S, if f i.1 = f i.2 then (a i.1 * conj (a i.2)).re else 0 := by + classical + have hc : ((∫ θ, ‖fourierPolynomial S f a θ‖ ^ 2 + ∂AddCircle.haarAddCircle : ℝ) : ℂ) = + ∑ i ∈ S ×ˢ S, if f i.1 = f i.2 then a i.1 * conj (a i.2) else 0 := by + rw [← integral_complex_ofReal] + simp_rw [Complex.ofReal_pow, ← Complex.mul_conj', fourierPolynomial_conj] + rw [integral_fourier_product] + apply Finset.sum_congr rfl + intro i _ + simp only [add_neg_eq_zero] + have hr := congrArg Complex.re hc + simpa only [Complex.ofReal_re, Complex.re_sum, apply_ite, Complex.zero_re] using hr + +/-- The exact weighted additive-energy identity. In particular a positive +integer dilation of the frequencies leaves its additive relation unchanged. -/ +theorem integral_norm_fourierPolynomial_fourth {ι : Type*} (S : Finset ι) + (f : ι → ℤ) (a : ι → ℂ) : + (∫ θ, ‖fourierPolynomial S f a θ‖ ^ 4 ∂AddCircle.haarAddCircle) = + ∑ i ∈ (S ×ˢ S) ×ˢ (S ×ˢ S), + if f i.1.1 + f i.1.2 = f i.2.1 + f i.2.2 then + (a i.1.1 * a i.1.2 * conj (a i.2.1 * a i.2.2)).re else 0 := by + have h := integral_norm_fourierPolynomial_sq (S ×ˢ S) + (fun i => f i.1 + f i.2) (fun i => a i.1 * a i.2) + convert h using 1 + apply integral_congr_ae + exact Filter.Eventually.of_forall fun θ => by + dsimp only + rw [← fourierPolynomial_mul, norm_mul] + ring + +/-- The actual polynomial in `(q:rough-fourier)`. -/ +noncomputable def roughFourierPolynomial (Z : Finset ℕ) (h : ℕ) : AddCircle (1 : ℝ) → ℂ := + fourierPolynomial Z (fun z => (h : ℤ) * z) (fun z => (z : ℂ)⁻¹) + +theorem norm_roughFourierPolynomial_le (Z : Finset ℕ) (h : ℕ) (D : ℝ) + (hD : 0 < D) (hZ : ∀ z ∈ Z, D ≤ (z : ℝ)) (θ : AddCircle (1 : ℝ)) : + ‖roughFourierPolynomial Z h θ‖ ≤ Z.card / D := by + apply (norm_fourierPolynomial_le Z _ _ θ).trans + calc + _ ≤ ∑ _z ∈ Z, D⁻¹ := by + apply Finset.sum_le_sum + intro z hz + rw [norm_inv, Complex.norm_natCast] + exact inv_anti₀ hD (hZ z hz) + _ = _ := by simp [div_eq_mul_inv] + +/-- Weighted additive energy, without any sieve hypothesis. -/ +theorem roughFourierPolynomial_fourth_moment (Z : Finset ℕ) (h : ℕ) (hh : 0 < h) : + (∫ θ, ‖roughFourierPolynomial Z h θ‖ ^ 4 ∂AddCircle.haarAddCircle) = + ∑ i ∈ ((Z ×ˢ Z) ×ˢ (Z ×ˢ Z)).filter + (fun i => i.1.1 + i.1.2 = i.2.1 + i.2.2), + (i.1.1 : ℝ)⁻¹ * (i.1.2 : ℝ)⁻¹ * (i.2.1 : ℝ)⁻¹ * (i.2.2 : ℝ)⁻¹ := by + rw [roughFourierPolynomial, integral_norm_fourierPolynomial_fourth, Finset.sum_filter] + apply Finset.sum_congr rfl + intro i _ + have hrel : (h : ℤ) * (i.1.1 : ℤ) + (h : ℤ) * i.1.2 = + (h : ℤ) * i.2.1 + (h : ℤ) * i.2.2 ↔ i.1.1 + i.1.2 = i.2.1 + i.2.2 := by + rw [← mul_add, ← mul_add, mul_right_inj' (show (h : ℤ) ≠ 0 by exact_mod_cast hh.ne')] + exact_mod_cast Iff.rfl + simp only [hrel] + split_ifs + · simp only [← Complex.ofReal_natCast, ← Complex.ofReal_inv, ← Complex.ofReal_mul, + Complex.conj_ofReal, Complex.ofReal_re] + ring + · rfl + +/-- A triple/quadruple count enters the fourth moment only through this +explicit positive weight estimate. -/ +theorem roughFourierPolynomial_fourth_moment_le (Z : Finset ℕ) (h : ℕ) (hh : 0 < h) + (D : ℝ) (hD : 0 < D) (hZ : ∀ z ∈ Z, D ≤ (z : ℝ)) : + (∫ θ, ‖roughFourierPolynomial Z h θ‖ ^ 4 ∂AddCircle.haarAddCircle) ≤ + (((Z ×ˢ Z) ×ˢ (Z ×ˢ Z)).filter + (fun i => i.1.1 + i.1.2 = i.2.1 + i.2.2)).card * (D⁻¹) ^ 4 := by + rw [roughFourierPolynomial_fourth_moment Z h hh] + calc + _ ≤ ∑ _i ∈ ((Z ×ˢ Z) ×ˢ (Z ×ˢ Z)).filter + (fun i => i.1.1 + i.1.2 = i.2.1 + i.2.2), (D⁻¹) ^ 4 := by + apply Finset.sum_le_sum + intro i hi + have hm := Finset.mem_product.mp (Finset.mem_filter.mp hi).1 + have h₁ := inv_anti₀ hD (hZ _ (Finset.mem_product.mp hm.1).1) + have h₂ := inv_anti₀ hD (hZ _ (Finset.mem_product.mp hm.1).2) + have h₃ := inv_anti₀ hD (hZ _ (Finset.mem_product.mp hm.2).1) + have h₄ := inv_anti₀ hD (hZ _ (Finset.mem_product.mp hm.2).2) + calc + _ ≤ D⁻¹ * D⁻¹ * D⁻¹ * D⁻¹ := by gcongr + _ = _ := by ring + _ = _ := by simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughFourierSieve.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughFourierSieve.lean new file mode 100644 index 0000000000000000000000000000000000000000..375cd1749aaccbcbd283d340418066904756ef8e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughFourierSieve.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughSieveCounts +import OAI.NumberTheory.TwoPoint.Bounds.SieveBoundaryScale +import OAI.NumberTheory.TwoPoint.Bounds.MertensScale + +namespace OAI + +/-! The manuscript rough-integer Fourier estimates, deduced from the +published bounded Mertens input and the proved finite sieve. -/ + +namespace TwoPointCorrelations + +open Finset Filter MeasureTheory +open scoped Classical + +/-- Manuscript `(q:rough-fourier)`, uniformly in the interval length and in +every subset of the integers having no prime factor below the cutoff. -/ +theorem PrimeReciprocalInput.rough_fourier (hM : PrimeReciprocalInput) : + ∃ U V : ℝ, 0 < U ∧ 0 < V ∧ ∀ᶠ L : ℝ in atTop, + ∀ (D h : ℕ), (1 / 2 : ℝ) * Real.exp (L ^ (199 / 200 : ℝ)) ≤ D → 0 < h → + ∀ Z : Finset ℕ, + (∀ z ∈ Z, D ≤ z ∧ z < D + D ∧ + avoidsPrimeSet (sievePrimesUpTo (Real.exp (L ^ (99 / 100 : ℝ)))) z) → + (∀ θ, ‖roughFourierPolynomial Z h θ‖ ≤ U * L ^ (-99 / 100 : ℝ)) ∧ + (∫ θ, ‖roughFourierPolynomial Z h θ‖ ^ 4 ∂AddCircle.haarAddCircle) ≤ + V / (D : ℝ) * L ^ (-99 / 25 : ℝ) := by + obtain ⟨C, hC, hprime⟩ := hM.rough_scale + refine ⟨Real.exp C + 2, Real.exp (4 * C + 6) + 2, by positivity, by positivity, ?_⟩ + filter_upwards [hprime, eventually_ge_atTop (Real.exp 1), + eventually_sieve_boundary_cost 1002 1 (by norm_num) zero_le_one, + eventually_sieve_boundary_cost 1002 3 (by norm_num) (by norm_num)] with + L hprimeL hL hb₁ hb₃ + intro D h hD hh Z hZ + have hL₁ : 1 ≤ L := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hL + have hlog : 1 ≤ Real.log L := by + rw [← Real.log_exp 1] + exact Real.log_le_log (Real.exp_pos 1) hL + have hDp : (0 : ℝ) < D := lt_of_lt_of_le (by positivity) hD + have hDN : 0 < D := by exact_mod_cast hDp + let : NeZero D := ⟨hDN.ne'⟩ + let Y := Real.exp (L ^ (99 / 100 : ℝ)) + let P := sievePrimesUpTo Y + let r := ⌈500 * Real.log L⌉₊ + have hY : 0 ≤ Y := (Real.exp_pos _).le + have hP (p : ℕ) (hp : p ∈ P) : Nat.Prime p := sievePrimesUpTo_prime Y p hp + have hmax (p : ℕ) (hp : p ∈ P) : (p : ℝ) ≤ Y := sievePrimesUpTo_le Y hY p hp + have hcard : (P.card : ℝ) ≤ Y := sievePrimesUpTo_card_le Y hY + have hrlo : 220 * Real.log L ≤ (2 * r + 1 : ℕ) := by + have hr : 500 * Real.log L ≤ (r : ℝ) := Nat.le_ceil _ + push_cast + linarith + have hrhi : (2 * r : ℕ) ≤ (1002 : ℝ) * Real.log L := by + have hr : (r : ℝ) < 500 * Real.log L + 1 := + Nat.ceil_lt_add_one (by positivity) + push_cast + linarith + have he₁ := hb₁ Y P.card D (2 * r) hY (Nat.cast_nonneg _) hcard le_rfl hrhi hD + have he₃ := hb₃ Y P.card D (2 * r) hY (Nat.cast_nonneg _) hcard le_rfl hrhi hD + have hup : (∑ p ∈ P, 1 / (p : ℝ)) ≤ 5 * Real.log L := by + have hp := hprimeL.2 + change (∑ p ∈ P, 1 / (p : ℝ)) ≤ (5 / 4 : ℝ) * Real.log L at hp + linarith + have hprob₁ := rough_interval_probability P hP D D r L C Y hL₁ hY hmax + hprimeL.1 hup hrlo + have hprob₃ := rough_cube_probability P hP (D, D, D) D r L C Y hL₁ hY hmax + hprimeL.1 hprimeL.2 hrlo + have hpower₁ : L ^ (-100 : ℝ) ≤ L ^ (-99 / 100 : ℝ) := + Real.rpow_le_rpow_of_exponent_le hL₁ (by norm_num) + have hpower₃ : L ^ (-100 : ℝ) ≤ L ^ (-99 / 25 : ℝ) := + Real.rpow_le_rpow_of_exponent_le hL₁ (by norm_num) + apply roughFourier_bounds_of_sieve P Z D h hh L (Real.exp C + 2) + (Real.exp (4 * C + 6) + 2) hZ + · exact hprob₁.trans (by nlinarith only [he₁, hpower₁]) + · exact hprob₃.trans (by nlinarith only [he₃, hpower₃]) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughLiouvilleShifts.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughLiouvilleShifts.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c74c93b50bd14abe9c6d1c5da6378a308af468d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughLiouvilleShifts.lean @@ -0,0 +1,55 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughFourierSieve +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftEndpoints + +namespace OAI + +/-! The complete quantitative rough-shift analytic estimate, conditional +only on the stated published Mertens and MRT inputs. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +/-- Manuscript `(q:rough-shifts)`, including arbitrary (possibly nonunit) +progression classes. The finite rough set is unrestricted within its interval. -/ +theorem rough_liouville_shifts (hM : PrimeReciprocalInput) + (hMRT : MRTLiouvilleShortInput) (h : ℕ) (hh : 0 < h) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, ∀ Y D l : ℕ, + (1 / 2 : ℝ) * Real.exp (L ^ (199 / 200 : ℝ)) ≤ D → + (D : ℝ) ≤ Real.exp (2 * L) → + Real.exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ)) ≤ Y → + ∀ [NeZero l] (a : ZMod l) (Z : Finset ℕ), + (∀ z ∈ Z, D ≤ z ∧ z < D + D ∧ + avoidsPrimeSet (sievePrimesUpTo (Real.exp (L ^ (99 / 100 : ℝ)))) z) → + ‖roughShiftAverage (progressionSequence liouville l a) liouville Z h Y‖ ≤ + C * L ^ (-21 / 20 : ℝ) := by + obtain ⟨U, V, hU, hV, hFourier⟩ := hM.rough_fourier + obtain ⟨K, hK, hWindow⟩ := hMRT.progression_window_scale + let C := 2 * U + (2 * (h : ℝ) + 1) + (2 * (h : ℝ) + 1) * U * V * K + refine ⟨C, by dsimp [C]; positivity, ?_⟩ + filter_upwards [hFourier, hWindow, eventually_rough_interval_lower, + eventually_ge_atTop 10] with L hFourierL hWindowL hLowerL hL + intro Y D l hDlower hDupper hYlower _ a Z hZ + have hL₁ : 1 ≤ L := by linarith + have hD₁₀ : 10 ≤ D := hLowerL D hDlower + have hYp : (0 : ℝ) < Y := (Real.exp_pos _).trans_le hYlower + have hYN : 0 < Y := by exact_mod_cast hYp + have hratio := rough_shift_ratio L hL D Y hDupper hYlower + have hrat₁ : (D : ℝ) / Y ≤ 1 := hratio.trans (by + simpa only [Real.rpow_zero] using + Real.rpow_le_rpow_of_exponent_le hL₁ (show (-21 / 20 : ℝ) ≤ 0 by norm_num)) + have hDY : D ≤ Y := by exact_mod_cast (div_le_one hYp).mp hrat₁ + have hYplus : Real.exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ)) ≤ (Y + 1 : ℕ) := + hYlower.trans (by exact_mod_cast Nat.le_succ Y) + obtain ⟨hB, hFourth⟩ := hFourierL D h hDlower hh Z hZ + exact rough_shift_power_bound (progressionSequence liouville l a) liouville + (liouville_oneBounded.progressionSequence l a) liouville_oneBounded Z D h Y + (by omega) hYN (fun z hz => by have := (hZ z hz).2.1; omega) + L U V K hL₁ hU.le hV.le hK.le hratio hB hFourth + (fun θ => hWindowL Y D l (by omega) hD₁₀ (by omega) + hDlower hDupper hYplus a θ) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftAverage.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..b21c9cf449bcccb9c95a621dc4a8cd7f408e2b01 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftAverage.lean @@ -0,0 +1,149 @@ +import OAI.NumberTheory.TwoPoint.Bounds.WindowPolynomialBounds +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftBoundary + +namespace OAI + +/-! +# A finite rough-shift correlation inequality + +The three terms are the explicit translation error, the low-frequency +Cauchy--Schwarz term, and the high-frequency fourth-moment term. Sieve +estimates and MRT scale estimates enter only through their numerical bounds. +-/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +noncomputable def roughShiftProfile (f g : ℕ → ℂ) (Z : Finset ℕ) (h n : ℕ) : ℂ := + ∑ z ∈ Z, (z : ℂ)⁻¹ * (f n * g (n + h * z)) + +noncomputable def roughShiftAverage (f g : ℕ → ℂ) (Z : Finset ℕ) (h Y : ℕ) : ℂ := + positivePrefix (roughShiftProfile f g Z h) Y / (Y : ℂ) + +lemma norm_roughShiftProfile_le (f g : ℕ → ℂ) (hf : OneBounded f) (hg : OneBounded g) + (Z : Finset ℕ) (h n : ℕ) (hn : 0 < n) : + ‖roughShiftProfile f g Z h n‖ ≤ ∑ z ∈ Z, (z : ℝ)⁻¹ := by + have hh := norm_weightedShiftProfile_le Z (fun z => (z : ℂ)⁻¹) + (fun z => h * z) f g hf hg 1 0 n hn + simpa only [weightedShiftProfile, roughShiftProfile, Nat.mod_one, ite_true, + norm_inv, Complex.norm_natCast] using hh + +lemma translated_roughShiftProfile_eq (f g : ℕ → ℂ) (Z : Finset ℕ) (D h Y : ℕ) + (hZ : ∀ z ∈ Z, z ≤ 2 * D) : + translatedPrefixAverage (roughShiftProfile f g Z h) Y D = + (D : ℂ)⁻¹ * ∑ v ∈ range Y, ∫ θ, + roughFourierPolynomial Z h θ * forwardWindowPolynomial f D (v + 1) θ * + backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ + ∂AddCircle.haarAddCircle := by + unfold translatedPrefixAverage + congr 1 + calc + _ = ∑ m ∈ Icc 1 D, + positivePrefix (fun n => roughShiftProfile f g Z h (n + m)) Y := by + simpa only [Nat.zero_add] using (sum_Icc_shift + (fun m => positivePrefix (fun n => roughShiftProfile f g Z h (n + m)) Y) 0 D).symm + _ = _ := by + rw [summed_rough_shift_convolution f g Z D h Y hZ] + rfl + +lemma rough_window_energy_sum_bound (f g : ℕ → ℂ) (hf : OneBounded f) + (hg : OneBounded g) (D Q Y : ℕ) : + (∑ v ∈ range Y, + Real.sqrt (∫ θ, ‖forwardWindowPolynomial f D (v + 1) θ‖ ^ 2 + ∂AddCircle.haarAddCircle) * + Real.sqrt (∫ θ, ‖backwardWindowPolynomial g Q (v + 1) θ‖ ^ 2 + ∂AddCircle.haarAddCircle)) ≤ (Y : ℝ) * (Real.sqrt D * Real.sqrt Q) := by + calc + _ ≤ ∑ _v ∈ range Y, Real.sqrt (D : ℝ) * Real.sqrt Q := by + apply sum_le_sum + intro v _ + exact mul_le_mul + (Real.sqrt_le_sqrt (integral_forwardWindowPolynomial_sq_le f hf D (v + 1))) + (Real.sqrt_le_sqrt (integral_backwardWindowPolynomial_sq_le g hg Q (v + 1))) + (Real.sqrt_nonneg _) (Real.sqrt_nonneg _) + _ = _ := by simp + +/-- All Fourier ingredients are now attached to the concrete two windows. -/ +theorem rough_convolution_sum_bound (f g : ℕ → ℂ) (hf : OneBounded f) + (hg : OneBounded g) (Z : Finset ℕ) (D h Y : ℕ) + (ε U V K : ℝ) (hε : 0 < ε) (hU : 0 ≤ U) (hK : 0 ≤ K) + (hB : ∀ θ, ‖roughFourierPolynomial Z h θ‖ ≤ U) + (hV : (∫ θ, ‖roughFourierPolynomial Z h θ‖ ^ 4 + ∂AddCircle.haarAddCircle) ≤ V) + (hF : ∀ θ, (∑ v ∈ range Y, ‖forwardWindowPolynomial f D (v + 1) θ‖) ≤ K) : + ‖∑ v ∈ range Y, ∫ θ, + roughFourierPolynomial Z h θ * forwardWindowPolynomial f D (v + 1) θ * + backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ + ∂AddCircle.haarAddCircle‖ ≤ + ε * ((Y : ℝ) * (Real.sqrt D * Real.sqrt ((2 * h + 1) * D))) + + (U * ((2 * h + 1) * D) * K / ε ^ 4) * V := by + have hh := fourier_region_bound (range Y) (roughFourierPolynomial Z h) + (fun v => forwardWindowPolynomial f D (v + 1)) + (fun v => backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1)) + (continuous_fourierPolynomial _ _ _) + (fun v _ => continuous_forwardWindowPolynomial f D (v + 1)) + (fun v _ => continuous_backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1)) + ε U ((2 * h + 1) * D) K hε hU (by positivity) hK hB + (fun v _ θ => by + simpa only [Nat.cast_mul, Nat.cast_add, Nat.cast_ofNat, Nat.cast_one] using + norm_backwardWindowPolynomial_le g hg ((2 * h + 1) * D) (v + 1) θ) hF + apply hh.trans + apply add_le_add + · apply mul_le_mul_of_nonneg_left _ hε.le + simpa only [Nat.cast_mul, Nat.cast_add, Nat.cast_ofNat, Nat.cast_one] using + rough_window_energy_sum_bound f g hf hg D ((2 * h + 1) * D) Y + · exact mul_le_mul_of_nonneg_left hV (by positivity) + +lemma normalized_translated_roughShift_bound (f g : ℕ → ℂ) + (Z : Finset ℕ) (D h Y : ℕ) (hD : 0 < D) (hY : 0 < Y) + (hZ : ∀ z ∈ Z, z ≤ 2 * D) (W : ℝ) + (hW : ‖∑ v ∈ range Y, ∫ θ, + roughFourierPolynomial Z h θ * forwardWindowPolynomial f D (v + 1) θ * + backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ + ∂AddCircle.haarAddCircle‖ ≤ W) : + ‖translatedPrefixAverage (roughShiftProfile f g Z h) Y D / (Y : ℂ)‖ ≤ + W / ((Y : ℝ) * D) := by + rw [translated_roughShiftProfile_eq f g Z D h Y hZ, + norm_div, norm_mul, norm_inv, Complex.norm_natCast, Complex.norm_natCast] + have hDr : (0 : ℝ) < D := by exact_mod_cast hD + have hYr : (0 : ℝ) < Y := by exact_mod_cast hY + calc + _ ≤ (D : ℝ)⁻¹ * W / Y := + div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hW (by positivity)) hYr.le + _ = _ := by simp only [div_eq_mul_inv, mul_inv_rev]; ring + +/-- The finite correlation bound before inserting the sieve estimates and +the size estimates for the published MRT error. -/ +theorem rough_shift_average_bound (f g : ℕ → ℂ) (hf : OneBounded f) + (hg : OneBounded g) (Z : Finset ℕ) (D h Y : ℕ) (hD : 0 < D) (hY : 0 < Y) + (hZ : ∀ z ∈ Z, z ≤ 2 * D) + (ε U V K : ℝ) (hε : 0 < ε) (hU : 0 ≤ U) (hK : 0 ≤ K) + (hB : ∀ θ, ‖roughFourierPolynomial Z h θ‖ ≤ U) + (hV : (∫ θ, ‖roughFourierPolynomial Z h θ‖ ^ 4 + ∂AddCircle.haarAddCircle) ≤ V) + (hF : ∀ θ, (∑ v ∈ range Y, ‖forwardWindowPolynomial f D (v + 1) θ‖) ≤ K) : + ‖roughShiftAverage f g Z h Y‖ ≤ + 2 * (D : ℝ) / Y * (∑ z ∈ Z, (z : ℝ)⁻¹) + + (ε * ((Y : ℝ) * (Real.sqrt D * Real.sqrt ((2 * h + 1) * D))) + + (U * ((2 * h + 1) * D) * K / ε ^ 4) * V) / ((Y : ℝ) * D) := by + let u := roughShiftProfile f g Z h + have he := norm_normalized_translation_error u Y D hY hD + (∑ z ∈ Z, (z : ℝ)⁻¹) (sum_nonneg (fun z _ => by positivity)) + (fun n hn => norm_roughShiftProfile_le f g hf hg Z h n hn) + have hc := normalized_translated_roughShift_bound f g Z D h Y hD hY hZ _ + (rough_convolution_sum_bound f g hf hg Z D h Y ε U V K hε hU hK hB hV hF) + calc + ‖roughShiftAverage f g Z h Y‖ = ‖translatedPrefixAverage u Y D / (Y : ℂ) - + (translatedPrefixAverage u Y D - positivePrefix u Y) / (Y : ℂ)‖ := by + congr 1 + dsimp [roughShiftAverage, u] + ring + _ ≤ ‖translatedPrefixAverage u Y D / (Y : ℂ)‖ + + ‖(translatedPrefixAverage u Y D - positivePrefix u Y) / (Y : ℂ)‖ := norm_sub_le _ _ + _ ≤ _ := by simpa only [add_comm] using add_le_add hc he + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftBoundary.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftBoundary.lean new file mode 100644 index 0000000000000000000000000000000000000000..6bfa7c527e4197e6ba49f70d3ed9ed9530949aac --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftBoundary.lean @@ -0,0 +1,139 @@ +import OAI.NumberTheory.TwoPoint.Basic +import Mathlib.Analysis.Normed.Module.Basic + +namespace OAI + +/-! +# The endpoint error in the rough-shift averaging argument + +These are finite identities and bounds from the proof of (q:rough-shifts) +in quantitative/03-analytic.tex. No short-sum or sieve estimate is assumed. +The averages below use the positive integers `1,...,Y` and translations +`1,...,D`; the resulting error is at most `2D/Y` times the total weight. +-/ + +namespace TwoPointCorrelations + +open scoped BigOperators + +/-- A positive prefix, also when its length is zero. -/ +def positivePrefix (u : ℕ → ℂ) (Y : ℕ) : ℂ := + ∑ v ∈ Finset.range Y, u (v + 1) + +/-- The average of the `D` translated positive prefixes. -/ +noncomputable def translatedPrefixAverage (u : ℕ → ℂ) (Y D : ℕ) : ℂ := + (D : ℂ)⁻¹ * ∑ m ∈ Finset.range D, positivePrefix (fun n => u (n + (m + 1))) Y + +theorem positivePrefix_translate_identity (u : ℕ → ℂ) (Y m : ℕ) : + positivePrefix (fun n => u (n + m)) Y - positivePrefix u Y = + positivePrefix (fun n => u (n + Y)) m - positivePrefix u m := by + have hsplit : positivePrefix u Y + positivePrefix (fun n => u (n + Y)) m = + positivePrefix u m + positivePrefix (fun n => u (n + m)) Y := by + have h₁ : positivePrefix u (Y + m) = + positivePrefix u Y + positivePrefix (fun n => u (n + Y)) m := by + simpa only [positivePrefix, Nat.add_comm, Nat.add_left_comm, Nat.add_assoc] using + Finset.sum_range_add (fun n => u (n + 1)) Y m + have h₂ : positivePrefix u (m + Y) = + positivePrefix u m + positivePrefix (fun n => u (n + m)) Y := by + simpa only [positivePrefix, Nat.add_comm, Nat.add_left_comm, Nat.add_assoc] using + Finset.sum_range_add (fun n => u (n + 1)) m Y + exact h₁.symm.trans ((congrArg (positivePrefix u) (Nat.add_comm Y m)).trans h₂) + linear_combination -hsplit + +theorem norm_positivePrefix_le (u : ℕ → ℂ) (Y : ℕ) (B : ℝ) + (hu : ∀ n, 0 < n → ‖u n‖ ≤ B) : ‖positivePrefix u Y‖ ≤ Y * B := by + calc + _ ≤ ∑ v ∈ Finset.range Y, ‖u (v + 1)‖ := norm_sum_le _ _ + _ ≤ ∑ _v ∈ Finset.range Y, B := + Finset.sum_le_sum (fun v _ => hu (v + 1) (by omega)) + _ = _ := by simp + +/-- Translating by `m` loses at most `m` terms at each endpoint. No relation +between the prefix length and the translation is needed. -/ +theorem norm_positivePrefix_translate_sub_le (u : ℕ → ℂ) (Y m : ℕ) (B : ℝ) + (hu : ∀ n, 0 < n → ‖u n‖ ≤ B) : + ‖positivePrefix (fun n => u (n + m)) Y - positivePrefix u Y‖ ≤ 2 * m * B := by + rw [positivePrefix_translate_identity] + calc + _ ≤ ‖positivePrefix (fun n => u (n + Y)) m‖ + ‖positivePrefix u m‖ := + norm_sub_le _ _ + _ ≤ (m : ℝ) * B + m * B := add_le_add + (norm_positivePrefix_le _ _ _ (fun n hn => hu _ (by omega))) + (norm_positivePrefix_le _ _ _ hu) + _ = _ := by ring + +/-- Averaging positive translations has the same finite endpoint bound. -/ +theorem norm_translatedPrefixAverage_sub_le (u : ℕ → ℂ) (Y D : ℕ) + (hD : 0 < D) (B : ℝ) (hB : 0 ≤ B) + (hu : ∀ n, 0 < n → ‖u n‖ ≤ B) : + ‖translatedPrefixAverage u Y D - positivePrefix u Y‖ ≤ 2 * D * B := by + have hDc : (D : ℂ) ≠ 0 := by exact_mod_cast hD.ne' + have hDr : (0 : ℝ) < D := by exact_mod_cast hD + have heq : translatedPrefixAverage u Y D - positivePrefix u Y = + (D : ℂ)⁻¹ * ∑ m ∈ Finset.range D, + (positivePrefix (fun n => u (n + (m + 1))) Y - positivePrefix u Y) := by + simp only [translatedPrefixAverage, Finset.sum_sub_distrib, Finset.sum_const, + Finset.card_range, nsmul_eq_mul, mul_sub] + field_simp + rw [heq, norm_mul, norm_inv, Complex.norm_natCast] + calc + _ ≤ (D : ℝ)⁻¹ * ∑ m ∈ Finset.range D, + ‖positivePrefix (fun n => u (n + (m + 1))) Y - positivePrefix u Y‖ := + mul_le_mul_of_nonneg_left (norm_sum_le _ _) (inv_nonneg.mpr hDr.le) + _ ≤ (D : ℝ)⁻¹ * ∑ _m ∈ Finset.range D, (2 * D * B) := by + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr hDr.le) + apply Finset.sum_le_sum + intro m hm + apply (norm_positivePrefix_translate_sub_le u Y (m + 1) B hu).trans + have hmD : ((m + 1 : ℕ) : ℝ) ≤ D := by + exact_mod_cast (Nat.succ_le_of_lt (Finset.mem_range.mp hm)) + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hmD (by norm_num : (0 : ℝ) ≤ 2)) hB + _ = _ := by simp only [Finset.sum_const, Finset.card_range, nsmul_eq_mul]; field_simp + +/-- The normalized endpoint error, in exactly the `D/Y` scale used in +the rough-shift lemma. -/ +theorem norm_normalized_translation_error (u : ℕ → ℂ) (Y D : ℕ) + (hY : 0 < Y) (hD : 0 < D) (B : ℝ) (hB : 0 ≤ B) + (hu : ∀ n, 0 < n → ‖u n‖ ≤ B) : + ‖(translatedPrefixAverage u Y D - positivePrefix u Y) / (Y : ℂ)‖ ≤ + 2 * (D : ℝ) / Y * B := by + rw [norm_div, Complex.norm_natCast] + have hYr : (0 : ℝ) < Y := by exact_mod_cast hY + apply (div_le_div_of_nonneg_right + (norm_translatedPrefixAverage_sub_le u Y D hD B hB hu) hYr.le).trans + exact le_of_eq (by ring) + +/-- The actual weighted progression-correlation profile. -/ +def weightedShiftProfile {ι : Type*} (Z : Finset ι) (w : ι → ℂ) (shift : ι → ℕ) + (f g : ℕ → ℂ) (l b n : ℕ) : ℂ := + ∑ z ∈ Z, w z * (if n % l = b % l then f n * g (n + shift z) else 0) + +theorem norm_weightedShiftProfile_le {ι : Type*} (Z : Finset ι) (w : ι → ℂ) + (shift : ι → ℕ) (f g : ℕ → ℂ) (hf : OneBounded f) (hg : OneBounded g) + (l b n : ℕ) (hn : 0 < n) : + ‖weightedShiftProfile Z w shift f g l b n‖ ≤ ∑ z ∈ Z, ‖w z‖ := by + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro z _ + by_cases hmod : n % l = b % l + · simp only [hmod, ite_true, norm_mul] + have hprod := mul_le_mul (hf n hn) (hg _ (by omega)) + (norm_nonneg (g (n + shift z))) (by norm_num : (0 : ℝ) ≤ 1) + simpa only [mul_one] using mul_le_mul_of_nonneg_left hprod (norm_nonneg (w z)) + · simp only [hmod, ite_false, mul_zero, norm_zero] + exact norm_nonneg _ + +theorem weighted_rough_shift_boundary {ι : Type*} (Z : Finset ι) (w : ι → ℂ) + (shift : ι → ℕ) (f g : ℕ → ℂ) (hf : OneBounded f) (hg : OneBounded g) + (l b Y D : ℕ) (hY : 0 < Y) (hD : 0 < D) : + ‖(translatedPrefixAverage (weightedShiftProfile Z w shift f g l b) Y D - + positivePrefix (weightedShiftProfile Z w shift f g l b) Y) / (Y : ℂ)‖ ≤ + 2 * (D : ℝ) / Y * ∑ z ∈ Z, ‖w z‖ := by + exact norm_normalized_translation_error _ Y D hY hD _ + (Finset.sum_nonneg (fun _ _ => norm_nonneg _)) + (fun n hn => norm_weightedShiftProfile_le Z w shift f g hf hg l b n hn) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftConvolution.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftConvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..25ef77c3b778048f7c15296e01866ea5b120f345 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftConvolution.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughFourier +import OAI.NumberTheory.TwoPoint.Bounds.ShortSumSampling + +namespace OAI + +/-! Exact Fourier convolution for the translated rough-shift average. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +noncomputable def forwardWindowPolynomial (f : ℕ → ℂ) (D v : ℕ) : + AddCircle (1 : ℝ) → ℂ := + fourierPolynomial (Icc 1 D) (fun m => (m : ℤ)) (fun m => f (v + m)) + +noncomputable def backwardWindowPolynomial (g : ℕ → ℂ) (Q v : ℕ) : + AddCircle (1 : ℝ) → ℂ := + fourierPolynomial (Icc 1 Q) (fun a => -(a : ℤ)) (fun a => g (v + a)) + +/-- Orthogonality imposes precisely `a=m+hz`; the long window contains +every selected frequency, so there is no further truncation error. -/ +theorem rough_shift_convolution (f g : ℕ → ℂ) (Z : Finset ℕ) (D h v : ℕ) + (hZ : ∀ z ∈ Z, z ≤ 2 * D) : + (∫ θ, roughFourierPolynomial Z h θ * forwardWindowPolynomial f D v θ * + backwardWindowPolynomial g ((2 * h + 1) * D) v θ ∂AddCircle.haarAddCircle) = + ∑ z ∈ Z, (z : ℂ)⁻¹ * ∑ m ∈ Icc 1 D, f (v + m) * g (v + m + h * z) := by + unfold roughFourierPolynomial forwardWindowPolynomial backwardWindowPolynomial + simp_rw [fourierPolynomial_mul] + rw [integral_fourierPolynomial] + simp only [sum_product] + apply sum_congr rfl + intro z hz + rw [mul_sum] + apply sum_congr rfl + intro m hm + have hm1 : 1 ≤ m := (mem_Icc.mp hm).1 + have hmD : m ≤ D := (mem_Icc.mp hm).2 + have ha : m + h * z ∈ Icc 1 ((2 * h + 1) * D) := by + simp only [mem_Icc] + constructor + · omega + · nlinarith [Nat.mul_le_mul_left h (hZ z hz)] + rw [sum_eq_single (m + h * z)] + · have he : (h : ℤ) * z + m + -(↑(m + h * z) : ℤ) = 0 := by + push_cast + ring + rw [ite_eq_left he] + rw [show v + (m + h * z) = v + m + h * z by omega] + ring + · intro a _ hne + have he : ¬((h : ℤ) * z + m + -(a : ℤ) = 0) := by + intro hh + apply hne + exact_mod_cast (show (a : ℤ) = m + h * z by linarith) + exact ite_eq_right he + · exact fun hnot => False.elim (hnot ha) + +/-- Summing the convolution identity gives the exact translated average +used before the endpoint comparison. -/ +theorem summed_rough_shift_convolution (f g : ℕ → ℂ) (Z : Finset ℕ) + (D h Y : ℕ) (hZ : ∀ z ∈ Z, z ≤ 2 * D) : + (∑ v ∈ range Y, ∫ θ, + roughFourierPolynomial Z h θ * forwardWindowPolynomial f D (v + 1) θ * + backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ + ∂AddCircle.haarAddCircle) = + ∑ m ∈ Icc 1 D, ∑ v ∈ range Y, ∑ z ∈ Z, + (z : ℂ)⁻¹ * (f (v + 1 + m) * g (v + 1 + m + h * z)) := by + simp_rw [rough_shift_convolution f g Z D h _ hZ, mul_sum] + calc + _ = ∑ v ∈ range Y, ∑ m ∈ Icc 1 D, ∑ z ∈ Z, + (z : ℂ)⁻¹ * (f (v + 1 + m) * g (v + 1 + m + h * z)) := by + apply sum_congr rfl + intro v _ + rw [sum_comm] + _ = _ := sum_comm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftEndpoints.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftEndpoints.lean new file mode 100644 index 0000000000000000000000000000000000000000..2929073598dfe3b5bdf46378a160d74a3080e63e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftEndpoints.lean @@ -0,0 +1,49 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftScale + +namespace OAI + +/-! The physical interval scales imply every endpoint-size condition used +in the translated rough-shift average. -/ + +namespace TwoPointCorrelations + +open Filter + +theorem rough_shift_ratio (L : ℝ) (hL : 10 ≤ L) (D Y : ℕ) + (hD : (D : ℝ) ≤ Real.exp (2 * L)) + (hY : Real.exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ)) ≤ Y) : + (D : ℝ) / Y ≤ L ^ (-21 / 20 : ℝ) := by + have hL₁ : 1 ≤ L := by linarith + have hLp : 0 < L := by linarith + have hYp : (0 : ℝ) < Y := (Real.exp_pos _).trans_le hY + have hp : L ^ (2 : ℝ) ≤ L ^ (1000 : ℝ) := + Real.rpow_le_rpow_of_exponent_le hL₁ (by norm_num) + have hsq : (10 : ℝ) * L ≤ L ^ 2 := by + have hh := mul_le_mul_of_nonneg_right hL hLp.le + nlinarith only [hh] + have hlog : Real.log L ≤ L := (Real.log_le_sub_one_of_pos hLp).trans (by linarith) + have hgap : 2 * L - (1 / 2 : ℝ) * L ^ (1000 : ℝ) ≤ + Real.log L * (-21 / 20 : ℝ) := by + norm_num only [Real.rpow_two] at hp + nlinarith only [hp, hsq, hlog, hL] + calc + _ ≤ Real.exp (2 * L) / Real.exp ((1 / 2 : ℝ) * L ^ (1000 : ℝ)) := + div_le_div₀ (Real.exp_pos _).le hD (Real.exp_pos _) hY + _ = Real.exp (2 * L - (1 / 2 : ℝ) * L ^ (1000 : ℝ)) := (Real.exp_sub _ _).symm + _ ≤ _ := by + rw [Real.rpow_def_of_pos hLp (-21 / 20 : ℝ)] + exact Real.exp_le_exp.mpr hgap + +theorem eventually_rough_interval_lower : + ∀ᶠ L : ℝ in atTop, ∀ D : ℕ, + (1 / 2 : ℝ) * Real.exp (L ^ (199 / 200 : ℝ)) ≤ D → 10 ≤ D := by + have hg := ((Real.tendsto_exp_atTop.comp + (tendsto_rpow_atTop (show 0 < (199 / 200 : ℝ) by norm_num))).const_mul_atTop + (show (0 : ℝ) < 1 / 2 by norm_num)).eventually (eventually_ge_atTop 10) + filter_upwards [hg] with L hL + intro D hD + exact_mod_cast hL.trans hD + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c77b6741923f31e3ff2c8cdf8d0bd148cd756d4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughShiftScale.lean @@ -0,0 +1,120 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftAverage +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTScale + +namespace OAI + +/-! Explicit power arithmetic in the rough-shift Fourier argument. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +lemma rough_reciprocal_mass_le_sup (Z : Finset ℕ) (h : ℕ) (U : ℝ) + (hU : ‖roughFourierPolynomial Z h 0‖ ≤ U) : + (∑ z ∈ Z, (z : ℝ)⁻¹) ≤ U := by + have he : roughFourierPolynomial Z h 0 = ((∑ z ∈ Z, (z : ℝ)⁻¹ : ℝ) : ℂ) := by + simp only [roughFourierPolynomial, fourierPolynomial, fourier_eval_zero, mul_one, + Complex.ofReal_sum, Complex.ofReal_inv, Complex.ofReal_natCast] + rw [he, Complex.norm_real, Real.norm_of_nonneg + (sum_nonneg (fun z _ => by positivity))] at hU + exact hU + +lemma rough_window_sqrt_bound (D h : ℕ) : + Real.sqrt (D : ℝ) * Real.sqrt ((2 * (h : ℝ) + 1) * D) ≤ + (2 * (h : ℝ) + 1) * D := by + have ht : (D : ℝ) ≤ (2 * (h : ℝ) + 1) * D := by + nlinarith [show (0 : ℝ) ≤ (h : ℝ) * D by positivity] + calc + _ ≤ Real.sqrt ((2 * (h : ℝ) + 1) * D) * + Real.sqrt ((2 * (h : ℝ) + 1) * D) := + mul_le_mul_of_nonneg_right (Real.sqrt_le_sqrt ht) (Real.sqrt_nonneg _) + _ = _ := by rw [← pow_two, Real.sq_sqrt (by positivity)] + +lemma rough_fourier_exponent_identity (L : ℝ) (hL : 0 < L) : + L ^ (-99 / 100 : ℝ) * L ^ (-4 / 5 : ℝ) * L ^ (-99 / 25 : ℝ) / + (L ^ (-21 / 20 : ℝ)) ^ (4 : ℕ) = L ^ (-31 / 20 : ℝ) := by + have hp : (L ^ (-21 / 20 : ℝ)) ^ (4 : ℕ) = L ^ ((-21 / 20 : ℝ) * 4) := by + rw [← Real.rpow_natCast, ← Real.rpow_mul hL.le] + norm_num + rw [hp, ← Real.rpow_add hL, ← Real.rpow_add hL, ← Real.rpow_sub hL] + norm_num + +lemma rough_low_term_bound (D h Y : ℕ) (hD : 0 < D) (hY : 0 < Y) + (ε : ℝ) (hε : 0 ≤ ε) : + (ε * ((Y : ℝ) * (Real.sqrt D * Real.sqrt ((2 * (h : ℝ) + 1) * D)))) / + ((Y : ℝ) * D) ≤ (2 * (h : ℝ) + 1) * ε := by + have hDr : (0 : ℝ) < D := by exact_mod_cast hD + have hYr : (0 : ℝ) < Y := by exact_mod_cast hY + calc + _ ≤ (ε * ((Y : ℝ) * ((2 * (h : ℝ) + 1) * D))) / ((Y : ℝ) * D) := by + exact div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left (rough_window_sqrt_bound D h) hYr.le) hε) + (mul_pos hYr hDr).le + _ = _ := by field_simp + +lemma rough_high_term_identity (D h Y : ℕ) (hD : 0 < D) (hY : 0 < Y) + (L U V K : ℝ) (hL : 0 < L) : + (((U * L ^ (-99 / 100 : ℝ)) * ((2 * (h : ℝ) + 1) * D) * + (K * Y * D * L ^ (-4 / 5 : ℝ)) / (L ^ (-21 / 20 : ℝ)) ^ (4 : ℕ)) * + (V / D * L ^ (-99 / 25 : ℝ))) / ((Y : ℝ) * D) = + (2 * (h : ℝ) + 1) * U * V * K * L ^ (-31 / 20 : ℝ) := by + have hDr : (D : ℝ) ≠ 0 := by exact_mod_cast hD.ne' + have hYr : (Y : ℝ) ≠ 0 := by exact_mod_cast hY.ne' + have hpow : L ^ (-21 / 20 : ℝ) ≠ 0 := (Real.rpow_pos_of_pos hL _).ne' + calc + _ = ((2 * (h : ℝ) + 1) * U * V * K) * + (L ^ (-99 / 100 : ℝ) * L ^ (-4 / 5 : ℝ) * L ^ (-99 / 25 : ℝ) / + (L ^ (-21 / 20 : ℝ)) ^ (4 : ℕ)) := by + field_simp + _ = _ := by rw [rough_fourier_exponent_identity L hL] + +/-- The Fourier bound has the exact exponent `-21/20`. The stronger +`-31/20` contribution is absorbed only at this final numerical step. -/ +theorem rough_shift_power_bound (f g : ℕ → ℂ) (hf : OneBounded f) + (hg : OneBounded g) (Z : Finset ℕ) (D h Y : ℕ) (hD : 0 < D) (hY : 0 < Y) + (hZ : ∀ z ∈ Z, z ≤ 2 * D) (L U V K : ℝ) + (hL : 1 ≤ L) (hU : 0 ≤ U) (hV : 0 ≤ V) (hK : 0 ≤ K) + (hendpoint : (D : ℝ) / Y ≤ L ^ (-21 / 20 : ℝ)) + (hB : ∀ θ, ‖roughFourierPolynomial Z h θ‖ ≤ U * L ^ (-99 / 100 : ℝ)) + (hfourth : (∫ θ, ‖roughFourierPolynomial Z h θ‖ ^ 4 + ∂AddCircle.haarAddCircle) ≤ V / D * L ^ (-99 / 25 : ℝ)) + (hF : ∀ θ, (∑ v ∈ range Y, ‖forwardWindowPolynomial f D (v + 1) θ‖) ≤ + K * Y * D * L ^ (-4 / 5 : ℝ)) : + ‖roughShiftAverage f g Z h Y‖ ≤ + (2 * U + (2 * (h : ℝ) + 1) + (2 * (h : ℝ) + 1) * U * V * K) * + L ^ (-21 / 20 : ℝ) := by + have hLp : 0 < L := zero_lt_one.trans_le hL + have hmass : (∑ z ∈ Z, (z : ℝ)⁻¹) ≤ U := by + apply (rough_reciprocal_mass_le_sup Z h _ (hB 0)).trans + have hp : L ^ (-99 / 100 : ℝ) ≤ 1 := by + simpa only [Real.rpow_zero] using + Real.rpow_le_rpow_of_exponent_le hL (show (-99 / 100 : ℝ) ≤ 0 by norm_num) + exact (mul_le_mul_of_nonneg_left hp hU).trans_eq (mul_one U) + have he : 2 * (D : ℝ) / Y * (∑ z ∈ Z, (z : ℝ)⁻¹) ≤ + 2 * U * L ^ (-21 / 20 : ℝ) := by + calc + _ = 2 * ((D : ℝ) / Y) * (∑ z ∈ Z, (z : ℝ)⁻¹) := by ring + _ ≤ 2 * L ^ (-21 / 20 : ℝ) * U := + mul_le_mul (mul_le_mul_of_nonneg_left hendpoint (by norm_num)) hmass + (sum_nonneg (fun z _ => by positivity)) (by positivity) + _ = _ := by ring + have hraw := rough_shift_average_bound f g hf hg Z D h Y hD hY hZ + (L ^ (-21 / 20 : ℝ)) (U * L ^ (-99 / 100 : ℝ)) + (V / D * L ^ (-99 / 25 : ℝ)) (K * Y * D * L ^ (-4 / 5 : ℝ)) + (Real.rpow_pos_of_pos hLp _) (by positivity) (by positivity) hB hfourth hF + have hlow := rough_low_term_bound D h Y hD hY + (L ^ (-21 / 20 : ℝ)) (Real.rpow_nonneg hLp.le _) + have hhigh := rough_high_term_identity D h Y hD hY L U V K hLp + have hgap : L ^ (-31 / 20 : ℝ) ≤ L ^ (-21 / 20 : ℝ) := + Real.rpow_le_rpow_of_exponent_le hL (by norm_num) + apply hraw.trans + rw [add_div, hhigh] + have ht := mul_le_mul_of_nonneg_left hgap + (show 0 ≤ (2 * (h : ℝ) + 1) * U * V * K by positivity) + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughSieveCounts.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughSieveCounts.lean new file mode 100644 index 0000000000000000000000000000000000000000..b001ad8162e009ef24819d9867b40029fa8c2c3e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughSieveCounts.lean @@ -0,0 +1,170 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughSieveProbability +import OAI.NumberTheory.TwoPoint.Bounds.RoughFourier + +namespace OAI + +/-! Passing from actual uniform samples to subset and additive-energy +counts. Every additive quadruple is injected into its first three entries. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +lemma uniformFiniteLaw_probability {α : Type*} [Fintype α] [Nonempty α] + (E : α → Prop) : (uniformFiniteLaw α).probability E = + ((univ.filter E).card : ℝ) / Fintype.card α := by + simp only [FiniteLaw.probability, FiniteLaw.average, uniformFiniteLaw, ← mul_sum, + sum_boole] + ring + +noncomputable def roughIntervalSamples (P : Finset ℕ) (A N : ℕ) : Finset (Fin N) := + univ.filter (fun j => avoidsPrimeSet P (A + j.val)) + +noncomputable def roughCubeSamples (P : Finset ℕ) (A : ℕ × ℕ × ℕ) (N : ℕ) : + Finset (Fin N × Fin N × Fin N) := + univ.filter (fun j => fourFormsAvoidPrimeSet P + (A.1 + j.1.val, A.2.1 + j.2.1.val, A.2.2 + j.2.2.val)) + +lemma roughIntervalSamples_probability (P : Finset ℕ) (A N : ℕ) [NeZero N] : + (roughIntervalSamples P A N).card = (N : ℝ) * + (uniformFiniteLaw (Fin N)).probability (fun j => avoidsPrimeSet P (A + j.val)) := by + rw [uniformFiniteLaw_probability] + simp only [Fintype.card_fin, roughIntervalSamples] + have hN : (N : ℝ) ≠ 0 := by exact_mod_cast NeZero.ne N + field_simp [hN] + +lemma roughCubeSamples_probability (P : Finset ℕ) (A : ℕ × ℕ × ℕ) (N : ℕ) + [NeZero N] : + (roughCubeSamples P A N).card = (N : ℝ) ^ 3 * + (uniformFiniteLaw (Fin N × Fin N × Fin N)).probability + (fun j => fourFormsAvoidPrimeSet P + (A.1 + j.1.val, A.2.1 + j.2.1.val, A.2.2 + j.2.2.val)) := by + rw [uniformFiniteLaw_probability] + simp only [Fintype.card_prod, Fintype.card_fin, Nat.cast_mul, roughCubeSamples] + have hN : (N : ℝ) ≠ 0 := by exact_mod_cast NeZero.ne N + field_simp [hN] + +theorem rough_subset_card_le (P Z : Finset ℕ) (A N : ℕ) + (hZ : ∀ z ∈ Z, A ≤ z ∧ z < A + N ∧ avoidsPrimeSet P z) : + Z.card ≤ (roughIntervalSamples P A N).card := by + let offset (z : Z) : Fin N := ⟨(z : ℕ) - A, by + have hz := hZ z z.property + omega⟩ + let f : Z → roughIntervalSamples P A N := fun z => ⟨offset z, by + have hz := hZ z z.property + simp only [roughIntervalSamples, mem_filter, mem_univ, true_and] + change avoidsPrimeSet P (A + ((z : ℕ) - A)) + rw [Nat.add_sub_of_le hz.1] + exact hz.2.2⟩ + have hf : Function.Injective f := by + intro z w he + have hv := congrArg (fun t : roughIntervalSamples P A N => (t : Fin N).val) he + have hz := hZ z z.property + have hw := hZ w w.property + apply Subtype.ext + change (z : ℕ) - A = (w : ℕ) - A at hv + omega + simpa only [Fintype.card_coe] using Fintype.card_le_of_injective f hf + +noncomputable def additiveQuadruples (Z : Finset ℕ) : + Finset ((ℕ × ℕ) × (ℕ × ℕ)) := + ((Z ×ˢ Z) ×ˢ (Z ×ˢ Z)).filter (fun q => q.1.1 + q.1.2 = q.2.1 + q.2.2) + +lemma mem_additiveQuadruples {Z : Finset ℕ} {q : (ℕ × ℕ) × (ℕ × ℕ)} + (hq : q ∈ additiveQuadruples Z) : + q.1.1 ∈ Z ∧ q.1.2 ∈ Z ∧ q.2.1 ∈ Z ∧ q.2.2 ∈ Z ∧ + q.1.1 + q.1.2 = q.2.1 + q.2.2 := by + simpa only [additiveQuadruples, mem_filter, mem_product, and_assoc] using hq + +theorem rough_additiveQuadruples_card_le (P Z : Finset ℕ) (A N : ℕ) + (hZ : ∀ z ∈ Z, A ≤ z ∧ z < A + N ∧ avoidsPrimeSet P z) : + (additiveQuadruples Z).card ≤ (roughCubeSamples P (A, A, A) N).card := by + let Q := additiveQuadruples Z + have hq (q : Q) := mem_additiveQuadruples q.property + let off (z : ℕ) (hz : z ∈ Z) : Fin N := ⟨z - A, by have := hZ z hz; omega⟩ + let f : Q → roughCubeSamples P (A, A, A) N := fun q => + ⟨(off q.val.1.1 (hq q).1, off q.val.1.2 (hq q).2.1, + off q.val.2.1 (hq q).2.2.1), by + have h₁ := hZ q.val.1.1 (hq q).1 + have h₂ := hZ q.val.1.2 (hq q).2.1 + have h₃ := hZ q.val.2.1 (hq q).2.2.1 + have h₄ := hZ q.val.2.2 (hq q).2.2.2.1 + simp only [roughCubeSamples, mem_filter, mem_univ, true_and] + change fourFormsAvoidPrimeSet P + (A + (q.val.1.1 - A), A + (q.val.1.2 - A), A + (q.val.2.1 - A)) + rw [Nat.add_sub_of_le h₁.1, Nat.add_sub_of_le h₂.1, Nat.add_sub_of_le h₃.1] + refine ⟨h₁.2.2, h₂.2.2, h₃.2.2, ?_⟩ + intro p hp hd + have he : (q.val.1.1 : ℤ) + q.val.1.2 - q.val.2.1 = q.val.2.2 := by + have := (hq q).2.2.2.2 + omega + rw [he] at hd + exact h₄.2.2 p hp (Int.natCast_dvd_natCast.mp hd)⟩ + have hf : Function.Injective f := by + intro q r he + have he₁ := congrArg (fun t : roughCubeSamples P (A, A, A) N => + ((t : Fin N × Fin N × Fin N).1).val) he + have he₂ := congrArg (fun t : roughCubeSamples P (A, A, A) N => + ((t : Fin N × Fin N × Fin N).2.1).val) he + have he₃ := congrArg (fun t : roughCubeSamples P (A, A, A) N => + ((t : Fin N × Fin N × Fin N).2.2).val) he + change q.val.1.1 - A = r.val.1.1 - A at he₁ + change q.val.1.2 - A = r.val.1.2 - A at he₂ + change q.val.2.1 - A = r.val.2.1 - A at he₃ + have hq₁ := (hZ q.val.1.1 (hq q).1).1 + have hq₂ := (hZ q.val.1.2 (hq q).2.1).1 + have hq₃ := (hZ q.val.2.1 (hq q).2.2.1).1 + have hr₁ := (hZ r.val.1.1 (hq r).1).1 + have hr₂ := (hZ r.val.1.2 (hq r).2.1).1 + have hr₃ := (hZ r.val.2.1 (hq r).2.2.1).1 + have hqe := (hq q).2.2.2.2 + have hre := (hq r).2.2.2.2 + apply Subtype.ext + apply Prod.ext + · apply Prod.ext <;> omega + · apply Prod.ext <;> omega + simpa only [Q, Fintype.card_coe] using Fintype.card_le_of_injective f hf + +/-- The actual rough interval and three-variable sieve probabilities imply +both manuscript Fourier bounds, uniformly over every subset of rough integers. -/ +theorem roughFourier_bounds_of_sieve (P Z : Finset ℕ) (D h : ℕ) [NeZero D] + (hh : 0 < h) (L U V : ℝ) + (hZ : ∀ z ∈ Z, D ≤ z ∧ z < D + D ∧ avoidsPrimeSet P z) + (h₁ : (uniformFiniteLaw (Fin D)).probability + (fun j => avoidsPrimeSet P (D + j.val)) ≤ U * L ^ (-99 / 100 : ℝ)) + (h₄ : (uniformFiniteLaw (Fin D × Fin D × Fin D)).probability + (fun j => fourFormsAvoidPrimeSet P + (D + j.1.val, D + j.2.1.val, D + j.2.2.val)) ≤ V * L ^ (-99 / 25 : ℝ)) : + (∀ θ, ‖roughFourierPolynomial Z h θ‖ ≤ U * L ^ (-99 / 100 : ℝ)) ∧ + (∫ θ, ‖roughFourierPolynomial Z h θ‖ ^ 4 ∂AddCircle.haarAddCircle) ≤ + V / (D : ℝ) * L ^ (-99 / 25 : ℝ) := by + have hD : (0 : ℝ) < D := by exact_mod_cast NeZero.pos D + have hzr (z : ℕ) (hz : z ∈ Z) : (D : ℝ) ≤ z := by exact_mod_cast (hZ z hz).1 + have hc : (Z.card : ℝ) ≤ (D : ℝ) * (U * L ^ (-99 / 100 : ℝ)) := by + calc + _ ≤ ((roughIntervalSamples P D D).card : ℝ) := by + exact_mod_cast rough_subset_card_le P Z D D hZ + _ = _ := roughIntervalSamples_probability P D D + _ ≤ _ := mul_le_mul_of_nonneg_left h₁ hD.le + have hq : ((additiveQuadruples Z).card : ℝ) ≤ + (D : ℝ) ^ 3 * (V * L ^ (-99 / 25 : ℝ)) := by + calc + _ ≤ ((roughCubeSamples P (D, D, D) D).card : ℝ) := by + exact_mod_cast rough_additiveQuadruples_card_le P Z D D hZ + _ = _ := roughCubeSamples_probability P (D, D, D) D + _ ≤ _ := mul_le_mul_of_nonneg_left h₄ (by positivity) + constructor + · intro θ + apply (norm_roughFourierPolynomial_le Z h (D : ℝ) hD hzr θ).trans + exact (div_le_iff₀ hD).mpr (by nlinarith only [hc]) + · calc + _ ≤ ((additiveQuadruples Z).card : ℝ) * ((D : ℝ)⁻¹) ^ 4 := + roughFourierPolynomial_fourth_moment_le Z h hh (D : ℝ) hD hzr + _ ≤ ((D : ℝ) ^ 3 * (V * L ^ (-99 / 25 : ℝ))) * ((D : ℝ)⁻¹) ^ 4 := + mul_le_mul_of_nonneg_right hq (by positivity) + _ = _ := by field_simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughSieveProbability.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughSieveProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b60c9d059986cb607e0a1e267b9498bc587fa18 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RoughSieveProbability.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteRoughSieve +import Mathlib.Data.Nat.Prime.Basic + +namespace OAI + +/-! The finite sieve applied to the actual one- and four-form rough events. +Only the classical reciprocal-prime estimates remain in the quantitative +bounds; all finite local and intersection calculations are proved. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def avoidsPrimeSet (P : Finset ℕ) (n : ℕ) : Prop := ∀ p ∈ P, ¬p ∣ n + +def fourFormsAvoidPrimeSet (P : Finset ℕ) (x : ℕ × ℕ × ℕ) : Prop := + avoidsPrimeSet P x.1 ∧ avoidsPrimeSet P x.2.1 ∧ avoidsPrimeSet P x.2.2 ∧ + ∀ p ∈ P, ¬(p : ℤ) ∣ (x.1 : ℤ) + x.2.1 - x.2.2 + +lemma primeSet_pairwise_coprime (P : Finset ℕ) (hP : ∀ p ∈ P, Nat.Prime p) : + Pairwise (fun p q : P => (p : ℕ).Coprime (q : ℕ)) := by + intro p q hpq + exact (Nat.coprime_primes (hP p p.property) (hP q q.property)).mpr + (fun h => hpq (Subtype.ext h)) + +lemma avoidsPrimeSet_iff_residues (P : Finset ℕ) (n : ℕ) : + avoidsPrimeSet P n ↔ ∀ p : P, (n : ZMod (p : ℕ)) ≠ 0 := by + simp only [avoidsPrimeSet, Subtype.forall, ne_eq, ZMod.natCast_eq_zero_iff] + +lemma fourFormsAvoidPrimeSet_iff_residues (P : Finset ℕ) + [∀ p : P, NeZero (p : ℕ)] (x : ℕ × ℕ × ℕ) : + fourFormsAvoidPrimeSet P x ↔ ∀ p : P, + ¬fourFormBad ((x.1 : ZMod (p : ℕ)), (x.2.1 : ZMod (p : ℕ)), + (x.2.2 : ZMod (p : ℕ))) := by + have hlast (p : P) : + ((x.1 : ZMod (p : ℕ)) + (x.2.1 : ZMod (p : ℕ)) - (x.2.2 : ZMod (p : ℕ)) = 0) ↔ + (p : ℤ) ∣ (x.1 : ℤ) + x.2.1 - x.2.2 := by + simpa only [Int.cast_sub, Int.cast_add, Int.cast_natCast] using + ZMod.intCast_zmod_eq_zero_iff_dvd ((x.1 : ℤ) + x.2.1 - x.2.2) (p : ℕ) + simp only [fourFormsAvoidPrimeSet, avoidsPrimeSet_iff_residues, + fourFormBad, not_or, hlast, forall_and, Subtype.forall] + +theorem rough_interval_probability (P : Finset ℕ) (hP : ∀ p ∈ P, Nat.Prime p) + (A N : ℕ) [NeZero N] (r : ℕ) (L C Y : ℝ) (hL : 1 ≤ L) (hY : 0 ≤ Y) + (hmax : ∀ p ∈ P, (p : ℝ) ≤ Y) + (hlower : (99 / 100 : ℝ) * Real.log L - C ≤ ∑ p ∈ P, 1 / (p : ℝ)) + (hupper : (∑ p ∈ P, 1 / (p : ℝ)) ≤ 5 * Real.log L) + (hr : 220 * Real.log L ≤ (2 * r + 1 : ℕ)) : + (uniformFiniteLaw (Fin N)).probability (fun j => avoidsPrimeSet P (A + j.val)) ≤ + Real.exp C * L ^ (-99 / 100 : ℝ) + L ^ (-100 : ℝ) + + 1 / (N : ℝ) * (2 * r + 1 : ℕ) * ((P.card : ℝ) * Y + 1) ^ (2 * r) := by + let (p : P) : NeZero (p : ℕ) := ⟨(hP p p.property).ne_zero⟩ + have hh := finite_interval_sieve (fun p : P => (p : ℕ)) (primeSet_pairwise_coprime P hP) + A N (fun _ x => x = 0) r Y hY (fun p => hmax p p.property) + have he : avoidsEvents univ (fun p : P => fun j : Fin N => + ((A + j.val : ℕ) : ZMod (p : ℕ)) = 0) = + (fun j => avoidsPrimeSet P (A + j.val)) := by + funext j + simp only [avoidsEvents, mem_univ, forall_true_left, avoidsPrimeSet_iff_residues] + simp only [he, oneFormBadDensity, Fintype.card_coe] at hh + have hsum : (∑ p : P, 1 / (p : ℝ)) ≤ 5 * Real.log L := by + rw [← sum_subtype (p := fun p : ℕ => p ∈ P) P (fun _ => Iff.rfl) + (fun p => 1 / (p : ℝ))] + exact hupper + have ht := elementarySymmetric_log_tail (univ : Finset P) + (fun p => 1 / (p : ℝ)) (fun p _ => by positivity) (2 * r + 1) L hL hsum hr + have hp := oneForm_product_scale P (fun p hp => (hP p hp).two_le) + L C (zero_lt_one.trans_le hL) hlower + rw [prod_subtype (p := fun p : ℕ => p ∈ P) P (fun _ => Iff.rfl)] at hp + exact hh.trans (by gcongr) + +theorem rough_cube_probability (P : Finset ℕ) (hP : ∀ p ∈ P, Nat.Prime p) + (A : ℕ × ℕ × ℕ) (N : ℕ) [NeZero N] (r : ℕ) (L C Y : ℝ) + (hL : 1 ≤ L) (hY : 0 ≤ Y) (hmax : ∀ p ∈ P, (p : ℝ) ≤ Y) + (hlower : (99 / 100 : ℝ) * Real.log L - C ≤ ∑ p ∈ P, 1 / (p : ℝ)) + (hupper : (∑ p ∈ P, 1 / (p : ℝ)) ≤ (5 / 4 : ℝ) * Real.log L) + (hr : 220 * Real.log L ≤ (2 * r + 1 : ℕ)) : + (uniformFiniteLaw (Fin N × Fin N × Fin N)).probability (fun j => + fourFormsAvoidPrimeSet P (A.1 + j.1.val, A.2.1 + j.2.1.val, A.2.2 + j.2.2.val)) ≤ + Real.exp (4 * C + 6) * L ^ (-99 / 25 : ℝ) + L ^ (-100 : ℝ) + + 3 / (N : ℝ) * (2 * r + 1 : ℕ) * ((P.card : ℝ) * Y + 1) ^ (2 * r) := by + let (p : P) : NeZero (p : ℕ) := ⟨(hP p p.property).ne_zero⟩ + have hh := finite_cube_sieve (fun p : P => (p : ℕ)) (primeSet_pairwise_coprime P hP) + A N (fun _ => fourFormBad) r Y hY (fun p => hmax p p.property) + have he : avoidsEvents univ (fun p : P => fun j : Fin N × Fin N × Fin N => + fourFormBad (((A.1 + j.1.val : ℕ) : ZMod (p : ℕ)), + ((A.2.1 + j.2.1.val : ℕ) : ZMod (p : ℕ)), + ((A.2.2 + j.2.2.val : ℕ) : ZMod (p : ℕ)))) = + (fun j => fourFormsAvoidPrimeSet P + (A.1 + j.1.val, A.2.1 + j.2.1.val, A.2.2 + j.2.2.val)) := by + funext j + simp only [avoidsEvents, mem_univ, forall_true_left, fourFormsAvoidPrimeSet_iff_residues] + change _ ≤ (∏ p : P, (1 - fourFormBadDensity (p : ℕ))) + + elementarySymmetric univ (fun p : P => fourFormBadDensity (p : ℕ)) (2 * r + 1) + _ at hh + rw [he] at hh + simp only [Fintype.card_coe] at hh + have hsum : (∑ p : P, fourFormBadDensity (p : ℕ)) ≤ 5 * Real.log L := by + calc + _ ≤ ∑ p : P, 4 / (p : ℝ) := + sum_le_sum (fun p _ => (fourFormBadDensity_bounds (p : ℕ)).2) + _ = 4 * ∑ p ∈ P, 1 / (p : ℝ) := by + rw [← sum_subtype (p := fun p : ℕ => p ∈ P) P (fun _ => Iff.rfl) + (fun p => 4 / (p : ℝ))] + simp only [div_eq_mul_inv, one_mul, ← mul_sum] + _ ≤ _ := by linarith + have ht := elementarySymmetric_log_tail (univ : Finset P) + (fun p => fourFormBadDensity (p : ℕ)) (fun p _ => fourFormBadDensity_nonneg _) + (2 * r + 1) L hL hsum hr + have hp := fourForm_product_scale P (fun p hp => (hP p hp).two_le) + L C (zero_lt_one.trans_le hL) hlower + exact hh.trans (by gcongr) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RunCoverage.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RunCoverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..bcff7362cb746be098a40446d3faa6ec6ae6c4d8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RunCoverage.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CompressedRuns +import OAI.NumberTheory.TwoPoint.Bounds.RunPartitionProperties + +namespace OAI + +/-! Every observed regular class is present in an encoded regular segment. -/ + +namespace TwoPointCorrelations + +variable {α : Type*} [DecidableEq α] + +/-- Greedy compression can suppress only the preceding label; no observed +class disappears from the previous-label/run-head pair. -/ +theorem columnRunHeads_cover (l : List α) (previous : Option α) (a : α) (ha : a ∈ l) : + previous = some a ∨ a ∈ columnRunHeads (l.map some) previous := by + induction l generalizing previous with + | nil => simp at ha + | cons b rest ih => + rcases List.mem_cons.mp ha with rfl | ha + · by_cases hp : previous = some a + · exact Or.inl hp + · exact Or.inr (by simp [columnRunHeads, hp]) + · rcases ih (some b) ha with heq | hm + · have hab : b = a := Option.some.inj heq + subst b + by_cases hp : previous = some a + · exact Or.inl hp + · exact Or.inr (by simp [columnRunHeads, hp]) + · exact Or.inr (by + simp only [List.map_cons, columnRunHeads] + split_ifs <;> simp [hm]) + +theorem mem_columnRunHeads (l : List α) (a : α) (ha : a ∈ l) : + a ∈ columnRunHeads (l.map some) none := by + exact (columnRunHeads_cover l none a ha).resolve_left (by simp) + +omit [DecidableEq α] in +/-- A regular observed run occurs in one of the actual regular pieces, +so the shared forest numbering applies to it. -/ +theorem partitionColumnRuns_regular_cover (omitted : α → Bool) (runs : List α) + (a : α) (ha : a ∈ runs) (hregular : omitted a = false) : + ∃ segment, Sum.inl segment ∈ partitionColumnRuns omitted runs ∧ a ∈ segment := by + have hflat : a ∈ (partitionColumnRuns omitted runs).flatMap (Sum.elim id List.singleton) := by + rwa [partitionColumnRuns_flatten] + obtain ⟨piece, hp, ha⟩ := List.mem_flatMap.mp hflat + cases piece with + | inl segment => exact ⟨segment, hp, ha⟩ + | inr b => + have hab : a = b := List.mem_singleton.mp ha + subst b + have hm : a ∈ (partitionColumnRuns omitted runs).filterMap (Sum.elim (fun _ => none) some) := + List.mem_filterMap.mpr ⟨.inr a, hp, rfl⟩ + rw [partitionColumnRuns_omitted] at hm + have ht := (List.mem_filter.mp hm).2 + simp [hregular] at ht + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RunPartition.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RunPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..e271608b96a47afcc650f26d1ca40eac6263a226 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RunPartition.lean @@ -0,0 +1,107 @@ +import Mathlib.Data.List.Basic +import Mathlib.Tactic + +namespace OAI + +/-! Cutting a compressed perfect block into regular segments and omitted runs. -/ + +namespace TwoPointCorrelations + +variable {α : Type*} + +/-- Omitted labels stand alone; consecutive regular labels form one segment. -/ +def partitionColumnRuns (omitted : α → Bool) : List α → List (List α ⊕ α) + | [] => [] + | a :: rest => + if omitted a then .inr a :: partitionColumnRuns omitted rest + else match partitionColumnRuns omitted rest with + | .inl segment :: tail => .inl (a :: segment) :: tail + | tail => .inl [a] :: tail + +/-- Cutting does not reorder, omit or duplicate any compressed run. -/ +theorem partitionColumnRuns_flatten (omitted : α → Bool) (runs : List α) : + (partitionColumnRuns omitted runs).flatMap (Sum.elim id List.singleton) = runs := by + induction runs with + | nil => rfl + | cons a rest ih => + cases ha : omitted a with + | true => simpa [partitionColumnRuns, ha, List.singleton] using congrArg (List.cons a) ih + | false => + cases ht : partitionColumnRuns omitted rest with + | nil => simpa [partitionColumnRuns, ha, ht] using congrArg (List.cons a) ih + | cons head tail => + cases head <;> simpa [partitionColumnRuns, ha, ht] using congrArg (List.cons a) ih + +/-- The omitted part is exactly the original subsequence of omitted runs. -/ +theorem partitionColumnRuns_omitted (omitted : α → Bool) (runs : List α) : + (partitionColumnRuns omitted runs).filterMap (Sum.elim (fun _ => none) some) = + runs.filter omitted := by + induction runs with + | nil => rfl + | cons a rest ih => + cases ha : omitted a with + | true => simpa [partitionColumnRuns, ha, List.filterMap_cons, Sum.elim] using + congrArg (List.cons a) ih + | false => + cases ht : partitionColumnRuns omitted rest with + | nil => simpa [partitionColumnRuns, ha, ht, List.filterMap_cons, Sum.elim] using ih + | cons head tail => + cases head <;> simpa [partitionColumnRuns, ha, ht, List.filterMap_cons, Sum.elim] using ih + +/-- A merge mask needs no more slots than the compressed run list. -/ +theorem partitionColumnRuns_length_le (omitted : α → Bool) (runs : List α) : + (partitionColumnRuns omitted runs).length ≤ runs.length := by + induction runs with + | nil => simp [partitionColumnRuns] + | cons a rest ih => + cases ha : omitted a with + | true => simpa [partitionColumnRuns, ha] using Nat.succ_le_succ ih + | false => + cases ht : partitionColumnRuns omitted rest with + | nil => simp [partitionColumnRuns, ha, ht] + | cons head tail => + cases head with + | inl segment => + simp only [ht, List.length_cons] at ih + simpa [partitionColumnRuns, ha, ht] using ih.trans (Nat.le_succ _) + | inr label => simpa [partitionColumnRuns, ha, ht] using Nat.succ_le_succ ih + +def regularPieceCount (pieces : List (List α ⊕ α)) : ℕ := + (pieces.filterMap (Sum.elim some (fun _ => none))).length + +def omittedPieceCount (pieces : List (List α ⊕ α)) : ℕ := + (pieces.filterMap (Sum.elim (fun _ => none) some)).length + +def startsWithRegularPiece (pieces : List (List α ⊕ α)) : Bool := + (pieces.head?.map (Sum.elim (fun _ => true) (fun _ => false))).getD false + +/-- Every regular segment except a possible initial one is charged to an +omitted run. The stronger head-sensitive form makes the induction exact. -/ +theorem partitionColumnRuns_count_strong (omitted : α → Bool) (runs : List α) : + regularPieceCount (partitionColumnRuns omitted runs) ≤ + omittedPieceCount (partitionColumnRuns omitted runs) + + if startsWithRegularPiece (partitionColumnRuns omitted runs) then 1 else 0 := by + induction runs with + | nil => simp [partitionColumnRuns, regularPieceCount, omittedPieceCount, startsWithRegularPiece] + | cons a rest ih => + cases ht : partitionColumnRuns omitted rest with + | nil => + cases ha : omitted a <;> + simp [partitionColumnRuns, ha, ht, regularPieceCount, omittedPieceCount, + startsWithRegularPiece, List.filterMap_cons, Sum.elim] + | cons head tail => + cases head <;> cases ha : omitted a <;> + simp [partitionColumnRuns, ha, ht, regularPieceCount, omittedPieceCount, + startsWithRegularPiece, List.filterMap_cons, Sum.elim] at ih ⊢ <;> omega + +theorem partitionColumnRuns_regular_count (omitted : α → Bool) (runs : List α) : + regularPieceCount (partitionColumnRuns omitted runs) ≤ (runs.filter omitted).length + 1 := by + have h := partitionColumnRuns_count_strong omitted runs + have ho : omittedPieceCount (partitionColumnRuns omitted runs) = (runs.filter omitted).length := by + exact congrArg List.length (partitionColumnRuns_omitted omitted runs) + rw [ho] at h + split_ifs at h <;> omega + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RunPartitionProperties.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RunPartitionProperties.lean new file mode 100644 index 0000000000000000000000000000000000000000..1109b2e9ba27a6df6f9a8fd22c290a07190960c4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RunPartitionProperties.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RunPartition +import Mathlib.Data.List.Chain +import Mathlib.Data.List.Infix + +namespace OAI + +/-! The omitted-label cut retains the actual adjacency of every regular segment. -/ + +namespace TwoPointCorrelations + +variable {α β : Type*} + +/-- Every regular piece is a contiguous part of the original run list. -/ +theorem partitionColumnRuns_regular_infix (omitted : α → Bool) (runs segment : List α) + (hsegment : Sum.inl segment ∈ partitionColumnRuns omitted runs) : + segment.IsInfix runs := by + have hm : segment ∈ (partitionColumnRuns omitted runs).map (Sum.elim id List.singleton) := + List.mem_map.mpr ⟨.inl segment, hsegment, rfl⟩ + have hi := List.infix_of_mem_flatten hm + change segment.IsInfix ((partitionColumnRuns omitted runs).flatMap (Sum.elim id List.singleton)) at hi + rwa [partitionColumnRuns_flatten] at hi + +/-- Cutting out omitted runs does not create new adjacent pairs inside a piece. -/ +theorem partitionColumnRuns_regular_chain (R : α → α → Prop) + (omitted : α → Bool) (runs segment : List α) (hchain : runs.IsChain R) + (hsegment : Sum.inl segment ∈ partitionColumnRuns omitted runs) : + segment.IsChain R := + hchain.infix (partitionColumnRuns_regular_infix omitted runs segment hsegment) + +/-- The cut algorithm produces only nonempty regular pieces, all of whose +entries really are regular. -/ +theorem partitionColumnRuns_regular_entries (omitted : α → Bool) (runs : List α) : + ∀ segment, Sum.inl segment ∈ partitionColumnRuns omitted runs → + segment ≠ [] ∧ ∀ a ∈ segment, omitted a = false := by + induction runs with + | nil => simp [partitionColumnRuns] + | cons a rest ih => + intro segment hs + cases ha : omitted a with + | true => + simp only [partitionColumnRuns, ha, ↓reduceIte, + List.mem_cons, Sum.inl_ne_inr, false_or] at hs + exact ih segment hs + | false => + cases ht : partitionColumnRuns omitted rest with + | nil => + simp only [partitionColumnRuns, ha, Bool.false_eq_true, ↓reduceIte, ht, + List.mem_singleton, Sum.inl.injEq] at hs + subst segment + simp [ha] + | cons head tail => + cases head with + | inl old => + have hold := ih old (by rw [ht]; simp) + simp only [partitionColumnRuns, ha, Bool.false_eq_true, ↓reduceIte, ht, + List.mem_cons, Sum.inl.injEq] at hs + rcases hs with rfl | hs + · exact ⟨List.cons_ne_nil _ _, fun b hb => by + rcases List.mem_cons.mp hb with rfl | hb + · exact ha + · exact hold.2 b hb⟩ + · exact ih segment (by rw [ht]; exact List.mem_cons_of_mem _ hs) + | inr b => + simp only [partitionColumnRuns, ha, Bool.false_eq_true, ↓reduceIte, ht, + List.mem_cons, Sum.inl.injEq, Sum.inl_ne_inr, false_or] at hs + rcases hs with rfl | hs + · simp [ha] + · exact ih segment (by rw [ht]; exact List.mem_cons_of_mem _ hs) + +/-- Run positions and their labels may be cut in parallel: the algorithm +uses only the omitted predicate, so forgetting the positions commutes with it. -/ +theorem partitionColumnRuns_map (f : α → β) (omitted : β → Bool) (runs : List α) : + partitionColumnRuns omitted (runs.map f) = + (partitionColumnRuns (fun a => omitted (f a)) runs).map (Sum.map (List.map f) f) := by + induction runs with + | nil => rfl + | cons a rest ih => + cases ha : omitted (f a) with + | true => simpa [partitionColumnRuns, ha] using congrArg (List.cons (.inr (f a))) ih + | false => + cases ht : partitionColumnRuns (fun a => omitted (f a)) rest with + | nil => simp [partitionColumnRuns, ha, ht, ih] + | cons head tail => + cases head <;> simp [partitionColumnRuns, ha, ht, ih, Sum.map] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RunSegments.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RunSegments.lean new file mode 100644 index 0000000000000000000000000000000000000000..92351405a87aa7baa0dee60b1a7b909308169d16 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RunSegments.lean @@ -0,0 +1,121 @@ +import OAI.NumberTheory.TwoPoint.Walks.BlockGeometry + +namespace OAI + +/-! Interval-shaped label uses bound omitted runs and regular segments. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {α : Type*} [DecidableEq α] + +omit [DecidableEq α] in +/-- A sequence obtained by keeping run starts has no repeated label when +every label's original occurrences form an interval. -/ +theorem run_labels_injective {m n : ℕ} (label : Fin n → α) + (hinterval : ∀ i j k : Fin n, i ≤ j → j ≤ k → label i = label k → label j = label i) + (start : Fin m → Fin n) (hstart : StrictMono start) + (hchange : ∀ i j : Fin m, i.val + 1 = j.val → label (start i) ≠ label (start j)) : + Function.Injective (label ∘ start) := by + have hless : ∀ i j : Fin m, i < j → label (start i) ≠ label (start j) := by + intro i j hij heq + let next : Fin m := ⟨i.val + 1, by omega⟩ + have hinext : i ≤ next := by change i.val ≤ i.val + 1; omega + have hnextj : next ≤ j := by change i.val + 1 ≤ j.val; exact hij + have hn := hinterval (start i) (start next) (start j) + (hstart.monotone hinext) (hstart.monotone hnextj) heq + exact hchange i next rfl hn.symm + intro i j heq + rcases lt_trichotomy i j with hij | hij | hji + · exact (hless i j hij heq).elim + · exact hij + · exact (hless j i hji heq.symm).elim + +omit [DecidableEq α] in +theorem fin_label_intervals {n : ℕ} (label : Fin n → α) + (h : OccurrenceIntervals (fun p i => ∃ hi : i < n, label ⟨i, hi⟩ = p) 0 n) : + ∀ i j k : Fin n, i ≤ j → j ≤ k → label i = label k → label j = label i := by + intro i j k hij hjk heq + obtain ⟨_, hj⟩ := h (label i) i j k (Nat.zero_le _) hij hjk k.isLt + ⟨i.isLt, rfl⟩ ⟨k.isLt, heq.symm⟩ + exact hj + +def omittedRunPositions {m : ℕ} (label : Fin m → α) (omitted : Finset α) : Finset (Fin m) := + univ.filter (fun i => label i ∈ omitted) + +/-- One omitted label contributes at most one run in a perfect block. -/ +theorem omitted_runs_le {m : ℕ} (label : Fin m → α) (omitted : Finset α) + (hinj : Function.Injective label) : + (omittedRunPositions label omitted).card ≤ omitted.card := by + apply card_le_card_of_injOn label + · intro i hi + exact (mem_filter.mp hi).2 + · intro i _ j _ hij + exact hinj hij + +/-- A regular segment starts at the first run or immediately after an +omitted run. Empty segments are not counted. -/ +def RegularRunStart {m : ℕ} (label : Fin m → α) (omitted : Finset α) (i : Fin m) : Prop := + label i ∉ omitted ∧ (i.val = 0 ∨ ∃ j : Fin m, j.val + 1 = i.val ∧ label j ∈ omitted) + +noncomputable def regularRunStarts {m : ℕ} (label : Fin m → α) (omitted : Finset α) : + Finset (Fin m) := by + classical + exact univ.filter (RegularRunStart label omitted) + +/-- Charge every noninitial regular segment to its immediately preceding +omitted run. This argument allows any numerical values of the labels. -/ +theorem regular_segments_le {m : ℕ} (label : Fin m → α) (omitted : Finset α) : + (regularRunStarts label omitted).card ≤ (omittedRunPositions label omitted).card + 1 := by + classical + let f : (regularRunStarts label omitted) → Option (omittedRunPositions label omitted) := fun i => + if hi : i.val.val = 0 then none else + some ⟨(mem_filter.mp i.property).2.2.resolve_left hi |>.choose, + mem_filter.mpr ⟨mem_univ _, + ((mem_filter.mp i.property).2.2.resolve_left hi).choose_spec.2⟩⟩ + have hf : Function.Injective f := by + intro i j hij + apply Subtype.ext + apply Fin.ext + by_cases hi : i.val.val = 0 + · by_cases hj : j.val.val = 0 + · exact hi.trans hj.symm + · simp only [f, dite_eq_left hi, dite_eq_right hj] at hij + cases hij + · by_cases hj : j.val.val = 0 + · simp only [f, dite_eq_right hi, dite_eq_left hj] at hij + cases hij + · have hprev := congrArg (fun z : Option (omittedRunPositions label omitted) => + z.map (fun k => k.val.val)) hij + simp only [f, dite_eq_right hi, dite_eq_right hj, Option.map_some, Option.some.injEq] at hprev + have hip := ((mem_filter.mp i.property).2.2.resolve_left hi).choose_spec.1 + have hjp := ((mem_filter.mp j.property).2.2.resolve_left hj).choose_spec.1 + omega + have hc := Fintype.card_le_of_injective f hf + simpa only [Fintype.card_coe, Fintype.card_option] using hc + +theorem regular_segments_le_omitted_labels {m : ℕ} (label : Fin m → α) + (omitted : Finset α) (hinj : Function.Injective label) : + (regularRunStarts label omitted).card ≤ omitted.card + 1 := + (regular_segments_le label omitted).trans (Nat.add_le_add_right (omitted_runs_le label omitted hinj) 1) + +/-- Across `B` perfect blocks these are the exact combinatorial budgets +used in the endpoint and omitted-label parts of the forest code. -/ +theorem block_run_budgets {B : ℕ} (m : Fin B → ℕ) + (label : ∀ b, Fin (m b) → α) (omitted : Finset α) + (hinj : ∀ b, Function.Injective (label b)) : + (∑ b, (omittedRunPositions (label b) omitted).card) ≤ omitted.card * B ∧ + (∑ b, (regularRunStarts (label b) omitted).card) ≤ (omitted.card + 1) * B := by + constructor + · calc + _ ≤ ∑ _b : Fin B, omitted.card := sum_le_sum (fun b _ => omitted_runs_le _ _ (hinj b)) + _ = _ := by simp [mul_comm] + · calc + _ ≤ ∑ _b : Fin B, (omitted.card + 1) := + sum_le_sum (fun b _ => regular_segments_le_omitted_labels _ _ (hinj b)) + _ = _ := by simp [mul_comm] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/RunTransitionPaths.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/RunTransitionPaths.lean new file mode 100644 index 0000000000000000000000000000000000000000..41c6a9dfb16b86550b41149738e606ea28422300 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/RunTransitionPaths.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.TwoPoint.Bounds.QuotientRunPaths + +namespace OAI + +/-! Greedy transitions of an actual constant-run sequence give quotient paths. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {K α ι : Type*} [Field K] [Fintype α] [DecidableEq ι] + +/-- Scan the remaining positions, recording precisely the starts of new runs. -/ +def scanRunTransitions (runLabel : ℕ → ι) : ℕ → ℕ → ι → List (ℕ × ι) + | _, 0, _ => [] + | n, len + 1, previous => + if runLabel n = previous then scanRunTransitions runLabel (n + 1) len previous + else (n, runLabel n) :: scanRunTransitions runLabel (n + 1) len (runLabel n) + +/-- Local constant-run geometry suffices for the actual greedy transition list; +no path, run boundaries, or scalar sums are supplied as encoding data. -/ +theorem scanRunTransitions_data (D : Submodule K (α → K)) + (anchor : ι → (α → K) ⧸ D) (regularLabel : ι → α) + (label : ℕ → α) (coefficient : ℕ → K) (runLabel : ℕ → ι) + (start finish : ℕ) + (hlabel : ∀ t ∈ Ico start finish, label t = regularLabel (runLabel t)) + (hline : ∀ t ∈ Ico start finish, + ∃ c : K, D.mkQ (formalDeparture label coefficient t) = anchor (runLabel t) + + c • D.mkQ (Pi.basisFun K α (regularLabel (runLabel t)))) + (hnonzero : ∀ a b i, start ≤ a → a < b → b ≤ finish → + (∀ t ∈ Ico a b, label t = regularLabel i) → (∑ t ∈ Ico a b, coefficient t) ≠ 0) + (a n len : ℕ) (i : ι) (hsa : start ≤ a) (han : a < n) (hend : n + len ≤ finish) + (hcurrent : runLabel a = i) + (hconst : ∀ t ∈ Ico a n, label t = regularLabel i) : + QuotientRunData D anchor regularLabel label coefficient a i + (scanRunTransitions runLabel n len i) := by + induction len generalizing a n i with + | zero => trivial + | succ len ih => + have hn : n ∈ Ico start finish := mem_Ico.mpr ⟨by omega, by omega⟩ + by_cases heq : runLabel n = i + · rw [scanRunTransitions, ite_eq_left heq] + apply ih a (n + 1) i hsa (by omega) (by omega) hcurrent + intro t ht + rcases mem_Ico.mp ht with ⟨hat, htn⟩ + by_cases htn' : t < n + · exact hconst t (mem_Ico.mpr ⟨hat, htn'⟩) + · have hteq : t = n := by omega + subst t + simpa only [heq] using hlabel n hn + · rw [scanRunTransitions, ite_eq_right heq] + refine ⟨han.le, hconst, hnonzero a n i hsa han (by omega) hconst, + Ne.symm heq, hline n hn, ?_⟩ + apply ih n (n + 1) (runLabel n) (by omega) (by omega) (by omega) rfl + intro t ht + have hteq : t = n := by have := mem_Ico.mp ht; omega + subst t + exact hlabel n hn + +/-- Begin immediately after the first position of a nonempty regular segment. -/ +theorem regular_segment_run_data (D : Submodule K (α → K)) + (anchor : ι → (α → K) ⧸ D) (regularLabel : ι → α) + (label : ℕ → α) (coefficient : ℕ → K) (runLabel : ℕ → ι) + (start len : ℕ) (hlen : 0 < len) + (hlabel : ∀ t ∈ Ico start (start + len), label t = regularLabel (runLabel t)) + (hline : ∀ t ∈ Ico start (start + len), + ∃ c : K, D.mkQ (formalDeparture label coefficient t) = anchor (runLabel t) + + c • D.mkQ (Pi.basisFun K α (regularLabel (runLabel t)))) + (hnonzero : ∀ a b i, start ≤ a → a < b → b ≤ start + len → + (∀ t ∈ Ico a b, label t = regularLabel i) → (∑ t ∈ Ico a b, coefficient t) ≠ 0) : + QuotientRunData D anchor regularLabel label coefficient start (runLabel start) + (scanRunTransitions runLabel (start + 1) (len - 1) (runLabel start)) := by + apply scanRunTransitions_data D anchor regularLabel label coefficient runLabel start + (start + len) hlabel hline hnonzero start (start + 1) (len - 1) (runLabel start) + le_rfl (by omega) (by omega) rfl + intro t ht + have hteq : t = start := by have := mem_Ico.mp ht; omega + subst t + exact hlabel start (mem_Ico.mpr ⟨le_rfl, by omega⟩) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SampleDensity.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SampleDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..1efc9b2a02e6471fd449d87cc98fa650cc62b5d6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SampleDensity.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteAverages +import OAI.NumberTheory.TwoPoint.Circuits.FourierCorrection + +namespace OAI + +/-! Exact densities on the Boolean cube induced by a finite sampling map. -/ + +namespace TwoPointCorrelations + +open Finset + +/-- Density relative to uniform measure of a finite uniformly sampled map. -/ +noncomputable def sampleDensity {α : Type*} [Fintype α] {n : ℕ} + (sample : α → BooleanCube n) (x : BooleanCube n) : ℝ := + (Fintype.card (BooleanCube n) : ℝ) / Fintype.card α * + ∑ a, if sample a = x then 1 else 0 + +lemma sampleDensity_nonneg {α : Type*} [Fintype α] {n : ℕ} + (sample : α → BooleanCube n) (x : BooleanCube n) : 0 ≤ sampleDensity sample x := by + unfold sampleDensity + positivity + +/-- Expectations against the induced density are exactly empirical averages. -/ +lemma sampleDensity_expectation {α : Type*} [Fintype α] [Nonempty α] {n : ℕ} + (sample : α → BooleanCube n) (F : BooleanCube n → ℝ) : + cubeAverage (fun x => sampleDensity sample x * F x) = + uniformAverage (fun a => F (sample a)) := by + have hα : (Fintype.card α : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + have hcube : (Fintype.card (BooleanCube n) : ℝ) ≠ 0 := by + exact_mod_cast Fintype.card_ne_zero + have hsum : (∑ x : BooleanCube n, + (∑ a, if sample a = x then (1 : ℝ) else 0) * F x) = ∑ a, F (sample a) := by + simp_rw [Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a _ + simp + unfold cubeAverage sampleDensity uniformAverage + calc + _ = ((Fintype.card (BooleanCube n) : ℝ) / Fintype.card α * + (∑ x : BooleanCube n, (∑ a, if sample a = x then (1 : ℝ) else 0) * F x)) / + Fintype.card (BooleanCube n) := by + congr 1 + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + ring + _ = _ := by rw [hsum]; field_simp + +lemma sampleDensity_mean {α : Type*} [Fintype α] [Nonempty α] {n : ℕ} + (sample : α → BooleanCube n) : cubeAverage (sampleDensity sample) = 1 := by + simpa using sampleDensity_expectation sample (fun _ => 1) + +lemma sampleDensity_walshCoefficient {α : Type*} [Fintype α] [Nonempty α] {n : ℕ} + (sample : α → BooleanCube n) (S : Finset (Fin n)) : + walshCoefficient (sampleDensity sample) S = uniformAverage (fun a => walsh S (sample a)) := + sampleDensity_expectation sample (walsh S) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ScalarComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ScalarComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..90f057f4448233988942aeb35cd40a526e07ac61 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ScalarComparison.lean @@ -0,0 +1,45 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DecoderComparison + +namespace OAI + +/-! Signed scalar expansions preserve their coefficients through comparison. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma uniformAverage_mul_const {α : Type*} [Fintype α] (c : ℝ) (f : α → ℝ) : + uniformAverage (fun x => c * f x) = c * uniformAverage f := by + unfold uniformAverage + rw [← Finset.mul_sum] + ring + +/-- Each event is compared before absolute values are taken. The total error +is weighted by the absolute values of the original signed coefficients. -/ +theorem scalar_average_comparison {α β ι : Type*} + [Fintype α] [Fintype β] [Fintype ι] + (f : ι → α → ℝ) (g : ι → β → ℝ) (c error : ι → ℝ) + (h : ∀ i, |uniformAverage (f i) - uniformAverage (g i)| ≤ error i) : + |uniformAverage (fun x => ∑ i, c i * f i x) - + uniformAverage (fun y => ∑ i, c i * g i y)| ≤ ∑ i, |c i| * error i := by + simp_rw [uniformAverage_sum, uniformAverage_mul_const] + rw [← Finset.sum_sub_distrib] + calc + _ ≤ ∑ i, |c i * uniformAverage (f i) - c i * uniformAverage (g i)| := + Finset.abs_sum_le_sum_abs _ _ + _ = ∑ i, |c i| * |uniformAverage (f i) - uniformAverage (g i)| := by + simp_rw [← mul_sub, abs_mul] + _ ≤ _ := Finset.sum_le_sum (fun i _ => mul_le_mul_of_nonneg_left (h i) (abs_nonneg _)) + +/-- Uniform event error times total absolute coefficient mass. -/ +theorem scalar_average_comparison_uniform {α β ι : Type*} + [Fintype α] [Fintype β] [Fintype ι] + (f : ι → α → ℝ) (g : ι → β → ℝ) (c : ι → ℝ) (error : ℝ) + (h : ∀ i, |uniformAverage (f i) - uniformAverage (g i)| ≤ error) : + |uniformAverage (fun x => ∑ i, c i * f i x) - + uniformAverage (fun y => ∑ i, c i * g i y)| ≤ (∑ i, |c i|) * error := by + simpa only [Finset.sum_mul] using scalar_average_comparison f g c (fun _ => error) h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SelfAdjointPath.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SelfAdjointPath.lean new file mode 100644 index 0000000000000000000000000000000000000000..1cd9a0a0276d44b90bb6b277047ae0fe4bb6e7b0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SelfAdjointPath.lean @@ -0,0 +1,109 @@ +import Mathlib.Analysis.InnerProductSpace.Rayleigh +import Mathlib.Topology.Order.IntermediateValue + +namespace OAI + +/-! +# Positivity along an invertible self-adjoint path + +The resolvent path in manuscript Lemma `q:noncommuting` starts at the +identity and is self-adjoint and invertible throughout a real interval. +Its positivity follows from continuity of the least Rayleigh quotient. +The argument is carried out in finite dimension. +-/ + +open Filter + +namespace TwoPointCorrelations + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℂ E] [Nontrivial E] + +noncomputable def leastRayleigh (T : E →L[ℂ] E) : ℝ := + ⨅ x : {x : E // x ≠ 0}, T.rayleighQuotient x + +omit [Nontrivial E] in +lemma rayleigh_bddBelow (T : E →L[ℂ] E) : + BddBelow (Set.range fun x : {x : E // x ≠ 0} => T.rayleighQuotient x) := by + refine ⟨-‖T‖, ?_⟩ + rintro y ⟨x, rfl⟩ + exact (abs_le.mp (T.rayleighQuotient_le_norm x)).1 + +omit [Nontrivial E] in +lemma leastRayleigh_le (T : E →L[ℂ] E) (x : E) (hx : x ≠ 0) : + leastRayleigh T ≤ T.rayleighQuotient x := + ciInf_le (rayleigh_bddBelow T) ⟨x, hx⟩ + +lemma leastRayleigh_le_add_norm (T S : E →L[ℂ] E) : + leastRayleigh T ≤ leastRayleigh S + ‖T - S‖ := by + let : Nonempty {x : E // x ≠ 0} := ⟨⟨Classical.choose (exists_ne (0 : E)), + Classical.choose_spec (exists_ne (0 : E))⟩⟩ + have hpoint (x : {x : E // x ≠ 0}) : + leastRayleigh T - ‖T - S‖ ≤ S.rayleighQuotient x := by + have ht := leastRayleigh_le T x x.property + have hb := (abs_le.mp ((T - S).rayleighQuotient_le_norm x)).2 + have heq : (T - S).rayleighQuotient x = + T.rayleighQuotient x - S.rayleighQuotient x := by + simp [sub_eq_add_neg, ContinuousLinearMap.rayleighQuotient_add] + rw [heq] at hb + linarith + have hi : leastRayleigh T - ‖T - S‖ ≤ leastRayleigh S := le_ciInf hpoint + linarith + +lemma leastRayleigh_lipschitz : LipschitzWith 1 (leastRayleigh (E := E)) := by + apply LipschitzWith.of_dist_le_mul + intro T S + have hTS := leastRayleigh_le_add_norm T S + have hST := leastRayleigh_le_add_norm S T + rw [norm_sub_rev S T] at hST + simp only [NNReal.coe_one, one_mul, dist_eq_norm] + exact abs_le.mpr ⟨by linarith, by linarith⟩ + +@[simp] lemma leastRayleigh_id : leastRayleigh (ContinuousLinearMap.id ℂ E) = 1 := by + let : Nonempty {x : E // x ≠ 0} := ⟨⟨Classical.choose (exists_ne (0 : E)), + Classical.choose_spec (exists_ne (0 : E))⟩⟩ + have hpoint (x : {x : E // x ≠ 0}) : + (ContinuousLinearMap.id ℂ E).rayleighQuotient x = 1 := by + have hn : ‖(x : E)‖ ^ 2 ≠ 0 := pow_ne_zero _ (norm_ne_zero_iff.mpr x.property) + simp only [ContinuousLinearMap.rayleighQuotient, + ContinuousLinearMap.reApplyInnerSelf_apply, ContinuousLinearMap.id_apply, + inner_self_eq_norm_sq_to_K] + norm_cast + exact div_self hn + simp [leastRayleigh, hpoint] + +lemma leastRayleigh_ne_zero [FiniteDimensional ℂ E] (T : E →L[ℂ] E) + (hself : T.IsSymmetric) (hinj : Function.Injective T) : leastRayleigh T ≠ 0 := by + intro hz + have heig := hself.hasEigenvalue_iInf_of_finiteDimensional + change Module.End.HasEigenvalue (T : E →ₗ[ℂ] E) (leastRayleigh T : ℂ) at heig + rw [hz, Complex.ofReal_zero] at heig + obtain ⟨x, hx, hxne⟩ := heig.exists_hasEigenvector + rw [Module.End.mem_eigenspace_iff] at hx + have hzero : T x = T 0 := by simpa using hx + exact hxne (hinj hzero) + +/-- A finite-dimensional continuous self-adjoint path that starts at the +identity and remains injective has strictly positive quadratic form. -/ +theorem selfAdjoint_path_positive [FiniteDimensional ℂ E] + (F : ℝ → E →L[ℂ] E) (a b : ℝ) (hab : a ≤ b) + (hcont : ContinuousOn F (Set.Icc a b)) (hstart : F a = ContinuousLinearMap.id ℂ E) + (hself : ∀ t ∈ Set.Icc a b, (F t).IsSymmetric) + (hinj : ∀ t ∈ Set.Icc a b, Function.Injective (F t)) : + ∀ x : E, x ≠ 0 → 0 < (inner ℂ (F b x) x).re := by + have hc : ContinuousOn (fun t => leastRayleigh (F t)) (Set.Icc a b) := + leastRayleigh_lipschitz.continuous.comp_continuousOn hcont + have hstart' : leastRayleigh (F a) = 1 := by rw [hstart, leastRayleigh_id] + have hend : 0 < leastRayleigh (F b) := by + by_contra! hn + obtain ⟨t, ht, heq⟩ := intermediate_value_Icc' hab hc + (show (0 : ℝ) ∈ Set.Icc (leastRayleigh (F b)) (leastRayleigh (F a)) by + exact ⟨hn, by rw [hstart']; norm_num⟩) + exact leastRayleigh_ne_zero (F t) (hself t ht) (hinj t ht) heq + intro x hx + have hr : 0 < (F b).rayleighQuotient x := hend.trans_le (leastRayleigh_le (F b) x hx) + have hn : 0 < ‖x‖ ^ 2 := sq_pos_of_pos (norm_pos_iff.mpr hx) + exact (div_pos_iff_of_pos_right hn).mp hr + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftMatrixTranslation.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftMatrixTranslation.lean new file mode 100644 index 0000000000000000000000000000000000000000..b80ca354795c5c0ff12e17e82294a30ef49f10f6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftMatrixTranslation.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShiftedIntegerPaths + +namespace OAI + +/-! Translate the physical block coordinates without changing its +matrix. Arithmetic weights and the numerical gate use the same origin. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem physicalShiftMatrix_translate {D V : Type*} + [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] + (embed : V → D × ℤ) (Q : Finset ℕ) (tuple : D → ℕ) (h : ℕ) + (gate : D → ℤ → ℤ → Prop) (weight : SignedStep → ℤ → ℝ) (c : ℤ) : + shiftMatrix embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate (fun t n => weight t (n + c))) = + shiftMatrix (fun i => ((embed i).1, (embed i).2 + c)) (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h (fun d n m => gate d (n - c) (m - c)) weight) := by + ext i j + apply sum_congr rfl + intro e _ + have he : integerShiftNext Q tuple h e ((embed i).1, (embed i).2 + c) = + ((embed j).1, (embed j).2 + c) ↔ + integerShiftNext Q tuple h e (embed i) = embed j := by + rw [Prod.ext_iff, Prod.ext_iff] + change (e.1 = (embed j).1 ∧ (embed i).2 + c + + (SignedStep.mk e.2.2 (tuple e.1) e.2.1).displacement h = (embed j).2 + c) ↔ + (e.1 = (embed j).1 ∧ (embed i).2 + + (SignedStep.mk e.2.2 (tuple e.1) e.2.1).displacement h = (embed j).2) + constructor <;> rintro ⟨hd, hz⟩ <;> refine ⟨hd, ?_⟩ <;> omega + have hw : physicalShiftWeight Q tuple h (fun d n m => gate d (n - c) (m - c)) weight + e ((embed i).1, (embed i).2 + c) = + physicalShiftWeight Q tuple h gate (fun t n => weight t (n + c)) e (embed i) := by + have hs : (embed i).2 + c + + (SignedStep.mk e.2.2 (tuple e.1) e.2.1).displacement h - c = + (embed i).2 + (SignedStep.mk e.2.2 (tuple e.1) e.2.1).displacement h := by omega + have hc : ((embed i).1 ≠ e.1 ∧ + gate e.1 (((embed i).2 + c) - c) + ((integerShiftNext Q tuple h e ((embed i).1, (embed i).2 + c)).2 - c)) ↔ + ((embed i).1 ≠ e.1 ∧ + gate e.1 (embed i).2 (integerShiftNext Q tuple h e (embed i)).2) := by + simp only [integerShiftNext, add_sub_cancel_right, hs] + by_cases hg : (embed i).1 ≠ e.1 ∧ + gate e.1 (embed i).2 (integerShiftNext Q tuple h e (embed i)).2 + · simp only [physicalShiftWeight, ite_eq_left hg, ite_eq_left (hc.mpr hg)] + · simp only [physicalShiftWeight, ite_eq_right hg, ite_eq_right (mt hc.mp hg)] + simp only [he, hw] + by_cases hc : integerShiftNext Q tuple h e (embed i) = embed j + · simp only [ite_eq_left hc] + · simp only [ite_eq_right hc] + +theorem physicalBlockMatrix_eq_integer {D V : Type*} + [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] + (site : V → ℤ) (Q : Finset ℕ) (tuple : D → ℕ) (h : ℕ) + (gate : D → ℤ → ℤ → Prop) (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) + (g : ℤ → ℝ) (center : ℕ → ℤ → ℝ) (L K : ℝ) + (extra : ℕ → ℤ → Prop) (keep : ℤ → Prop) (c : ℤ) : + shiftMatrix (fun x : D × V => (x.1, site x.2)) (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate (fun t n => + maskedSignedIntegerWeight Q u eligible g center L K extra h keep t (n + c))) = + blockNonbacktrackingMatrix (fun d i j => + if gate d (site i) (site j) ∧ keep (site i + c) ∧ keep (site j + c) then + integerEdgeMatrix (fun i => site i + c) Q u (eligible (tuple d)) g (center (tuple d)) + L K (extra (tuple d)) h (tuple d) i j else 0) := by + rw [physicalShiftMatrix_translate, physicalShiftWeight_masked_eq_integer] + have hb := block_integer_matrix_eq_shift (fun i => site i + c) Q tuple u + (fun d => eligible (tuple d)) g (fun d => center (tuple d)) L K + (fun d => extra (tuple d)) h (integerVertexGate (fun d n m => gate d (n - c) (m - c)) keep) + apply hb.symm.trans + congr 1 + funext d i j + simp only [integerVertexGate, add_sub_cancel_right] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftMatrixWords.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftMatrixWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..95c9569601bb6aa17c7a416b2489feebe7514891 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftMatrixWords.lean @@ -0,0 +1,201 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MatrixClosedWords + +namespace OAI + +/-! Expand finite shift matrices using step labels, without enumerating intermediate sites. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {V E S : Type*} [Fintype V] [DecidableEq V] [Fintype E] + +noncomputable def shiftMatrix (embed : V → S) (next : E → S → S) + (weight : E → S → ℝ) : Matrix V V ℝ := by + classical + exact fun i j => ∑ e, if next e (embed i) = embed j then weight e (embed i) else 0 + +noncomputable def retainedShiftWeight (embed : V → S) (next : E → S → S) + (weight : E → S → ℝ) (e : E) (x : S) : ℝ := by + classical + exact if next e x ∈ Set.range embed then weight e x else 0 + +omit [DecidableEq V] [Fintype E] in +lemma retainedShiftWeight_nonzero (embed : V → S) (next : E → S → S) + (weight : E → S → ℝ) (e : E) (x : S) + (hw : retainedShiftWeight embed next weight e x ≠ 0) : + next e x ∈ Set.range embed ∧ weight e x ≠ 0 := by + classical + unfold retainedShiftWeight at hw + split_ifs at hw with he + · exact ⟨he, hw⟩ + · contradiction + +def shiftWordEnd (next : E → S → S) : {k : ℕ} → S → (Fin k → E) → S + | 0, x, _ => x + | _k + 1, x, w => shiftWordEnd next (next (w 0) x) (Fin.tail w) + +noncomputable def shiftWordWeight (embed : V → S) (next : E → S → S) + (weight : E → S → ℝ) : {k : ℕ} → S → (Fin k → E) → ℝ + | 0, _, _ => 1 + | _k + 1, x, w => retainedShiftWeight embed next weight (w 0) x * + shiftWordWeight embed next weight (next (w 0) x) (Fin.tail w) + +noncomputable def shiftWordTerm (embed : V → S) (next : E → S → S) + (weight : E → S → ℝ) {k : ℕ} (x y : S) (w : Fin k → E) : ℝ := by + classical + exact if shiftWordEnd next x w = y then shiftWordWeight embed next weight x w else 0 + +omit [DecidableEq V] [Fintype E] in +lemma sum_at_injective_site (embed : V → S) (hinj : Function.Injective embed) + (z : S) (f : S → ℝ) : + (∑ j, if z = embed j then f (embed j) else 0) = + if z ∈ Set.range embed then f z else 0 := by + classical + by_cases hz : z ∈ Set.range embed + · obtain ⟨j, rfl⟩ := hz + have he (i : V) : embed j = embed i ↔ j = i := hinj.eq_iff + simp [he] + · have he (j : V) : z ≠ embed j := fun h => hz ⟨j, h.symm⟩ + simp [he, hz] + +omit [DecidableEq V] in +lemma shiftMatrix_action (embed : V → S) (hinj : Function.Injective embed) + (next : E → S → S) (weight : E → S → ℝ) (i : V) (f : S → ℝ) : + (∑ j, shiftMatrix embed next weight i j * f (embed j)) = + ∑ e, retainedShiftWeight embed next weight e (embed i) * f (next e (embed i)) := by + classical + simp only [shiftMatrix, sum_mul] + rw [sum_comm] + apply sum_congr rfl + intro e _ + have he (j : V) : + (if next e (embed i) = embed j then weight e (embed i) else 0) * f (embed j) = + if next e (embed i) = embed j then weight e (embed i) * f (embed j) else 0 := by + split_ifs <;> simp + simp_rw [he] + rw [sum_at_injective_site embed hinj (next e (embed i)) + (fun z => weight e (embed i) * f z)] + unfold retainedShiftWeight + split_ifs <;> simp + +omit [DecidableEq V] [Fintype E] in +lemma shiftWordTerm_cons (embed : V → S) (next : E → S → S) + (weight : E → S → ℝ) {k : ℕ} (x y : S) (e : E) (w : Fin k → E) : + shiftWordTerm embed next weight x y (Fin.cons e w) = + retainedShiftWeight embed next weight e x * + shiftWordTerm embed next weight (next e x) y w := by + classical + simp only [shiftWordTerm, shiftWordEnd, shiftWordWeight, Fin.cons_zero, Fin.tail_cons] + split_ifs <;> simp + +/-- Only the initial site and the step labels are summed. Intermediate sites +are forced by the integer shifts and killed when they leave the finite domain. -/ +theorem shiftMatrix_pow_words (embed : V → S) (hinj : Function.Injective embed) + (next : E → S → S) (weight : E → S → ℝ) (k : ℕ) (i j : V) : + (shiftMatrix embed next weight ^ k) i j = + ∑ w : Fin k → E, shiftWordTerm embed next weight (embed i) (embed j) w := by + classical + induction k generalizing i with + | zero => + simp only [pow_zero, Matrix.one_apply, shiftWordTerm, shiftWordEnd, shiftWordWeight, + hinj.eq_iff, Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_fin, + pow_zero, one_smul] + | succ k ih => + rw [pow_succ', Matrix.mul_apply] + simp_rw [ih] + rw [shiftMatrix_action embed hinj next weight i + (fun x => ∑ w : Fin k → E, shiftWordTerm embed next weight x (embed j) w)] + rw [sum_fin_cons] + simp_rw [mul_sum, shiftWordTerm_cons] + +theorem shiftMatrix_power_closed_words (embed : V → S) (hinj : Function.Injective embed) + (next : E → S → S) (weight : E → S → ℝ) (k : ℕ) : + matrixFrobeniusSq (shiftMatrix embed next weight ^ k) = + ∑ i, ∑ j, ∑ u : Fin k → E, ∑ v : Fin k → E, + shiftWordTerm embed next weight (embed i) (embed j) u * + shiftWordTerm embed next weight (embed i) (embed j) v := by + unfold matrixFrobeniusSq + apply sum_congr rfl + intro i _ + apply sum_congr rfl + intro j _ + rw [shiftMatrix_pow_words embed hinj, pow_two, sum_mul] + simp_rw [mul_sum] + +omit [DecidableEq V] [Fintype E] in +lemma shiftWordWeight_support (embed : V → S) (next : E → S → S) + (weight : E → S → ℝ) {k : ℕ} (x : S) (w : Fin k → E) + (hx : x ∈ Set.range embed) (hw : shiftWordWeight embed next weight x w ≠ 0) : + shiftWordEnd next x w ∈ Set.range embed := by + classical + induction k generalizing x with + | zero => exact hx + | succ k ih => + have hp := mul_ne_zero_iff.mp hw + have hn : next (w 0) x ∈ Set.range embed := by + by_contra hn + exact hp.1 (by simp [retainedShiftWeight, hn]) + exact ih (next (w 0) x) (Fin.tail w) hn hp.2 + +omit [DecidableEq V] [Fintype E] in +/-- The common endpoint is forced by the first word, and hence contributes +no additional factor equal to the number of sites. -/ +lemma sum_shiftWordTerm_pair (embed : V → S) (hinj : Function.Injective embed) + (next : E → S → S) (weight : E → S → ℝ) {k : ℕ} (i : V) + (u v : Fin k → E) : + (∑ j, shiftWordTerm embed next weight (embed i) (embed j) u * + shiftWordTerm embed next weight (embed i) (embed j) v) = + if shiftWordEnd next (embed i) u = shiftWordEnd next (embed i) v then + shiftWordWeight embed next weight (embed i) u * + shiftWordWeight embed next weight (embed i) v else 0 := by + classical + by_cases he : shiftWordEnd next (embed i) u = shiftWordEnd next (embed i) v + · have ht (j : V) : shiftWordTerm embed next weight (embed i) (embed j) u * + shiftWordTerm embed next weight (embed i) (embed j) v = + if shiftWordEnd next (embed i) u = embed j then + shiftWordWeight embed next weight (embed i) u * + shiftWordWeight embed next weight (embed i) v else 0 := by + simp only [shiftWordTerm, ← he] + split_ifs <;> simp + simp_rw [ht] + rw [sum_at_injective_site embed hinj _ (fun _ => + shiftWordWeight embed next weight (embed i) u * + shiftWordWeight embed next weight (embed i) v)] + by_cases hm : shiftWordEnd next (embed i) u ∈ Set.range embed + · rw [ite_eq_left hm, ite_eq_left he] + · have hz : shiftWordWeight embed next weight (embed i) u = 0 := by + by_contra hz + exact hm (shiftWordWeight_support embed next weight (embed i) u ⟨i, rfl⟩ hz) + rw [ite_eq_right hm, ite_eq_left he, hz, zero_mul] + · have ht (j : V) : shiftWordTerm embed next weight (embed i) (embed j) u * + shiftWordTerm embed next weight (embed i) (embed j) v = 0 := by + unfold shiftWordTerm + split_ifs with hu hv + · exact (he (hu.trans hv.symm)).elim + all_goals simp + simp [ht, he] + +theorem shiftMatrix_moment_forced_words (embed : V → S) (hinj : Function.Injective embed) + (next : E → S → S) (weight : E → S → ℝ) (k : ℕ) : + matrixFrobeniusSq (shiftMatrix embed next weight ^ k) = + ∑ i, ∑ u : Fin k → E, ∑ v : Fin k → E, + if shiftWordEnd next (embed i) u = shiftWordEnd next (embed i) v then + shiftWordWeight embed next weight (embed i) u * + shiftWordWeight embed next weight (embed i) v else 0 := by + classical + rw [shiftMatrix_power_closed_words embed hinj] + apply sum_congr rfl + intro i _ + rw [sum_comm] + apply sum_congr rfl + intro u _ + rw [sum_comm] + apply sum_congr rfl + intro v _ + exact sum_shiftWordTerm_pair embed hinj next weight i u v + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftTraceComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftTraceComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..3db409082d167ef45ca331ac8b41721f16e51cac --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftTraceComparison.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShiftMatrixWords + +namespace OAI + +/-! Signed expectation and comparison of the forced-word trace expansion. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {V E S Ω Ω' : Type*} [Fintype V] [DecidableEq V] [Fintype E] + [Fintype Ω] [Fintype Ω'] + +noncomputable def shiftClosedWeight (embed : V → S) (next : E → S → S) + (weight : E → S → ℝ) (k : ℕ) (i : V) (u v : Fin k → E) : ℝ := by + classical + exact if shiftWordEnd next (embed i) u = shiftWordEnd next (embed i) v then + shiftWordWeight embed next weight (embed i) u * + shiftWordWeight embed next weight (embed i) v else 0 + +theorem average_shiftMatrix_moment (embed : V → S) (hinj : Function.Injective embed) + (next : E → S → S) (weight : Ω → E → S → ℝ) (μ : FiniteLaw Ω) (k : ℕ) : + μ.average (fun ω => matrixFrobeniusSq (shiftMatrix embed next (weight ω) ^ k)) = + ∑ i, ∑ u : Fin k → E, ∑ v : Fin k → E, + μ.average (fun ω => shiftClosedWeight embed next (weight ω) k i u v) := by + simp only [shiftMatrix_moment_forced_words embed hinj, shiftClosedWeight, + FiniteLaw.average, mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro i _ + rw [sum_comm] + apply sum_congr rfl + intro u _ + rw [sum_comm] + +/-- The signed expectations are compared before taking absolute values. +There is one initial-site factor, and no intermediate-site factor. -/ +theorem shiftMatrix_moment_comparison (embed : V → S) (hinj : Function.Injective embed) + (next : E → S → S) (weight : Ω → E → S → ℝ) (weight' : Ω' → E → S → ℝ) + (μ : FiniteLaw Ω) (ν : FiniteLaw Ω') (k : ℕ) (ε : ℝ) + (hcompare : ∀ i u v, + |μ.average (fun ω => shiftClosedWeight embed next (weight ω) k i u v) - + ν.average (fun ω => shiftClosedWeight embed next (weight' ω) k i u v)| ≤ ε) : + |μ.average (fun ω => matrixFrobeniusSq (shiftMatrix embed next (weight ω) ^ k)) - + ν.average (fun ω => matrixFrobeniusSq (shiftMatrix embed next (weight' ω) ^ k))| ≤ + (Fintype.card V : ℝ) * (Fintype.card E : ℝ) ^ (2 * k) * ε := by + classical + rw [average_shiftMatrix_moment embed hinj, average_shiftMatrix_moment embed hinj, + ← sum_sub_distrib] + simp_rw [← sum_sub_distrib] + calc + _ ≤ ∑ i, ∑ u : Fin k → E, ∑ v : Fin k → E, + |μ.average (fun ω => shiftClosedWeight embed next (weight ω) k i u v) - + ν.average (fun ω => shiftClosedWeight embed next (weight' ω) k i u v)| := by + apply (abs_sum_le_sum_abs _ _).trans + apply sum_le_sum + intro i _ + apply (abs_sum_le_sum_abs _ _).trans + apply sum_le_sum + intro u _ + exact abs_sum_le_sum_abs _ _ + _ ≤ ∑ _i : V, ∑ _u : Fin k → E, ∑ _v : Fin k → E, ε := + sum_le_sum (fun i _ => sum_le_sum (fun u _ => sum_le_sum (fun v _ => hcompare i u v))) + _ = _ := by + simp only [sum_const, card_univ, nsmul_eq_mul, Fintype.card_fun, Fintype.card_fin, + Nat.cast_pow] + rw [show 2 * k = k + k by omega, pow_add] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftTransfer.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..16a05d5ad5d51eacb720cd5044f11a292c78c7d7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftTransfer.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.TwoPoint.Bounds.AffineTransfer +import OAI.NumberTheory.TwoPoint.Statements + +namespace OAI + +/-! +# Transfer from a positive gap to two arbitrary shifts + +Cancellation for a positive gap gives cancellation for any two +distinct nonnegative shifts. +-/ + +open Filter + +namespace TwoPointCorrelations + +def UnshiftedCorrectedElliott : Prop := + ∀ f g : ℕ → ℂ, Multiplicative f → Multiplicative g → + OneBounded f → OneBounded g → + (UniformlyNonpretentious f ∨ UniformlyNonpretentious g) → + ∀ h : ℕ, 0 < h → + Tendsto (fun N : ℕ => correlationSum f g 0 h N / (N : ℂ)) atTop (nhds 0) + +lemma residuePrefix_one (u : ℕ → ℂ) (b N : ℕ) : + residuePrefix u 1 b N = ∑ n ∈ Finset.Icc 1 N, u n := by + have hs : Finset.Ioc 0 N = Finset.Icc 1 N := by + ext n + simp only [Finset.mem_Ioc, Finset.mem_Icc] + omega + simp only [residuePrefix, hs, Nat.mod_one, ite_true] + +theorem correlation_shift_zero (f g : ℕ → ℂ) (h b : ℕ) + (hzero : Tendsto (fun N : ℕ => correlationSum f g 0 h N / (N : ℂ)) + atTop (nhds 0)) : + Tendsto (fun N : ℕ => correlationSum f g b (b + h) N / (N : ℂ)) + atTop (nhds 0) := by + have hp : Tendsto (fun N : ℕ => + residuePrefix (fun n => f n * g (n + h)) 1 b N / (N : ℂ)) atTop (nhds 0) := by + simpa only [residuePrefix_one, correlationSum, Nat.add_zero] using hzero + have ht := affine_mean_tendsto_zero (fun n => f n * g (n + h)) 1 b (by decide) hp + simpa only [correlationSum, one_mul, Nat.add_assoc] using ht + +theorem UnshiftedCorrectedElliott.binary (hcore : UnshiftedCorrectedElliott) : + BinaryCorrectedElliott := by + intro f g hf hg hfb hgb hnp h₁ h₂ hne + rcases lt_or_gt_of_ne hne with hlt | hgt + · have h := correlation_shift_zero f g (h₂ - h₁) h₁ + (hcore f g hf hg hfb hgb hnp _ (Nat.sub_pos_of_lt hlt)) + simpa only [Nat.add_sub_of_le hlt.le] using h + · have h := correlation_shift_zero g f (h₁ - h₂) h₂ + (hcore g f hg hf hgb hfb hnp.symm _ (Nat.sub_pos_of_lt hgt)) + simpa only [Nat.add_sub_of_le hgt.le, correlationSum, mul_comm] using h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedDegreeDeletion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedDegreeDeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..90dafe45f4f2403925f1d18a3eb7ff0e4ba865ac --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedDegreeDeletion.lean @@ -0,0 +1,114 @@ +import OAI.NumberTheory.TwoPoint.Bounds.VariableDegreeDeletion + +namespace OAI + +/-! Pair-dependent endpoint shifts do not change the degree cost. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem BravermanDepth22Input.eventually_shifted_tuple_degree_deletion + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M) + (_hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (P : Fin J → Finset ℕ), primeTuplePool P = data.P → + (∀ j, ∀ p ∈ P j, p.Prime) → + (∀ j l, l ≠ j → Disjoint (P j) (P l)) → + ∀ W : ℝ, 10 ≤ W → (∀ j, primeHarmonicMass (P j) ≤ 2 * W) → + (J : ℝ) ≤ L ^ 2 → 6 * W * J ≤ 400 * Real.log L → + ∀ (D : Finset ℕ), D ⊆ primeTupleDivisors P → + ∀ (Q : Finset ℕ), Q ⊆ retainedPrimeDivisors data.Q → + (∀ q ∈ Q, (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) → + ∀ (bins : Finset ℤ) (η : ℝ) (c : ℕ → ℝ), 0 < η → + ∀ (site : ℤ → ℕ → ℕ → ℤ) (a N : ℤ → ℕ), (∀ j ∈ bins, Real.exp (L ^ A / 2) ≤ (N j : ℝ)) → + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ Q.filter (actualPaddingBin η (c d) j), + uniformAverage (fun x : Fin (N j) => + positiveDegreeCost data.P d.primeFactors W q ((a j + x.val : ℤ) + site j d q))) ≤ + (2 : ℝ) ^ J * (∏ j, primeHarmonicMass (P j)) * paddingTiltNormalizer data.Q * + Real.exp (-2 * W * J) + + bins.card * D.card * Q.card * Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_integer_degree_cost + refine ⟨A, hA, ?_⟩ + filter_upwards [hb] with L hb + intro h J M B data hB hpool hBL P hP hprime hdisjoint W hW hV hJ hTL D hD Q hQ + hqdegree bins η c hη site a N hN + have hmass : (∑ p ∈ data.P, 1 / (p : ℝ)) ≤ 2 * W * J := by + rw [← primeHarmonicMass_eq_sum, ← hP, primeTuplePool_mass P hdisjoint] + calc + _ ≤ ∑ _j : Fin J, 2 * W := sum_le_sum (fun j _ => hV j) + _ = _ := by simp; ring + have ht (d : ℕ) (hd : d ∈ D) : + (∑ j ∈ bins, ∑ q ∈ Q.filter (actualPaddingBin η (c d) j), + uniformAverage (fun x : Fin (N j) => + positiveDegreeCost data.P d.primeFactors W q ((a j + x.val : ℤ) + site j d q))) ≤ + positivePrimeNormalizer d.primeFactors * Real.exp (-2 * W * J) * paddingTiltNormalizer data.Q + + bins.card * Q.card * Real.exp (-(L ^ 9)) := by + have ha := primeTupleDivisors_arithmetic P hprime hdisjoint (hD hd) + have heach (j : ℤ) (hj : j ∈ bins) : + (∑ q ∈ Q.filter (actualPaddingBin η (c d) j), + uniformAverage (fun x : Fin (N j) => + positiveDegreeCost data.P d.primeFactors W q ((a j + x.val : ℤ) + site j d q))) ≤ + positivePrimeNormalizer d.primeFactors * Real.exp (-2 * W * J) * + (∑ q ∈ Q.filter (actualPaddingBin η (c d) j), actualPaddingCoefficient q / q) + + Q.card * Real.exp (-(L ^ 9)) := by + have hpoint (q : ℕ) (hq : q ∈ Q.filter (actualPaddingBin η (c d) j)) : + uniformAverage (fun x : Fin (N j) => + positiveDegreeCost data.P d.primeFactors W q + ((a j + x.val : ℤ) + site j d q)) ≤ + actualPaddingCoefficient q / q * positivePrimeNormalizer d.primeFactors * + Real.exp (-2 * W * J) + Real.exp (-(L ^ 9)) := by + have hx := hb h J M B data hB hpool hBL d.primeFactors (ha.2.2.trans_eq hP) + (by simpa only [ha.2.1] using hJ) W hW (by simpa only [ha.2.1] using hTL) + (by simpa only [ha.2.1] using hmass) q (hQ (mem_filter.mp hq).1) + (hqdegree q (mem_filter.mp hq).1) (site j d q) (a j) (N j) (hN j hj) + simpa only [positiveDegreeCost, ha.2.1] using hx + have hcard : ((Q.filter (actualPaddingBin η (c d) j)).card : ℝ) ≤ Q.card := by + exact_mod_cast card_filter_le Q (actualPaddingBin η (c d) j) + calc + _ ≤ ∑ q ∈ Q.filter (actualPaddingBin η (c d) j), + (actualPaddingCoefficient q / q * positivePrimeNormalizer d.primeFactors * + Real.exp (-2 * W * J) + Real.exp (-(L ^ 9))) := sum_le_sum hpoint + _ = positivePrimeNormalizer d.primeFactors * Real.exp (-2 * W * J) * + (∑ q ∈ Q.filter (actualPaddingBin η (c d) j), actualPaddingCoefficient q / q) + + (Q.filter (actualPaddingBin η (c d) j)).card * Real.exp (-(L ^ 9)) := by + simp only [sum_add_distrib, ← sum_mul, sum_const, nsmul_eq_mul] + ring + _ ≤ _ := by + have he := mul_le_mul_of_nonneg_right hcard (Real.exp_pos (-(L ^ 9))).le + linarith + calc + _ ≤ ∑ j ∈ bins, (positivePrimeNormalizer d.primeFactors * Real.exp (-2 * W * J) * + (∑ q ∈ Q.filter (actualPaddingBin η (c d) j), actualPaddingCoefficient q / q) + + Q.card * Real.exp (-(L ^ 9))) := sum_le_sum heach + _ = positivePrimeNormalizer d.primeFactors * Real.exp (-2 * W * J) * + (∑ j ∈ bins, ∑ q ∈ Q.filter (actualPaddingBin η (c d) j), actualPaddingCoefficient q / q) + + bins.card * Q.card * Real.exp (-(L ^ 9)) := by + simp only [sum_add_distrib, ← mul_sum, sum_const, nsmul_eq_mul] + ring + _ ≤ _ := by + have hm := mul_le_mul_of_nonneg_left + (padding_bin_reciprocal_sum_le data.Q Q data.primeQ hQ bins η (c d) hη) + (show 0 ≤ positivePrimeNormalizer d.primeFactors * Real.exp (-2 * W * J) by + unfold positivePrimeNormalizer; positivity) + linarith + rw [sum_comm] + calc + _ ≤ ∑ d ∈ D, (positivePrimeNormalizer d.primeFactors * Real.exp (-2 * W * J) * + paddingTiltNormalizer data.Q + bins.card * Q.card * Real.exp (-(L ^ 9))) := sum_le_sum ht + _ = (∑ d ∈ D, positivePrimeNormalizer d.primeFactors) * Real.exp (-2 * W * J) * + paddingTiltNormalizer data.Q + bins.card * D.card * Q.card * Real.exp (-(L ^ 9)) := by + simp only [sum_add_distrib, ← sum_mul, sum_const, nsmul_eq_mul] + ring + _ ≤ _ := by + have hm := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (tuple_normalizer_sum_le P hprime hdisjoint D hD) + (Real.exp_pos (-2 * W * J)).le) (paddingTiltNormalizer_pos data.Q).le + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedIntegerPaths.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedIntegerPaths.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d72ae41363b939470a04c1bf7a6f1b71a58712e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedIntegerPaths.lean @@ -0,0 +1,125 @@ +import OAI.NumberTheory.TwoPoint.Bounds.IntegerVertexMask + +namespace OAI + +/-! Arithmetic translation leaves the physical copy and block gates fixed. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +variable {D V : Type*} + +lemma scalarWalkProduct_translate (h : ℕ) (weight : SignedStep → ℤ → ℝ) + (c n : ℤ) (w : List SignedStep) : + scalarWalkProduct h (fun t z => weight t (z + c)) n w = + scalarWalkProduct h weight (n + c) w := by + induction w generalizing n with + | nil => rfl + | cons t w ih => + simp only [scalarWalkProduct, ih] + rw [show n + t.displacement h + c = n + c + t.displacement h by ring] + +noncomputable def physicalShiftWeight (Q : Finset ℕ) (tuple : D → ℕ) (h : ℕ) + (gate : D → ℤ → ℤ → Prop) (weight : SignedStep → ℤ → ℝ) + (e : D × (Q × Bool)) (x : D × ℤ) : ℝ := + if x.1 ≠ e.1 ∧ gate e.1 x.2 (integerShiftNext Q tuple h e x).2 then + weight ⟨e.2.2, tuple e.1, e.2.1⟩ x.2 else 0 + +variable [Fintype V] [DecidableEq D] + +lemma retained_physicalShiftWeight (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (h : ℕ) (gate : D → ℤ → ℤ → Prop) + (weight : SignedStep → ℤ → ℝ) (e : D × (Q × Bool)) (x : D × ℤ) : + retainedShiftWeight embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate weight) e x = + integerStepMask embed Q tuple h gate e x * + weight ⟨e.2.2, tuple e.1, e.2.1⟩ x.2 := by + by_cases hc : x.1 ≠ e.1 + · by_cases hg : gate e.1 x.2 (integerShiftNext Q tuple h e x).2 + · by_cases hr : integerShiftNext Q tuple h e x ∈ Set.range embed + · simp [retainedShiftWeight, physicalShiftWeight, integerStepMask, hc, hg, hr] + · simp [retainedShiftWeight, integerStepMask, hr] + · simp [retainedShiftWeight, physicalShiftWeight, integerStepMask, hc, hg] + · simp [retainedShiftWeight, physicalShiftWeight, integerStepMask, hc] + +theorem physicalShiftWord_product (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (h : ℕ) (gate : D → ℤ → ℤ → Prop) + (weight : SignedStep → ℤ → ℝ) {k : ℕ} + (x : D × ℤ) (w : Fin k → D × (Q × Bool)) : + shiftWordWeight embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate weight) x w = + integerPathMask embed Q tuple h gate x w * + scalarWalkProduct h weight x.2 (integerStepWord Q tuple w) := by + induction k generalizing x with + | zero => simp [shiftWordWeight, integerPathMask, integerStepWord, scalarWalkProduct] + | succ k ih => + rw [shiftWordWeight, retained_physicalShiftWeight, ih] + simp only [integerPathMask, integerStepWord, List.ofFn_succ, List.map_cons, scalarWalkProduct] + dsimp only [integerShiftNext, Fin.tail_def] + ring + +theorem physicalShiftWord_closed_pair (embed : V → D × ℤ) (Q : Finset ℕ) + (tuple : D → ℕ) (h : ℕ) (gate : D → ℤ → ℤ → Prop) + (weight : SignedStep → ℤ → ℝ) + (hflip : ∀ t n, weight t.flip (n + t.displacement h) = weight t n) + (c : ℤ) {k : ℕ} (x : D × ℤ) (a b : Fin k → D × (Q × Bool)) + (hend : shiftWordEnd (integerShiftNext Q tuple h) x a = + shiftWordEnd (integerShiftNext Q tuple h) x b) : + shiftWordWeight embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate (fun t n => weight t (n + c))) x a * + shiftWordWeight embed (integerShiftNext Q tuple h) + (physicalShiftWeight Q tuple h gate (fun t n => weight t (n + c))) x b = + (integerPathMask embed Q tuple h gate x a * integerPathMask embed Q tuple h gate x b) * + scalarWalkProduct h weight (x.2 + c) (integerClosedWordCode Q tuple (a, b)) := by + have he := congrArg (fun y : D × ℤ => y.2) hend + rw [integerShiftEnd_site, integerShiftEnd_site] at he + have hd : wordDisplacement h (integerStepWord Q tuple a) = + wordDisplacement h (integerStepWord Q tuple b) := by omega + rw [physicalShiftWord_product, physicalShiftWord_product, + scalarWalkProduct_translate, scalarWalkProduct_translate] + unfold integerClosedWordCode + rw [← scalarWalkProduct_closed_pair h weight hflip (x.2 + c) _ _ hd] + ring + +noncomputable def maskedSignedIntegerWeight (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → ℕ → Prop) (g : ℤ → ℝ) (center : ℕ → ℤ → ℝ) + (L K : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) (keep : ℤ → Prop) + (t : SignedStep) (n : ℤ) : ℝ := + vertexIndicator keep n * + signedIntegerWeight Q u (eligible t.tuple) g (center t.tuple) L K + (extra t.tuple) h t n * vertexIndicator keep (n + t.displacement h) + +lemma maskedSignedIntegerWeight_flip (Q : Finset ℕ) (u : ℕ → ℝ) + (eligible : ℕ → ℕ → Prop) (g : ℤ → ℝ) (center : ℕ → ℤ → ℝ) + (L K : ℝ) (extra : ℕ → ℤ → Prop) (h : ℕ) (keep : ℤ → Prop) + (t : SignedStep) (n : ℤ) : + maskedSignedIntegerWeight Q u eligible g center L K extra h keep + t.flip (n + t.displacement h) = + maskedSignedIntegerWeight Q u eligible g center L K extra h keep t n := by + unfold maskedSignedIntegerWeight + rw [signedIntegerWeight_flip, SignedStep.displacement_flip] + rw [show n + t.displacement h + -t.displacement h = n by ring] + dsimp only [SignedStep.flip] + ring + +theorem physicalShiftWeight_masked_eq_integer (Q : Finset ℕ) (tuple : D → ℕ) + (u : ℕ → ℝ) (eligible : ℕ → ℕ → Prop) (g : ℤ → ℝ) + (center : ℕ → ℤ → ℝ) (L K : ℝ) (extra : ℕ → ℤ → Prop) + (h : ℕ) (gate : D → ℤ → ℤ → Prop) (keep : ℤ → Prop) : + physicalShiftWeight Q tuple h gate + (maskedSignedIntegerWeight Q u eligible g center L K extra h keep) = + integerShiftWeight Q tuple u (fun d => eligible (tuple d)) g + (fun d => center (tuple d)) L K (fun d => extra (tuple d)) h + (integerVertexGate gate keep) := by + funext e x + by_cases hc : x.1 ≠ e.1 <;> + by_cases hg : gate e.1 x.2 (integerShiftNext Q tuple h e x).2 <;> + by_cases hn : keep x.2 <;> + by_cases hm : keep (integerShiftNext Q tuple h e x).2 <;> + simp_all [physicalShiftWeight, maskedSignedIntegerWeight, integerShiftWeight, + integerVertexGate, vertexIndicator, integerShiftNext] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedPaddingBound.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedPaddingBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e0096e57ec987f4f80c9eb4d7e9e00d9eb4ebc6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedPaddingBound.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShiftedPaddingComparison + +namespace OAI + +/-! The literal padding deletion bound when each product bin has its +own averaging interval. The product-model cost is paid only once. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem BravermanDepth22Input.eventually_shifted_padding_deletion_uniform + (hBr : BravermanDepth22Input) (hP : ModFiveThetaInput) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ E : Finset ℕ, + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M), + data.Q = paddingPrimeSupply E L → + ∀ (_hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (P : Fin J → Finset ℕ), primeTuplePool P = data.P → + (∀ j, ∀ p ∈ P j, p.Prime) → + (∀ j l, l ≠ j → Disjoint (P j) (P l)) → (J : ℝ) ≤ L ^ 2 → + ∀ (D : Finset ℕ), D ⊆ primeTupleDivisors P → + ∀ (Q : Finset ℕ), Q ⊆ retainedPrimeDivisors data.Q → + (∀ q ∈ Q, (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) → + ∀ (bins : Finset ℤ) (η K : ℝ) (c : ℕ → ℝ), 0 < η → η ≤ 1 → 0 < K → + ∀ (site : ℤ → ℕ → ℕ → ℤ) (a N : ℤ → ℕ), + (∀ j ∈ bins, Real.exp (L ^ A / 2) ≤ (N j : ℝ)) → + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ Q, uniformAverage (fun x : Fin (N j) => + paddingRejectionAtom data.Q d.primeFactors Q (actualPaddingBin η (c d) j) L K q + ((a j + x.val : ℤ) + site j d q))) / paddingTiltNormalizer data.Q ≤ + (2 : ℝ) ^ J * (∏ j, primeHarmonicMass (P j)) * (C / K + L ^ (-100 : ℝ)) + + (2 * bins.card * D.card * Q.card * Real.exp (-(L ^ 9))) / + paddingTiltNormalizer data.Q := by + obtain ⟨A, hA, hc⟩ := hBr.eventually_shifted_padding_comparison + refine ⟨A, hA, ?_⟩ + intro E + obtain ⟨C, hC, hm⟩ := hP.eventually_model_tuple_padding_deletion E + refine ⟨C, hC, ?_⟩ + filter_upwards [hc, hm] with L hc hm + intro h J M B data hQ hB hpool hBL P hPeq hprime hdisjoint hJ D hD Q hQsub hqdegree + bins η K c hη hηone hK site a N hN + have hd (d : ℕ) (hd : d ∈ D) := primeTupleDivisors_arithmetic P hprime hdisjoint (hD hd) + have he := hc h J M B data hB hpool hBL D + (fun d hmem => ((hd d hmem).2.2.trans_eq hPeq).trans subset_union_left) + (fun d hmem => by simpa only [(hd d hmem).2.1] using hJ) + Q hQsub hqdegree bins η K c site a N hN + have he' := (abs_le.mp he).2 + have hm' := hm h J M B data hQ hB P hPeq hprime hdisjoint D hD Q hQsub + bins η K c hη hηone hK 0 + simp only [add_zero] at hm' + have hS := paddingTiltNormalizer_pos data.Q + have hx := (div_le_div_iff_of_pos_right hS).mpr he' + rw [sub_div] at hx + linarith + +theorem BravermanDepth22Input.eventually_shifted_padding_deletion + (hBr : BravermanDepth22Input) (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ (A : ℕ) (C : ℝ), 1000 ≤ A ∧ 0 < C ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M), + data.Q = paddingPrimeSupply E L → + ∀ (_hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (P : Fin J → Finset ℕ), primeTuplePool P = data.P → + (∀ j, ∀ p ∈ P j, p.Prime) → + (∀ j l, l ≠ j → Disjoint (P j) (P l)) → (J : ℝ) ≤ L ^ 2 → + ∀ (D : Finset ℕ), D ⊆ primeTupleDivisors P → + ∀ (Q : Finset ℕ), Q ⊆ retainedPrimeDivisors data.Q → + (∀ q ∈ Q, (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) → + ∀ (bins : Finset ℤ) (η K : ℝ) (c : ℕ → ℝ), 0 < η → η ≤ 1 → 0 < K → + ∀ (site : ℤ → ℕ → ℕ → ℤ) (a N : ℤ → ℕ), + (∀ j ∈ bins, Real.exp (L ^ A / 2) ≤ (N j : ℝ)) → + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ Q, uniformAverage (fun x : Fin (N j) => + paddingRejectionAtom data.Q d.primeFactors Q (actualPaddingBin η (c d) j) L K q + ((a j + x.val : ℤ) + site j d q))) / paddingTiltNormalizer data.Q ≤ + (2 : ℝ) ^ J * (∏ j, primeHarmonicMass (P j)) * (C / K + L ^ (-100 : ℝ)) + + (2 * bins.card * D.card * Q.card * Real.exp (-(L ^ 9))) / + paddingTiltNormalizer data.Q := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_shifted_padding_deletion_uniform hP + obtain ⟨C, hC, hb⟩ := hb E + exact ⟨A, C, hA, hC, hb⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedPaddingComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedPaddingComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..09861049a1104ac23b51c49c397b4e1a879a5f4c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedPaddingComparison.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.TwoPoint.Bounds.VariablePaddingDeletion +import OAI.NumberTheory.TwoPoint.Bounds.PositiveCostPeriodicity + +namespace OAI + +/-! Each numerical pair can be sampled at its own additive shift. +The common model is recovered by exact residue translation. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem BravermanDepth22Input.eventually_shifted_padding_comparison + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M) + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (D : Finset ℕ), + (∀ d ∈ D, d.primeFactors ⊆ data.P ∪ data.Q) → + (∀ d ∈ D, (d.primeFactors.card : ℝ) ≤ L ^ 2) → + ∀ (Q : Finset ℕ), Q ⊆ retainedPrimeDivisors data.Q → + (∀ q ∈ Q, (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) → + ∀ (bins : Finset ℤ) (η K : ℝ) (c : ℕ → ℝ) (site : ℤ → ℕ → ℕ → ℤ) (a N : ℤ → ℕ), + (∀ j ∈ bins, Real.exp (L ^ A / 2) ≤ (N j : ℝ)) → + |(∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ Q, uniformAverage (fun x : Fin (N j) => + paddingRejectionAtom data.Q d.primeFactors Q (actualPaddingBin η (c d) j) L K q + ((a j + x.val : ℤ) + site j d q))) - + (data.residueLaw B hB).average (fun x => ∑ d ∈ D, + positivePrimeWeight d.primeFactors (data.residueOrigin x) * + paddingRejectedMass data.Q Q bins η (c d) L K (data.residueOrigin x))| ≤ + 2 * bins.card * D.card * Q.card * Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_padding_atom_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hb] with L hb + intro h J M B data hB hpool hBL D hD hcard Q hQ hqdegree bins η K c site a N hN + let I := bins ×ˢ (D ×ˢ Q) + let f := fun (i : ℤ × (ℕ × ℕ)) (n : ℤ) => + paddingRejectionAtom data.Q i.2.1.primeFactors Q (actualPaddingBin η (c i.2.1) i.1) + L K i.2.2 (n + site i.1 i.2.1 i.2.2) + let g := fun (i : ℤ × (ℕ × ℕ)) (x : ↥(data.P ∪ data.Q) → Fin B) => + paddingRejectionAtom data.Q i.2.1.primeFactors Q (actualPaddingBin η (c i.2.1) i.1) + L K i.2.2 (data.residueOrigin x) + have hs := finite_interval_family_error I (data.residueLaw B hB) + (fun i => a i.1) (fun i => N i.1) f g (fun _ => 2 * Real.exp (-(L ^ 9))) (by + intro i hi + obtain ⟨hj, hdq⟩ := mem_product.mp hi + obtain ⟨hd, hq⟩ := mem_product.mp hdq + have hx := hb h J M B data hB hpool hBL i.2.1.primeFactors (hD _ hd) (hcard _ hd) + i.2.2 (hQ hq) (hqdegree _ hq) Q hQ (actualPaddingBin η (c i.2.1) i.1) + K (site i.1 i.2.1 i.2.2) (a i.1) (N i.1) (hN _ hj) + rw [data.padding_rejection_average_translate hB i.2.1.primeFactors Q (hD _ hd) + hQ (actualPaddingBin η (c i.2.1) i.1) L K i.2.2 (hQ hq) + (site i.1 i.2.1 i.2.2)] at hx + exact hx) + have he : (∑ _i ∈ I, 2 * Real.exp (-(L ^ 9))) = + 2 * bins.card * D.card * Q.card * Real.exp (-(L ^ 9)) := by + simp only [sum_const, nsmul_eq_mul, I, card_product, Nat.cast_mul] + ring + rw [he] at hs + simp only [I, sum_product, f, g] at hs + have hmodel (x : ↥(data.P ∪ data.Q) → Fin B) : + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ Q, + paddingRejectionAtom data.Q d.primeFactors Q (actualPaddingBin η (c d) j) L K q + (data.residueOrigin x)) = + ∑ d ∈ D, positivePrimeWeight d.primeFactors (data.residueOrigin x) * + paddingRejectedMass data.Q Q bins η (c d) L K (data.residueOrigin x) := by + rw [sum_comm] + apply sum_congr rfl + intro d _ + exact (padding_rejection_bin_identity data.Q d.primeFactors Q bins η (c d) L K _).symm + simpa only [hmodel] using hs + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedRareComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedRareComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..42c8b5520b275bb6a35a18ac06bc3dbd5929447d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedRareComparison.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PositiveCostPeriodicity +import OAI.NumberTheory.TwoPoint.Bounds.VariableWindowComparison +import OAI.NumberTheory.TwoPoint.Bounds.SourceDeletionTerms + +namespace OAI + +/-! Rare-site row comparison with a distinct additive shift at every +numerical pair, in particular the opposite endpoint of that edge. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def shiftedProhibitedRow {h J M : ℕ} (data : ProhibitedPrimeFamily h J M) + (s : ℕ) (D : Finset ℕ) (padding : ℕ → Finset ℕ) (site : ℕ → ℕ → ℤ) (n : ℤ) : ℝ := + ∑ d ∈ D, ∑ q ∈ padding d, actualPaddingCoefficient q * + positivePrimeWeight d.primeFactors (n + site d q) * + if (q : ℤ) ∣ n + site d q ∧ + ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) (n + site d q) then 1 else 0 + +theorem BravermanDepth22Input.eventually_shifted_prohibited_row_comparison + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B s cap : ℕ) (data : ProhibitedPrimeFamily h J M) + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + (s : ℝ) ≤ L → (cap : ℝ) ≤ L ^ 2 → + (data.pairs.card : ℝ) ≤ Real.exp (101 * L) → + (∀ dq ∈ data.pairs, (dq.2 * dq.1).primeFactors.card ≤ cap) → + ∀ (D : Finset ℕ), + (∀ d ∈ D, d.primeFactors ⊆ data.P ∪ data.Q) → + (∀ d ∈ D, (d.primeFactors.card : ℝ) ≤ L ^ 2) → + ∀ (padding : ℕ → Finset ℕ), + (∀ d ∈ D, padding d ⊆ retainedPrimeDivisors data.Q) → + (∀ d ∈ D, ∀ q ∈ padding d, (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) → + ∀ (site : ℕ → ℕ → ℤ) (a N : ℕ), Real.exp (L ^ A / 2) ≤ (N : ℝ) → + |(∑ d ∈ D, ∑ q ∈ padding d, uniformAverage (fun x : Fin N => + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors ((a + x.val : ℤ) + site d q) * + if (q : ℤ) ∣ (a + x.val : ℤ) + site d q ∧ + ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) ((a + x.val : ℤ) + site d q) + then 1 else 0)) - + (data.residueLaw B hB).average (fun x => + prohibitedPositiveRow data s D padding (data.residueOrigin x))| ≤ + (∑ d ∈ D, (padding d).card : ℕ) * Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_prohibited_cost_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hb] with L hb + intro h J M B s cap data hB hpool hBL hs hcap hpair hdegree D hD hcard + padding hpadding hqdegree site a N hN + let μ := data.residueLaw B hB + let atom := fun d q n => actualPaddingCoefficient q * positivePrimeWeight (Nat.primeFactors d) n * + if (q : ℤ) ∣ n ∧ ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) n then 1 else 0 + have hpoint (d : ℕ) (hd : d ∈ D) (q : ℕ) (hq : q ∈ padding d) : + |uniformAverage (fun x : Fin N => atom d q ((a + x.val : ℤ) + site d q)) - + μ.average (fun x => atom d q (data.residueOrigin x))| ≤ Real.exp (-(L ^ 9)) := by + have hx := hb h J M B s cap data hB hpool hBL hs hcap hpair hdegree + d.primeFactors (hD d hd) (hcard d hd) q (hpadding d hd hq) (hqdegree d hd q hq) + (site d q) a N hN + dsimp only at hx + rw [data.prohibited_cost_average_translate hB d.primeFactors (hD d hd) s q + (hpadding d hd hq) (site d q)] at hx + exact hx + have hinner (d : ℕ) (hd : d ∈ D) : + |(∑ q ∈ padding d, uniformAverage (fun x : Fin N => + atom d q ((a + x.val : ℤ) + site d q))) - + μ.average (fun x => ∑ q ∈ padding d, atom d q (data.residueOrigin x))| ≤ + (padding d).card * Real.exp (-(L ^ 9)) := by + rw [μ.average_finset_sum] + simpa only [sum_const, nsmul_eq_mul] using finset_sum_error (padding d) + (fun q => uniformAverage (fun x : Fin N => atom d q ((a + x.val : ℤ) + site d q))) + (fun q => μ.average (fun x => atom d q (data.residueOrigin x))) + (fun _ => Real.exp (-(L ^ 9))) (hpoint d hd) + have hout := finset_sum_error D + (fun d => ∑ q ∈ padding d, uniformAverage (fun x : Fin N => + atom d q ((a + x.val : ℤ) + site d q))) + (fun d => μ.average (fun x => ∑ q ∈ padding d, atom d q (data.residueOrigin x))) + (fun d => (padding d).card * Real.exp (-(L ^ 9))) hinner + rw [← μ.average_finset_sum, ← sum_mul, ← Nat.cast_sum] at hout + exact hout + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedRareDeletion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedRareDeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce41196f017d2245e39a33e79d4b6235f07996af --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedRareDeletion.lean @@ -0,0 +1,220 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShiftedRareComparison +import OAI.NumberTheory.TwoPoint.Walks.CanonicalRareDeletion + +namespace OAI + +/-! The actual rare-event deletion bound is unchanged by separate endpoint +shifts for each pair. All arithmetic and circuit budgets are supplied here. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem BravermanDepth22Input.eventually_shifted_actual_prohibited_deletion_uniform + (hBr : BravermanDepth22Input) (hP : ModFiveThetaInput) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ (E : Finset ℕ) (W C : ℝ), + 10 ≤ W → 0 ≤ C → ∀ᶠ L : ℝ in atTop, + ∀ (h M B s cap : ℕ) (data : ProhibitedPrimeFamily h (primeSupplyCount W L) M), + data.P = centeredPrimePool E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) → + data.Q = paddingPrimeSupply E L → + ∀ (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + (s : ℝ) ≤ L → (cap : ℝ) ≤ L ^ 2 → + (data.pairs.card : ℝ) ≤ Real.exp (101 * L) → + (∀ dq ∈ data.pairs, (dq.2 * dq.1).primeFactors.card ≤ cap) → + (data.residueLaw B hB).probability (data.deletedEvent s B) ≤ + Real.exp (-(1 / 2 : ℝ) * L ^ (199 / 200 : ℝ)) → + (primeSupplyCount W L : ℝ) ≤ L ^ 2 → + ∀ (D : Finset ℕ), D ⊆ primeTupleDivisors + (centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L)) → + ∀ (padding : ℕ → Finset ℕ), + (∀ d ∈ D, padding d ⊆ retainedPrimeDivisors data.Q) → + (∀ d ∈ D, ∀ q ∈ padding d, (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) → + (∀ d ∈ D, ∀ q ∈ padding d, (d, q) ∈ data.pairs) → + ∀ (T : ℝ), 0 ≤ T → T ≤ Real.exp (C * Real.log L) → + ∀ (site : ℕ → ℕ → ℤ) (a N : ℕ), Real.exp (L ^ A / 2) ≤ (N : ℝ) → + T * uniformAverage (fun x : Fin N => + shiftedProhibitedRow data s D padding site (a + x.val)) ≤ + Real.exp (-L ^ (9 / 10 : ℝ)) + + T * data.pairs.card * Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hc⟩ := hBr.eventually_shifted_prohibited_row_comparison + refine ⟨A, hA, ?_⟩ + intro E W C hW hC + filter_upwards [hc, hP.eventually_prohibited_model_row E W C hW hC, + eventually_ge_atTop (1 : ℝ)] with L hc hm hL + intro h M B s cap data hp hq hB hpool hBL hs hcap hpair hdegree hprob hJ D hD + padding hpadding hqdegree hpairs T hT hTcap site a N hN + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) + have hprime := centeredPrimeBands_prime E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) + have hdisj := centeredPrimeBands_disjoint E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) + (Real.rpow_nonneg (by linarith) _) (by linarith : 0 ≤ W) + have hd (d : ℕ) (hd : d ∈ D) := primeTupleDivisors_arithmetic P hprime hdisj (hD hd) + have hsupport (d : ℕ) (hmem : d ∈ D) : d.primeFactors ⊆ data.P ∪ data.Q := by + apply (hd d hmem).2.2.trans + rw [hp] + exact subset_union_left + have hcard (d : ℕ) (hmem : d ∈ D) : (d.primeFactors.card : ℝ) ≤ L ^ 2 := by + rw [(hd d hmem).2.1] + exact hJ + have hcompare := hc h (primeSupplyCount W L) M B s cap data hB hpool hBL hs hcap + hpair hdegree D hsupport hcard padding hpadding hqdegree site a N hN + have hcompare' : |uniformAverage (fun x : Fin N => + shiftedProhibitedRow data s D padding site (a + x.val)) - + (data.residueLaw B hB).average (fun x => + prohibitedPositiveRow data s D padding (data.residueOrigin x))| ≤ + (∑ d ∈ D, (padding d).card : ℕ) * Real.exp (-(L ^ 9)) := by + simpa only [shiftedProhibitedRow, uniformAverage_finset_sum] using hcompare + have hmodel := hm h M B s data hp hq hB hprob D hD padding hpadding T hT hTcap 0 + simp only [add_zero] at hmodel + have hcount : ((∑ d ∈ D, (padding d).card : ℕ) : ℝ) ≤ data.pairs.card := by + exact_mod_cast padding_pair_count_le D padding data.pairs hpairs + have hdiff := (le_abs_self _).trans hcompare' + have hdiffT := mul_le_mul_of_nonneg_left hdiff hT + have hcountT := mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_right hcount (Real.exp_pos (-(L ^ 9))).le) hT + nlinarith + + +theorem BravermanDepth22Input.eventually_shifted_actual_prohibited_deletion + (hBr : BravermanDepth22Input) (hP : ModFiveThetaInput) + (E : Finset ℕ) (W C : ℝ) (hW : 10 ≤ W) (hC : 0 ≤ C) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h M B s cap : ℕ) (data : ProhibitedPrimeFamily h (primeSupplyCount W L) M), + data.P = centeredPrimePool E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L) → + data.Q = paddingPrimeSupply E L → + ∀ (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + (s : ℝ) ≤ L → (cap : ℝ) ≤ L ^ 2 → + (data.pairs.card : ℝ) ≤ Real.exp (101 * L) → + (∀ dq ∈ data.pairs, (dq.2 * dq.1).primeFactors.card ≤ cap) → + (data.residueLaw B hB).probability (data.deletedEvent s B) ≤ + Real.exp (-(1 / 2 : ℝ) * L ^ (199 / 200 : ℝ)) → + (primeSupplyCount W L : ℝ) ≤ L ^ 2 → + ∀ (D : Finset ℕ), D ⊆ primeTupleDivisors + (centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L)) → + ∀ (padding : ℕ → Finset ℕ), + (∀ d ∈ D, padding d ⊆ retainedPrimeDivisors data.Q) → + (∀ d ∈ D, ∀ q ∈ padding d, (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) → + (∀ d ∈ D, ∀ q ∈ padding d, (d, q) ∈ data.pairs) → + ∀ (T : ℝ), 0 ≤ T → T ≤ Real.exp (C * Real.log L) → + ∀ (site : ℕ → ℕ → ℤ) (a N : ℕ), Real.exp (L ^ A / 2) ≤ (N : ℝ) → + T * uniformAverage (fun x : Fin N => + shiftedProhibitedRow data s D padding site (a + x.val)) ≤ + Real.exp (-L ^ (9 / 10 : ℝ)) + + T * data.pairs.card * Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_shifted_actual_prohibited_deletion_uniform hP + exact ⟨A, hA, hb E W C hW hC⟩ + +theorem ModFiveThetaInput.eventually_shifted_canonical_rare_deletion_uniform + (hP : ModFiveThetaInput) (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ (h : ℕ) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E), + ∀ (W C : ℝ) (hW : 10 ≤ W) (_hC : 0 ≤ C), ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ (eligible : ℕ → ℕ → Prop), + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + let M := ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL (by linarith) hE + let padding := canonicalPairPadding Q M eligible + ∀ T : ℝ, 0 ≤ T → T ≤ Real.exp (C * Real.log L) → + ∀ (site : ℕ → ℕ → ℤ) (a N : ℕ), Real.exp (L ^ A / 2) ≤ (N : ℝ) → + T * uniformAverage (fun x : Fin N => + shiftedProhibitedRow data ⌊L ^ (1 / 10 : ℝ)⌋₊ (primeTupleDivisors P) padding + site (a + x.val)) ≤ + Real.exp (-L ^ (9 / 10 : ℝ)) + T * Real.exp (101 * L) * Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_shifted_actual_prohibited_deletion_uniform hP + refine ⟨A, hA, ?_⟩ + intro h E hE W C hW hC + have hWone : 1 ≤ W := by linarith + have hb := hb E W C hW hC + filter_upwards [hb, hP.eventually_actual_prohibited_density h E hE W hWone, + hP.eventually_actual_pool_masses E W hWone, eventually_ge_atTop (4800 : ℝ)] + with L hb hd hm hlarge + intro hL η hη hηone eligible he + dsimp only + let J := primeSupplyCount W L + let M := ⌊100 * Real.log L⌋₊ + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + let data := canonicalTraceFamily h E W L eligible hL hWone hE + let padding := canonicalPairPadding Q M eligible + let hB := canonicalTraceFamily_residue_bound h E W L eligible hL hWone hE + have hpool : (data.P ∪ data.Q).Nonempty := by + by_contra hn + have hempty : data.P = ∅ := not_nonempty_iff_eq_empty.mp + (fun hp => hn (hp.mono subset_union_left)) + have hp := hm.2.2.1 + change 1 ≤ primeHarmonicMass data.P at hp + rw [hempty] at hp + norm_num [primeHarmonicMass] at hp + have hJM : ((J + M : ℕ) : ℝ) ≤ L ^ 2 := + (prime_trace_degree_budget W L hWone hL).1.trans (by + have hlog : Real.log L ≤ L := + (Real.log_le_sub_one_of_pos (by linarith)).trans (by linarith) + nlinarith) + have hJ : (J : ℝ) ≤ L ^ 2 := by + have hjle : (J : ℝ) ≤ ((J + M : ℕ) : ℝ) := by exact_mod_cast Nat.le_add_right J M + exact hjle.trans hJM + have hs : (⌊L ^ (1 / 10 : ℝ)⌋₊ : ℝ) ≤ L := by + apply (Nat.floor_le (Real.rpow_nonneg (zero_le_one.trans hL) _)).trans + simpa using Real.rpow_le_rpow_of_exponent_le hL (show (1 / 10 : ℝ) ≤ 1 by norm_num) + have hpair : (data.pairs.card : ℝ) ≤ Real.exp (101 * L) := + actualProhibitedPrimeFamily_pairs_card h J M E (L ^ (199 / 200 : ℝ)) W L η eligible + (Real.rpow_nonneg (zero_le_one.trans hL) _) (zero_le_one.trans hWone) hE hL hη hηone he + have hpadding (d : ℕ) (_hd : d ∈ primeTupleDivisors P) : + padding d ⊆ retainedPrimeDivisors data.Q := by + intro q hq + exact (mem_filter.mp (mem_filter.mp hq).1).1 + have hqdegree (d : ℕ) (_hd : d ∈ primeTupleDivisors P) (q : ℕ) (hq : q ∈ padding d) : + (q.primeFactors.card : ℝ) ≤ 100 * Real.log L := by + have hM : q.primeFactors.card ≤ M := (mem_filter.mp (mem_filter.mp hq).1).2 + have hMr : (q.primeFactors.card : ℝ) ≤ M := by exact_mod_cast hM + exact hMr.trans (prime_trace_degree_budget W L hWone hL).2 + have hpairs (d : ℕ) (hd : d ∈ primeTupleDivisors P) (q : ℕ) (hq : q ∈ padding d) : + (d, q) ∈ data.pairs := by + have hm := mem_filter.mp hq + have hq' := mem_filter.mp hm.1 + exact (actualProhibitedPrimeFamily_pairs h J M E (L ^ (199 / 200 : ℝ)) W L eligible + (Real.rpow_nonneg (zero_le_one.trans hL) _) (zero_le_one.trans hWone) hE d q).mpr + ⟨hd, hq'.1, hq'.2, hm.2⟩ + intro T hT hTcap site a N hN + have ht := hb h M ⌊Real.exp L⌋₊ ⌊L ^ (1 / 10 : ℝ)⌋₊ (J + M) data rfl rfl hB + hpool (Nat.floor_le (Real.exp_pos _).le) hs hJM hpair data.whole_factor_card_le + (hd hL eligible) hJ (primeTupleDivisors P) subset_rfl padding hpadding hqdegree hpairs + T hT hTcap site a N hN + apply ht.trans + have hc := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hpair hT) + (Real.exp_pos (-(L ^ 9))).le + linarith + + +theorem ModFiveThetaInput.eventually_shifted_canonical_rare_deletion + (hP : ModFiveThetaInput) (hBr : BravermanDepth22Input) + (h : ℕ) (E : Finset ℕ) (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (W C : ℝ) (hW : 10 ≤ W) (hC : 0 ≤ C) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ (eligible : ℕ → ℕ → Prop), + (∀ d q, eligible d q → PaddingPairEligible L η d q) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + let M := ⌊100 * Real.log L⌋₊ + let data := canonicalTraceFamily h E W L eligible hL (by linarith) hE + let padding := canonicalPairPadding Q M eligible + ∀ T : ℝ, 0 ≤ T → T ≤ Real.exp (C * Real.log L) → + ∀ (site : ℕ → ℕ → ℤ) (a N : ℕ), Real.exp (L ^ A / 2) ≤ (N : ℝ) → + T * uniformAverage (fun x : Fin N => + shiftedProhibitedRow data ⌊L ^ (1 / 10 : ℝ)⌋₊ (primeTupleDivisors P) padding + site (a + x.val)) ≤ + Real.exp (-L ^ (9 / 10 : ℝ)) + T * Real.exp (101 * L) * Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hP.eventually_shifted_canonical_rare_deletion_uniform hBr + exact ⟨A, hA, hb h E hE W C hW hC⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedVariableRare.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedVariableRare.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b99c5b7f4c2555ddd41b39b4337e0b4d80f54e9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShiftedVariableRare.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShiftedRareDeletion + +namespace OAI + +/-! Sum the canonical rare-site deletion over bins with separately +chosen integer intervals. The polynomial bin count is absorbed by +the proved second-moment rare-event estimate. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem ModFiveThetaInput.eventually_shifted_variable_rare_deletion_uniform + (hP : ModFiveThetaInput) (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ (h : ℕ) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E), + ∀ (W C : ℝ) (hW : 10 ≤ W) (_hC : 0 ≤ C), ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ (bins : Finset ℤ) (eligible : ℤ → ℕ → ℕ → Prop), + (∀ j ∈ bins, ∀ d q, eligible j d q → PaddingPairEligible L η d q) → + (bins.card : ℝ) ≤ Real.exp (C * Real.log L) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + let M := ⌊100 * Real.log L⌋₊ + ∀ (site : ℤ → ℕ → ℕ → ℤ) (a N : ℤ → ℕ), (∀ j ∈ bins, Real.exp (L ^ A / 2) ≤ (N j : ℝ)) → + (∑ j ∈ bins, uniformAverage (fun x : Fin (N j) => + shiftedProhibitedRow (canonicalTraceFamily h E W L (eligible j) hL (by linarith) hE) + ⌊L ^ (1 / 10 : ℝ)⌋₊ (primeTupleDivisors P) (canonicalPairPadding Q M (eligible j)) + (site j) (a j + x.val))) ≤ + Real.exp (-L ^ (9 / 10 : ℝ)) + bins.card * Real.exp (101 * L) * Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hP.eventually_shifted_canonical_rare_deletion_uniform hBr + refine ⟨A, hA, ?_⟩ + intro h E hE W C hW hC + have hb := hb h E hE W C hW hC + filter_upwards [hb] with L hb + intro hL η hη hηone bins eligible he hbins + dsimp only + intro site a N hN + by_cases hempty : bins = ∅ + · subst bins + simp only [sum_empty, card_empty, Nat.cast_zero, zero_mul, add_zero] + positivity + let T : ℝ := bins.card + let cost := fun j : ℤ => uniformAverage (fun x : Fin (N j) => + shiftedProhibitedRow (canonicalTraceFamily h E W L (eligible j) hL (by linarith) hE) + ⌊L ^ (1 / 10 : ℝ)⌋₊ + (primeTupleDivisors (centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W (primeSupplyCount W L))) + (canonicalPairPadding (paddingPrimeSupply E L) ⌊100 * Real.log L⌋₊ (eligible j)) + (site j) (a j + x.val)) + have hT : 0 < T := by + dsimp only [T] + exact_mod_cast card_pos.mpr (nonempty_iff_ne_empty.mpr hempty) + have heach (j : ℤ) (hj : j ∈ bins) : T * cost j ≤ + Real.exp (-L ^ (9 / 10 : ℝ)) + T * Real.exp (101 * L) * Real.exp (-(L ^ 9)) := + hb hL η hη hηone (eligible j) (he j hj) T hT.le hbins (site j) (a j) (N j) (hN j hj) + have hsum : T * (∑ j ∈ bins, cost j) ≤ + T * (Real.exp (-L ^ (9 / 10 : ℝ)) + T * Real.exp (101 * L) * Real.exp (-(L ^ 9))) := by + rw [mul_sum] + calc + _ ≤ ∑ _j ∈ bins, (Real.exp (-L ^ (9 / 10 : ℝ)) + + T * Real.exp (101 * L) * Real.exp (-(L ^ 9))) := sum_le_sum heach + _ = _ := by simp only [sum_const, nsmul_eq_mul]; rfl + exact le_of_mul_le_mul_left hsum hT + +theorem ModFiveThetaInput.eventually_shifted_variable_rare_deletion + (hP : ModFiveThetaInput) (hBr : BravermanDepth22Input) + (h : ℕ) (E : Finset ℕ) (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (W C : ℝ) (hW : 10 ≤ W) (hC : 0 ≤ C) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ (bins : Finset ℤ) (eligible : ℤ → ℕ → ℕ → Prop), + (∀ j ∈ bins, ∀ d q, eligible j d q → PaddingPairEligible L η d q) → + (bins.card : ℝ) ≤ Real.exp (C * Real.log L) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let Q := paddingPrimeSupply E L + let M := ⌊100 * Real.log L⌋₊ + ∀ (site : ℤ → ℕ → ℕ → ℤ) (a N : ℤ → ℕ), (∀ j ∈ bins, Real.exp (L ^ A / 2) ≤ (N j : ℝ)) → + (∑ j ∈ bins, uniformAverage (fun x : Fin (N j) => + shiftedProhibitedRow (canonicalTraceFamily h E W L (eligible j) hL (by linarith) hE) + ⌊L ^ (1 / 10 : ℝ)⌋₊ (primeTupleDivisors P) (canonicalPairPadding Q M (eligible j)) + (site j) (a j + x.val))) ≤ + Real.exp (-L ^ (9 / 10 : ℝ)) + bins.card * Real.exp (101 * L) * Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hP.eventually_shifted_variable_rare_deletion_uniform hBr + exact ⟨A, hA, hb h E hE W C hW hC⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ShortBlockPartition.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShortBlockPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa777b511fd9e56f4973a5a36a1944e20c5350f8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShortBlockPartition.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.TwoPoint.Walks.ColumnChunkBudgets +import Mathlib.Data.List.SplitLengths + +namespace OAI + +/-! The actual subdivision of perfect intervals into short blocks. -/ + +namespace TwoPointCorrelations + +variable {α : Type*} + +def shortBlockLengths (n s : ℕ) : List ℕ := List.replicate (n / s) s ++ [n % s] + +lemma shortBlockLengths_sum (n s : ℕ) : (shortBlockLengths n s).sum = n := by + simpa [shortBlockLengths, Nat.mul_comm] using Nat.div_add_mod n s + +def shortBlocks (s : ℕ) (l : List α) : List (List α) := + (shortBlockLengths l.length s).splitLengths l + +@[simp] theorem shortBlocks_flatten (s : ℕ) (l : List α) : (shortBlocks s l).flatten = l := by + exact List.flatten_splitLengths l _ (by rw [shortBlockLengths_sum]) + +@[simp] theorem shortBlocks_length (s : ℕ) (l : List α) : + (shortBlocks s l).length = l.length / s + 1 := by + simp [shortBlocks, shortBlockLengths] + +theorem shortBlocks_size (s : ℕ) (hs : 0 < s) (l : List α) : + ∀ block ∈ shortBlocks s l, block.length ≤ s := by + apply List.length_mem_splitLengths + intro n hn + simp only [shortBlockLengths, List.mem_append, List.mem_replicate, List.mem_singleton] at hn + rcases hn with ⟨_, rfl⟩ | rfl + · exact le_rfl + · exact (Nat.mod_lt _ hs).le + +theorem shortBlocks_infix (s : ℕ) (l block : List α) (hb : block ∈ shortBlocks s l) : + block.IsInfix l := by + have h := List.infix_of_mem_flatten hb + rwa [shortBlocks_flatten] at h + +/-- Imperfect positions stay single; perfect intervals are split into +full blocks of size `s` and one possible final shorter block. Empty final +blocks are harmless and are included in the upper bound. -/ +def subdivideColumnChunks (s : ℕ) (chunks : List (List α ⊕ α)) : List (List α ⊕ α) := + chunks.flatMap (Sum.elim (fun l => (shortBlocks s l).map Sum.inl) (fun a => [Sum.inr a])) + +lemma columnChunkEntries_map_inl (blocks : List (List α)) : + columnChunkEntries (blocks.map Sum.inl) = blocks.flatten.map (fun a => (a, true)) := by + induction blocks with + | nil => rfl + | cons block rest ih => + simpa [columnChunkEntries, Sum.elim, List.map_append] using + congrArg (List.append (block.map (fun a => (a, true)))) ih + +lemma columnChunkEntries_append (a b : List (List α ⊕ α)) : + columnChunkEntries (a ++ b) = columnChunkEntries a ++ columnChunkEntries b := by + simp [columnChunkEntries, List.flatMap_append] + +/-- Subdivision preserves every position, including its perfect/imperfect status. -/ +theorem subdivideColumnChunks_entries (s : ℕ) (chunks : List (List α ⊕ α)) : + columnChunkEntries (subdivideColumnChunks s chunks) = columnChunkEntries chunks := by + induction chunks with + | nil => rfl + | cons chunk rest ih => + cases chunk with + | inl l => + change columnChunkEntries ((shortBlocks s l).map Sum.inl ++ subdivideColumnChunks s rest) = + l.map (fun a => (a, true)) ++ columnChunkEntries rest + rw [columnChunkEntries_append, columnChunkEntries_map_inl, shortBlocks_flatten, ih] + | inr a => + simpa [subdivideColumnChunks, columnChunkEntries] using + congrArg (List.cons (a, false)) ih + +def perfectChunkLength (chunks : List (List α ⊕ α)) : ℕ := + (chunks.map (Sum.elim List.length (fun _ => 0))).sum + +lemma perfectChunkCount_append (a b : List (List α ⊕ α)) : + perfectChunkCount (a ++ b) = perfectChunkCount a + perfectChunkCount b := by + simp [perfectChunkCount, List.filterMap_append] + +lemma perfectChunkCount_map_inl (blocks : List (List α)) : + perfectChunkCount (blocks.map Sum.inl) = blocks.length := by + simp [perfectChunkCount, List.filterMap_map, Function.comp_def, Sum.elim] + +/-- The number of short perfect blocks is at most the total perfect length + divided by the block size, plus the number of original perfect intervals. -/ +theorem subdivideColumnChunks_count (s : ℕ) (chunks : List (List α ⊕ α)) : + perfectChunkCount (subdivideColumnChunks s chunks) ≤ + perfectChunkLength chunks / s + perfectChunkCount chunks := by + induction chunks with + | nil => simp [subdivideColumnChunks, perfectChunkCount, perfectChunkLength] + | cons chunk rest ih => + cases chunk with + | inl l => + have hd := Nat.div_add_div_le_add_div (x := l.length) (y := perfectChunkLength rest) (z := s) + change perfectChunkCount ((shortBlocks s l).map Sum.inl ++ subdivideColumnChunks s rest) ≤ + (l.length + perfectChunkLength rest) / s + (perfectChunkCount rest + 1) + rw [perfectChunkCount_append, perfectChunkCount_map_inl, shortBlocks_length] + omega + | inr a => + simpa [subdivideColumnChunks, perfectChunkCount, perfectChunkLength, Sum.elim, + List.filterMap_cons] using ih + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ShortColumnBlocks.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShortColumnBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e768a4dc9714b6273144d7147640c69dc0c1afa --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShortColumnBlocks.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PerfectIntervalFamily +import OAI.NumberTheory.TwoPoint.Walks.ColumnPieceMembership +import OAI.NumberTheory.TwoPoint.Walks.CanonicalColumnNames + +namespace OAI + +/-! The actual short perfect blocks of a finite column, with all positions and budgets. -/ + +namespace TwoPointCorrelations + +variable {α : Type*} {n : ℕ} + +def columnNatLabel (label : Fin n → α) (hn : 0 < n) (t : ℕ) : α := + if ht : t < n then label ⟨t, ht⟩ else label ⟨0, hn⟩ + +def columnNatPerfect (perfect : Finset (Fin n)) (t : ℕ) : Bool := + if ht : t < n then decide ((⟨t, ht⟩ : Fin n) ∈ perfect) else false + +theorem columnNatLabel_fin (label : Fin n → α) (hn : 0 < n) (i : Fin n) : + columnNatLabel label hn i.val = label i := by + simp only [columnNatLabel, dite_eq_left i.isLt, Fin.eta] + +theorem columnNatPerfect_fin (perfect : Finset (Fin n)) (i : Fin n) : + columnNatPerfect perfect i.val = decide (i ∈ perfect) := by + simp [columnNatPerfect, i.isLt] + +theorem range_map_eq_ofFn {β : Type*} (f : ℕ → β) (n : ℕ) : + (List.range n).map f = List.ofFn (fun i : Fin n => f i.val) := by + simpa using (List.ofFn_getElem_eq_map (List.range n) f).symm + +def shortColumnChunks (label : Fin n → α) (hn : 0 < n) (perfect : Finset (Fin n)) (s : ℕ) : + List (List α ⊕ α) := + (shortPerfectColumnChunks s ((List.range n).map (fun t => (t, columnNatPerfect perfect t)))).map + (Sum.map (List.map (columnNatLabel label hn)) (columnNatLabel label hn)) + +theorem shortColumnChunks_entries (label : Fin n → α) (hn : 0 < n) + (perfect : Finset (Fin n)) (s : ℕ) : + columnChunkEntries (shortColumnChunks label hn perfect s) = + (columnPositionEntries perfect).map (fun p => (label p.1, p.2)) := by + rw [shortColumnChunks, columnChunkEntries_map, shortPerfectColumnChunks_entries] + simp only [Function.comp_def, range_map_eq_ofFn, columnNatLabel_fin, + columnNatPerfect_fin, columnPositionEntries, List.map_ofFn] + +/-- The short blocks used by the decoder are actual intervals, all of +length at most `s`. Their count and total length satisfy the original +position budgets, before any quotient geometry is used. -/ +theorem shortColumnChunks_blocks (label : Fin n → α) (hn : 0 < n) + (perfect : Finset (Fin n)) (s : ℕ) (hs : 0 < s) : + ∃ blocks : List (ℕ × ℕ), + (shortColumnChunks label hn perfect s).filterMap (Sum.elim some (fun _ => none)) = + blocks.map (fun b => blockLabelList (columnNatLabel label hn) b.1 b.2) ∧ + (blocks.map Prod.snd).sum ≤ n ∧ + blocks.length ≤ n / s + ((columnPositionEntries perfect).filter (fun p => !p.2)).length + 1 ∧ + ∀ b ∈ blocks, b.1 + b.2 ≤ n ∧ b.2 ≤ s ∧ + ∀ t ∈ intervalPositions b, columnNatPerfect perfect t = true := by + let entries := (List.range n).map (fun t => (t, columnNatPerfect perfect t)) + let chunks := shortPerfectColumnChunks s entries + obtain ⟨blocks, hblocks, hcount, hsum, hvalid⟩ := + shortPerfectColumnChunks_interval_family n s (columnNatPerfect perfect) + refine ⟨blocks, ?_, hsum, ?_, ?_⟩ + · change (chunks.map (Sum.map (List.map (columnNatLabel label hn)) (columnNatLabel label hn))).filterMap _ = _ + rw [mapped_pieces_regular, ← hblocks, List.map_map] + simp only [intervalPositions, blockLabelList, List.map_map, Function.comp_def] + · have hc := shortPerfectColumnChunks_count s entries + rw [← hcount] at hc + have hflags : (entries.filter (fun p => !p.2)).length = + ((columnPositionEntries perfect).filter (fun p => !p.2)).length := by + have he : entries = (columnPositionEntries perfect).map (fun p => (p.1.val, p.2)) := by + simp only [entries, range_map_eq_ofFn, columnNatPerfect_fin, columnPositionEntries, List.map_ofFn, Function.comp_def] + rw [he, List.filter_map, List.length_map] + rfl + have he : entries.length = n := by simp only [entries, List.length_map, List.length_range] + simpa only [he, hflags] using hc + · intro b hb + refine ⟨(hvalid b hb).1, ?_, (hvalid b hb).2⟩ + have hm : intervalPositions b ∈ chunks.filterMap (Sum.elim some (fun _ => none)) := by + rw [← hblocks] + exact List.mem_map.mpr ⟨b, hb, rfl⟩ + obtain ⟨piece, hp, he⟩ := List.mem_filterMap.mp hm + have hi : Sum.inl (intervalPositions b) ∈ chunks := by + cases piece with + | inl block => cases he; exact hp + | inr a => simp at he + have hl := shortPerfectColumnChunks_regular_size s hs entries (intervalPositions b) hi + simpa only [intervalPositions, List.length_map, List.length_range] using hl + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ShortSumSampling.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShortSumSampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee085d49638e8ac8f713f1f5de88f1f09564ef63 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ShortSumSampling.lean @@ -0,0 +1,175 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ProgressionFourier + +namespace OAI + +/-! +# Sampling the published short-interval estimate + +For integral short lengths, a moving short sum is constant on each unit +cell of its origin. Thus its published integral controls the actual finite +sum of integer origins, with outer cutoff `Y+1`. The progression restriction +is an average of fixed frequencies and has total coefficient mass one. +-/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +lemma shortExponentialSum_on_unit_cell (b : ℕ → ℂ) (D : ℕ) (α : ℝ) + (v : ℕ) {y : ℝ} (hy : y ∈ Set.Ico (v : ℝ) (v + 1)) : + shortExponentialSum b D α y = shortExponentialSum b D α v := by + have hy0 : 0 ≤ y := (Nat.cast_nonneg v).trans hy.1 + have hf := Nat.floor_eq_on_Ico v y hy + unfold shortExponentialSum + rw [Nat.floor_add_natCast hy0, hf, Nat.floor_natCast, + Nat.floor_add_natCast (Nat.cast_nonneg v) D, Nat.floor_natCast] + +lemma shortExponentialSum_unit_integrable (b : ℕ → ℂ) (D : ℕ) (α : ℝ) (v : ℕ) : + IntervalIntegrable (fun y => ‖shortExponentialSum b D α y‖) + volume (v : ℝ) (v + 1) := by + apply (intervalIntegrable_const : IntervalIntegrable + (fun _ : ℝ => ‖shortExponentialSum b D α v‖) volume (v : ℝ) (v + 1)).congr_uIoo + intro y hy + rw [Set.uIoo_of_le (by linarith : (v : ℝ) ≤ v + 1)] at hy + exact congrArg norm (shortExponentialSum_on_unit_cell b D α v ⟨hy.1.le, hy.2⟩).symm + +lemma integral_shortExponentialSum_unit (b : ℕ → ℂ) (D : ℕ) (α : ℝ) (v : ℕ) : + (∫ y in (v : ℝ)..(v + 1), ‖shortExponentialSum b D α y‖) = + ‖shortExponentialSum b D α v‖ := by + calc + _ = ∫ _y in (v : ℝ)..(v + 1), ‖shortExponentialSum b D α v‖ := by + apply intervalIntegral.integral_congr_Ioo_of_le (by linarith) + intro y hy + exact congrArg norm (shortExponentialSum_on_unit_cell b D α v ⟨hy.1.le, hy.2⟩) + _ = _ := by simp + +/-- Exact unit-cell decomposition, with no endpoint error. -/ +theorem shortExponentialIntegral_eq_sum (b : ℕ → ℂ) (X D : ℕ) (α : ℝ) : + shortExponentialIntegral b X D α = + ∑ v ∈ range X, ‖shortExponentialSum b D α v‖ := by + unfold shortExponentialIntegral + symm + calc + _ = ∑ v ∈ range X, ∫ y in (v : ℝ)..((v + 1 : ℕ) : ℝ), + ‖shortExponentialSum b D α y‖ := by + apply sum_congr rfl + intro v _ + simpa only [Nat.cast_add, Nat.cast_one] using + (integral_shortExponentialSum_unit b D α v).symm + _ = _ := by + simpa only [Nat.cast_zero] using + (intervalIntegral.sum_integral_adjacent_intervals + (a := fun n : ℕ => (n : ℝ)) (n := X) + (fun v _ => by simpa only [Nat.cast_add, Nat.cast_one] using + shortExponentialSum_unit_integrable b D α v)) + +/-- The positive integer origins used in the manuscript occupy all but +the first unit cell of the published integral. -/ +theorem sum_positive_shortExponentialSum_le (b : ℕ → ℂ) (Y D : ℕ) (α : ℝ) : + (∑ v ∈ range Y, ‖shortExponentialSum b D α (v + 1 : ℕ)‖) ≤ + shortExponentialIntegral b (Y + 1) D α := by + rw [shortExponentialIntegral_eq_sum, sum_range_succ'] + exact le_add_of_nonneg_right (norm_nonneg _) + +lemma sum_Icc_shift (f : ℕ → ℂ) (v D : ℕ) : + (∑ n ∈ Icc (v + 1) (v + D), f n) = ∑ m ∈ range D, f (v + m + 1) := by + symm + apply sum_bij (fun m _ => v + m + 1) + · intro m hm + simp only [mem_range] at hm + simp only [mem_Icc] + omega + · intro m hm n hn he + omega + · intro n hn + simp only [mem_Icc] at hn + refine ⟨n - (v + 1), ?_, ?_⟩ + · simp only [mem_range] + omega + · omega + · intro m _ + rfl + +lemma shortExponentialSum_at_nat (b : ℕ → ℂ) (D v : ℕ) (α : ℝ) : + shortExponentialSum b D α v = + ∑ n ∈ Icc (v + 1) (v + D), b n * additiveCharacter α n := by + simp only [shortExponentialSum, Nat.floor_natCast, + Nat.floor_add_natCast (Nat.cast_nonneg v) D] + +lemma additiveCharacter_nat_add (α : ℝ) (m n : ℕ) : + additiveCharacter α (m + n) = additiveCharacter α m * additiveCharacter α n := by + unfold additiveCharacter + rw [← Complex.exp_add] + congr 1 + push_cast + ring + +lemma norm_additiveCharacter (α : ℝ) (n : ℕ) : ‖additiveCharacter α n‖ = 1 := by + exact Complex.norm_exp_ofReal_mul_I _ + +/-- The short Fourier polynomial indexed by increments `1,...,D`. -/ +noncomputable def shortWindowSum (b : ℕ → ℂ) (D : ℕ) (α : ℝ) (v : ℕ) : ℂ := + ∑ m ∈ range D, b (v + m + 1) * additiveCharacter α (m + 1) + +lemma shortExponentialSum_eq_window (b : ℕ → ℂ) (D v : ℕ) (α : ℝ) : + shortExponentialSum b D α v = additiveCharacter α v * shortWindowSum b D α v := by + rw [shortExponentialSum_at_nat, sum_Icc_shift] + unfold shortWindowSum + rw [mul_sum] + apply sum_congr rfl + intro m _ + rw [show v + m + 1 = v + (m + 1) by omega, additiveCharacter_nat_add] + ring + +lemma norm_shortExponentialSum_eq_window (b : ℕ → ℂ) (D v : ℕ) (α : ℝ) : + ‖shortExponentialSum b D α v‖ = ‖shortWindowSum b D α v‖ := by + rw [shortExponentialSum_eq_window, norm_mul, norm_additiveCharacter, one_mul] + +/-- A uniform fixed-frequency integral bound controls every progression +class of actual discrete windows, including nonunit classes. -/ +theorem progression_short_sum_from_integral (b : ℕ → ℂ) (D Y l : ℕ) + [NeZero l] (a : ZMod l) (α K : ℝ) + (hK : ∀ β : ℝ, shortExponentialIntegral b (Y + 1) D β ≤ K) : + (∑ v ∈ range Y, ‖∑ n ∈ Icc (v + 2) (v + 1 + D), + if (n : ZMod l) = a then b n * additiveCharacter α n else 0‖) ≤ K := by + calc + _ ≤ ∑ v ∈ range Y, (l : ℝ)⁻¹ * ∑ j : ZMod l, + ‖∑ n ∈ Icc (v + 2) (v + 1 + D), + b n * additiveCharacter (α + (j.val : ℝ) / l) n‖ := + sum_le_sum (fun v _ => norm_progression_fourier_le _ b l a α) + _ = (l : ℝ)⁻¹ * ∑ j : ZMod l, ∑ v ∈ range Y, + ‖shortExponentialSum b D (α + (j.val : ℝ) / l) (v + 1 : ℕ)‖ := by + rw [← mul_sum, sum_comm] + congr 1 + apply sum_congr rfl + intro j _ + apply sum_congr rfl + intro v _ + rw [shortExponentialSum_at_nat] + _ ≤ (l : ℝ)⁻¹ * ∑ _j : ZMod l, K := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact sum_le_sum (fun j _ => + (sum_positive_shortExponentialSum_le b Y D _).trans (hK _)) + _ = K := by + simp only [sum_const, card_univ, ZMod.card, nsmul_eq_mul] + have hl : (l : ℝ) ≠ 0 := by exact_mod_cast NeZero.ne l + field_simp + +/-- Published MRT Theorem 1.3 applied to the actual progression windows. -/ +theorem MRTLiouvilleShortInput.progression_integer_windows + (hMRT : MRTLiouvilleShortInput) : + ∃ C : ℝ, 0 < C ∧ ∀ (Y D l : ℕ), 10 ≤ D → D ≤ Y + 1 → + ∀ [NeZero l] (a : ZMod l) (α : ℝ), + (∑ v ∈ range Y, ‖∑ n ∈ Icc (v + 2) (v + 1 + D), + if (n : ZMod l) = a then liouville n * additiveCharacter α n else 0‖) ≤ + C * (D : ℝ) * (Y + 1 : ℕ) * mrtShortError (Y + 1) D := by + obtain ⟨C, hC, hbound⟩ := hMRT + refine ⟨C, hC, ?_⟩ + intro Y D l hD hDY _ a α + exact progression_short_sum_from_integral liouville D Y l a α _ + (fun β => hbound (Y + 1) D hD hDY β) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveBoundary.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveBoundary.lean new file mode 100644 index 0000000000000000000000000000000000000000..b19e374b606991f90f4e840c6a20e6dd132bcccb --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveBoundary.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveModel +import Mathlib.Data.Nat.Choose.Bounds + +namespace OAI + +/-! Explicit accumulation of the finitely many CRT counting errors. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma elementarySymmetric_crude {ι : Type*} (P : Finset ι) (a : ι → ℝ) + (Y : ℝ) (hY : 0 ≤ Y) (ha : ∀ i ∈ P, 0 ≤ a i ∧ a i ≤ Y) (j : ℕ) : + elementarySymmetric P a j ≤ ((P.card : ℝ) * Y) ^ j := by + calc + _ ≤ ∑ _S ∈ P.powersetCard j, Y ^ j := by + apply sum_le_sum + intro S hS + obtain ⟨hSP, hcard⟩ := mem_powersetCard.mp hS + have hh : (∏ i ∈ S, a i) ≤ ∏ _i ∈ S, Y := by + exact prod_le_prod₀ (fun i hi => (ha i (hSP hi)).1) + (fun i hi => (ha i (hSP hi)).2) + simpa only [prod_const, hcard] using hh + _ = (P.card.choose j : ℝ) * Y ^ j := by + simp only [sum_const, card_powersetCard, nsmul_eq_mul] + _ ≤ (P.card : ℝ) ^ j * Y ^ j := by + apply mul_le_mul_of_nonneg_right _ (pow_nonneg hY j) + exact_mod_cast Nat.choose_le_pow P.card j + _ = _ := (mul_pow _ _ _).symm + +lemma truncatedElementary_crude {ι : Type*} (P : Finset ι) (a : ι → ℝ) + (Y : ℝ) (hY : 0 ≤ Y) (ha : ∀ i ∈ P, 0 ≤ a i ∧ a i ≤ Y) (R : ℕ) : + (∑ j ∈ range (R + 1), elementarySymmetric P a j) ≤ + (R + 1 : ℕ) * ((P.card : ℝ) * Y + 1) ^ R := by + have hb : 1 ≤ (P.card : ℝ) * Y + 1 := by + linarith [show 0 ≤ (P.card : ℝ) * Y by positivity] + calc + _ ≤ ∑ _j ∈ range (R + 1), ((P.card : ℝ) * Y + 1) ^ R := by + apply sum_le_sum + intro j hj + calc + _ ≤ ((P.card : ℝ) * Y) ^ j := elementarySymmetric_crude P a Y hY ha j + _ ≤ ((P.card : ℝ) * Y + 1) ^ j := by gcongr; linarith + _ ≤ ((P.card : ℝ) * Y + 1) ^ R := + pow_le_pow_right₀ hb (Nat.le_of_lt_succ (mem_range.mp hj)) + _ = _ := by simp only [sum_const, card_range, nsmul_eq_mul] + +lemma sieveIntersectionError_factor {ι : Type*} (P : Finset ι) (a : ι → ℝ) + (C : ℝ) (N R : ℕ) : + sieveIntersectionError P (fun S => C / N * ∏ i ∈ S, a i) R = + C / N * ∑ j ∈ range (R + 1), elementarySymmetric P a j := by + simp only [sieveIntersectionError, elementarySymmetric, mul_sum] + +/-- If an intersection indexed by `S` has normalized CRT error at most +`C * (∏ i∈S, a i) / N`, the whole finite truncation costs this explicit +quantity. In the application `a i` is the selected prime and `C=1` or `3`. -/ +theorem sieveIntersectionError_crude {ι : Type*} (P : Finset ι) (a : ι → ℝ) + (Y C : ℝ) (hY : 0 ≤ Y) (hC : 0 ≤ C) + (ha : ∀ i ∈ P, 0 ≤ a i ∧ a i ≤ Y) (N R : ℕ) : + sieveIntersectionError P (fun S => C / N * ∏ i ∈ S, a i) R ≤ + C / N * (R + 1 : ℕ) * ((P.card : ℝ) * Y + 1) ^ R := by + rw [sieveIntersectionError_factor] + exact (mul_le_mul_of_nonneg_left (truncatedElementary_crude P a Y hY ha R) + (div_nonneg hC (Nat.cast_nonneg N))).trans_eq (by ring) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveBoundaryScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveBoundaryScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..a7960d80c78ce5efb10af7667e1f509bb3a40c0f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveBoundaryScale.lean @@ -0,0 +1,110 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveScale + +namespace OAI + +/-! Explicit accounting for the finite CRT boundary term. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma sieve_boundary_numerator (X T C C₀ B : ℝ) (R : ℕ) + (hX : 1 ≤ X) (hT : 1 ≤ T) (hC : 0 ≤ C) (hC₀ : 0 ≤ C₀) + (hB : 0 ≤ B) (hBexp : B ≤ Real.exp (3 * X)) (hR : (R : ℝ) ≤ C * T) : + C₀ * (R + 1 : ℕ) * B ^ R ≤ Real.exp ((C₀ + 4 * C) * X * T) := by + have hXT : 1 ≤ X * T := by nlinarith + have hpow : B ^ R ≤ Real.exp ((R : ℝ) * (3 * X)) := by + rw [Real.exp_nat_mul] + exact pow_le_pow_left₀ hB hBexp R + have hRexp : (R + 1 : ℕ) ≤ Real.exp (R : ℝ) := by + exact_mod_cast Real.add_one_le_exp (R : ℝ) + have hCexp : C₀ ≤ Real.exp C₀ := by linarith [Real.add_one_le_exp C₀] + calc + _ ≤ Real.exp C₀ * Real.exp (R : ℝ) * Real.exp ((R : ℝ) * (3 * X)) := by + gcongr + _ = Real.exp (C₀ + (R : ℝ) + (R : ℝ) * (3 * X)) := by + rw [← Real.exp_add, ← Real.exp_add] + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have h₀ : C₀ ≤ C₀ * (X * T) := by nlinarith + have h₁ : (R : ℝ) ≤ C * X * T := by + have hh := mul_le_mul_of_nonneg_left hX (mul_nonneg hC (by linarith : 0 ≤ T)) + nlinarith + have h₂ := mul_le_mul_of_nonneg_right hR (show 0 ≤ 3 * X by linarith) + nlinarith + +lemma sieve_base_le_exp (X Y n : ℝ) (hX : 1 ≤ X) + (hY : 0 ≤ Y) (_hn : 0 ≤ n) (hnY : n ≤ Y) (hYexp : Y ≤ Real.exp X) : + n * Y + 1 ≤ Real.exp (3 * X) := by + have he : 2 ≤ Real.exp X := by linarith [Real.add_one_le_exp X] + have he₂ : 1 ≤ Real.exp (2 * X) := Real.one_le_exp (by linarith) + calc + _ ≤ Real.exp X * Real.exp X + 1 := by + gcongr + exact hnY.trans hYexp + _ = Real.exp (2 * X) + 1 := by rw [← Real.exp_add]; congr 2; ring + _ ≤ Real.exp (2 * X) * Real.exp X := by nlinarith + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +/-- Uniformly in the modulus cutoff, number of moduli and logarithmic +truncation order, the literal finite boundary term is `O(L^-100)`. -/ +theorem eventually_sieve_boundary_cost (C C₀ : ℝ) (hC : 0 ≤ C) (hC₀ : 0 ≤ C₀) : + ∀ᶠ L : ℝ in atTop, ∀ (Y n : ℝ) (N R : ℕ), + 0 ≤ Y → 0 ≤ n → n ≤ Y → Y ≤ Real.exp (L ^ (99 / 100 : ℝ)) → + (R : ℝ) ≤ C * Real.log L → + (1 / 2 : ℝ) * Real.exp (L ^ (199 / 200 : ℝ)) ≤ N → + C₀ / (N : ℝ) * (R + 1 : ℕ) * (n * Y + 1) ^ R ≤ L ^ (-100 : ℝ) := by + have hK : 0 ≤ C₀ + 4 * C + 1 := by positivity + filter_upwards [eventually_ge_atTop (Real.exp 1), + eventually_sieve_boundary_exponent (C₀ + 4 * C + 1) hK] with L hL hsmall + intro Y n N R hY hn hnY hYexp hR hN + have hL₁ : 1 ≤ L := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hL + have hLp : 0 < L := zero_lt_one.trans_le hL₁ + have hlog : 1 ≤ Real.log L := by + rw [← Real.log_exp 1] + exact Real.log_le_log (Real.exp_pos 1) hL + have hX : 1 ≤ L ^ (99 / 100 : ℝ) := Real.one_le_rpow hL₁ (by norm_num) + have hXT : 1 ≤ L ^ (99 / 100 : ℝ) * Real.log L := by nlinarith + have hnum := sieve_boundary_numerator (L ^ (99 / 100 : ℝ)) (Real.log L) C C₀ + (n * Y + 1) R hX hlog hC hC₀ (by positivity) + (sieve_base_le_exp _ _ _ hX hY hn hnY hYexp) hR + have hNp : (0 : ℝ) < N := lt_of_lt_of_le (by positivity) hN + have hdiv : (1 / (N : ℝ)) ≤ 2 * Real.exp (-(L ^ (199 / 200 : ℝ))) := by + apply (div_le_iff₀ hNp).mpr + have hh := mul_le_mul_of_nonneg_left hN + (show 0 ≤ 2 * Real.exp (-(L ^ (199 / 200 : ℝ))) by positivity) + have hc : (2 * Real.exp (-(L ^ (199 / 200 : ℝ)))) * + ((1 / 2 : ℝ) * Real.exp (L ^ (199 / 200 : ℝ))) = 1 := by + calc + _ = Real.exp (-(L ^ (199 / 200 : ℝ))) * + Real.exp (L ^ (199 / 200 : ℝ)) := by ring + _ = 1 := by rw [← Real.exp_add, neg_add_cancel, Real.exp_zero] + rw [hc] at hh + nlinarith only [hh] + calc + _ = (C₀ * (R + 1 : ℕ) * (n * Y + 1) ^ R) * (1 / (N : ℝ)) := by ring + _ ≤ Real.exp ((C₀ + 4 * C) * L ^ (99 / 100 : ℝ) * Real.log L) * + (2 * Real.exp (-(L ^ (199 / 200 : ℝ)))) := by gcongr + _ ≤ Real.exp (L ^ (99 / 100 : ℝ) * Real.log L) * + Real.exp ((C₀ + 4 * C) * L ^ (99 / 100 : ℝ) * Real.log L) * + Real.exp (-(L ^ (199 / 200 : ℝ))) := by + have he : 2 ≤ Real.exp (L ^ (99 / 100 : ℝ) * Real.log L) := by + linarith [Real.add_one_le_exp (L ^ (99 / 100 : ℝ) * Real.log L)] + calc + _ = 2 * (Real.exp ((C₀ + 4 * C) * L ^ (99 / 100 : ℝ) * Real.log L) * + Real.exp (-(L ^ (199 / 200 : ℝ)))) := by ring + _ ≤ Real.exp (L ^ (99 / 100 : ℝ) * Real.log L) * + (Real.exp ((C₀ + 4 * C) * L ^ (99 / 100 : ℝ) * Real.log L) * + Real.exp (-(L ^ (199 / 200 : ℝ)))) := + mul_le_mul_of_nonneg_right he (by positivity) + _ = _ := by ring + _ = Real.exp ((C₀ + 4 * C + 1) * L ^ (99 / 100 : ℝ) * Real.log L - + L ^ (199 / 200 : ℝ)) := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + _ ≤ _ := hsmall + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveCRT.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveCRT.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f569044d16f4988a32f6455840c2679f2353d88 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveCRT.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveModel +import OAI.NumberTheory.TwoPoint.Bounds.ResidueBox + +namespace OAI + +/-! Exact CRT factorization of the one- and three-variable local sieve +models. The interval/box errors are kept separate in `ResidueBox`. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma FiniteLaw.probability_equiv {α β : Type*} [Fintype α] [Fintype β] + (μ : FiniteLaw α) (ν : FiniteLaw β) (e : α ≃ β) + (hweight : ∀ x, μ.weight x = ν.weight (e x)) (E : β → Prop) : + μ.probability (fun x => E (e x)) = ν.probability E := by + unfold FiniteLaw.probability FiniteLaw.average + simp_rw [hweight] + exact e.sum_comp (fun y => ν.weight y * if E y then 1 else 0) + +noncomputable def sieveCubeCRT {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) : + (ZMod (∏ i, s i) × ZMod (∏ i, s i) × ZMod (∏ i, s i)) ≃ + (∀ i, ZMod (s i) × ZMod (s i) × ZMod (s i)) where + toFun x i := (ZMod.prodEquivPi s hcop x.1 i, + ZMod.prodEquivPi s hcop x.2.1 i, ZMod.prodEquivPi s hcop x.2.2 i) + invFun y := ((ZMod.prodEquivPi s hcop).symm (fun i => (y i).1), + (ZMod.prodEquivPi s hcop).symm (fun i => (y i).2.1), + (ZMod.prodEquivPi s hcop).symm (fun i => (y i).2.2)) + left_inv x := by + apply Prod.ext + · exact (ZMod.prodEquivPi s hcop).symm_apply_apply x.1 + · apply Prod.ext + · exact (ZMod.prodEquivPi s hcop).symm_apply_apply x.2.1 + · exact (ZMod.prodEquivPi s hcop).symm_apply_apply x.2.2 + right_inv y := by + funext i + apply Prod.ext + · exact congrFun ((ZMod.prodEquivPi s hcop).apply_symm_apply (fun i => (y i).1)) i + · apply Prod.ext + · exact congrFun ((ZMod.prodEquivPi s hcop).apply_symm_apply (fun i => (y i).2.1)) i + · exact congrFun ((ZMod.prodEquivPi s hcop).apply_symm_apply (fun i => (y i).2.2)) i + +lemma uniformZModLaw_crt_weight {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) (x : ZMod (∏ i, s i)) : + (uniformZModLaw (∏ i, s i)).weight x = + (FiniteLaw.dependentIndependent (fun i => uniformZModLaw (s i))).weight + (ZMod.prodEquivPi s hcop x) := by + simp [uniformZModLaw, FiniteLaw.dependentIndependent, one_div, + prod_inv_distrib, Nat.cast_prod] + +lemma uniformCube_crt_weight {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (x : ZMod (∏ i, s i) × ZMod (∏ i, s i) × ZMod (∏ i, s i)) : + (uniformResidueCubeLaw (∏ i, s i)).weight x = + (FiniteLaw.dependentIndependent (fun i => uniformResidueCubeLaw (s i))).weight + (sieveCubeCRT s hcop x) := by + simp only [uniformResidueCubeLaw, FiniteLaw.product, uniformZModLaw, + FiniteLaw.dependentIndependent, prod_mul_distrib, one_div, prod_inv_distrib, Nat.cast_prod] + +/-- CRT evaluates an intersection of one-variable local conditions exactly. -/ +theorem sieveCRT_one_probability {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (E : ∀ i, ZMod (s i) → Prop) : + (uniformZModLaw (∏ i, s i)).probability + (fun x => ∀ i, E i (ZMod.prodEquivPi s hcop x i)) = + ∏ i, (uniformZModLaw (s i)).probability (E i) := by + calc + _ = (FiniteLaw.dependentIndependent (fun i => uniformZModLaw (s i))).probability + (fun x => ∀ i, E i (x i)) := + FiniteLaw.probability_equiv _ _ (ZMod.prodEquivPi s hcop).toEquiv + (uniformZModLaw_crt_weight s hcop) (fun x => ∀ i, E i (x i)) + _ = _ := FiniteLaw.dependentIndependent_probability_all + (fun i => uniformZModLaw (s i)) E + +/-- CRT evaluates an intersection of local three-variable conditions +exactly, retaining the dependence among the forms at each individual prime. -/ +theorem sieveCRT_cube_probability {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (E : ∀ i, (ZMod (s i) × ZMod (s i) × ZMod (s i)) → Prop) : + (uniformResidueCubeLaw (∏ i, s i)).probability + (fun x => ∀ i, E i (sieveCubeCRT s hcop x i)) = + ∏ i, (uniformResidueCubeLaw (s i)).probability (E i) := by + calc + _ = (FiniteLaw.dependentIndependent (fun i => uniformResidueCubeLaw (s i))).probability + (fun x => ∀ i, E i (x i)) := + FiniteLaw.probability_equiv _ _ (sieveCubeCRT s hcop) + (uniformCube_crt_weight s hcop) (fun x => ∀ i, E i (x i)) + _ = _ := FiniteLaw.dependentIndependent_probability_all + (fun i => uniformResidueCubeLaw (s i)) E + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveCutoffScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveCutoffScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..d8daa03eca0763b68c4bcb5926848d6d1d3b27a4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveCutoffScale.lean @@ -0,0 +1,96 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveGoldbachPairs +import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics + +namespace OAI + +/-! The integer power cutoff needed to absorb the finite sieve remainder. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma sieve_power_cutoff_log {x : ℝ} (hx : 1 ≤ x) + (hlog : 16 * Real.log 2 ≤ Real.log x) (hlarge : 4 ≤ x ^ (1 / 8 : ℝ)) : + let z := ⌊x ^ (1 / 8 : ℝ)⌋₊ + 2 ≤ z ∧ (z : ℝ) ≤ x ^ (1 / 8 : ℝ) ∧ + Real.log x / 16 ≤ Real.log z ∧ Real.log z ≤ Real.log x := by + let y := x ^ (1 / 8 : ℝ) + let z := ⌊y⌋₊ + have hx0 : 0 < x := by linarith + have hy0 : 0 < y := Real.rpow_pos_of_pos hx0 _ + have hz2 : 2 ≤ z := (Nat.le_floor_iff hy0.le).mpr (by dsimp [y]; linarith) + have hz0 : (0 : ℝ) < z := by exact_mod_cast (show 0 < z by omega) + have hzy : (z : ℝ) ≤ y := Nat.floor_le hy0.le + have hyz : y / 2 ≤ (z : ℝ) := by + have hf := Nat.lt_floor_add_one y + change y < (z : ℝ) + 1 at hf + dsimp [y] at * + linarith + have hlow := Real.log_le_log (div_pos hy0 (by norm_num)) hyz + rw [Real.log_div hy0.ne' (by norm_num), show Real.log y = (1 / 8 : ℝ) * Real.log x from + Real.log_rpow hx0 _] at hlow + have hyx : y ≤ x := Real.rpow_le_self_of_one_le hx (by norm_num) + exact ⟨hz2, hzy, by linarith, Real.log_le_log hz0 (hzy.trans hyx)⟩ + +lemma sieve_power_cutoff_error {x : ℝ} {z : ℕ} (hx : 1 ≤ x) + (hlog : 1 ≤ Real.log x) (hz : (z : ℝ) ≤ x ^ (1 / 8 : ℝ)) + (hzlog : Real.log z ≤ Real.log x) (hzlog0 : 0 ≤ Real.log z) + (hsmall : Real.log x ^ 6 ≤ (1 / 32 : ℝ) * x ^ (1 / 2 : ℝ)) : + (z : ℝ) ^ 2 * (1 + Real.log z) ^ 4 + 2 * z ≤ x / Real.log x ^ 2 := by + have hx0 : 0 < x := by linarith + have hy1 : 1 ≤ x ^ (1 / 8 : ℝ) := Real.one_le_rpow hx (by norm_num) + have hy0 : 0 ≤ x ^ (1 / 8 : ℝ) := (zero_le_one.trans hy1) + have hz2 := pow_le_pow_left₀ (Nat.cast_nonneg z) hz 2 + have hlogs := pow_le_pow_left₀ (by linarith : 0 ≤ 1 + Real.log z) + (show 1 + Real.log z ≤ 2 * Real.log x by linarith) 4 + have h6 : Real.log x ^ 2 ≤ Real.log x ^ 6 := pow_le_pow_right₀ hlog (by norm_num) + have hy2 : x ^ (1 / 8 : ℝ) ≤ (x ^ (1 / 8 : ℝ)) ^ 2 := by nlinarith + have hterm : (z : ℝ) ^ 2 * (1 + Real.log z) ^ 4 + 2 * z ≤ + (x ^ (1 / 8 : ℝ)) ^ 2 * (16 * Real.log x ^ 4 + 2) := by + have hp := mul_le_mul hz2 hlogs (by positivity) (by positivity) + nlinarith + have hpoly : (16 * Real.log x ^ 4 + 2) * Real.log x ^ 2 ≤ 18 * Real.log x ^ 6 := by + nlinarith + have hpow : (x ^ (1 / 8 : ℝ)) ^ 2 * x ^ (1 / 2 : ℝ) = x ^ (3 / 4 : ℝ) := by + rw [← Real.rpow_mul_natCast hx0.le, ← Real.rpow_add hx0] + norm_num + apply (le_div_iff₀ (sq_pos_of_pos (by linarith : 0 < Real.log x))).mpr + calc + _ ≤ ((x ^ (1 / 8 : ℝ)) ^ 2 * (16 * Real.log x ^ 4 + 2)) * Real.log x ^ 2 := + mul_le_mul_of_nonneg_right hterm (sq_nonneg _) + _ = (x ^ (1 / 8 : ℝ)) ^ 2 * ((16 * Real.log x ^ 4 + 2) * Real.log x ^ 2) := by ring + _ ≤ (x ^ (1 / 8 : ℝ)) ^ 2 * (18 * Real.log x ^ 6) := + mul_le_mul_of_nonneg_left hpoly (sq_nonneg _) + _ ≤ (x ^ (1 / 8 : ℝ)) ^ 2 * (18 * ((1 / 32 : ℝ) * x ^ (1 / 2 : ℝ))) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hsmall (by norm_num)) (sq_nonneg _) + _ = (18 / 32 : ℝ) * x ^ (3 / 4 : ℝ) := by rw [← hpow]; ring + _ ≤ x ^ (3 / 4 : ℝ) := by nlinarith [Real.rpow_nonneg hx0.le (3 / 4 : ℝ)] + _ ≤ x := Real.rpow_le_self_of_one_le hx (by norm_num) + +theorem sieve_power_cutoff_eventually (A : ℝ) : + ∀ᶠ x : ℝ in atTop, 1 ≤ x ∧ 1 ≤ Real.log x ∧ + let z := ⌊x ^ (1 / 8 : ℝ)⌋₊ + 2 ≤ z ∧ A ≤ Real.log z ∧ Real.log x ≤ 16 * Real.log z ∧ + (z : ℝ) ^ 2 * (1 + Real.log z) ^ 4 + 2 * z ≤ x / Real.log x ^ 2 := by + have hl := Real.tendsto_log_atTop.eventually + (eventually_ge_atTop (max 1 (max (16 * A) (16 * Real.log 2)))) + have hy := (tendsto_rpow_atTop (by norm_num : (0 : ℝ) < 1 / 8)).eventually + (eventually_ge_atTop (4 : ℝ)) + have hs := (isLittleO_log_rpow_rpow_atTop (6 : ℝ) + (by norm_num : (0 : ℝ) < 1 / 2)).bound (by norm_num : (0 : ℝ) < 1 / 32) + filter_upwards [eventually_ge_atTop (1 : ℝ), hl, hy, hs] with x hx hl hy hs + have hlog : 1 ≤ Real.log x := (le_max_left _ _).trans hl + have hA : 16 * A ≤ Real.log x := (le_max_left _ _).trans ((le_max_right _ _).trans hl) + have h2 : 16 * Real.log 2 ≤ Real.log x := (le_max_right _ _).trans ((le_max_right _ _).trans hl) + obtain ⟨hz, hzx, hlow, hhigh⟩ := sieve_power_cutoff_log hx h2 hy + have hsmall : Real.log x ^ 6 ≤ (1 / 32 : ℝ) * x ^ (1 / 2 : ℝ) := by + rw [show Real.log x ^ (6 : ℝ) = Real.log x ^ (6 : ℕ) from Real.rpow_natCast _ _] at hs + simpa only [Real.norm_of_nonneg (by positivity : 0 ≤ Real.log x ^ (6 : ℕ)), + Real.norm_of_nonneg (Real.rpow_nonneg (by linarith : 0 ≤ x) (1 / 2 : ℝ))] using hs + refine ⟨hx, hlog, hz, by linarith, by linarith, ?_⟩ + exact sieve_power_cutoff_error hx hlog hzx hhigh + (Real.log_nonneg (by exact_mod_cast (show 1 ≤ ⌊x ^ (1 / 8 : ℝ)⌋₊ by omega))) hsmall + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveDivisorAverage.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveDivisorAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..821c268f276f0f130ea88e9abe7eccb3849c5c9d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveDivisorAverage.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTPrimeSquareMean +import Mathlib.Analysis.PSeries + +namespace OAI + +/-! Averaging a nonnegative divisor sum by counting its multiples. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma sieve_divisors_filter {N n : ℕ} (hn : 0 < n) (hnN : n ≤ N) : + n.divisors = (Icc 1 N).filter (fun d => d ∣ n) := by + ext d + constructor + · intro hd + obtain ⟨hdn, _⟩ := Nat.mem_divisors.mp hd + exact mem_filter.mpr ⟨mem_Icc.mpr + ⟨Nat.pos_of_mem_divisors hd, (Nat.le_of_dvd hn hdn).trans hnN⟩, hdn⟩ + · intro hd + exact Nat.mem_divisors.mpr ⟨(mem_filter.mp hd).2, hn.ne'⟩ + +theorem sieve_divisor_sum_average (N : ℕ) (a : ℕ → ℝ) + (ha : ∀ d, 0 ≤ a d) : + (∑ n ∈ Icc 1 N, ∑ d ∈ n.divisors, a d) ≤ + (N : ℝ) * ∑ d ∈ Icc 1 N, a d / d := by + calc + _ = ∑ n ∈ Icc 1 N, ∑ d ∈ Icc 1 N, if d ∣ n then a d else 0 := by + apply sum_congr rfl + intro n hn + rw [sieve_divisors_filter (mem_Icc.mp hn).1 (mem_Icc.mp hn).2, sum_filter] + _ = ∑ d ∈ Icc 1 N, ∑ n ∈ Icc 1 N, if d ∣ n then a d else 0 := sum_comm + _ = ∑ d ∈ Icc 1 N, a d * ((N / d : ℕ) : ℝ) := by + apply sum_congr rfl + intro d hd + have hc := mrt_count_multiples (N := N) (mem_Icc.mp hd).1 + rw [show (∑ n ∈ Icc 1 N, if d ∣ n then a d else 0) = + a d * (∑ n ∈ Icc 1 N, if d ∣ n then (1 : ℝ) else 0) by + rw [mul_sum] + apply sum_congr rfl + intro n _ + split_ifs <;> simp] + rw [hc] + _ ≤ ∑ d ∈ Icc 1 N, a d * ((N : ℝ) / d) := by + apply sum_le_sum + intro d _ + exact mul_le_mul_of_nonneg_left Nat.cast_div_le (ha d) + _ = _ := by + rw [mul_sum] + apply sum_congr rfl + intro d _ + ring + +lemma sieve_inverse_sqrt_div {d : ℕ} (hd : 0 < d) : + (1 / Real.sqrt (d : ℝ)) / d = (d : ℝ) ^ (-(3 / 2 : ℝ)) := by + have hdr : (0 : ℝ) < d := by exact_mod_cast hd + rw [div_div, Real.rpow_neg hdr.le, one_div, Real.sqrt_eq_rpow] + congr 1 + calc + (d : ℝ) ^ (1 / 2 : ℝ) * d = (d : ℝ) ^ (1 / 2 : ℝ) * (d : ℝ) ^ (1 : ℝ) := by rw [Real.rpow_one] + _ = (d : ℝ) ^ (3 / 2 : ℝ) := by rw [← Real.rpow_add hdr]; norm_num + +theorem sieve_inverse_sqrt_divisor_average (N : ℕ) : + (∑ n ∈ Icc 1 N, ∑ d ∈ n.divisors, 1 / Real.sqrt (d : ℝ)) ≤ + (N : ℝ) * (∑' d : ℕ, (d : ℝ) ^ (-(3 / 2 : ℝ))) := by + apply (sieve_divisor_sum_average N (fun d => 1 / Real.sqrt (d : ℝ)) (by intro d; positivity)).trans + apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg N) + calc + _ = ∑ d ∈ Icc 1 N, (d : ℝ) ^ (-(3 / 2 : ℝ)) := by + apply sum_congr rfl + intro d hd + exact sieve_inverse_sqrt_div (mem_Icc.mp hd).1 + _ ≤ _ := (Real.summable_nat_rpow.mpr (by norm_num : -(3 / 2 : ℝ) < -1)).sum_le_tsum _ + (fun d _ => Real.rpow_nonneg (Nat.cast_nonneg d) _) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveEulerLower.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveEulerLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..92febff29c1161144a910f3508dd25f0e7c7cda8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveEulerLower.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveGoldbachLocal +import OAI.NumberTheory.TwoPoint.Bounds.PrimeReciprocalTheorem + +namespace OAI + +/-! The required logarithmic Euler-product lower bound and singular factor. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def sieveEulerFactor (p : ℕ) : ℝ := (1 - 1 / (p : ℝ))⁻¹ + +noncomputable def sieveSingularFactor (N : ℕ) : ℝ := + ∏ p ∈ N.primeFactors, sieveEulerFactor p + +lemma sieve_euler_base_pos {p : ℕ} (hp : p.Prime) : 0 < 1 - 1 / (p : ℝ) := by + have hpR : (1 : ℝ) < p := by exact_mod_cast hp.one_lt + rw [sub_pos, div_lt_one (by positivity)] + exact hpR + +lemma sieve_euler_factor_pos {p : ℕ} (hp : p.Prime) : 0 < sieveEulerFactor p := + inv_pos.mpr (sieve_euler_base_pos hp) + +lemma sieve_euler_factor_one_le {p : ℕ} (hp : p.Prime) : 1 ≤ sieveEulerFactor p := by + unfold sieveEulerFactor + apply (one_le_inv₀ (sieve_euler_base_pos hp)).mpr + have : (0 : ℝ) ≤ 1 / (p : ℝ) := by positivity + linarith + +lemma sieve_euler_factor_exp {p : ℕ} (hp : p.Prime) : + Real.exp (1 / (p : ℝ)) ≤ sieveEulerFactor p := by + apply (Real.le_log_iff_exp_le (sieve_euler_factor_pos hp)).mp + rw [sieveEulerFactor, Real.log_inv] + linarith [Real.log_le_sub_one_of_pos (sieve_euler_base_pos hp)] + +lemma sieve_euler_product_exp (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) : + Real.exp (∑ p ∈ P, 1 / (p : ℝ)) ≤ ∏ p ∈ P, sieveEulerFactor p := by + rw [Real.exp_sum] + exact prod_le_prod₀ (fun _ _ => (Real.exp_pos _).le) + (fun p hp => sieve_euler_factor_exp (hP p hp)) + +lemma sieve_euler_product_log_lower : + ∃ c : ℝ, 0 < c ∧ ∀ y : ℝ, 2 ≤ y → + c * Real.log y ≤ ∏ p ∈ sievePrimesUpTo y, sieveEulerFactor p := by + obtain ⟨C, hC⟩ := primeReciprocalInput + refine ⟨Real.exp (-C), Real.exp_pos _, ?_⟩ + intro y hy + have hy1 : 1 < y := by linarith + have hlog : 0 < Real.log y := Real.log_pos hy1 + have hsum : Real.log (Real.log y) - C ≤ ∑ p ∈ sievePrimesUpTo y, 1 / (p : ℝ) := by + linarith [(abs_le.mp (hC y hy)).1] + calc + Real.exp (-C) * Real.log y = Real.exp (Real.log (Real.log y) - C) := by + rw [sub_eq_add_neg, Real.exp_add, Real.exp_log hlog] + ring + _ ≤ Real.exp (∑ p ∈ sievePrimesUpTo y, 1 / (p : ℝ)) := Real.exp_le_exp.mpr hsum + _ ≤ _ := sieve_euler_product_exp _ (sievePrimesUpTo_prime y) + +lemma sieve_singular_factor_pos (N : ℕ) : 0 < sieveSingularFactor N := by + apply prod_pos + intro p hp + exact sieve_euler_factor_pos (Nat.mem_primeFactors.mp hp).1 + +lemma sieve_singular_factor_one_le (N : ℕ) : 1 ≤ sieveSingularFactor N := by + apply one_le_prod₀ + intro p hp + exact sieve_euler_factor_one_le (Nat.mem_primeFactors.mp hp).1 + +lemma sieve_singular_correction_le {N : ℕ} (hN : N ≠ 0) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) : + (sieveSingularFactor N)⁻¹ ≤ ∏ p ∈ P, (if p ∣ N then 1 - 1 / (p : ℝ) else 1) := by + have hsub : P.filter (fun p => p ∣ N) ⊆ N.primeFactors := by + intro p hp + exact Nat.mem_primeFactors.mpr ⟨hP p (mem_filter.mp hp).1, (mem_filter.mp hp).2, hN⟩ + have he := prod_le_prod_of_subset_of_le_one₀ (f := fun p : ℕ => 1 - 1 / (p : ℝ)) hsub + (fun p hp => (sieve_euler_base_pos (Nat.mem_primeFactors.mp hp).1).le) + (fun p _ _ => by + have : (0 : ℝ) ≤ 1 / (p : ℝ) := by positivity + linarith) + simpa only [sieveSingularFactor, sieveEulerFactor, ← prod_inv_distrib, inv_inv, prod_filter] using he + +lemma sieve_goldbach_product_lower {N : ℕ} (hN : 2 ∣ N) (hN0 : N ≠ 0) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) : + (∏ p ∈ P, sieveEulerFactor p) ^ 2 / sieveSingularFactor N ≤ + ∏ p ∈ P, (1 + sieveGoldbachWeight N p) := by + have hnonneg : 0 ≤ (∏ p ∈ P, sieveEulerFactor p) ^ 2 := sq_nonneg _ + calc + _ ≤ (∏ p ∈ P, sieveEulerFactor p) ^ 2 * + (∏ p ∈ P, (if p ∣ N then 1 - 1 / (p : ℝ) else 1)) := by + rw [div_eq_mul_inv] + exact mul_le_mul_of_nonneg_left (sieve_singular_correction_le hN0 P hP) hnonneg + _ = ∏ p ∈ P, (sieveEulerFactor p ^ 2 * (if p ∣ N then 1 - 1 / (p : ℝ) else 1)) := by + rw [prod_mul_distrib, prod_pow] + _ ≤ _ := by + apply prod_le_prod₀ + · intro p hp + apply mul_nonneg (sq_nonneg _) + split_ifs + · exact (sieve_euler_base_pos (hP p hp)).le + · norm_num + · exact fun p hp => sieve_goldbach_factor_ge hN (hP p hp) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveEulerTruncation.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveEulerTruncation.lean new file mode 100644 index 0000000000000000000000000000000000000000..46f8c13698b4757bfb92209019014e138fed5fbe --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveEulerTruncation.lean @@ -0,0 +1,77 @@ +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Algebra.BigOperators.Group.Finset.Powerset +import Mathlib.Analysis.SpecialFunctions.Log.Basic + +namespace OAI + +/-! A finite Euler product retains at least half its mass below a cutoff +whenever its logarithmic moment is at most half that cutoff. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma sieve_euler_log_moment {ι : Type*} (S : Finset ι) (g ℓ : ι → ℝ) + (hg : ∀ p ∈ S, 0 ≤ g p) : + (∑ T ∈ S.powerset, (∏ p ∈ T, g p) * (∑ p ∈ T, ℓ p)) = + (∏ p ∈ S, (1 + g p)) * (∑ p ∈ S, g p / (1 + g p) * ℓ p) := by + classical + induction S using Finset.induction_on with + | empty => simp + | @insert a S ha ih => + have hga : 0 ≤ g a := hg a (mem_insert_self _ _) + have hgS : ∀ p ∈ S, 0 ≤ g p := fun p hp => hg p (mem_insert_of_mem hp) + have hne : 1 + g a ≠ 0 := by positivity + have hn (T : Finset ι) (hT : T ∈ S.powerset) : a ∉ T := + fun h => ha ((mem_powerset.mp hT) h) + have hins : + (∑ T ∈ S.powerset, (∏ p ∈ insert a T, g p) * (∑ p ∈ insert a T, ℓ p)) = + g a * ℓ a * (∏ p ∈ S, (1 + g p)) + + g a * ((∏ p ∈ S, (1 + g p)) * (∑ p ∈ S, g p / (1 + g p) * ℓ p)) := by + calc + _ = ∑ T ∈ S.powerset, + (g a * ℓ a * (∏ p ∈ T, g p) + g a * ((∏ p ∈ T, g p) * (∑ p ∈ T, ℓ p))) := by + apply sum_congr rfl + intro T hT + rw [prod_insert (hn T hT), sum_insert (hn T hT)] + ring + _ = _ := by + rw [sum_add_distrib, ← mul_sum, ← mul_sum, ← prod_one_add, ih hgS] + rw [sum_powerset_insert ha, hins, ih hgS, prod_insert ha, sum_insert ha] + field_simp + ring + +lemma sieve_euler_truncation {ι : Type*} (S : Finset ι) (g ℓ : ι → ℝ) + (hg : ∀ p ∈ S, 0 ≤ g p) (hℓ : ∀ p ∈ S, 0 ≤ ℓ p) + {L : ℝ} (hL : 0 < L) + (hmean : (∑ p ∈ S, g p / (1 + g p) * ℓ p) ≤ L / 2) : + (∏ p ∈ S, (1 + g p)) / 2 ≤ + ∑ T ∈ S.powerset with (∑ p ∈ T, ℓ p) ≤ L, ∏ p ∈ T, g p := by + classical + let Z := ∏ p ∈ S, (1 + g p) + have hZ : 0 ≤ Z := prod_nonneg (fun p hp => by linarith [hg p hp]) + have hweight (T : Finset ι) (hT : T ∈ S.powerset) : 0 ≤ ∏ p ∈ T, g p := + prod_nonneg (fun p hp => hg p (mem_powerset.mp hT hp)) + have hcost (T : Finset ι) (hT : T ∈ S.powerset) : 0 ≤ ∑ p ∈ T, ℓ p := + sum_nonneg (fun p hp => hℓ p (mem_powerset.mp hT hp)) + have htail : + L * (∑ T ∈ S.powerset with ¬ (∑ p ∈ T, ℓ p) ≤ L, ∏ p ∈ T, g p) ≤ + ∑ T ∈ S.powerset, (∏ p ∈ T, g p) * (∑ p ∈ T, ℓ p) := by + rw [sum_filter, mul_sum] + apply sum_le_sum + intro T hT + split_ifs with h + · simpa using mul_nonneg (hweight T hT) (hcost T hT) + · simpa only [mul_comm] using mul_le_mul_of_nonneg_left (le_of_lt (lt_of_not_ge h)) (hweight T hT) + rw [sieve_euler_log_moment S g ℓ hg] at htail + have hm := mul_le_mul_of_nonneg_left hmean hZ + have htotal := sum_filter_add_sum_filter_not S.powerset + (fun T => (∑ p ∈ T, ℓ p) ≤ L) (fun T => ∏ p ∈ T, g p) + rw [← prod_one_add] at htotal + dsimp [Z] at hZ hm + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveGoldbachDenominator.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveGoldbachDenominator.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad111ceba283bfaed0eda8a5f46b13728bd7ec6d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveGoldbachDenominator.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveGoldbachTruncation +import OAI.NumberTheory.TwoPoint.Bounds.SieveEulerLower + +namespace OAI + +/-! The dimension-two denominator bound for the finite Goldbach sieve. -/ + +namespace TwoPointCorrelations + +open Finset Problem337 +open scoped Classical + +lemma sieve_goldbach_denominator_two_scale : + ∃ c : ℝ, 0 < c ∧ ∀ N z : ℕ, 2 ∣ N → N ≠ 0 → 2 ≤ z → + ∀ y : ℝ, 2 ≤ y → + 4 * (Real.log y + halaszMertensConstant) ≤ Real.log z → + c * Real.log y ^ 2 / sieveSingularFactor N ≤ + GoldbachSelberg.denominator N (primorial z) z := by + obtain ⟨c, hc, hEuler⟩ := sieve_euler_product_log_lower + refine ⟨c ^ 2 / 2, by positivity, ?_⟩ + intro N z hN hN0 hz y hy hscale + have hylog : 0 ≤ Real.log y := Real.log_nonneg (by linarith) + have he := pow_le_pow_left₀ (mul_nonneg hc.le hylog) (hEuler y hy) 2 + have hprod := sieve_goldbach_product_lower hN hN0 (sievePrimesUpTo y) (sievePrimesUpTo_prime y) + have hden := sieve_goldbach_denominator_small_primes N z hN hz (by linarith) hscale + have hS := sieve_singular_factor_pos N + have hdiv := div_le_div_of_nonneg_right he hS.le + calc + _ = (c * Real.log y) ^ 2 / sieveSingularFactor N / 2 := by ring + _ ≤ (∏ p ∈ sievePrimesUpTo y, sieveEulerFactor p) ^ 2 / sieveSingularFactor N / 2 := by + linarith + _ ≤ (∏ p ∈ sievePrimesUpTo y, (1 + sieveGoldbachWeight N p)) / 2 := by linarith + _ ≤ _ := hden + +/-- A single explicit logarithmic lower threshold gives the usual +`log(z)^2 / singularFactor(N)` denominator. -/ +theorem sieve_goldbach_denominator_log_square : + ∃ c : ℝ, 0 < c ∧ ∀ N z : ℕ, 2 ∣ N → N ≠ 0 → 2 ≤ z → + 8 * (halaszMertensConstant + Real.log 2) ≤ Real.log z → + c * Real.log z ^ 2 / sieveSingularFactor N ≤ + GoldbachSelberg.denominator N (primorial z) z := by + obtain ⟨c, hc, hden⟩ := sieve_goldbach_denominator_two_scale + refine ⟨c / 64, by positivity, ?_⟩ + intro N z hN hN0 hz hscale + let y := Real.exp (Real.log z / 8) + have hlog2 : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) + have hy : 2 ≤ y := by + rw [show (2 : ℝ) = Real.exp (Real.log 2) by rw [Real.exp_log (by norm_num)]] + apply Real.exp_le_exp.mpr + linarith [halaszMertensConstant_nonneg] + have hylog : Real.log y = Real.log z / 8 := Real.log_exp _ + have ht : 4 * (Real.log y + halaszMertensConstant) ≤ Real.log z := by + rw [hylog] + linarith + have he := hden N z hN hN0 hz y hy ht + rw [hylog] at he + convert he using 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveGoldbachLocal.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveGoldbachLocal.lean new file mode 100644 index 0000000000000000000000000000000000000000..635d4fbc299f94cc0ad4569262990bc96c6acbf4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveGoldbachLocal.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.EgyptianFractions.GoldbachSieveLocal +import OAI.NumberTheory.TwoPoint.Bounds.SieveEulerTruncation + +namespace OAI + +/-! The positive Euler factors of the actual binary Goldbach sieve. -/ + +namespace TwoPointCorrelations + +open Finset Problem337 +open scoped Classical + +noncomputable def sieveGoldbachWeight (N p : ℕ) : ℝ := + goldbachSieveDensity N p / (1 - goldbachSieveDensity N p) + +lemma sieve_goldbach_density_lt_one {N p : ℕ} (hN : 2 ∣ N) (hp : p.Prime) : + goldbachSieveDensity N p < 1 := + goldbachSieveDensity_prime_lt_one N p hp (fun _ => hN) + +lemma sieve_goldbach_weight_pos {N p : ℕ} (hN : 2 ∣ N) (hp : p.Prime) : + 0 < sieveGoldbachWeight N p := + div_pos (goldbachSieveDensity_prime_pos N p hp) + (sub_pos.mpr (sieve_goldbach_density_lt_one hN hp)) + +lemma sieve_goldbach_one_add {N p : ℕ} (hN : 2 ∣ N) (hp : p.Prime) : + 1 + sieveGoldbachWeight N p = (1 - goldbachSieveDensity N p)⁻¹ := by + have h := ne_of_gt (sub_pos.mpr (sieve_goldbach_density_lt_one hN hp)) + unfold sieveGoldbachWeight + field_simp + ring + +lemma sieve_goldbach_normalized {N p : ℕ} (hN : 2 ∣ N) (hp : p.Prime) : + sieveGoldbachWeight N p / (1 + sieveGoldbachWeight N p) = + goldbachSieveDensity N p := by + have h := ne_of_gt (sub_pos.mpr (sieve_goldbach_density_lt_one hN hp)) + rw [sieve_goldbach_one_add hN hp] + unfold sieveGoldbachWeight + field_simp + +lemma sieve_goldbach_mean_le {N : ℕ} (hN : 2 ∣ N) (P : Finset ℕ) + (hP : ∀ p ∈ P, p.Prime) : + (∑ p ∈ P, sieveGoldbachWeight N p / (1 + sieveGoldbachWeight N p) * Real.log p) ≤ + 2 * (∑ p ∈ P, Real.log (p : ℝ) / p) := by + rw [mul_sum] + apply sum_le_sum + intro p hp + rw [sieve_goldbach_normalized hN (hP p hp), goldbachSieveDensity_prime N p (hP p hp)] + have hpR : (0 : ℝ) < p := by exact_mod_cast (hP p hp).pos + have hlog : 0 ≤ Real.log (p : ℝ) := Real.log_nonneg (by exact_mod_cast (hP p hp).one_le) + split_ifs <;> simp only [div_eq_mul_inv] <;> + nlinarith [mul_nonneg (inv_nonneg.mpr hpR.le) hlog] + +lemma sieve_goldbach_factor_ge {N p : ℕ} (hN : 2 ∣ N) (hp : p.Prime) : + (1 - 1 / (p : ℝ))⁻¹ ^ 2 * (if p ∣ N then 1 - 1 / (p : ℝ) else 1) ≤ + 1 + sieveGoldbachWeight N p := by + have hpR : (1 : ℝ) < p := by exact_mod_cast hp.one_lt + have hp0 : (p : ℝ) ≠ 0 := by positivity + have hp1 : (p : ℝ) - 1 ≠ 0 := by linarith + rw [sieve_goldbach_one_add hN hp, goldbachSieveDensity_prime N p hp] + by_cases hdiv : p ∣ N + · simp only [hdiv, ite_true] + field_simp + nlinarith + · have hp2 : (2 : ℝ) < p := by + have h : 2 < p := by + have := hp.two_le + by_contra hc + have he : p = 2 := by omega + exact hdiv (he ▸ hN) + exact_mod_cast h + have hp2ne : (p : ℝ) - 2 ≠ 0 := by linarith + simp only [hdiv, ite_false, mul_one] + have he : (1 - 1 / (p : ℝ))⁻¹ = (p : ℝ) / ((p : ℝ) - 1) := by + field_simp + have hd : (1 - 2 / (p : ℝ))⁻¹ = (p : ℝ) / ((p : ℝ) - 2) := by + field_simp + rw [he, hd, div_pow] + apply (div_le_div_iff₀ (sq_pos_of_pos (by linarith : (0 : ℝ) < p - 1)) + (by linarith : (0 : ℝ) < p - 2)).mpr + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveGoldbachPairs.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveGoldbachPairs.lean new file mode 100644 index 0000000000000000000000000000000000000000..4cdabd46af733084720960d0901bf12a9912402e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveGoldbachPairs.lean @@ -0,0 +1,46 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveGoldbachDenominator + +namespace OAI + +/-! The finite Goldbach upper bound with its denominator evaluated. -/ + +namespace TwoPointCorrelations + +open Finset Problem337 +open scoped Classical + +lemma sieve_primesLE_card (z : ℕ) : (Nat.primesLE z).card ≤ z := by + have hs : Nat.primesLE z ⊆ Icc 1 z := by + intro p hp + exact mem_Icc.mpr ⟨(Nat.prime_of_mem_primesLE hp).pos, Nat.le_of_mem_primesLE hp⟩ + simpa using card_le_card hs + +theorem sieve_goldbach_pairs_finite : + ∃ C : ℝ, 0 < C ∧ ∀ N z : ℕ, 2 ∣ N → N ≠ 0 → 2 ≤ z → + 8 * (halaszMertensConstant + Real.log 2) ≤ Real.log z → + ((PrimePairSieve.primePairs N).card : ℝ) ≤ + C * N * sieveSingularFactor N / Real.log z ^ 2 + + (z : ℝ) ^ 2 * (1 + Real.log z) ^ 4 + 2 * z := by + obtain ⟨c, hc, hden⟩ := sieve_goldbach_denominator_log_square + refine ⟨1 / c, by positivity, ?_⟩ + intro N z hN hN0 hz hscale + have hlog : 0 < Real.log (z : ℝ) := Real.log_pos (by exact_mod_cast (show 1 < z by omega)) + have hS := sieve_singular_factor_pos N + have hd := hden N z hN hN0 hz hscale + have hmain : ((N - 1 : ℕ) : ℝ) / GoldbachSelberg.denominator N (primorial z) z ≤ + (1 / c) * N * sieveSingularFactor N / Real.log z ^ 2 := by + calc + _ ≤ (N : ℝ) / GoldbachSelberg.denominator N (primorial z) z := by + apply div_le_div_of_nonneg_right _ (GoldbachSelberg.denominator_pos N (primorial z) + hN (squarefree_primorial z) (by omega)).le + exact_mod_cast Nat.sub_le N 1 + _ ≤ (N : ℝ) / (c * Real.log z ^ 2 / sieveSingularFactor N) := + div_le_div_of_nonneg_left (Nat.cast_nonneg N) (by positivity) hd + _ = _ := by field_simp + have hp := GoldbachSelberg.primePairs_le_primorial N hN (z := z) (by omega) + have hcard : ((Nat.primesLE z).card : ℝ) ≤ z := by exact_mod_cast sieve_primesLE_card z + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveGoldbachTruncation.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveGoldbachTruncation.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d0e5c10d453ed6f9072ef6ba337596d452bf8f5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveGoldbachTruncation.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SievePrimeSubsets +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimeMass + +namespace OAI + +/-! The logarithmic-moment criterion applied to the actual Goldbach sieve. -/ + +namespace TwoPointCorrelations + +open Finset Problem337 +open scoped Classical + +lemma sieve_prime_subset_log_cutoff (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + {z : ℕ} (hz : 0 < z) : + (∑ p ∈ P, Real.log p) ≤ Real.log z ↔ (∏ p ∈ P, p) ≤ z := by + have hp : 0 < ∏ p ∈ P, (p : ℝ) := + prod_pos (fun p hp => by exact_mod_cast (hP p hp).pos) + rw [← sieve_prime_subset_log P hP, Real.log_le_log_iff hp (by exact_mod_cast hz)] + rw [← Nat.cast_prod] + exact Nat.cast_le + +theorem sieve_goldbach_denominator_half_product (N z : ℕ) (hN : 2 ∣ N) (hz : 2 ≤ z) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (hmean : 2 * (∑ p ∈ P, Real.log (p : ℝ) / p) ≤ Real.log z / 2) : + (∏ p ∈ P, (1 + sieveGoldbachWeight N p)) / 2 ≤ + GoldbachSelberg.denominator N (primorial z) z := by + have hz0 : (0 : ℝ) < Real.log z := Real.log_pos (by exact_mod_cast (show 1 < z by omega)) + have he := sieve_euler_truncation P (sieveGoldbachWeight N) (fun p => Real.log p) + (fun p hp => (sieve_goldbach_weight_pos hN (hP p hp)).le) + (fun p hp => Real.log_nonneg (by exact_mod_cast (hP p hp).one_le)) hz0 + ((sieve_goldbach_mean_le hN P hP).trans hmean) + have hsets : P.powerset.filter (fun T : Finset ℕ => (∑ p ∈ T, Real.log (p : ℝ)) ≤ Real.log z) = + P.powerset.filter (fun T => (∏ p ∈ T, p) ≤ z) := by + ext T + simp only [mem_filter] + constructor + · rintro ⟨hT, h⟩ + exact ⟨hT, (sieve_prime_subset_log_cutoff T + (fun p hp => hP p (mem_powerset.mp hT hp)) (by omega)).mp h⟩ + · rintro ⟨hT, h⟩ + exact ⟨hT, (sieve_prime_subset_log_cutoff T + (fun p hp => hP p (mem_powerset.mp hT hp)) (by omega)).mpr h⟩ + rw [hsets] at he + exact he.trans (sieve_prime_subset_denominator N z hN P hP) + +/-- The small-prime cutoff is chosen using a logarithmic inequality, avoiding +any rounding assumption on its real value. -/ +theorem sieve_goldbach_denominator_small_primes (N z : ℕ) (hN : 2 ∣ N) (hz : 2 ≤ z) + {y : ℝ} (hy : 1 ≤ y) + (hscale : 4 * (Real.log y + halaszMertensConstant) ≤ Real.log z) : + (∏ p ∈ sievePrimesUpTo y, (1 + sieveGoldbachWeight N p)) / 2 ≤ + GoldbachSelberg.denominator N (primorial z) z := by + apply sieve_goldbach_denominator_half_product N z hN hz (sievePrimesUpTo y) + (sievePrimesUpTo_prime y) + linarith [halasz_prime_prefix_mass_le hy] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveIntersections.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveIntersections.lean new file mode 100644 index 0000000000000000000000000000000000000000..44424c5bf8f08a8612fd76524ad5351309a1c887 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveIntersections.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResidueSampling + +namespace OAI + +/-! Exact selected-modulus intersection estimates on a single fixed +interval or cube. These discharge the arithmetic premise of Bonferroni. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma selected_pairwise_coprime {ι : Type*} [DecidableEq ι] + (s : ι → ℕ) (hcop : Pairwise (fun i j => (s i).Coprime (s j))) (S : Finset ι) : + Pairwise (fun i j : S => (s i).Coprime (s j)) := by + intro i j hij + exact hcop (fun h => hij (Subtype.ext h)) + +theorem sieve_one_intersection {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A N : ℕ) [NeZero N] (E : ∀ i, ZMod (s i) → Prop) (S : Finset ι) : + |(uniformFiniteLaw (Fin N)).probability + (eventIntersection (fun i (j : Fin N) => E i ((A + j.val : ℕ) : ZMod (s i))) S) - + ∏ i ∈ S, (uniformZModLaw (s i)).probability (E i)| ≤ + (∏ i ∈ S, (s i : ℝ)) / N := by + let q : S → ℕ := fun i => s i + have hc := selected_pairwise_coprime s hcop S + have hmap (j : Fin N) (i : S) : + ZMod.prodEquivPi q hc ((A : ZMod (∏ i, q i)) + (j.val : ZMod (∏ i, q i))) i = + ((A + j.val : ℕ) : ZMod (s i)) := by + rw [← Nat.cast_add] + simp only [ZMod.prodEquivPi_apply, map_natCast] + have hh := sieveCRT_one_sample_discrepancy q hc (A : ZMod (∏ i, q i)) N + (fun i => E i) + simp_rw [hmap] at hh + have he : (fun j : Fin N => ∀ i : S, E i ((A + j.val : ℕ) : ZMod (s i))) = + eventIntersection (fun i (j : Fin N) => E i ((A + j.val : ℕ) : ZMod (s i))) S := by + funext j + simp only [eventIntersection, Subtype.forall] + rw [he, Nat.cast_prod] at hh + rw [← prod_subtype (p := fun i => i ∈ S) S (fun _ => Iff.rfl) + (fun i => (uniformZModLaw (s i)).probability (E i)), + ← prod_subtype (p := fun i => i ∈ S) S (fun _ => Iff.rfl) + (fun i => (s i : ℝ))] at hh + exact hh + +theorem sieve_cube_intersection {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ℕ × ℕ × ℕ) (N : ℕ) [NeZero N] + (E : ∀ i, (ZMod (s i) × ZMod (s i) × ZMod (s i)) → Prop) (S : Finset ι) : + |(uniformFiniteLaw (Fin N × Fin N × Fin N)).probability + (eventIntersection (fun i (j : Fin N × Fin N × Fin N) => E i + (((A.1 + j.1.val : ℕ) : ZMod (s i)), + ((A.2.1 + j.2.1.val : ℕ) : ZMod (s i)), + ((A.2.2 + j.2.2.val : ℕ) : ZMod (s i)))) S) - + ∏ i ∈ S, (uniformResidueCubeLaw (s i)).probability (E i)| ≤ + 3 / (N : ℝ) * ∏ i ∈ S, (s i : ℝ) := by + let q : S → ℕ := fun i => s i + have hc := selected_pairwise_coprime s hcop S + have hmap (j : Fin N × Fin N × Fin N) (i : S) : + sieveCubeCRT q hc + ((A.1 : ZMod (∏ i, q i)) + (j.1.val : ZMod (∏ i, q i)), + (A.2.1 : ZMod (∏ i, q i)) + (j.2.1.val : ZMod (∏ i, q i)), + (A.2.2 : ZMod (∏ i, q i)) + (j.2.2.val : ZMod (∏ i, q i))) i = + (((A.1 + j.1.val : ℕ) : ZMod (s i)), + ((A.2.1 + j.2.1.val : ℕ) : ZMod (s i)), + ((A.2.2 + j.2.2.val : ℕ) : ZMod (s i))) := by + simp only [← Nat.cast_add] + exact sieveCubeCRT_natCast q hc _ _ _ i + have hh := sieveCRT_cube_sample_discrepancy q hc + ((A.1 : ZMod (∏ i, q i)), (A.2.1 : ZMod (∏ i, q i)), (A.2.2 : ZMod (∏ i, q i))) N + (fun i => E i) + simp_rw [hmap] at hh + have he : (fun j : Fin N × Fin N × Fin N => ∀ i : S, E i + (((A.1 + j.1.val : ℕ) : ZMod (s i)), ((A.2.1 + j.2.1.val : ℕ) : ZMod (s i)), + ((A.2.2 + j.2.2.val : ℕ) : ZMod (s i)))) = + eventIntersection (fun i (j : Fin N × Fin N × Fin N) => E i + (((A.1 + j.1.val : ℕ) : ZMod (s i)), ((A.2.1 + j.2.1.val : ℕ) : ZMod (s i)), + ((A.2.2 + j.2.2.val : ℕ) : ZMod (s i)))) S := by + funext j + simp only [eventIntersection, Subtype.forall] + rw [he, Nat.cast_prod] at hh + rw [← prod_subtype (p := fun i => i ∈ S) S (fun _ => Iff.rfl) + (fun i => (uniformResidueCubeLaw (s i)).probability (E i)), + ← prod_subtype (p := fun i => i ∈ S) S (fun _ => Iff.rfl) + (fun i => (s i : ℝ))] at hh + convert hh using 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveModel.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..70eb3326e5c804645fd8dd35243c6f4e816a4a48 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveModel.lean @@ -0,0 +1,192 @@ +import OAI.NumberTheory.TwoPoint.Bounds.Bonferroni +import Mathlib.Analysis.SpecialFunctions.Log.Basic +import Mathlib.Data.Fintype.Pi + +namespace OAI + +/-! The exact independent model and a generating-function bound for its +Bonferroni remainder, using only finite probability identities. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace FiniteLaw + +noncomputable def dependentIndependent {ι : Type*} [Fintype ι] [DecidableEq ι] + {A : ι → Type*} [∀ i, Fintype (A i)] (μ : ∀ i, FiniteLaw (A i)) : + FiniteLaw (∀ i, A i) where + weight x := ∏ i, (μ i).weight (x i) + nonneg x := prod_nonneg (fun i _ => (μ i).nonneg (x i)) + total := by + rw [← Fintype.prod_sum (fun i x => (μ i).weight x)] + simp only [FiniteLaw.total, prod_const_one] + +lemma dependentIndependent_average_product {ι : Type*} [Fintype ι] [DecidableEq ι] + {A : ι → Type*} [∀ i, Fintype (A i)] (μ : ∀ i, FiniteLaw (A i)) + (f : ∀ i, A i → ℝ) : + (dependentIndependent μ).average (fun x => ∏ i, f i (x i)) = + ∏ i, (μ i).average (f i) := by + simp only [average, dependentIndependent, ← prod_mul_distrib] + exact (Fintype.prod_sum (fun i x => (μ i).weight x * f i x)).symm + +lemma dependentIndependent_probability_all {ι : Type*} [Fintype ι] [DecidableEq ι] + {A : ι → Type*} [∀ i, Fintype (A i)] (μ : ∀ i, FiniteLaw (A i)) + (E : ∀ i, A i → Prop) : + (dependentIndependent μ).probability (fun x => ∀ i, E i (x i)) = + ∏ i, (μ i).probability (E i) := by + unfold probability + calc + _ = (dependentIndependent μ).average + (fun x => ∏ i, if E i (x i) then (1 : ℝ) else 0) := by + congr 1 + funext x + by_cases hx : ∀ i, E i (x i) <;> simp [Fintype.prod_boole, hx] + _ = _ := dependentIndependent_average_product μ + (fun i x => if E i x then (1 : ℝ) else 0) + +lemma probability_complement {α : Type*} [Fintype α] (μ : FiniteLaw α) (E : α → Prop) : + μ.probability (fun x => ¬E x) = 1 - μ.probability E := by + have hsum : μ.probability E + μ.probability (fun x => ¬E x) = 1 := by + unfold probability average + rw [← sum_add_distrib] + calc + _ = ∑ x, μ.weight x := by + apply sum_congr rfl + intro x _ + by_cases hx : E x <;> simp [hx] + _ = 1 := μ.total + linarith + +lemma dependentIndependent_intersection {ι : Type*} [Fintype ι] [DecidableEq ι] + {A : ι → Type*} [∀ i, Fintype (A i)] (μ : ∀ i, FiniteLaw (A i)) + (E : ∀ i, A i → Prop) (S : Finset ι) : + (dependentIndependent μ).probability (eventIntersection (fun i x => E i (x i)) S) = + ∏ i ∈ S, (μ i).probability (E i) := by + have he : eventIntersection (fun i (x : ∀ i, A i) => E i (x i)) S = + (fun (x : ∀ i, A i) => ∀ i, i ∈ S → E i (x i)) := rfl + rw [he, dependentIndependent_probability_all μ (fun i a => i ∈ S → E i a)] + have hi (i : ι) : (μ i).probability (fun x => i ∈ S → E i x) = + if i ∈ S then (μ i).probability (E i) else 1 := by + by_cases h : i ∈ S + · simp [h] + · simp [probability, h] + simp only [hi] + simp + +lemma dependentIndependent_avoid {ι : Type*} [Fintype ι] [DecidableEq ι] + {A : ι → Type*} [∀ i, Fintype (A i)] (μ : ∀ i, FiniteLaw (A i)) + (E : ∀ i, A i → Prop) : + (dependentIndependent μ).probability (avoidsEvents univ (fun i x => E i (x i))) = + ∏ i, (1 - (μ i).probability (E i)) := by + have he : avoidsEvents univ (fun i (x : ∀ i, A i) => E i (x i)) = + (fun (x : ∀ i, A i) => ∀ i, ¬E i (x i)) := by funext x; simp [avoidsEvents] + rw [he, dependentIndependent_probability_all μ (fun i a => ¬E i a)] + simp only [probability_complement] + +end FiniteLaw + +noncomputable def elementarySymmetric {ι : Type*} (P : Finset ι) (a : ι → ℝ) (j : ℕ) : ℝ := + ∑ S ∈ P.powersetCard j, ∏ i ∈ S, a i + +lemma independent_intersectionMass {ι : Type*} [Fintype ι] [DecidableEq ι] + {A : ι → Type*} [∀ i, Fintype (A i)] (μ : ∀ i, FiniteLaw (A i)) + (E : ∀ i, A i → Prop) (P : Finset ι) (j : ℕ) : + eventIntersectionMass (FiniteLaw.dependentIndependent μ) P + (fun i x => E i (x i)) j = elementarySymmetric P + (fun i => (μ i).probability (E i)) j := by + simp only [eventIntersectionMass, elementarySymmetric, + FiniteLaw.dependentIndependent_intersection] + +/-- Exponential weighting bounds one elementary symmetric layer. This +avoids factorial estimates and gives the same finite-sieve tail. -/ +theorem elementarySymmetric_exp_bound {ι : Type*} (P : Finset ι) (a : ι → ℝ) + (ha : ∀ i ∈ P, 0 ≤ a i) (j : ℕ) (t : ℝ) (ht : 0 < t) : + elementarySymmetric P a j ≤ Real.exp (t * ∑ i ∈ P, a i) / t ^ j := by + have hm : t ^ j * elementarySymmetric P a j = + ∑ S ∈ P.powersetCard j, ∏ i ∈ S, t * a i := by + unfold elementarySymmetric + rw [mul_sum] + apply sum_congr rfl + intro S hS + rw [prod_mul_distrib, prod_const, (mem_powersetCard.mp hS).2] + have hsub : P.powersetCard j ⊆ P.powerset := by + intro S hS + exact mem_powerset.mpr (mem_powersetCard.mp hS).1 + have hb : t ^ j * elementarySymmetric P a j ≤ Real.exp (t * ∑ i ∈ P, a i) := by + rw [hm] + calc + _ ≤ ∑ S ∈ P.powerset, ∏ i ∈ S, t * a i := by + apply sum_le_sum_of_subset_of_nonneg hsub + intro S hS _ + exact prod_nonneg (fun i hi => mul_nonneg ht.le + (ha i ((mem_powerset.mp hS) hi))) + _ = ∏ i ∈ P, (1 + t * a i) := (prod_one_add P).symm + _ ≤ ∏ i ∈ P, Real.exp (t * a i) := by + apply prod_le_prod₀ + · intro i hi + exact add_nonneg zero_le_one (mul_nonneg ht.le (ha i hi)) + · intro i _ + linarith [Real.add_one_le_exp (t * a i)] + _ = Real.exp (∑ i ∈ P, t * a i) := (Real.exp_sum P _).symm + _ = _ := by rw [mul_sum] + exact (le_div_iff₀ (pow_pos ht j)).mpr (by simpa [mul_comm] using hb) + +/-- A direct useful specialization: tail order `j` and total local mass +`M` give `exp(2M) / 2^j`. -/ +lemma elementarySymmetric_two_bound {ι : Type*} (P : Finset ι) (a : ι → ℝ) + (ha : ∀ i ∈ P, 0 ≤ a i) (j : ℕ) : + elementarySymmetric P a j ≤ Real.exp (2 * ∑ i ∈ P, a i) / (2 : ℝ) ^ j := + elementarySymmetric_exp_bound P a ha j 2 (by norm_num) + +/-- The next-layer tail is already at most `L⁻¹⁰⁰` once its order exceeds +`220 log L` and the total local mass is at most `5 log L`. The manuscript +uses the considerably larger order `1000 log L`. -/ +theorem elementarySymmetric_log_tail {ι : Type*} (P : Finset ι) (a : ι → ℝ) + (ha : ∀ i ∈ P, 0 ≤ a i) (j : ℕ) (L : ℝ) (hL : 1 ≤ L) + (hmass : (∑ i ∈ P, a i) ≤ 5 * Real.log L) + (hj : 220 * Real.log L ≤ (j : ℝ)) : + elementarySymmetric P a j ≤ L ^ (-100 : ℝ) := by + have hLp : 0 < L := zero_lt_one.trans_le hL + have hlog : 0 ≤ Real.log L := Real.log_nonneg hL + have hlog2 : (1 / 2 : ℝ) ≤ Real.log 2 := by + have hh := Real.one_sub_inv_le_log_of_pos (show (0 : ℝ) < 2 by norm_num) + norm_num at hh + linarith + apply (elementarySymmetric_two_bound P a ha j).trans + rw [← Real.rpow_natCast, Real.rpow_def_of_pos (show (0 : ℝ) < 2 by norm_num), + ← Real.exp_sub, Real.rpow_def_of_pos hLp] + apply Real.exp_le_exp.mpr + have horder : 110 * Real.log L ≤ (j : ℝ) * Real.log 2 := by + calc + _ = (220 * Real.log L) * (1 / 2 : ℝ) := by ring + _ ≤ (j : ℝ) * (1 / 2 : ℝ) := mul_le_mul_of_nonneg_right hj (by norm_num) + _ ≤ (j : ℝ) * Real.log 2 := mul_le_mul_of_nonneg_left hlog2 (Nat.cast_nonneg j) + nlinarith + +/-- Finite sieve upper bound with the independent local model fully +evaluated. The only arithmetic premise is the error of each actual +intersection count. -/ +theorem finite_independent_sieve_bound {ι α : Type*} + [Fintype ι] [DecidableEq ι] [Fintype α] + {A : ι → Type*} [∀ i, Fintype (A i)] + (actual : FiniteLaw α) (E : ι → α → Prop) + (laws : ∀ i, FiniteLaw (A i)) (bad : ∀ i, A i → Prop) + (r : ℕ) (err : Finset ι → ℝ) + (herr : ∀ S ∈ (univ : Finset ι).powerset, S.card ≤ 2 * r → + |actual.probability (eventIntersection E S) - + ∏ i ∈ S, (laws i).probability (bad i)| ≤ err S) : + actual.probability (avoidsEvents univ E) ≤ + (∏ i, (1 - (laws i).probability (bad i))) + + elementarySymmetric univ (fun i => (laws i).probability (bad i)) (2 * r + 1) + + sieveIntersectionError univ err (2 * r) := by + have hh := bonferroni_transfer actual (FiniteLaw.dependentIndependent laws) univ + E (fun i x => bad i (x i)) r err (fun S hS hcard => by + rw [FiniteLaw.dependentIndependent_intersection] + exact herr S hS hcard) + simpa only [FiniteLaw.dependentIndependent_avoid, independent_intersectionMass] using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SievePrimeEnergy.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SievePrimeEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..072b79ed3a487112e6cf78e2198298d604f1429a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SievePrimeEnergy.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveUniformPairs +import OAI.NumberTheory.TwoPoint.Bounds.SieveSingularAverage +import Mathlib.Combinatorics.Additive.Energy + +namespace OAI + +/-! Prime additive energy from the finite Goldbach sieve and the singular-factor mean square. -/ + +namespace TwoPointCorrelations + +open Finset Filter Problem337 +open scoped Classical Pointwise + +lemma sieve_prime_pair_card (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (N : ℕ) : + ((P ×ˢ P).filter (fun v => v.1 + v.2 = N)).card ≤ (PrimePairSieve.primePairs N).card := by + apply card_le_card_of_injOn Prod.fst + · rintro ⟨p, q⟩ hpq + obtain ⟨hpq, hsum⟩ := mem_filter.mp hpq + obtain ⟨hp, hq⟩ := mem_product.mp hpq + have hp2 := (hP p hp).two_le + have hq2 := (hP q hq).two_le + apply mem_filter.mpr + exact ⟨mem_Icc.mpr ⟨by omega, by omega⟩, + hP p hp, by convert hP q hq using 1; omega⟩ + · rintro ⟨p, q⟩ hpq ⟨r, s⟩ hrs heq + have hsum1 := (mem_filter.mp hpq).2 + have hsum2 := (mem_filter.mp hrs).2 + change p = r at heq + apply Prod.ext heq + omega + +lemma sieve_prime_sum_even {P : Finset ℕ} (hP : ∀ p ∈ P, p.Prime ∧ p ≠ 2) + {N : ℕ} (hN : N ∈ P + P) : 2 ∣ N := by + obtain ⟨p, hp, q, hq, rfl⟩ := mem_add.mp hN + have hpodd := (hP p hp).1.odd_of_ne_two (hP p hp).2 + have hqodd := (hP q hq).1.odd_of_ne_two (hP q hq).2 + exact (hpodd.add_odd hqodd).two_dvd + +/-- The number of zero-sum prime quadruples has the required four logarithms +uniformly for every finite prime set below twice the scale. -/ +theorem sieve_prime_additive_energy : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ x : ℝ in atTop, ∀ P : Finset ℕ, + (∀ p ∈ P, p.Prime ∧ p ≠ 2 ∧ (p : ℝ) ≤ 2 * x) → + (Finset.addEnergy P P : ℝ) ≤ C * x ^ 3 / Real.log x ^ 4 := by + obtain ⟨C, hC, hevent⟩ := sieve_goldbach_pairs_uniform + refine ⟨4 * C ^ 2 * (sieveSingularMeanConstant + 1), by + have := sieve_singular_mean_constant_nonneg + positivity, ?_⟩ + filter_upwards [hevent] with x hx + obtain ⟨hx1, hxlog, hpairs⟩ := hx + intro P hP + have hx0 : 0 < x := by linarith + have hlog0 : 0 < Real.log x := by linarith + let A := C * x / Real.log x ^ 2 + have hA : 0 ≤ A := by dsimp [A]; positivity + have hsub : P + P ⊆ Icc 1 ⌊4 * x⌋₊ := by + intro N hN + obtain ⟨p, hp, q, hq, rfl⟩ := mem_add.mp hN + have hp2 := (hP p hp).1.two_le + have hq2 := (hP q hq).1.two_le + apply mem_Icc.mpr + constructor + · omega + · apply (Nat.le_floor_iff (by positivity : 0 ≤ 4 * x)).mpr + push_cast + linarith [(hP p hp).2.2, (hP q hq).2.2] + have hpair (N : ℕ) (hN : N ∈ P + P) : + (((P ×ˢ P).filter (fun v => v.1 + v.2 = N)).card : ℝ) ≤ A * sieveSingularFactor N := by + have hNI := mem_Icc.mp (hsub hN) + have hNx : (N : ℝ) ≤ 4 * x := + (show (N : ℝ) ≤ ⌊4 * x⌋₊ by exact_mod_cast hNI.2).trans (Nat.floor_le (by positivity)) + calc + _ ≤ ((PrimePairSieve.primePairs N).card : ℝ) := by + exact_mod_cast sieve_prime_pair_card P (fun p hp => (hP p hp).1) N + _ ≤ C * x * sieveSingularFactor N / Real.log x ^ 2 := hpairs N (by omega) + (sieve_prime_sum_even (fun p hp => ⟨(hP p hp).1, (hP p hp).2.1⟩) hN) hNx + _ = _ := by dsimp [A]; ring + have henergy : (Finset.addEnergy P P : ℝ) ≤ + A ^ 2 * (∑ N ∈ Icc 1 ⌊4 * x⌋₊, sieveSingularFactor N ^ 2) := by + rw [Finset.addEnergy_eq_sum_sq', Nat.cast_sum] + calc + _ = ∑ N ∈ P + P, (((P ×ˢ P).filter (fun v => v.1 + v.2 = N)).card : ℝ) ^ 2 := by + simp only [Nat.cast_pow] + _ ≤ ∑ N ∈ P + P, (A * sieveSingularFactor N) ^ 2 := by + apply sum_le_sum + intro N hN + exact pow_le_pow_left₀ (Nat.cast_nonneg _) (hpair N hN) 2 + _ = A ^ 2 * (∑ N ∈ P + P, sieveSingularFactor N ^ 2) := by + simp only [mul_pow, mul_sum] + _ ≤ _ := mul_le_mul_of_nonneg_left + (sum_le_sum_of_subset_of_nonneg hsub (fun N _ _ => sq_nonneg _)) (sq_nonneg _) + have havg := sieve_singular_square_average ⌊4 * x⌋₊ + have hfloor := Nat.floor_le (by positivity : 0 ≤ 4 * x) + have hK := sieve_singular_mean_constant_nonneg + calc + _ ≤ A ^ 2 * (sieveSingularMeanConstant * ⌊4 * x⌋₊) := + henergy.trans (mul_le_mul_of_nonneg_left havg (sq_nonneg _)) + _ ≤ A ^ 2 * (sieveSingularMeanConstant * (4 * x)) := by + gcongr + _ ≤ A ^ 2 * ((sieveSingularMeanConstant + 1) * (4 * x)) := by + gcongr + linarith + _ = _ := by dsimp [A]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SievePrimeSubsets.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SievePrimeSubsets.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9737e04e5d3f636b29a1cb882cf9319a891cd4a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SievePrimeSubsets.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.EgyptianFractions.GoldbachSelbergBound +import OAI.NumberTheory.TwoPoint.Bounds.SieveGoldbachLocal + +namespace OAI + +/-! Products of prime subsets realize distinct terms of the finite sieve denominator. -/ + +namespace TwoPointCorrelations + +open Finset Problem337 +open scoped Classical + +lemma sieve_prime_subset_squarefree (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) : + Squarefree (∏ p ∈ P, p) := by + apply Finset.squarefree_prod_of_pairwise_isCoprime + · intro p hp q hq hpq + change IsRelPrime p q + rw [← Nat.coprime_iff_isRelPrime] + exact (Nat.coprime_primes (hP p hp) (hP q hq)).mpr hpq + · exact fun p hp => (hP p hp).squarefree + +lemma sieve_prime_subset_injective (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) : + Set.InjOn (fun T : Finset ℕ => ∏ p ∈ T, p) (↑P.powerset : Set (Finset ℕ)) := by + intro S hS T hT hprod + have hSp : ∀ p ∈ S, p.Prime := fun p hp => hP p (mem_powerset.mp hS hp) + have hTp : ∀ p ∈ T, p.Prime := fun p hp => hP p (mem_powerset.mp hT hp) + calc + S = (∏ p ∈ S, p).primeFactors := (Nat.primeFactors_prod hSp).symm + _ = (∏ p ∈ T, p).primeFactors := congrArg Nat.primeFactors hprod + _ = T := Nat.primeFactors_prod hTp + +lemma sieve_prime_subset_weight (N : ℕ) (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) : + goldbachSieveDensity N (∏ p ∈ P, p) * + (∏ p ∈ (∏ p ∈ P, p).primeFactors, (1 - goldbachSieveDensity N p)⁻¹) = + ∏ p ∈ P, sieveGoldbachWeight N p := by + rw [(goldbachSieveDensity_isMultiplicative N).map_prod_of_prime P hP, + Nat.primeFactors_prod hP, ← prod_mul_distrib] + rfl + +lemma sieve_prime_subset_log (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) : + Real.log (∏ p ∈ P, (p : ℝ)) = ∑ p ∈ P, Real.log p := by + apply Real.log_prod + intro p hp + exact_mod_cast (hP p hp).ne_zero + +/-- A truncated prime-subset Euler product is a genuine subsum of the actual +Goldbach denominator. -/ +theorem sieve_prime_subset_denominator (N z : ℕ) (hN : 2 ∣ N) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) : + (∑ T ∈ P.powerset with (∏ p ∈ T, p) ≤ z, ∏ p ∈ T, sieveGoldbachWeight N p) ≤ + GoldbachSelberg.denominator N (primorial z) z := by + let A := P.powerset.filter (fun T => (∏ p ∈ T, p) ≤ z) + let w := fun d : ℕ => goldbachSieveDensity N d * + ∏ p ∈ d.primeFactors, (1 - goldbachSieveDensity N p)⁻¹ + have hinj := (sieve_prime_subset_injective P hP).mono (show (↑A : Set (Finset ℕ)) ⊆ ↑P.powerset by + intro T hT + exact (mem_filter.mp hT).1) + have himg : A.image (fun T => ∏ p ∈ T, p) ⊆ (Icc 1 z).filter Squarefree := by + intro d hd + obtain ⟨T, hT, rfl⟩ := mem_image.mp hd + have hTp : ∀ p ∈ T, p.Prime := fun p hp => hP p (mem_powerset.mp (mem_filter.mp hT).1 hp) + exact mem_filter.mpr ⟨mem_Icc.mpr ⟨Nat.succ_le_of_lt + (prod_pos (fun p hp => (hTp p hp).pos)), (mem_filter.mp hT).2⟩, + sieve_prime_subset_squarefree T hTp⟩ + have hnonneg (d : ℕ) (_hd : d ∈ (Icc 1 z).filter Squarefree) : 0 ≤ w d := by + have hroot : 0 ≤ goldbachSieveDensity N d := by + rw [goldbachSieveDensity_apply] + positivity + apply mul_nonneg hroot + apply prod_nonneg + intro p hp + exact inv_nonneg.mpr (sub_nonneg.mpr (sieve_goldbach_density_lt_one hN + (Nat.mem_primeFactors.mp hp).1).le) + calc + _ = ∑ T ∈ A, w (∏ p ∈ T, p) := by + apply sum_congr rfl + intro T hT + exact (sieve_prime_subset_weight N T + (fun p hp => hP p (mem_powerset.mp (mem_filter.mp hT).1 hp))).symm + _ = ∑ d ∈ A.image (fun T => ∏ p ∈ T, p), w d := (sum_image hinj).symm + _ ≤ ∑ d ∈ (Icc 1 z).filter Squarefree, w d := + sum_le_sum_of_subset_of_nonneg himg (fun d hd _ => hnonneg d hd) + _ = _ := by rw [GoldbachSelberg.denominator_primorial, sum_filter] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveProducts.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..e2e377e1b880704034cfa79d100c7f9a9dab01cd --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveProducts.lean @@ -0,0 +1,113 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FourFormLocal +import Mathlib.Analysis.PSeries + +namespace OAI + +/-! Local-density products for the rough sieve. The only prime information +needed is a lower bound for the ordinary reciprocal sum. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma reciprocal_square_sum_le_one (P : Finset ℕ) (hP : ∀ p ∈ P, 2 ≤ p) : + (∑ p ∈ P, 1 / (p : ℝ) ^ 2) ≤ 1 := by + have hsub : P ⊆ Ioo 1 (P.sup id + 1) := by + intro p hp + exact mem_Ioo.mpr ⟨by have := hP p hp; omega, + Nat.lt_succ_of_le (le_sup (f := id) hp)⟩ + calc + _ ≤ ∑ p ∈ Ioo 1 (P.sup id + 1), ((p : ℝ) ^ 2)⁻¹ := by + simp only [one_div] + exact sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => by positivity) + _ ≤ 1 := by + have hh := sum_Ioo_inv_sq_le (α := ℝ) 1 (P.sup id + 1) + norm_num at hh + exact hh + +lemma one_sub_product_le_exp {ι : Type*} [Fintype ι] (ν : ι → ℝ) + (hν : ∀ i, ν i ≤ 1) : + (∏ i, (1 - ν i)) ≤ Real.exp (-(∑ i, ν i)) := by + calc + _ ≤ ∏ i, Real.exp (-ν i) := by + apply prod_le_prod₀ + · intro i _ + exact sub_nonneg.mpr (hν i) + · intro i _ + have hh := Real.add_one_le_exp (-ν i) + linarith + _ = Real.exp (∑ i, -ν i) := (Real.exp_sum univ _).symm + _ = _ := by rw [sum_neg_distrib] + +/-- Four-form local avoidance loses precisely four reciprocal prime sums, +up to an absolute constant from the convergent square sum. -/ +theorem fourForm_product_bound (P : Finset ℕ) [∀ p : P, NeZero (p : ℕ)] + (hP : ∀ p ∈ P, 2 ≤ p) : + (∏ p : P, (1 - fourFormBadDensity (p : ℕ))) ≤ + Real.exp 6 * Real.exp (-4 * ∑ p ∈ P, 1 / (p : ℝ)) := by + have hν (p : P) : fourFormBadDensity (p : ℕ) ≤ 1 := + (uniformResidueCubeLaw (p : ℕ)).probability_le_one fourFormBad + have hlower : 4 * (∑ p ∈ P, 1 / (p : ℝ)) - 6 ≤ + ∑ p : P, fourFormBadDensity (p : ℕ) := by + have hs := sum_le_sum (fun (p : P) (_ : p ∈ (univ : Finset P)) => + (fourFormBadDensity_bounds (p : ℕ)).1) + have he₁ : (∑ p : P, 4 / (p : ℝ)) = 4 * ∑ p ∈ P, 1 / (p : ℝ) := by + rw [← sum_subtype (p := fun p : ℕ => p ∈ P) P (fun _ => Iff.rfl) + (fun p => 4 / (p : ℝ))] + simp only [div_eq_mul_inv, one_mul, ← mul_sum] + have he₂ : (∑ p : P, 6 / (p : ℝ) ^ 2) = 6 * ∑ p ∈ P, 1 / (p : ℝ) ^ 2 := by + rw [← sum_subtype (p := fun p : ℕ => p ∈ P) P (fun _ => Iff.rfl) + (fun p => 6 / (p : ℝ) ^ 2)] + simp only [div_eq_mul_inv, one_mul, ← mul_sum] + rw [sum_sub_distrib, he₁, he₂] at hs + have hsq := reciprocal_square_sum_le_one P hP + linarith + calc + _ ≤ Real.exp (-(∑ p : P, fourFormBadDensity (p : ℕ))) := + one_sub_product_le_exp _ hν + _ ≤ Real.exp (6 - 4 * ∑ p ∈ P, 1 / (p : ℝ)) := Real.exp_le_exp.mpr (by linarith) + _ = _ := by rw [sub_eq_add_neg, Real.exp_add]; congr 2; ring + +theorem oneForm_product_bound (P : Finset ℕ) (hP : ∀ p ∈ P, 2 ≤ p) : + (∏ p ∈ P, (1 - 1 / (p : ℝ))) ≤ Real.exp (-(∑ p ∈ P, 1 / (p : ℝ))) := by + have hp (p : P) : 1 / (p : ℝ) ≤ 1 := by + have hpr : (2 : ℝ) ≤ (p : ℕ) := by exact_mod_cast hP p p.property + exact (div_le_one (by linarith : (0 : ℝ) < (p : ℕ))).mpr (by linarith) + have hh := one_sub_product_le_exp (fun p : P => 1 / (p : ℝ)) hp + rw [← prod_subtype (p := fun p : ℕ => p ∈ P) P (fun _ => Iff.rfl) + (fun p => 1 - 1 / (p : ℝ)), + ← sum_subtype (p := fun p : ℕ => p ∈ P) P (fun _ => Iff.rfl) + (fun p => 1 / (p : ℝ))] at hh + exact hh + +/-- The lower half of the classical reciprocal-prime estimate gives the +one-form power saving, with its constant displayed. -/ +theorem oneForm_product_scale (P : Finset ℕ) (hP : ∀ p ∈ P, 2 ≤ p) + (L C : ℝ) (hL : 0 < L) + (hprime : (99 / 100 : ℝ) * Real.log L - C ≤ ∑ p ∈ P, 1 / (p : ℝ)) : + (∏ p ∈ P, (1 - 1 / (p : ℝ))) ≤ Real.exp C * L ^ (-99 / 100 : ℝ) := by + apply (oneForm_product_bound P hP).trans + calc + _ ≤ Real.exp (C - (99 / 100 : ℝ) * Real.log L) := + Real.exp_le_exp.mpr (by linarith) + _ = _ := by rw [Real.rpow_def_of_pos hL, ← Real.exp_add]; congr 1; ring + +/-- The same classical lower bound gives the full fourth-moment exponent. -/ +theorem fourForm_product_scale (P : Finset ℕ) [∀ p : P, NeZero (p : ℕ)] + (hP : ∀ p ∈ P, 2 ≤ p) (L C : ℝ) (hL : 0 < L) + (hprime : (99 / 100 : ℝ) * Real.log L - C ≤ ∑ p ∈ P, 1 / (p : ℝ)) : + (∏ p : P, (1 - fourFormBadDensity (p : ℕ))) ≤ + Real.exp (4 * C + 6) * L ^ (-99 / 25 : ℝ) := by + apply (fourForm_product_bound P hP).trans + calc + _ ≤ Real.exp 6 * Real.exp (4 * C - (99 / 25 : ℝ) * Real.log L) := by + apply mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) (Real.exp_pos _).le + _ = _ := by + rw [Real.rpow_def_of_pos hL, ← Real.exp_add, ← Real.exp_add] + congr 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..21a57e369b0f6158f66d07c3b97530ba67953ef1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveScale.lean @@ -0,0 +1,47 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveBoundary +import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics + +namespace OAI + +/-! The logarithmic truncation length is negligible compared with the +physical interval exponent in the finite rough sieve. -/ + +namespace TwoPointCorrelations + +open Filter + +/-- Any fixed `exp(O(L^.99 log L))` counting cost is absorbed by the +interval length `exp(L^.995)`, with the explicit power needed below. -/ +theorem eventually_sieve_boundary_exponent (K : ℝ) (hK : 0 ≤ K) : + ∀ᶠ L : ℝ in atTop, + Real.exp (K * L ^ (99 / 100 : ℝ) * Real.log L - L ^ (199 / 200 : ℝ)) ≤ + L ^ (-100 : ℝ) := by + have hden : 0 < K + 100 := by linarith + have hs := (isLittleO_log_rpow_atTop + (show 0 < (1 / 200 : ℝ) by norm_num)).bound (show 0 < 1 / (K + 100) by positivity) + filter_upwards [eventually_ge_atTop 1, hs] with L hL hsL + have hLp : 0 < L := zero_lt_one.trans_le hL + have hlog : 0 ≤ Real.log L := Real.log_nonneg hL + rw [Real.norm_eq_abs, abs_of_nonneg hlog, Real.norm_eq_abs, + abs_of_pos (Real.rpow_pos_of_pos hLp _)] at hsL + have hc : Real.log L * (K + 100) ≤ L ^ (1 / 200 : ℝ) := by + apply (le_div_iff₀ hden).mp + convert hsL using 1 + ring + have hm := mul_le_mul_of_nonneg_right hc + (Real.rpow_nonneg hLp.le (99 / 100 : ℝ)) + have he : L ^ (1 / 200 : ℝ) * L ^ (99 / 100 : ℝ) = L ^ (199 / 200 : ℝ) := by + rw [← Real.rpow_add hLp] + norm_num + rw [he] at hm + have hx : 1 ≤ L ^ (99 / 100 : ℝ) := Real.one_le_rpow hL (by norm_num) + have hlogx : 100 * Real.log L ≤ 100 * L ^ (99 / 100 : ℝ) * Real.log L := by + have hh := mul_le_mul_of_nonneg_right hx (show 0 ≤ 100 * Real.log L by positivity) + nlinarith only [hh] + rw [Real.rpow_def_of_pos hLp (-100 : ℝ)] + apply Real.exp_le_exp.mpr + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveSingularAverage.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveSingularAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..23c06d73175ef97a0c608f2c7e4675e382fd4aa9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveSingularAverage.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SievePrimeSubsets +import OAI.NumberTheory.TwoPoint.Bounds.SieveSingularLocal +import OAI.NumberTheory.TwoPoint.Bounds.SieveDivisorAverage + +namespace OAI + +/-! An absolute mean-square bound for the Goldbach singular factor. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma sieve_prime_sqrt_product (P : Finset ℕ) : + (∏ p ∈ P, 1 / Real.sqrt (p : ℝ)) = 1 / Real.sqrt ((∏ p ∈ P, p : ℕ) : ℝ) := by + simp only [one_div] + rw [Nat.cast_prod, Real.sqrt_prod P (fun p _ => Nat.cast_nonneg p)] + exact prod_inv_distrib _ + +lemma sieve_prime_divisor_subsum {N : ℕ} (hN : N ≠ 0) : + (∏ p ∈ N.primeFactors, (1 + 1 / Real.sqrt (p : ℝ))) ≤ + ∑ d ∈ N.divisors, 1 / Real.sqrt (d : ℝ) := by + let P := N.primeFactors + have hP : ∀ p ∈ P, p.Prime := fun p hp => (Nat.mem_primeFactors.mp hp).1 + have hi := sieve_prime_subset_injective P hP + have himg : P.powerset.image (fun T => ∏ p ∈ T, p) ⊆ N.divisors := by + intro d hd + obtain ⟨T, hT, rfl⟩ := mem_image.mp hd + apply Nat.mem_divisors.mpr + exact ⟨(Finset.prod_dvd_prod_of_subset T P (fun p => p) (mem_powerset.mp hT)).trans + (Nat.prod_primeFactors_dvd N), hN⟩ + calc + _ = ∑ T ∈ P.powerset, ∏ p ∈ T, 1 / Real.sqrt (p : ℝ) := prod_one_add P + _ = ∑ T ∈ P.powerset, 1 / Real.sqrt ((∏ p ∈ T, p : ℕ) : ℝ) := by + apply sum_congr rfl + intro T _ + exact sieve_prime_sqrt_product T + _ = ∑ d ∈ P.powerset.image (fun T => ∏ p ∈ T, p), 1 / Real.sqrt (d : ℝ) := + (sum_image (f := fun d : ℕ => 1 / Real.sqrt (d : ℝ)) hi).symm + _ ≤ _ := sum_le_sum_of_subset_of_nonneg himg (fun _ _ _ => by positivity) + +lemma sieve_singular_square_divisor {N : ℕ} (hN : N ≠ 0) : + sieveSingularFactor N ^ 2 ≤ + (4 : ℝ) ^ 36 * (∑ d ∈ N.divisors, 1 / Real.sqrt (d : ℝ)) := + (sieve_singular_square_product N).trans + (mul_le_mul_of_nonneg_left (sieve_prime_divisor_subsum hN) (by positivity)) + +noncomputable def sieveSingularMeanConstant : ℝ := + (4 : ℝ) ^ 36 * (∑' d : ℕ, (d : ℝ) ^ (-(3 / 2 : ℝ))) + +lemma sieve_singular_mean_constant_nonneg : 0 ≤ sieveSingularMeanConstant := by + unfold sieveSingularMeanConstant + positivity + +/-- An absolute mean square for the singular factor, with no distribution +hypothesis on primes or on the target integer. -/ +theorem sieve_singular_square_average (N : ℕ) : + (∑ n ∈ Icc 1 N, sieveSingularFactor n ^ 2) ≤ sieveSingularMeanConstant * N := by + calc + _ ≤ ∑ n ∈ Icc 1 N, (4 : ℝ) ^ 36 * (∑ d ∈ n.divisors, 1 / Real.sqrt (d : ℝ)) := by + apply sum_le_sum + intro n hn + exact sieve_singular_square_divisor (by have := (mem_Icc.mp hn).1; omega) + _ = (4 : ℝ) ^ 36 * (∑ n ∈ Icc 1 N, ∑ d ∈ n.divisors, 1 / Real.sqrt (d : ℝ)) := + (mul_sum _ _ _).symm + _ ≤ (4 : ℝ) ^ 36 * ((N : ℝ) * (∑' d : ℕ, (d : ℝ) ^ (-(3 / 2 : ℝ)))) := + mul_le_mul_of_nonneg_left (sieve_inverse_sqrt_divisor_average N) (by positivity) + _ = _ := by unfold sieveSingularMeanConstant; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveSingularLocal.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveSingularLocal.lean new file mode 100644 index 0000000000000000000000000000000000000000..21ac24b542ec76b5542007fd8e2d85cb285a41ef --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveSingularLocal.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveEulerLower + +namespace OAI + +/-! An elementary square-root divisor majorant for the sieve singular factor. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma sieve_euler_factor_eq {p : ℕ} (hp : p.Prime) : + sieveEulerFactor p = (p : ℝ) / ((p : ℝ) - 1) := by + have hp0 : (p : ℝ) ≠ 0 := by exact_mod_cast hp.ne_zero + unfold sieveEulerFactor + field_simp + +lemma sieve_euler_factor_le_two {p : ℕ} (hp : p.Prime) : sieveEulerFactor p ≤ 2 := by + rw [sieve_euler_factor_eq hp] + have hpR : (2 : ℝ) ≤ p := by exact_mod_cast hp.two_le + apply (div_le_iff₀ (by linarith : (0 : ℝ) < p - 1)).mpr + linarith + +lemma sieve_euler_square_le {p : ℕ} (hp : p.Prime) : + sieveEulerFactor p ^ 2 ≤ 1 + 6 / (p : ℝ) := by + have hpR : (2 : ℝ) ≤ p := by exact_mod_cast hp.two_le + have hp0 : (0 : ℝ) < p := by linarith + have hp1 : (0 : ℝ) < p - 1 := by linarith + rw [sieve_euler_factor_eq hp, div_pow] + apply (div_le_iff₀ (sq_pos_of_pos hp1)).mpr + apply (mul_le_mul_iff_right₀ hp0).mp + field_simp + nlinarith [mul_nonneg (sub_nonneg.mpr hpR) (show (0 : ℝ) ≤ 4 * p - 3 by linarith)] + +lemma sieve_euler_square_sqrt {p : ℕ} (hp : p.Prime) (hp36 : 36 ≤ p) : + sieveEulerFactor p ^ 2 ≤ 1 + 1 / Real.sqrt (p : ℝ) := by + have hp0 : (0 : ℝ) < p := by exact_mod_cast hp.pos + have hs0 := Real.sqrt_pos.mpr hp0 + have hs2 := Real.sq_sqrt hp0.le + have hs6 : (6 : ℝ) ≤ Real.sqrt (p : ℝ) := by + have : (36 : ℝ) ≤ p := by exact_mod_cast hp36 + nlinarith [Real.sqrt_nonneg (p : ℝ)] + have he : 6 / (p : ℝ) ≤ 1 / Real.sqrt (p : ℝ) := by + apply (div_le_div_iff₀ hp0 hs0).mpr + nlinarith + exact (sieve_euler_square_le hp).trans (by linarith) + +lemma sieve_singular_square_product (N : ℕ) : + sieveSingularFactor N ^ 2 ≤ + (4 : ℝ) ^ 36 * (∏ p ∈ N.primeFactors, (1 + 1 / Real.sqrt (p : ℝ))) := by + let P := N.primeFactors + let S := P.filter (fun p => p < 36) + have hsmall : S.card ≤ 36 := by + have hs : S ⊆ range 36 := by + intro p hp + exact mem_range.mpr (mem_filter.mp hp).2 + simpa using card_le_card hs + have hfac (p : ℕ) (hp : p ∈ P) : + sieveEulerFactor p ^ 2 ≤ (if p < 36 then 4 else 1) * (1 + 1 / Real.sqrt (p : ℝ)) := by + have hprime := (Nat.mem_primeFactors.mp hp).1 + by_cases h36 : p < 36 + · rw [ite_eq_left h36] + have he := pow_le_pow_left₀ (sieve_euler_factor_pos hprime).le (sieve_euler_factor_le_two hprime) 2 + have : 0 ≤ 1 / Real.sqrt (p : ℝ) := by positivity + nlinarith + · rw [ite_eq_right h36, one_mul] + exact sieve_euler_square_sqrt hprime (by omega) + have hp := prod_le_prod₀ (fun p _ => sq_nonneg (sieveEulerFactor p)) hfac + have hconst : (∏ p ∈ P, (if p < 36 then (4 : ℝ) else 1)) ≤ (4 : ℝ) ^ 36 := by + have he : (∏ p ∈ P, (if p < 36 then (4 : ℝ) else 1)) = (4 : ℝ) ^ S.card := by + rw [← prod_filter] + simp only [S, prod_const] + rw [he] + exact pow_le_pow_right₀ (by norm_num) hsmall + rw [prod_mul_distrib, prod_pow] at hp + exact hp.trans (mul_le_mul_of_nonneg_right hconst + (prod_nonneg (fun p _ => by positivity))) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveUniformPairs.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveUniformPairs.lean new file mode 100644 index 0000000000000000000000000000000000000000..837176552f9a9b865b0932f6fda8893a880d29c4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SieveUniformPairs.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SieveCutoffScale + +namespace OAI + +/-! A uniform Goldbach bound for all even targets below one common scale. -/ + +namespace TwoPointCorrelations + +open Filter Problem337 + +lemma sieve_pair_scale_algebra {C x L l S n : ℝ} + (hC : 0 ≤ C) (hx : 0 ≤ x) (hL : 0 < L) (hl : 0 < l) + (hS : 1 ≤ S) (_hn : 0 ≤ n) (hnx : n ≤ 4 * x) (hLl : L ≤ 16 * l) : + C * n * S / l ^ 2 + x / L ^ 2 ≤ (1024 * C + 1) * x * S / L ^ 2 := by + have hS0 : 0 ≤ S := by linarith + have hLsq : L ^ 2 ≤ 256 * l ^ 2 := by nlinarith + have hratio : 1 / l ^ 2 ≤ 256 / L ^ 2 := by + apply (div_le_div_iff₀ (sq_pos_of_pos hl) (sq_pos_of_pos hL)).mpr + nlinarith + have hnS : C * n * S ≤ 4 * C * x * S := by + nlinarith [mul_le_mul_of_nonneg_right hnx (mul_nonneg hC hS0)] + have hxS : x ≤ x * S := by nlinarith + calc + _ = (C * n * S) * (1 / l ^ 2) + x / L ^ 2 := by ring + _ ≤ (4 * C * x * S) * (256 / L ^ 2) + (x * S) / L ^ 2 := by + apply add_le_add + · exact mul_le_mul hnS hratio (by positivity) (by positivity) + · exact div_le_div_of_nonneg_right hxS (sq_nonneg _) + _ = _ := by ring + +theorem sieve_goldbach_pairs_uniform : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ x : ℝ in atTop, + 1 ≤ x ∧ 1 ≤ Real.log x ∧ ∀ N : ℕ, N ≠ 0 → 2 ∣ N → (N : ℝ) ≤ 4 * x → + ((PrimePairSieve.primePairs N).card : ℝ) ≤ + C * x * sieveSingularFactor N / Real.log x ^ 2 := by + obtain ⟨C, hC, hpairs⟩ := sieve_goldbach_pairs_finite + refine ⟨1024 * C + 1, by positivity, ?_⟩ + filter_upwards [sieve_power_cutoff_eventually (8 * (halaszMertensConstant + Real.log 2))] + with x hx + obtain ⟨hx1, hxlog, hz2, hzscale, hzlog, hzerr⟩ := hx + refine ⟨hx1, hxlog, ?_⟩ + intro N hN0 hN hNx + let z := ⌊x ^ (1 / 8 : ℝ)⌋₊ + have hzlogpos : 0 < Real.log (z : ℝ) := Real.log_pos (by exact_mod_cast (show 1 < z by omega)) + have he := hpairs N z hN hN0 hz2 hzscale + have halg := sieve_pair_scale_algebra hC.le (by linarith : 0 ≤ x) + (by linarith : 0 < Real.log x) hzlogpos (sieve_singular_factor_one_le N) + (Nat.cast_nonneg N) hNx hzlog + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonCenteredCatalog.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonCenteredCatalog.lean new file mode 100644 index 0000000000000000000000000000000000000000..b6c7c6ff5252c97150391939712fc39af023665a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonCenteredCatalog.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CenteredWitnessCatalog +import OAI.NumberTheory.TwoPoint.Bounds.SingletonWordEnvelope + +namespace OAI + +/-! The complete singleton word contribution is bounded by the numerical witness catalog. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem singleton_centered_words_le_catalog {ι τ W : Type*} + [Fintype ι] [DecidableEq ι] [Fintype τ] [Fintype W] [DecidableEq W] + (p : ι → ℕ) (hprime : ∀ i, (p i).Prime) (hinj : Function.Injective p) + (B h s J n M D : ℕ) (P Q : Finset ℕ) (supply : ℕ → ℕ → Prop) + (F : Finset (List SignedStep)) + (label : List SignedStep → τ → ι) (target : List SignedStep → τ → Fin B) + (base : ι → Fin B) (R : List SignedStep → (ι → Fin B) → ℝ) + (word : List SignedStep → W → List SignedStep) + (attachment : List SignedStep → W → ℕ) + (C : List SignedStep → ℝ) (K : ℝ) (hK : 0 ≤ K) + (hpB : ∀ i, p i ≤ B) (hP : ∀ q ∈ P, q.Prime) (hQ : ∀ q ∈ Q, q.Prime) + (hPQ : Disjoint P Q) (hcover : ∀ q ∈ P ∪ Q, ∃ i, p i = q) + (htarget : ∀ main ∈ F, ∀ t, (target main t).val < p (label main t)) + (hR : ∀ main ∈ F, ∀ x, 0 ≤ R main x) + (hRC : ∀ main ∈ F, ∀ x, R main x ≤ C main) + (hC : ∀ main ∈ F, 0 ≤ C main) + (hcost : ∀ main ∈ F, + C main * 2 ^ (Fintype.card τ + (singletonLabels (label main)).card) ≤ K) + (hRdep : ∀ main ∈ F, ∀ x y, + (∀ i, i ∉ univ.image (label main) → x i = y i) → R main x = R main y) + (hS : ∀ main ∈ F, ∀ i ∈ univ.image (label main), p i ∈ wordDivisorPrimeSupport main) + (hatt : ∀ main ∈ F, ∀ w, attachment main w ≤ main.length) + (hminimal : ∀ main ∈ F, ∀ w, + MinimalWord (ForwardProhibited h s supply) (word main w)) + (hlen : ∀ main ∈ F, ∀ w, (word main w).length ≤ s) + (hdivsq : ∀ main ∈ F, ∀ w t, t ∈ word main w → Squarefree (t.padding * t.tuple)) + (hcard : ∀ main ∈ F, ∀ w t, t ∈ word main w → t.tuple.primeFactors.card = J) + (hsupport : ∀ main ∈ F, ∀ w q j, TuplePrimeAt (word main w) q j → + ¬q ∣ h ∧ ∀ t ∈ word main w, ¬q ∣ t.padding) + (hpad : ∀ main ∈ F, ∀ i ∈ singletonLabels (label main), ∀ w t, + t ∈ word main w → ¬p i ∣ t.padding) + (hwordcover : ∀ main ∈ F, ∀ w q, + q ∈ wordDivisorPrimeSupport (word main w) → ∃ i, p i = q) + (position : ∀ main, singletonLabels (label main) → ℕ) + (hmain : ∀ main ∈ F, ∀ i : singletonLabels (label main), ∀ v, + TuplePrimeAt main (p i) v → v = position main i) + (hretain : ∀ main ∈ F, ∀ x, + R main x ≠ 0 → RetainedMainTests p (univ.image (label main)) h B main x) + (hmainvalid : ∀ main ∈ F, ∀ t ∈ main, WitnessStepAdmissible P Q J M t) + (hwordvalid : ∀ main ∈ F, ∀ w t, t ∈ word main w → WitnessStepAdmissible P Q J M t) + (hD : ∀ main ∈ F, main.length + n * s ≤ D) + (hn : ∀ main ∈ F, n * (s * J) < (singletonLabels (label main)).card) : + (∑ main ∈ F, + |(FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hprime i).pos (hpB i))).average + (fun x => R main x * (∏ t, + ((if x (label main t) = target main t then (1 : ℝ) else 0) - + (p (label main t) : ℝ)⁻¹)) * + witnessAvoidance (fun w z => decide (AttachedResiduePositiveWord p h (word main w) + (wordDisplacement h (main.take (attachment main w))) B z)) x)|) ≤ + K * ∑ r : Fin (D + 1), ∑ d : WitnessRecord n r.val, + ∑ e : PrimeWordEncoding r.val (r.val * (J + M)) P Q, + if e.Witnesses n d.1.1.val (fun i => (d.1.2.1 i).val) + (fun i => (d.1.2.2 i).val) h s J supply then e.weight else 0 := by + apply centered_words_le_witness_catalog (fun r => r * (J + M)) P Q F p hinj B h s J supply + (fun i => (hprime i).pos) hpB hP hQ hcover label target base R _ C K hK + htarget hR hRC hC (fun _ _ x => witnessAvoidance_abs_le_one _ x) hcost hRdep hS + intro main hm x hx + exact singleton_envelope_has_padding_witness (label main) p hprime hinj B h s J n M D + P Q supply main (word main) (attachment main) (target main) base x (R main) + (hatt main hm) (hminimal main hm) (hlen main hm) (hdivsq main hm) (hcard main hm) + (hsupport main hm) (hpad main hm) (hwordcover main hm) (position main) (hmain main hm) + (hretain main hm x) (hmainvalid main hm) (hwordvalid main hm) hP hPQ (hD main hm) + (hn main hm) hx + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonDecay.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..6961f3042b372cffa1e5abf94b21bc398a84d351 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonDecay.lean @@ -0,0 +1,153 @@ +import OAI.NumberTheory.TwoPoint.Walks.RankDecay + +namespace OAI + +/-! The selected singleton savings dominate the complete crude trace cost. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma eventually_singleton_floor_bounds : + ∀ᶠ L : ℝ in atTop, + L ^ (1 / 12 : ℝ) / 32 ≤ ((⌊L ^ (1 / 12 : ℝ)⌋₊ / 8 : ℕ) : ℝ) ∧ + ((⌊L ^ (1 / 12 : ℝ)⌋₊ / 8 : ℕ) : ℝ) ≤ L := by + have hr := (tendsto_rpow_atTop (show 0 < (1 / 12 : ℝ) by norm_num)).eventually + (eventually_ge_atTop 32) + filter_upwards [eventually_ge_atTop 1, hr] with L hL hpow + have hf := Nat.lt_floor_add_one (L ^ (1 / 12 : ℝ)) + have hd : ⌊L ^ (1 / 12 : ℝ)⌋₊ < 8 * (⌊L ^ (1 / 12 : ℝ)⌋₊ / 8 + 1) := by + have he := Nat.mod_add_div ⌊L ^ (1 / 12 : ℝ)⌋₊ 8 + have hm := Nat.mod_lt ⌊L ^ (1 / 12 : ℝ)⌋₊ (show 0 < 8 by decide) + omega + have hd' : (⌊L ^ (1 / 12 : ℝ)⌋₊ : ℝ) < + 8 * ((⌊L ^ (1 / 12 : ℝ)⌋₊ / 8 : ℕ) : ℝ) + 8 := by exact_mod_cast hd + constructor + · linarith + · apply (show ((⌊L ^ (1 / 12 : ℝ)⌋₊ / 8 : ℕ) : ℝ) ≤ + (⌊L ^ (1 / 12 : ℝ)⌋₊ : ℝ) by exact_mod_cast Nat.div_le_self _ 8).trans + apply (Nat.floor_le (Real.rpow_nonneg (by linarith) _)).trans + simpa using Real.rpow_le_rpow_of_exponent_le hL (show (1 / 12 : ℝ) ≤ 1 by norm_num) + +/-- `647/600 = 1/12 + 199/200` exceeds the desired exponent `21/20`. +All fixed coefficients in the enumeration affect only the threshold. -/ +theorem eventually_singleton_decay (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ r : ℕ, + L ^ (1 / 12 : ℝ) / 32 ≤ (r : ℝ) → (r : ℝ) ≤ L → + Real.exp (C * L * (Real.log L) ^ 2) * + (Real.exp (C * Real.log L - L ^ (199 / 200 : ℝ))) ^ r ≤ + Real.exp (-L ^ (21 / 20 : ℝ)) := by + have h8 := (tendsto_rpow_atTop (show 0 < (19 / 300 : ℝ) by norm_num)).eventually + (eventually_ge_atTop 8) + have h64 := (tendsto_rpow_atTop (show 0 < (17 / 600 : ℝ) by norm_num)).eventually + (eventually_ge_atTop 64) + filter_upwards [eventually_ge_atTop 1, + Real.tendsto_log_atTop.eventually (eventually_ge_atTop 1), + eventually_crude_cost_small (2 * C) (by positivity), h8, h64] with L hL hlog hcost h8 h64 + intro r hrlo hrhi + have hLp : 0 < L := lt_of_lt_of_le zero_lt_one hL + have heq1 : L ^ (203 / 200 : ℝ) * L ^ (19 / 300 : ℝ) = L ^ (647 / 600 : ℝ) := by + rw [← Real.rpow_add hLp] + norm_num + have heq2 : L ^ (21 / 20 : ℝ) * L ^ (17 / 600 : ℝ) = L ^ (647 / 600 : ℝ) := by + rw [← Real.rpow_add hLp] + norm_num + have heq3 : L ^ (1 / 12 : ℝ) * L ^ (199 / 200 : ℝ) = L ^ (647 / 600 : ℝ) := by + rw [← Real.rpow_add hLp] + norm_num + have hp1 := mul_le_mul_of_nonneg_left h8 (Real.rpow_nonneg hLp.le (203 / 200 : ℝ)) + rw [heq1] at hp1 + have hp2 := mul_le_mul_of_nonneg_left h64 (Real.rpow_nonneg hLp.le (21 / 20 : ℝ)) + rw [heq2] at hp2 + have hnegative := mul_le_mul_of_nonneg_right hrlo + (Real.rpow_nonneg hLp.le (199 / 200 : ℝ)) + rw [div_mul_eq_mul_div, heq3] at hnegative + have hpositive := mul_le_mul_of_nonneg_left hrhi + (show 0 ≤ C * Real.log L by positivity) + have hlog' : Real.log L ≤ (Real.log L) ^ 2 := by nlinarith + have hpos2 := mul_le_mul_of_nonneg_left hlog' (show 0 ≤ C * L by positivity) + rw [← Real.exp_nat_mul, ← Real.exp_add] + apply Real.exp_le_exp.mpr + nlinarith + +/-- The one-coordinate progression factor in exponential form. -/ +lemma progression_factor_le_exp (N : ℕ) (H T D : ℝ) + (hH : Real.exp T ≤ H) (hN : 2 + Real.log N ≤ Real.exp D) : + H⁻¹ + (1 + Real.log N) / H ≤ Real.exp (D - T) := by + have hHp : 0 < H := (Real.exp_pos _).trans_le hH + calc + _ = (2 + Real.log N) * H⁻¹ := by rw [div_eq_mul_inv]; ring + _ ≤ Real.exp D * Real.exp (-T) := by + apply mul_le_mul hN _ (inv_nonneg.mpr hHp.le) (by positivity) + rw [Real.exp_neg] + exact inv_anti₀ (Real.exp_pos _) hH + _ = _ := by simp only [sub_eq_add_neg, Real.exp_add] + +/-- The actual cutoffs `N ≤ exp L` and `H ≥ exp(L^(199/200))` +give a progression factor at most one for all sufficiently large `L`. -/ +lemma eventually_singleton_progression_factor : + ∀ᶠ L : ℝ in atTop, ∀ (N : ℕ) (H : ℝ), 1 ≤ N → (N : ℝ) ≤ Real.exp L → + Real.exp (L ^ (199 / 200 : ℝ)) ≤ H → + H⁻¹ + (1 + Real.log N) / H ≤ Real.exp (2 * Real.log L - L ^ (199 / 200 : ℝ)) ∧ + H⁻¹ + (1 + Real.log N) / H ≤ 1 := by + have hs := (isLittleO_log_rpow_atTop (show 0 < (199 / 200 : ℝ) by norm_num)).bound + (show 0 < (1 / 2 : ℝ) by norm_num) + filter_upwards [eventually_ge_atTop 2, hs] with L hL hs + intro N H hN hNL hH + have hLp : 0 < L := by linarith + have hl : 0 ≤ Real.log L := Real.log_nonneg (by linarith) + rw [Real.norm_eq_abs, abs_of_nonneg hl, Real.norm_eq_abs, + abs_of_pos (Real.rpow_pos_of_pos hLp _)] at hs + have hlogN : Real.log (N : ℝ) ≤ L := by + have ht := Real.log_le_log (show (0 : ℝ) < N by exact_mod_cast lt_of_lt_of_le Nat.zero_lt_one hN) hNL + simpa only [Real.log_exp] using ht + have hnum : 2 + Real.log N ≤ Real.exp (2 * Real.log L) := by + have he : Real.exp (2 * Real.log L) = L ^ (2 : ℕ) := by + rw [show 2 * Real.log L = Real.log L + Real.log L by ring, + Real.exp_add, Real.exp_log hLp] + ring + rw [he] + nlinarith + have hb := progression_factor_le_exp N H (L ^ (199 / 200 : ℝ)) (2 * Real.log L) hH hnum + refine ⟨hb, hb.trans ?_⟩ + rw [← Real.exp_zero] + apply Real.exp_le_exp.mpr + linarith + +/-- Transfer the finite progression estimate to the same exponential +scale. Its harmless numerator `2 + log N` is kept explicitly. -/ +theorem eventually_singleton_total (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ (r N : ℕ) (H cost total : ℝ), + L ^ (1 / 12 : ℝ) / 32 ≤ (r : ℝ) → (r : ℝ) ≤ L → + Real.exp (L ^ (199 / 200 : ℝ)) ≤ H → + 2 + Real.log N ≤ Real.exp (C * Real.log L) → + 0 ≤ cost → cost ≤ Real.exp (C * L * (Real.log L) ^ 2) → + total ≤ cost * (H⁻¹ + (1 + Real.log N) / H) ^ r → + total ≤ Real.exp (-L ^ (21 / 20 : ℝ)) := by + filter_upwards [eventually_singleton_decay C hC] with L hL + intro r N H cost total hrlo hrhi hH hN hcost hcost' htotal + have hHp : 0 < H := (Real.exp_pos _).trans_le hH + have hnum : 0 ≤ 2 + Real.log N := by + by_cases hzero : N = 0 + · simp [hzero] + · have hn : (1 : ℝ) ≤ N := by exact_mod_cast Nat.one_le_iff_ne_zero.mpr hzero + have hl := Real.log_nonneg hn + linarith + have hbase := progression_factor_le_exp N H (L ^ (199 / 200 : ℝ)) + (C * Real.log L) hH hN + have hnonneg : 0 ≤ H⁻¹ + (1 + Real.log N) / H := by + rw [show H⁻¹ + (1 + Real.log N) / H = (2 + Real.log N) * H⁻¹ by + rw [div_eq_mul_inv]; ring] + positivity + apply htotal.trans + calc + _ ≤ cost * (Real.exp (C * Real.log L - L ^ (199 / 200 : ℝ))) ^ r := + mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hnonneg hbase r) hcost + _ ≤ Real.exp (C * L * (Real.log L) ^ 2) * + (Real.exp (C * Real.log L - L ^ (199 / 200 : ℝ))) ^ r := + mul_le_mul_of_nonneg_right hcost' (by positivity) + _ ≤ _ := hL r hrlo hrhi + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonEncodedSupport.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonEncodedSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..7bbc7fc7c61a7aeee5ff4dd904107469c749d896 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonEncodedSupport.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResidueWitnessHybrid +import OAI.NumberTheory.TwoPoint.Bounds.EncodedWitnessUnion +import OAI.NumberTheory.TwoPoint.Walks.WitnessRecordBounds + +namespace OAI + +/-! Nonzero singleton centering is supported on the finite encoded witness union. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def WitnessStepAdmissible (P Q : Finset ℕ) (J M : ℕ) (t : SignedStep) : Prop := + Squarefree t.tuple ∧ Squarefree t.padding ∧ + t.tuple.primeFactors.card ≤ J ∧ t.padding.primeFactors.card ≤ M ∧ + t.tuple.primeFactors ⊆ P ∧ t.padding.primeFactors ⊆ Q + +theorem selected_residue_has_encoded_witness {ι W : Type*} + [Fintype ι] [DecidableEq ι] [Fintype W] [DecidableEq W] + (S : Finset ι) (p : ι → ℕ) (hprime : ∀ i, (p i).Prime) (hinj : Function.Injective p) + (B h s J n M D : ℕ) (P Q : Finset ℕ) (supply : ℕ → ℕ → Prop) + (main : List SignedStep) (word : W → List SignedStep) (attachment : W → ℕ) + (a x : ι → Fin B) + (hatt : ∀ w, attachment w ≤ main.length) + (hminimal : ∀ w, MinimalWord (ForwardProhibited h s supply) (word w)) + (hlen : ∀ w, (word w).length ≤ s) + (hdivsq : ∀ w t, t ∈ word w → Squarefree (t.padding * t.tuple)) + (hcard : ∀ w t, t ∈ word w → t.tuple.primeFactors.card = J) + (hsupport : ∀ w q j, TuplePrimeAt (word w) q j → + ¬q ∣ h ∧ ∀ t ∈ word w, ¬q ∣ t.padding) + (hpad : ∀ i ∈ S, ∀ w t, t ∈ word w → ¬p i ∣ t.padding) + (hcover : ∀ w q, q ∈ wordDivisorPrimeSupport (word w) → ∃ i, p i = q) + (position : S → ℕ) + (hmain : ∀ i : S, ∀ v, TuplePrimeAt main (p i) v → v = position i) + (hSmain : ∀ i ∈ S, p i ∈ wordDivisorPrimeSupport main) + (hmainvalid : ∀ t ∈ main, WitnessStepAdmissible P Q J M t) + (hwordvalid : ∀ w t, t ∈ word w → WitnessStepAdmissible P Q J M t) + (hP : ∀ p ∈ P, p.Prime) (hPQ : Disjoint P Q) + (hD : main.length + n * s ≤ D) + (hnonzero : selectedMixedDifference S a + (witnessAvoidance (fun w z => decide (AttachedResiduePositiveWord p h (word w) + (wordDisplacement h (main.take (attachment w))) B z))) x ≠ 0) + (hn : n * (s * J) < S.card) : + ∃ R : Fin (D + 1), ∃ d : WitnessRecord n R.val, + ∃ e : PrimeWordEncoding R.val (R.val * (J + M)) P Q, + EncodedWitnessHybridEvent d e main p B h s J supply x := by + have hsq (w) (t) (ht : t ∈ word w) := (hwordvalid w t ht).1 + obtain ⟨index, _hindex, hnum, y, hy, htests⟩ := + selected_residue_witnesses_and_hybrid S p hprime hinj B h s J n supply main word + attachment a x hatt hminimal hlen hsq hdivsq hcard hsupport hpad hcover + position hmain hnonzero hn + let v := recordedWitnessWord main (fun i => word (index i)) + have hvlen : v.length ≤ D := + (recordedWitnessWord_length_le main (fun i => word (index i)) s + (fun i => hlen (index i))).trans hD + have hvalid (t) (ht : t ∈ v) : WitnessStepAdmissible P Q J M t := by + rcases (mem_recordedWitnessWord main (fun i => word (index i)) t).mp ht with + ht | ⟨i, hi⟩ + · exact hmainvalid t ht + · exact hwordvalid (index i) t hi + have hslots : Fintype.card (ActualPrimeSlot v.get) ≤ v.length * (J + M) := by + exact recordedWitnessWord_slots_le main (fun i => word (index i)) J M + (fun t ht => ⟨(hmainvalid t ht).2.2.1, (hmainvalid t ht).2.2.2.1⟩) + (fun i t ht => ⟨(hwordvalid (index i) t ht).2.2.1, + (hwordvalid (index i) t ht).2.2.2.1⟩) + have hdisjoint (t) (ht : t ∈ v) (u) (hu : u ∈ v) : + Disjoint t.tuple.primeFactors u.padding.primeFactors := + hPQ.mono (hvalid t ht).2.2.2.2.1 (hvalid u hu).2.2.2.2.2 + obtain ⟨d, e, he, hdecode, hem, hew, hea, heweight⟩ := + actual_witness_has_encoded_record main (fun i => word (index i)) + (fun i => attachment (index i)) (fun i => hatt (index i)) P Q (v.length * (J + M)) + h s J supply p hnum hslots (fun t ht => (hvalid t ht).1) + (fun t ht => (hvalid t ht).2.1) (fun t ht => (hvalid t ht).2.2.2.2.1) + (fun t ht => (hvalid t ht).2.2.2.2.2) hdisjoint hP + refine ⟨⟨v.length, Nat.lt_succ_of_le hvlen⟩, d, e, he, ⟨hem, ?_, heweight⟩, y, ?_, ?_⟩ + · rw [hdecode] + congr 1 + funext i + simpa only [hdecode] using (hew i).symm + · intro i hi + exact hy i (fun his => hi (hSmain i his)) + · intro i + rw [hew i, hea i] + exact htests i + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonFamily.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc8be65e1f55ff9d57e6b01c97b9a047b11ff38e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonFamily.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.TwoPoint.Bounds.OrderedPrimeSystems +import OAI.NumberTheory.TwoPoint.Bounds.CrudeWordCounting + +namespace OAI + +/-! Sum the reciprocal savings of fixed singleton relation records. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {ι I : Type*} [Fintype ι] [DecidableEq ι] [Fintype I] + +/-- The nonzero tests stay in every system event, so the estimate remains +valid for all resampled prime assignments. -/ +theorem singleton_family_bound (system : I → OrderedPrimeSystem ι) (K : ℕ) + (hsize : ∀ i, K ≤ (system i).size) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hV : 1 ≤ primeHarmonicMass P) + (H N : ℕ) (hH : 0 < H) (hN : 1 ≤ N) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ N) + (hdelta : (H : ℝ)⁻¹ + (1 + Real.log N) / H ≤ 1) + (weight : I → ℝ) (hw : ∀ i, 0 ≤ weight i) : + (∑ i, weight i * ∑ x : ι → P, + if (system i).Holds (integerPrimeAssignment Subtype.val x) + then ∏ z, ((x z).val : ℝ)⁻¹ else 0) ≤ + (∑ i, weight i) * primeHarmonicMass P ^ Fintype.card ι * + ((H : ℝ)⁻¹ + (1 + Real.log N) / H) ^ K := by + have hlog : 0 ≤ Real.log (N : ℝ) := Real.log_nonneg (by exact_mod_cast hN) + have hd : 0 ≤ (H : ℝ)⁻¹ + (1 + Real.log N) / H := by positivity + rw [mul_assoc, sum_mul] + apply sum_le_sum + intro i _ + apply mul_le_mul_of_nonneg_left _ (hw i) + apply ((system i).reciprocal_sum_bound P hP hV H N hH hN hlo hhi).trans + exact mul_le_mul_of_nonneg_left (pow_le_pow_of_le_one hd hdelta (hsize i)) + (pow_nonneg (by linarith) _) + +/-- Outside numerical data is averaged separately from the finite +combinatorial record, preserving the unrestricted reciprocal mass. -/ +theorem outer_singleton_family_bound + (Ξ : I → Type*) [∀ i, Fintype (Ξ i)] + (system : ∀ i, Ξ i → OrderedPrimeSystem ι) (K : ℕ) + (hsize : ∀ i x, K ≤ (system i x).size) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hV : 1 ≤ primeHarmonicMass P) + (H N : ℕ) (hH : 0 < H) (hN : 1 ≤ N) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ N) + (hdelta : (H : ℝ)⁻¹ + (1 + Real.log N) / H ≤ 1) + (outerWeight : ∀ i, Ξ i → ℝ) (hout : ∀ i x, 0 ≤ outerWeight i x) + (outerMass : ℝ) (hmass : ∀ i, ∑ x, outerWeight i x ≤ outerMass) + (weight : I → ℝ) (hw : ∀ i, 0 ≤ weight i) : + (∑ i, weight i * ∑ x, outerWeight i x * ∑ y : ι → P, + if (system i x).Holds (integerPrimeAssignment Subtype.val y) + then ∏ z, ((y z).val : ℝ)⁻¹ else 0) ≤ + (∑ i, weight i) * outerMass * primeHarmonicMass P ^ Fintype.card ι * + ((H : ℝ)⁻¹ + (1 + Real.log N) / H) ^ K := by + have hlog : 0 ≤ Real.log (N : ℝ) := Real.log_nonneg (by exact_mod_cast hN) + have hd : 0 ≤ (H : ℝ)⁻¹ + (1 + Real.log N) / H := by positivity + have hs (i : I) := singleton_family_bound (system i) K (hsize i) P hP hV H N hH hN + hlo hhi hdelta (outerWeight i) (hout i) + rw [mul_assoc, mul_assoc, sum_mul] + apply sum_le_sum + intro i _ + apply mul_le_mul_of_nonneg_left _ (hw i) + apply (hs i).trans + have hm := mul_le_mul_of_nonneg_right (hmass i) + (mul_nonneg (pow_nonneg (show 0 ≤ primeHarmonicMass P by linarith) (Fintype.card ι)) (pow_nonneg hd K)) + simpa only [mul_assoc] using hm + +/-- The exact finite code count bounds the total nonnegative record weight. -/ +theorem singleton_record_weight_bound (R N D : ℕ) + (encode : I → CrudeWordCode R N D) (hinj : Function.Injective encode) + (weight : I → ℝ) (W : ℝ) (hW : 0 ≤ W) (hw : ∀ i, weight i ≤ W) : + (∑ i, weight i) ≤ (Fintype.card (CrudeWordCode R N D) : ℝ) * W := by + have hcard := Fintype.card_le_of_injective encode hinj + calc + _ ≤ ∑ _i : I, W := sum_le_sum (fun i _ => hw i) + _ = (Fintype.card I : ℝ) * W := by simp only [sum_const, card_univ, nsmul_eq_mul] + _ ≤ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast hcard) hW + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonPaddingSupport.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonPaddingSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..5dac495cb6de829f9353bcdf2bbf40bb108a91ae --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonPaddingSupport.lean @@ -0,0 +1,133 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SingletonEncodedSupport +import OAI.NumberTheory.TwoPoint.Bounds.EncodedPaddingWitness +import OAI.NumberTheory.TwoPoint.Bounds.ForcedSingletonDifference + +namespace OAI + +/-! The selected singleton support retains the original padding event. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem selected_residue_has_padding_witness {ι W : Type*} + [Fintype ι] [DecidableEq ι] [Fintype W] [DecidableEq W] + (S : Finset ι) (p : ι → ℕ) (hprime : ∀ i, (p i).Prime) (hinj : Function.Injective p) + (B h s J n M D : ℕ) (P Q : Finset ℕ) (supply : ℕ → ℕ → Prop) + (main : List SignedStep) (word : W → List SignedStep) (attachment : W → ℕ) + (a x : ι → Fin B) + (hatt : ∀ w, attachment w ≤ main.length) + (hminimal : ∀ w, MinimalWord (ForwardProhibited h s supply) (word w)) + (hlen : ∀ w, (word w).length ≤ s) + (hdivsq : ∀ w t, t ∈ word w → Squarefree (t.padding * t.tuple)) + (hcard : ∀ w t, t ∈ word w → t.tuple.primeFactors.card = J) + (hsupport : ∀ w q j, TuplePrimeAt (word w) q j → + ¬q ∣ h ∧ ∀ t ∈ word w, ¬q ∣ t.padding) + (hpad : ∀ i ∈ S, ∀ w t, t ∈ word w → ¬p i ∣ t.padding) + (hcover : ∀ w q, q ∈ wordDivisorPrimeSupport (word w) → ∃ i, p i = q) + (position : S → ℕ) + (hmain : ∀ i : S, ∀ v, TuplePrimeAt main (p i) v → v = position i) + (V : Finset ι) (hSV : S ⊆ V) (hretain : RetainedMainTests p V h B main x) + (hmainvalid : ∀ t ∈ main, WitnessStepAdmissible P Q J M t) + (hwordvalid : ∀ w t, t ∈ word w → WitnessStepAdmissible P Q J M t) + (hP : ∀ p ∈ P, p.Prime) (hPQ : Disjoint P Q) + (hD : main.length + n * s ≤ D) + (hnonzero : selectedMixedDifference S a + (witnessAvoidance (fun w z => decide (AttachedResiduePositiveWord p h (word w) + (wordDisplacement h (main.take (attachment w))) B z))) x ≠ 0) + (hn : n * (s * J) < S.card) : + ∃ R : Fin (D + 1), ∃ d : WitnessRecord n R.val, + ∃ e : PrimeWordEncoding R.val (R.val * (J + M)) P Q, + EncodedPaddingWitnessEvent V d e main p B h s J supply x := by + have hsq (w) (t) (ht : t ∈ word w) := (hwordvalid w t ht).1 + obtain ⟨index, _hindex, hnum, y, hy, htests⟩ := + selected_residue_witnesses_and_hybrid S p hprime hinj B h s J n supply main word + attachment a x hatt hminimal hlen hsq hdivsq hcard hsupport hpad hcover + position hmain hnonzero hn + let v := recordedWitnessWord main (fun i => word (index i)) + have hvlen : v.length ≤ D := + (recordedWitnessWord_length_le main (fun i => word (index i)) s + (fun i => hlen (index i))).trans hD + have hvalid (t) (ht : t ∈ v) : WitnessStepAdmissible P Q J M t := by + rcases (mem_recordedWitnessWord main (fun i => word (index i)) t).mp ht with + ht | ⟨i, hi⟩ + · exact hmainvalid t ht + · exact hwordvalid (index i) t hi + have hslots : Fintype.card (ActualPrimeSlot v.get) ≤ v.length * (J + M) := by + exact recordedWitnessWord_slots_le main (fun i => word (index i)) J M + (fun t ht => ⟨(hmainvalid t ht).2.2.1, (hmainvalid t ht).2.2.2.1⟩) + (fun i t ht => ⟨(hwordvalid (index i) t ht).2.2.1, + (hwordvalid (index i) t ht).2.2.2.1⟩) + have hdisjoint (t) (ht : t ∈ v) (u) (hu : u ∈ v) : + Disjoint t.tuple.primeFactors u.padding.primeFactors := + hPQ.mono (hvalid t ht).2.2.2.2.1 (hvalid u hu).2.2.2.2.2 + obtain ⟨d, e, he, hdecode, hem, hew, hea, heweight⟩ := + actual_witness_has_encoded_record main (fun i => word (index i)) + (fun i => attachment (index i)) (fun i => hatt (index i)) P Q (v.length * (J + M)) + h s J supply p hnum hslots (fun t ht => (hvalid t ht).1) + (fun t ht => (hvalid t ht).2.1) (fun t ht => (hvalid t ht).2.2.2.2.1) + (fun t ht => (hvalid t ht).2.2.2.2.2) hdisjoint hP + refine ⟨⟨v.length, Nat.lt_succ_of_le hvlen⟩, d, e, he, ⟨hem, ?_, heweight⟩, hretain, y, ?_, ?_⟩ + · rw [hdecode] + congr 1 + funext i + simpa only [hdecode] using (hew i).symm + · intro i hi + exact hy i (fun his => hi (hSV his)) + · intro i + rw [hew i, hea i] + exact htests i + +theorem forced_selected_residue_has_padding_witness {ι W : Type*} + [Fintype ι] [DecidableEq ι] [Fintype W] [DecidableEq W] + (S : Finset ι) (p : ι → ℕ) (hprime : ∀ i, (p i).Prime) (hinj : Function.Injective p) + (B h s J n M D : ℕ) (P Q : Finset ℕ) (supply : ℕ → ℕ → Prop) + (main : List SignedStep) (word : W → List SignedStep) (attachment : W → ℕ) + (a b x : ι → Fin B) (lit : Finset ι) (hSlit : Disjoint S lit) + (hatt : ∀ w, attachment w ≤ main.length) + (hminimal : ∀ w, MinimalWord (ForwardProhibited h s supply) (word w)) + (hlen : ∀ w, (word w).length ≤ s) + (hdivsq : ∀ w t, t ∈ word w → Squarefree (t.padding * t.tuple)) + (hcard : ∀ w t, t ∈ word w → t.tuple.primeFactors.card = J) + (hsupport : ∀ w q j, TuplePrimeAt (word w) q j → + ¬q ∣ h ∧ ∀ t ∈ word w, ¬q ∣ t.padding) + (hpad : ∀ i ∈ S, ∀ w t, t ∈ word w → ¬p i ∣ t.padding) + (hcover : ∀ w q, q ∈ wordDivisorPrimeSupport (word w) → ∃ i, p i = q) + (position : S → ℕ) + (hmain : ∀ i : S, ∀ v, TuplePrimeAt main (p i) v → v = position i) + (V : Finset ι) (hSV : S ⊆ V) (hlitV : lit ⊆ V) + (hretain : RetainedMainTests p V h B main x) + (hmainvalid : ∀ t ∈ main, WitnessStepAdmissible P Q J M t) + (hwordvalid : ∀ w t, t ∈ word w → WitnessStepAdmissible P Q J M t) + (hP : ∀ p ∈ P, p.Prime) (hPQ : Disjoint P Q) + (hD : main.length + n * s ≤ D) + (hnonzero : selectedMixedDifference S a + (fun z => witnessAvoidance (fun w y => decide (AttachedResiduePositiveWord p h (word w) + (wordDisplacement h (main.take (attachment w))) B y)) (forceCoordinates lit b z)) x ≠ 0) + (hn : n * (s * J) < S.card) : + ∃ R : Fin (D + 1), ∃ d : WitnessRecord n R.val, + ∃ e : PrimeWordEncoding R.val (R.val * (J + M)) P Q, + EncodedPaddingWitnessEvent V d e main p B h s J supply x := by + let F : (ι → Fin B) → ℝ := witnessAvoidance (fun w z => decide + (AttachedResiduePositiveWord p h (word w) + (wordDisplacement h (main.take (attachment w))) B z)) + have hnz : selectedMixedDifference S a F (forceCoordinates lit b x) ≠ 0 := by + rw [← selectedMixedDifference_force_disjoint S lit hSlit a b x F] + exact hnonzero + have hsame : ∀ i, i ∉ V → forceCoordinates lit b x i = x i := by + intro i hi + have hilit : i ∉ lit := fun hilit => hi (hlitV hilit) + simp only [forceCoordinates_apply, hilit, ite_false] + have hretain' : RetainedMainTests p V h B main (forceCoordinates lit b x) := + (retainedMainTests_congr p V h B main _ x hsame).mpr hretain + obtain ⟨R, d, e, he⟩ := selected_residue_has_padding_witness S p hprime hinj + B h s J n M D P Q supply main word attachment a (forceCoordinates lit b x) + hatt hminimal hlen hdivsq hcard hsupport hpad hcover position hmain V hSV hretain' + hmainvalid hwordvalid hP hPQ hD hnz hn + exact ⟨R, d, e, (EncodedPaddingWitnessEvent.congr V d e main p B h s J supply + (forceCoordinates lit b x) x hsame).mp he⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonWordEnvelope.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonWordEnvelope.lean new file mode 100644 index 0000000000000000000000000000000000000000..0fb2683aa95606988284baf6f006a710a80729af --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SingletonWordEnvelope.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.TwoPoint.Walks.WeightedWordEnvelope +import OAI.NumberTheory.TwoPoint.Bounds.SingletonPaddingSupport + +namespace OAI + +/-! Every nonzero full-word envelope supplies the same bounded numerical witness record. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem singleton_envelope_has_padding_witness {ι τ W : Type*} + [Fintype ι] [DecidableEq ι] [Fintype τ] [Fintype W] [DecidableEq W] + (label : τ → ι) (p : ι → ℕ) (hprime : ∀ i, (p i).Prime) + (hinj : Function.Injective p) (B h s J n M D : ℕ) + (P Q : Finset ℕ) (supply : ℕ → ℕ → Prop) + (main : List SignedStep) (word : W → List SignedStep) (attachment : W → ℕ) + (target : τ → Fin B) (base x : ι → Fin B) (R : (ι → Fin B) → ℝ) + (hatt : ∀ w, attachment w ≤ main.length) + (hminimal : ∀ w, MinimalWord (ForwardProhibited h s supply) (word w)) + (hlen : ∀ w, (word w).length ≤ s) + (hdivsq : ∀ w t, t ∈ word w → Squarefree (t.padding * t.tuple)) + (hcard : ∀ w t, t ∈ word w → t.tuple.primeFactors.card = J) + (hsupport : ∀ w q j, TuplePrimeAt (word w) q j → + ¬q ∣ h ∧ ∀ t ∈ word w, ¬q ∣ t.padding) + (hpad : ∀ i ∈ singletonLabels label, ∀ w t, t ∈ word w → ¬p i ∣ t.padding) + (hcover : ∀ w q, q ∈ wordDivisorPrimeSupport (word w) → ∃ i, p i = q) + (position : singletonLabels label → ℕ) + (hmain : ∀ i : singletonLabels label, ∀ v, TuplePrimeAt main (p i) v → v = position i) + (hretain : R x ≠ 0 → RetainedMainTests p (univ.image label) h B main x) + (hmainvalid : ∀ t ∈ main, WitnessStepAdmissible P Q J M t) + (hwordvalid : ∀ w t, t ∈ word w → WitnessStepAdmissible P Q J M t) + (hP : ∀ q ∈ P, q.Prime) (hPQ : Disjoint P Q) + (hD : main.length + n * s ≤ D) + (hn : n * (s * J) < (singletonLabels label).card) + (hne : centeredWordEnvelope label target base R + (witnessAvoidance (fun w z => decide (AttachedResiduePositiveWord p h (word w) + (wordDisplacement h (main.take (attachment w))) B z))) x ≠ 0) : + ∃ r : Fin (D + 1), ∃ d : WitnessRecord n r.val, + ∃ e : PrimeWordEncoding r.val (r.val * (J + M)) P Q, + EncodedPaddingWitnessEvent (univ.image label) d e main p B h s J supply x := by + obtain ⟨U, _hU, _hL, hRx, hd⟩ := centeredWordEnvelope_ne_zero label target base R _ x hne + have hS : singletonLabels label ⊆ univ.image label := by + intro i hi + obtain ⟨t, ht⟩ := singleton_occurrence_exists label ⟨i, hi⟩ + exact mem_image.mpr ⟨t, mem_univ _, ht⟩ + have hlit : (nonsingletonSlots label \ U).image label ⊆ univ.image label := by + intro i hi + obtain ⟨t, _, ht⟩ := mem_image.mp hi + exact mem_image.mpr ⟨t, mem_univ _, ht⟩ + exact forced_selected_residue_has_padding_witness (singletonLabels label) p hprime hinj + B h s J n M D P Q supply main word attachment (singletonTarget label target base) + (litForcedTarget (nonsingletonSlots label \ U) label target base) x + ((nonsingletonSlots label \ U).image label) (singleton_disjoint_designated label U) + hatt hminimal hlen hdivsq hcard hsupport hpad hcover position hmain + (univ.image label) hS hlit (hretain hRx) hmainvalid hwordvalid hP hPQ hD hd hn + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothDivisorDecomposition.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothDivisorDecomposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a21ef98eb22b636c16bc1fa9076cfa71159a6a8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothDivisorDecomposition.lean @@ -0,0 +1,154 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MultiplicativeExtraction +import Mathlib.NumberTheory.SmoothNumbers +import Mathlib.Data.Nat.GCD.BigOperators +import Mathlib.Data.List.Prime + +namespace OAI + +/-! Exact decomposition along primes of a fixed dilation. The coefficient +of a smooth divisor is bounded by one; there is no signed local expansion +or factor exponential in the number of dilation primes. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def primeSmoothPart (P : Finset ℕ) (n : ℕ) : ℕ := + (n.primeFactorsList.filter (fun p => p ∈ P)).prod + +noncomputable def primeRoughPart (P : Finset ℕ) (n : ℕ) : ℕ := + (n.primeFactorsList.filter (fun p => p ∉ P)).prod + +lemma primeSmoothPart_mul_primeRoughPart (P : Finset ℕ) (n : ℕ) (hn : 0 < n) : + primeSmoothPart P n * primeRoughPart P n = n := by + have he := List.prod_map_filter_mul_prod_map_filter_not + (fun p : ℕ => p ∈ P) (fun p : ℕ => p) n.primeFactorsList + simpa [primeSmoothPart, primeRoughPart, Nat.prod_primeFactorsList hn.ne'] using he + +lemma primeSmoothPart_pos (P : Finset ℕ) (n : ℕ) (hn : 0 < n) : + 0 < primeSmoothPart P n := by + have he := primeSmoothPart_mul_primeRoughPart P n hn + exact Nat.pos_of_ne_zero (fun hz => by rw [hz, zero_mul] at he; omega) + +lemma primeRoughPart_pos (P : Finset ℕ) (n : ℕ) (hn : 0 < n) : + 0 < primeRoughPart P n := by + have he := primeSmoothPart_mul_primeRoughPart P n hn + exact Nat.pos_of_ne_zero (fun hz => by rw [hz, mul_zero] at he; omega) + +lemma primeSmoothPart_support (P : Finset ℕ) (n : ℕ) : + (primeSmoothPart P n).primeFactors ⊆ P := by + intro p hp + have hprime := Nat.prime_of_mem_primeFactors hp + have hd := Nat.dvd_of_mem_primeFactors hp + obtain ⟨r, hr, hpr⟩ := hprime.prime.dvd_prod_iff.mp hd + obtain ⟨hrn, hrP⟩ := List.mem_filter.mp hr + have hrprime := Nat.prime_of_mem_primeFactorsList hrn + have he : p = r := ((Nat.dvd_prime hrprime).mp hpr).resolve_left hprime.ne_one + exact he.symm ▸ (of_decide_eq_true hrP) + +lemma primeRoughPart_coprime (q n : ℕ) (hq : 0 < q) : + q.Coprime (primeRoughPart q.primeFactors n) := by + apply Nat.coprime_list_prod_right_iff.mpr + intro p hp + obtain ⟨hpn, hpq⟩ := List.mem_filter.mp hp + have hprime := Nat.prime_of_mem_primeFactorsList hpn + apply Nat.Coprime.symm + apply hprime.coprime_iff_not_dvd.mpr + intro hd + exact (of_decide_eq_true hpq) (Nat.mem_primeFactors.mpr ⟨hprime, hd, hq.ne'⟩) + +lemma coprime_of_primeFactors_subset {a q n : ℕ} + (ha : 0 < a) (hs : a.primeFactors ⊆ q.primeFactors) + (hqn : q.Coprime n) : a.Coprime n := by + apply Nat.coprime_of_dvd' + intro p hp hpa hpn + have hpq := Nat.dvd_of_mem_primeFactors (hs (Nat.mem_primeFactors.mpr ⟨hp, hpa, ha.ne'⟩)) + have hcp : p.Coprime n := hqn.of_dvd_left hpq + exact False.elim ((hp.coprime_iff_not_dvd.mp hcp) hpn) + +lemma primeSmoothPart_unique (q n a : ℕ) (hq : 0 < q) (hn : 0 < n) + (ha : a ∣ n) (hs : a.primeFactors ⊆ q.primeFactors) (hc : q.Coprime (n / a)) : + a = primeSmoothPart q.primeFactors n := by + have hap : 0 < a := Nat.pos_of_dvd_of_pos ha hn + have hsp := primeSmoothPart_pos q.primeFactors n hn + have he := primeSmoothPart_mul_primeRoughPart q.primeFactors n hn + have har := coprime_of_primeFactors_subset hap hs (primeRoughPart_coprime q n hq) + have has : a ∣ primeSmoothPart q.primeFactors n := by + exact har.dvd_of_dvd_mul_right (he.symm ▸ ha) + have hsc := coprime_of_primeFactors_subset hsp + (primeSmoothPart_support q.primeFactors n) hc + have hsa : primeSmoothPart q.primeFactors n ∣ a := by + apply hsc.dvd_of_dvd_mul_right + rw [Nat.mul_div_cancel' ha] + exact ⟨primeRoughPart q.primeFactors n, he.symm⟩ + exact Nat.dvd_antisymm has hsa + +noncomputable def coprimeRestriction (q : ℕ) (f : ℕ → ℂ) (n : ℕ) : ℂ := + if q.Coprime n then f n else 0 + +lemma coprimeRestriction_oneBounded (q : ℕ) {f : ℕ → ℂ} (hf : OneBounded f) : + OneBounded (coprimeRestriction q f) := by + intro n hn + unfold coprimeRestriction + split_ifs + · exact hf n hn + · simp + +lemma coprimeRestriction_multiplicative (q : ℕ) {f : ℕ → ℂ} + (hf : Multiplicative f) : Multiplicative (coprimeRestriction q f) := by + intro a b ha hb hab + unfold coprimeRestriction + by_cases hqa : q.Coprime a + · by_cases hqb : q.Coprime b + · rw [ite_eq_left (Nat.coprime_mul_iff_right.mpr ⟨hqa, hqb⟩), + ite_eq_left hqa, ite_eq_left hqb] + exact hf a b ha hb hab + · have hn : ¬q.Coprime (a * b) := fun hc => hqb (Nat.coprime_mul_iff_right.mp hc).2 + rw [ite_eq_right hn, ite_eq_left hqa, ite_eq_right hqb, mul_zero] + · have hn : ¬q.Coprime (a * b) := fun hc => hqa (Nat.coprime_mul_iff_right.mp hc).1 + rw [ite_eq_right hn, ite_eq_right hqa, zero_mul] + +lemma coprimeRestriction_prime (q : ℕ) (hq : 0 < q) (f : ℕ → ℂ) + {p : ℕ} (hp : p.Prime) (hpq : p ∉ q.primeFactors) : + coprimeRestriction q f p = f p := by + apply ite_eq_left + apply Nat.Coprime.symm + apply hp.coprime_iff_not_dvd.mpr + intro hd + exact hpq (Nat.mem_primeFactors.mpr ⟨hp, hd, hq.ne'⟩) + +/-- The fixed-dilation sequence is a positive-density convolution over +smooth divisors; its scalar coefficients have modulus at most one. -/ +theorem multiplicative_dilation_smooth_sum {f : ℕ → ℂ} (hf : Multiplicative f) + (q n : ℕ) (hq : 0 < q) (hn : 0 < n) : + f (q * n) = ∑ a ∈ n.divisors.filter (fun a => a.primeFactors ⊆ q.primeFactors), + f (q * a) * coprimeRestriction q f (n / a) := by + let s := primeSmoothPart q.primeFactors n + let r := primeRoughPart q.primeFactors n + have hs : 0 < s := primeSmoothPart_pos _ _ hn + have hr : 0 < r := primeRoughPart_pos _ _ hn + have he : s * r = n := primeSmoothPart_mul_primeRoughPart _ _ hn + have hqr : q.Coprime r := primeRoughPart_coprime q n hq + have hsr := coprime_of_primeFactors_subset hs (primeSmoothPart_support _ _) hqr + have hdiv : s ∣ n := ⟨r, he.symm⟩ + have hmem : s ∈ n.divisors.filter (fun a => a.primeFactors ⊆ q.primeFactors) := + mem_filter.mpr ⟨Nat.mem_divisors.mpr ⟨hdiv, hn.ne'⟩, primeSmoothPart_support _ _⟩ + rw [sum_eq_single s] + · rw [show n / s = r by rw [← he, Nat.mul_div_cancel_left _ hs]] + rw [coprimeRestriction, ite_eq_left hqr, ← hf (q * s) r (Nat.mul_pos hq hs) hr + (hqr.mul_left hsr)] + congr 1 + rw [mul_assoc, he] + · intro a ha hne + unfold coprimeRestriction + by_cases hc : q.Coprime (n / a) + · have ha' := mem_filter.mp ha + exact False.elim (hne (primeSmoothPart_unique q n a hq hn + (Nat.mem_divisors.mp ha'.1).1 ha'.2 hc)) + · rw [ite_eq_right hc, mul_zero] + · exact fun h => False.elim (h hmem) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothProductBounds.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothProductBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd822258ef567e8a463fac0848540e379cc1bb59 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothProductBounds.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SmoothReciprocalMass + +namespace OAI + +/-! Elementary bounds for the Euler cost of adjoining retained tuple primes. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma one_le_smoothReciprocalProduct (P : Finset ℕ) + (hP : ∀ p ∈ P, p.Prime) (s : ℝ) (hs : 0 < s) : + 1 ≤ smoothReciprocalProduct P s := by + apply one_le_prod₀ + intro p hp + have hr : (p : ℝ) ^ (-s) < 1 := + Real.rpow_lt_one_of_one_lt_of_neg (by exact_mod_cast (hP p hp).one_lt) (by linarith) + exact (one_le_inv₀ (sub_pos.mpr hr)).mpr (by + have hh := Real.rpow_nonneg (Nat.cast_nonneg p) (-s) + linarith) + +lemma smoothReciprocalProduct_union_le (P Q : Finset ℕ) + (hP : ∀ p ∈ P, p.Prime) (hQ : ∀ p ∈ Q, p.Prime) + (s : ℝ) (hs : 0 < s) : + smoothReciprocalProduct (P ∪ Q) s ≤ + smoothReciprocalProduct P s * smoothReciprocalProduct Q s := by + have he : smoothReciprocalProduct (P ∪ Q) s * smoothReciprocalProduct (P ∩ Q) s = + smoothReciprocalProduct P s * smoothReciprocalProduct Q s := by + exact prod_union_inter + have hnonneg := smoothReciprocalProduct_nonneg (P ∪ Q) + (fun p hp => (mem_union.mp hp).elim (hP p) (hQ p)) s hs + have hone := one_le_smoothReciprocalProduct (P ∩ Q) + (fun p hp => hP p (mem_inter.mp hp).1) s hs + exact (le_mul_of_one_le_right hnonneg hone).trans_eq he + +lemma smoothReciprocalProduct_mul_le (q t : ℕ) (hq : 0 < q) (ht : 0 < t) + (s : ℝ) (hs : 0 < s) : + smoothReciprocalProduct (q * t).primeFactors s ≤ + smoothReciprocalProduct q.primeFactors s * smoothReciprocalProduct t.primeFactors s := by + rw [Nat.primeFactors_mul hq.ne' ht.ne'] + exact smoothReciprocalProduct_union_le _ _ (fun _ hp => Nat.prime_of_mem_primeFactors hp) + (fun _ hp => Nat.prime_of_mem_primeFactors hp) s hs + +lemma reciprocal_one_sub_le_exp (r : ℝ) (hr : 0 ≤ r) (hrhalf : r ≤ 1 / 2) : + (1 - r)⁻¹ ≤ Real.exp (2 * r) := by + have hd : 0 < 1 - r := by linarith + have hinv : (1 - r)⁻¹ ≤ 1 + 2 * r := by + have hh : 1 / (1 - r) ≤ 1 + 2 * r := (div_le_iff₀ hd).mpr (by + nlinarith [mul_nonneg hr (show 0 ≤ 1 - 2 * r by linarith)]) + simpa only [one_div] using hh + exact hinv.trans (by simpa only [add_comm] using Real.add_one_le_exp (2 * r)) + +lemma smooth_half_product_exp_bound (P : Finset ℕ) + (hsmall : ∀ p ∈ P, (p : ℝ) ^ (-(1 / 2) : ℝ) ≤ 1 / 2) : + smoothReciprocalProduct P (1 / 2 : ℝ) ≤ + Real.exp (2 * ∑ p ∈ P, (p : ℝ) ^ (-(1 / 2) : ℝ)) := by + calc + _ ≤ ∏ p ∈ P, Real.exp (2 * (p : ℝ) ^ (-(1 / 2) : ℝ)) := by + apply prod_le_prod₀ + · intro p hp + apply inv_nonneg.mpr + have hh := hsmall p hp + linarith + · intro p hp + exact reciprocal_one_sub_le_exp _ (Real.rpow_nonneg (Nat.cast_nonneg p) _) (hsmall p hp) + _ = _ := by rw [← Real.exp_sum, mul_sum] + +lemma smooth_half_product_le_two (P : Finset ℕ) + (hsmall : ∀ p ∈ P, (p : ℝ) ^ (-(1 / 2) : ℝ) ≤ 1 / 2) + (hsum : 2 * ∑ p ∈ P, (p : ℝ) ^ (-(1 / 2) : ℝ) ≤ Real.log 2) : + smoothReciprocalProduct P (1 / 2 : ℝ) ≤ 2 := by + exact (smooth_half_product_exp_bound P hsmall).trans + ((Real.exp_le_exp.mpr hsum).trans_eq (Real.exp_log (by norm_num))) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothReciprocalMass.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothReciprocalMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..47dd95836df68983d701e5bd0000e691336c1760 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothReciprocalMass.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SmoothDivisorDecomposition +import Mathlib.NumberTheory.EulerProduct.Basic +import Mathlib.Analysis.SpecialFunctions.Pow.Real + +namespace OAI + +/-! Finite-prime smooth reciprocal sums. The exact Euler factors make +averaging the dilation cost against the padding law possible. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def smoothReciprocalProduct (P : Finset ℕ) (s : ℝ) : ℝ := + ∏ p ∈ P, (1 - (p : ℝ) ^ (-s))⁻¹ + +noncomputable def natNegativePower (s : ℝ) : ℕ →* ℝ where + toFun n := (n : ℝ) ^ (-s) + map_one' := by simp + map_mul' m n := by + push_cast + exact Real.mul_rpow (Nat.cast_nonneg m) (Nat.cast_nonneg n) + +lemma smoothReciprocalProduct_hasSum (P : Finset ℕ) + (hP : ∀ p ∈ P, p.Prime) (s : ℝ) (hs : 0 < s) : + HasSum (fun a : Nat.factoredNumbers P => (a.val : ℝ) ^ (-s)) + (smoothReciprocalProduct P s) := by + have h := EulerProduct.summable_and_hasSum_factoredNumbers_prod_filter_prime_geometric + (f := natNegativePower s) (fun {p} hp => by + change ‖(p : ℝ) ^ (-s)‖ < 1 + rw [Real.norm_eq_abs, abs_of_nonneg (Real.rpow_nonneg (Nat.cast_nonneg p) _)] + exact Real.rpow_lt_one_of_one_lt_of_neg (by exact_mod_cast hp.one_lt) (by linarith)) P + have he : P.filter Nat.Prime = P := filter_eq_self.mpr hP + simpa [natNegativePower, smoothReciprocalProduct, he] using h.2 + +lemma smoothReciprocalProduct_nonneg (P : Finset ℕ) + (hP : ∀ p ∈ P, p.Prime) (s : ℝ) (hs : 0 < s) : + 0 ≤ smoothReciprocalProduct P s := by + apply (smoothReciprocalProduct_hasSum P hP s hs).nonneg + intro a + exact Real.rpow_nonneg (Nat.cast_nonneg a.val) _ + +lemma smooth_reciprocal_sum_le (P A : Finset ℕ) + (hP : ∀ p ∈ P, p.Prime) (s : ℝ) (hs : 0 < s) + (hA : ∀ a ∈ A, a ∈ Nat.factoredNumbers P) : + (∑ a ∈ A, (a : ℝ) ^ (-s)) ≤ smoothReciprocalProduct P s := by + let e : A → Nat.factoredNumbers P := fun a => ⟨a.val, hA a.val a.property⟩ + have he : Function.Injective e := by + intro a b hab + apply Subtype.ext + exact congrArg (fun x : Nat.factoredNumbers P => x.val) hab + have hb := sum_le_hasSum (univ.image e) + (fun a _ => Real.rpow_nonneg (Nat.cast_nonneg a.val) (-s)) + (smoothReciprocalProduct_hasSum P hP s hs) + rw [sum_image (fun a _ b _ hab => he hab)] at hb + rw [← sum_coe_sort A (fun a : ℕ => (a : ℝ) ^ (-s))] + simpa only [e] using hb + +/-- The geometric reciprocal cost of every smooth part of a bounded +integer is controlled independently of the outer bound. -/ +lemma smooth_divisor_reciprocal_sum_le (q n : ℕ) (s : ℝ) (hs : 0 < s) : + (∑ a ∈ n.divisors.filter (fun a => a.primeFactors ⊆ q.primeFactors), + (a : ℝ) ^ (-s)) ≤ smoothReciprocalProduct q.primeFactors s := by + apply smooth_reciprocal_sum_le _ _ (fun _ hp => Nat.prime_of_mem_primeFactors hp) s hs + intro a ha + obtain ⟨ha, has⟩ := mem_filter.mp ha + exact Nat.mem_factoredNumbers_of_primeFactors_subset + (Nat.pos_of_dvd_of_pos (Nat.mem_divisors.mp ha).1 + (Nat.pos_of_ne_zero (Nat.mem_divisors.mp ha).2)).ne' has + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothTailDensity.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothTailDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..7031ed729583ddf5cea7a91a8e600ed3409ef049 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothTailDensity.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.TwoPoint.Bounds.TruncatedDilation +import OAI.NumberTheory.TwoPoint.Bounds.SmoothReciprocalMass + +namespace OAI + +/-! The density discarded by truncating the smooth part of an integer. +The bound retains the exact half-power Euler cost of the dilation. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma reciprocal_smooth_tail (P A : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (K : ℝ) (hK : 0 < K) (hA : ∀ a ∈ A, a ∈ Nat.factoredNumbers P) + (hlarge : ∀ a ∈ A, K ≤ (a : ℝ)) : + (∑ a ∈ A, 1 / (a : ℝ)) ≤ + K ^ (-(1 / 2) : ℝ) * smoothReciprocalProduct P (1 / 2 : ℝ) := by + calc + _ ≤ ∑ a ∈ A, K ^ (-(1 / 2) : ℝ) * (a : ℝ) ^ (-(1 / 2) : ℝ) := by + apply sum_le_sum + intro a ha + have hap : (0 : ℝ) < a := hK.trans_le (hlarge a ha) + have he : 1 / (a : ℝ) = (a : ℝ) ^ (-(1 / 2) : ℝ) * + (a : ℝ) ^ (-(1 / 2) : ℝ) := by + rw [← Real.rpow_add hap] + norm_num [Real.rpow_neg_one] + rw [he] + exact mul_le_mul_of_nonneg_right + (Real.rpow_le_rpow_of_nonpos hK (hlarge a ha) (by norm_num)) (by positivity) + _ = K ^ (-(1 / 2) : ℝ) * ∑ a ∈ A, (a : ℝ) ^ (-(1 / 2) : ℝ) := + (mul_sum _ _ _).symm + _ ≤ _ := mul_le_mul_of_nonneg_left + (smooth_reciprocal_sum_le P A hP (1 / 2) (by norm_num) hA) (by positivity) + +lemma smooth_part_tail_density (q K N : ℕ) (hK : 0 < K) : + (∑ v ∈ range N, if K < primeSmoothPart q.primeFactors (v + 1) + then (1 : ℝ) else 0) ≤ + (N : ℝ) * (K : ℝ) ^ (-(1 / 2) : ℝ) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + let A := (Icc (K + 1) N).filter (fun a => a.primeFactors ⊆ q.primeFactors) + have hA (a : ℕ) (ha : a ∈ A) : 0 < a := by + have hh := (mem_Icc.mp (mem_filter.mp ha).1).1 + omega + have hsum : (∑ v ∈ range N, if K < primeSmoothPart q.primeFactors (v + 1) + then (1 : ℝ) else 0) ≤ ∑ a ∈ A, ((N / a : ℕ) : ℝ) := by + calc + _ ≤ ∑ v ∈ range N, ∑ a ∈ A, if a ∣ v + 1 then (1 : ℝ) else 0 := by + apply sum_le_sum + intro v hv + apply (smoothPart_tail_indicator q (v + 1) K (by omega)).trans + apply sum_le_sum_of_subset_of_nonneg + · intro a ha + obtain ⟨ha, hs⟩ := mem_filter.mp ha + exact mem_filter.mpr ⟨mem_Icc.mpr ⟨(mem_Icc.mp ha).1, + (mem_Icc.mp ha).2.trans (by have hv' := mem_range.mp hv; omega)⟩, hs⟩ + · intro a _ _ + split_ifs <;> positivity + _ = _ := by + rw [sum_comm] + apply sum_congr rfl + intro a _ + have hh := congrArg (fun n : ℕ => (n : ℝ)) (Nat.card_multiples N a) + simpa only [card_filter, Nat.cast_sum, Nat.cast_ite, Nat.cast_one, + Nat.cast_zero] using hh + have hmass := reciprocal_smooth_tail q.primeFactors A + (fun p hp => Nat.prime_of_mem_primeFactors hp) (K : ℝ) + (by exact_mod_cast hK) + (fun a ha => Nat.mem_factoredNumbers_of_primeFactors_subset (hA a ha).ne' + (mem_filter.mp ha).2) + (fun a ha => by exact_mod_cast (show K ≤ a by + have hh := (mem_Icc.mp (mem_filter.mp ha).1).1; omega)) + calc + _ ≤ ∑ a ∈ A, ((N / a : ℕ) : ℝ) := hsum + _ ≤ ∑ a ∈ A, (N : ℝ) / a := sum_le_sum (fun _ _ => Nat.cast_div_le) + _ = (N : ℝ) * ∑ a ∈ A, 1 / (a : ℝ) := by + rw [mul_sum] + apply sum_congr rfl + intro a _ + ring + _ ≤ _ := (mul_le_mul_of_nonneg_left hmass (Nat.cast_nonneg N)).trans_eq (by ring) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothWindowBound.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothWindowBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba25ce68fefe45de4d88462ba8534f27a7eb73ac --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothWindowBound.lean @@ -0,0 +1,120 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SmoothWindowSum + +namespace OAI + +/-! Summing the shorter-window estimates costs a reciprocal smooth sum, +not the number of smooth divisors. The elementary endpoint error is explicit. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma smooth_harmonic_sum_le (q K : ℕ) : + (∑ a ∈ (Icc 1 K).filter (fun a => a.primeFactors ⊆ q.primeFactors), + 1 / (a : ℝ)) ≤ smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + let A := (Icc 1 K).filter (fun a => a.primeFactors ⊆ q.primeFactors) + have hA (a : ℕ) (ha : a ∈ A) : 0 < a := (mem_Icc.mp (mem_filter.mp ha).1).1 + calc + _ ≤ ∑ a ∈ A, (a : ℝ) ^ (-(1 / 2) : ℝ) := by + apply sum_le_sum + intro a ha + rw [one_div, ← Real.rpow_neg_one] + apply Real.rpow_le_rpow_of_exponent_le + · exact_mod_cast hA a ha + · norm_num + _ ≤ _ := smooth_reciprocal_sum_le q.primeFactors A + (fun p hp => Nat.prime_of_mem_primeFactors hp) (1 / 2) (by norm_num) + (fun a ha => Nat.mem_factoredNumbers_of_primeFactors_subset (hA a ha).ne' + (mem_filter.mp ha).2) + +lemma dilation_window_count_bound (a D Y : ℕ) + (ha : 0 < a) (haD : a ≤ D) (haY : a ≤ Y) : + (a : ℝ) * (D / a + 1 : ℕ) * (Y / a + 1 : ℕ) ≤ + 4 * (D : ℝ) * Y / a := by + have hap : (0 : ℝ) < a := by exact_mod_cast ha + have hd : (1 : ℝ) ≤ (D : ℝ) / a := (le_div_iff₀ hap).mpr (by simpa only [one_mul] using (show (a : ℝ) ≤ D by exact_mod_cast haD)) + have hy : (1 : ℝ) ≤ (Y : ℝ) / a := (le_div_iff₀ hap).mpr (by simpa only [one_mul] using (show (a : ℝ) ≤ Y by exact_mod_cast haY)) + have hD : ((D / a + 1 : ℕ) : ℝ) ≤ 2 * (D : ℝ) / a := by + have hh : ((D / a : ℕ) : ℝ) ≤ (D : ℝ) / a := Nat.cast_div_le + push_cast + calc + (D / a : ℕ) + (1 : ℝ) ≤ (D : ℝ) / a + 1 := add_le_add hh le_rfl + _ ≤ 2 * ((D : ℝ) / a) := by linarith only [hd] + _ = _ := by ring + have hY : ((Y / a + 1 : ℕ) : ℝ) ≤ 2 * (Y : ℝ) / a := by + have hh : ((Y / a : ℕ) : ℝ) ≤ (Y : ℝ) / a := Nat.cast_div_le + push_cast + calc + (Y / a : ℕ) + (1 : ℝ) ≤ (Y : ℝ) / a + 1 := add_le_add hh le_rfl + _ ≤ 2 * ((Y : ℝ) / a) := by linarith only [hy] + _ = _ := by ring + calc + _ ≤ (a : ℝ) * (2 * D / a) * (2 * Y / a) := by gcongr + _ = _ := by field_simp; ring + +/-- The finite analytic assembly used for a dilated nonpretentious factor. +`hbase` is subsequently supplied by the published MRT theorem, uniformly in +the original function's finite-prime changes. -/ +theorem smooth_dilation_window_bound {f : ℕ → ℂ} + (hf : Multiplicative f) (hfb : OneBounded f) + (q K D Y : ℕ) (hq : 0 < q) (hK : 0 < K) + (hKD : K ≤ D) (hDY : D ≤ Y) (C E : ℝ) (hC : 0 ≤ C) (hE : 0 ≤ E) + (hbase : ∀ a ∈ Icc 1 K, ∀ β : ℝ, + (∑ m ∈ range (Y / a + 1), + ‖shortWindowSum (coprimeRestriction q f) (D / a + 1) β m‖) ≤ + C * (D / a + 1 : ℕ) * (Y / a + 1 : ℕ) * E) + (α : ℝ) : + (∑ v ∈ range Y, ‖shortWindowSum (fun n => f (q * n)) D α v‖) ≤ + 4 * C * D * Y * E * smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) + + (K : ℝ) * Y + 2 * D * Y * (K : ℝ) ^ (-(1 / 2) : ℝ) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + let A := (Icc 1 K).filter (fun a => a.primeFactors ⊆ q.primeFactors) + have hcoeff : 0 ≤ 4 * C * D * Y * E := by positivity + have hs : (∑ a ∈ A, ((a : ℝ) * (∑ m ∈ range (Y / a + 1), + ‖shortWindowSum (coprimeRestriction q f) (D / a + 1) (a * α) m‖) + Y)) ≤ + 4 * C * D * Y * E * smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) + + (K : ℝ) * Y := by + calc + _ ≤ ∑ a ∈ A, (4 * C * D * Y * E * (1 / (a : ℝ)) + Y) := by + apply sum_le_sum + intro a ha + have haI := (mem_filter.mp ha).1 + have hap : 0 < a := (mem_Icc.mp haI).1 + have haD := (mem_Icc.mp haI).2.trans hKD + have haY := haD.trans hDY + apply add_le_add ?_ le_rfl + calc + _ ≤ (a : ℝ) * (C * (D / a + 1 : ℕ) * (Y / a + 1 : ℕ) * E) := + mul_le_mul_of_nonneg_left (hbase a haI _) (Nat.cast_nonneg a) + _ = (C * E) * ((a : ℝ) * (D / a + 1 : ℕ) * (Y / a + 1 : ℕ)) := by ring + _ ≤ (C * E) * (4 * (D : ℝ) * Y / a) := + mul_le_mul_of_nonneg_left (dilation_window_count_bound a D Y hap haD haY) + (mul_nonneg hC hE) + _ = _ := by ring + _ = 4 * C * D * Y * E * (∑ a ∈ A, 1 / (a : ℝ)) + (A.card : ℝ) * Y := by + rw [sum_add_distrib, ← mul_sum] + simp only [sum_const, nsmul_eq_mul] + _ ≤ _ := by + apply add_le_add + · exact mul_le_mul_of_nonneg_left (smooth_harmonic_sum_le q K) hcoeff + · apply mul_le_mul_of_nonneg_right _ (Nat.cast_nonneg Y) + have hsub : A ⊆ Icc 1 K := filter_subset _ _ + have hcard : A.card ≤ K := by simpa using card_le_card hsub + exact_mod_cast hcard + have htail : (D : ℝ) * (Y + D) * (K : ℝ) ^ (-(1 / 2) : ℝ) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) ≤ + 2 * D * Y * (K : ℝ) ^ (-(1 / 2) : ℝ) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + have hDYr : (D : ℝ) ≤ Y := by exact_mod_cast hDY + have hM := smoothReciprocalProduct_nonneg q.primeFactors + (fun p hp => Nat.prime_of_mem_primeFactors hp) (1 / 2) (by norm_num) + have hh : (D : ℝ) * (Y + D) ≤ 2 * D * Y := by nlinarith [show (0 : ℝ) ≤ D from Nat.cast_nonneg D] + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right hh (Real.rpow_nonneg (Nat.cast_nonneg K) _)) hM + exact (smooth_dilation_window_sum hf hfb q K D Y hq hK α).trans + ((add_le_add hs htail).trans_eq (by ring)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothWindowSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothWindowSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..9625ce505a2ae2f51fec6f79d116b8ce9ea271af --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SmoothWindowSum.lean @@ -0,0 +1,175 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DilatedWindows +import OAI.NumberTheory.TwoPoint.Bounds.SmoothTailDensity + +namespace OAI + +/-! The exact smooth-divisor decomposition inside a short Fourier window, +with the discarded tail bounded before any cancellation is used. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma shortWindowSum_sub (f g : ℕ → ℂ) (D v : ℕ) (α : ℝ) : + shortWindowSum (fun n => f n - g n) D α v = + shortWindowSum f D α v - shortWindowSum g D α v := by + simp only [shortWindowSum, sub_mul, sum_sub_distrib] + +lemma norm_shortWindowSum_le (f : ℕ → ℂ) (D v : ℕ) (α : ℝ) : + ‖shortWindowSum f D α v‖ ≤ ∑ m ∈ range D, ‖f (v + m + 1)‖ := by + apply (norm_sum_le _ _).trans + simp only [norm_mul, norm_additiveCharacter, mul_one, le_refl] + +lemma window_error_from_density (f g : ℕ → ℂ) (e : ℕ → ℝ) + (he : ∀ n, 0 ≤ e n) (hfg : ∀ n, 0 < n → ‖f n - g n‖ ≤ e n) + (D Y : ℕ) (α : ℝ) : + (∑ v ∈ range Y, ‖shortWindowSum f D α v - shortWindowSum g D α v‖) ≤ + (D : ℝ) * ∑ n ∈ range (Y + D), e (n + 1) := by + calc + _ ≤ ∑ v ∈ range Y, ∑ m ∈ range D, e (v + m + 1) := by + apply sum_le_sum + intro v _ + rw [← shortWindowSum_sub] + exact (norm_shortWindowSum_le _ _ _ _).trans + (sum_le_sum (fun m _ => hfg _ (by omega))) + _ = ∑ m ∈ range D, ∑ v ∈ range Y, e (v + m + 1) := sum_comm + _ ≤ ∑ _m ∈ range D, ∑ n ∈ range (Y + D), e (n + 1) := by + apply sum_le_sum + intro m hm + apply sum_le_sum_of_injOn (fun v => v + m) + · intro v _ w _ h + change v + m = w + m at h + omega + · intro x hx + obtain ⟨v, hv, rfl⟩ := mem_image.mp hx + simp only [mem_range] at hm hv ⊢ + omega + · intro v _ + exact le_rfl + · intro n _ _ + exact he _ + _ = _ := by simp + +lemma truncated_window_error {f : ℕ → ℂ} (hf : OneBounded f) + (q K D Y : ℕ) (hq : 0 < q) (hK : 0 < K) (α : ℝ) : + (∑ v ∈ range Y, ‖shortWindowSum (fun n => f (q * n)) D α v - + shortWindowSum (truncatedDilation q f K) D α v‖) ≤ + (D : ℝ) * (Y + D) * (K : ℝ) ^ (-(1 / 2) : ℝ) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + apply (window_error_from_density _ _ + (fun n => if K < primeSmoothPart q.primeFactors n then 1 else 0) + (fun _ => by split_ifs <;> positivity) + (fun n hn => norm_truncatedDilation_error hf q n K hq hn) D Y α).trans + have hb := smooth_part_tail_density q K (Y + D) hK + calc + _ ≤ (D : ℝ) * ((Y + D : ℕ) * (K : ℝ) ^ (-(1 / 2) : ℝ) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ)) := + mul_le_mul_of_nonneg_left hb (Nat.cast_nonneg D) + _ = _ := by push_cast; ring + +lemma smoothDilationTerm_as_dilation (q a : ℕ) (f : ℕ → ℂ) + (ha : a.primeFactors ⊆ q.primeFactors) : + smoothDilationTerm q f a = fun n => + f (q * a) * dilationSequence a (coprimeRestriction q f) n := by + funext n + unfold smoothDilationTerm dilationSequence + by_cases hd : a ∣ n + · rw [ite_eq_left ⟨ha, hd⟩, ite_eq_left hd] + · rw [ite_eq_right (fun h => hd h.2), ite_eq_right hd, mul_zero] + +lemma truncated_shortWindowSum {f : ℕ → ℂ} (hf : Multiplicative f) + (q K D v : ℕ) (hq : 0 < q) (α : ℝ) : + shortWindowSum (truncatedDilation q f K) D α v = + ∑ a ∈ (Icc 1 K).filter (fun a => a.primeFactors ⊆ q.primeFactors), + f (q * a) * shortWindowSum (dilationSequence a (coprimeRestriction q f)) D α v := by + unfold shortWindowSum + have hexpand : (∑ m ∈ range D, + truncatedDilation q f K (v + m + 1) * additiveCharacter α (m + 1)) = + ∑ m ∈ range D, (∑ a ∈ Icc 1 K, + smoothDilationTerm q f a (v + m + 1)) * additiveCharacter α (m + 1) := by + apply sum_congr rfl + intro m _ + rw [truncatedDilation_eq_sum hf q (v + m + 1) K hq (by omega)] + rw [hexpand] + simp_rw [sum_mul] + rw [sum_comm] + symm + rw [sum_filter] + apply sum_congr rfl + intro a _ + by_cases ha : a.primeFactors ⊆ q.primeFactors + · rw [ite_eq_left ha] + simp only [mul_sum, ← mul_assoc, smoothDilationTerm_as_dilation q a f ha] + · rw [ite_eq_right ha] + symm + apply sum_eq_zero + intro m _ + rw [smoothDilationTerm, ite_eq_right (fun h => ha h.1), zero_mul] + +/-- Finite short-window majorant: one genuine shorter window for each +smooth divisor, and one density term for all discarded smooth divisors. -/ +theorem smooth_dilation_window_sum {f : ℕ → ℂ} (hf : Multiplicative f) + (hfb : OneBounded f) (q K D Y : ℕ) (hq : 0 < q) (hK : 0 < K) (α : ℝ) : + (∑ v ∈ range Y, ‖shortWindowSum (fun n => f (q * n)) D α v‖) ≤ + (∑ a ∈ (Icc 1 K).filter (fun a => a.primeFactors ⊆ q.primeFactors), + ((a : ℝ) * (∑ m ∈ range (Y / a + 1), + ‖shortWindowSum (coprimeRestriction q f) (D / a + 1) (a * α) m‖) + Y)) + + (D : ℝ) * (Y + D) * (K : ℝ) ^ (-(1 / 2) : ℝ) * + smoothReciprocalProduct q.primeFactors (1 / 2 : ℝ) := by + let A := (Icc 1 K).filter (fun a => a.primeFactors ⊆ q.primeFactors) + have hs : (∑ v ∈ range Y, ‖shortWindowSum (truncatedDilation q f K) D α v‖) ≤ + ∑ a ∈ A, ((a : ℝ) * (∑ m ∈ range (Y / a + 1), + ‖shortWindowSum (coprimeRestriction q f) (D / a + 1) (a * α) m‖) + Y) := by + calc + _ ≤ ∑ v ∈ range Y, ∑ a ∈ A, + ‖shortWindowSum (dilationSequence a (coprimeRestriction q f)) D α v‖ := by + apply sum_le_sum + intro v _ + rw [truncated_shortWindowSum hf q K D v hq α] + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro a ha + have hap : 0 < a := (mem_Icc.mp (mem_filter.mp ha).1).1 + rw [norm_mul] + exact mul_le_of_le_one_left (norm_nonneg _) (hfb _ (Nat.mul_pos hq hap)) + _ = ∑ a ∈ A, ∑ v ∈ range Y, + ‖shortWindowSum (dilationSequence a (coprimeRestriction q f)) D α v‖ := sum_comm + _ ≤ _ := by + apply sum_le_sum + intro a ha + have hap : 0 < a := (mem_Icc.mp (mem_filter.mp ha).1).1 + calc + _ ≤ ∑ v ∈ range Y, + (‖shortWindowSum (coprimeRestriction q f) (D / a + 1) (a * α) (v / a)‖ + 1) := by + apply sum_le_sum + intro v _ + rw [← norm_shortExponentialSum_eq_window] + exact norm_shortExponentialSum_dilation_le _ + (coprimeRestriction_oneBounded q hfb) a D v hap α + _ = (∑ v ∈ range Y, + ‖shortWindowSum (coprimeRestriction q f) (D / a + 1) (a * α) (v / a)‖) + Y := by + simp only [sum_add_distrib, sum_const, card_range, nsmul_eq_mul, mul_one] + _ ≤ _ := add_le_add + (quotient_sample_sum_le _ (fun _ => norm_nonneg _) a Y hap) le_rfl + calc + _ ≤ (∑ v ∈ range Y, ‖shortWindowSum (truncatedDilation q f K) D α v‖) + + ∑ v ∈ range Y, ‖shortWindowSum (fun n => f (q * n)) D α v - + shortWindowSum (truncatedDilation q f K) D α v‖ := by + rw [← sum_add_distrib] + apply sum_le_sum + intro v _ + have he : shortWindowSum (fun n => f (q * n)) D α v = + shortWindowSum (truncatedDilation q f K) D α v + + (shortWindowSum (fun n => f (q * n)) D α v - + shortWindowSum (truncatedDilation q f K) D α v) := by abel + calc + _ = ‖shortWindowSum (truncatedDilation q f K) D α v + + (shortWindowSum (fun n => f (q * n)) D α v - + shortWindowSum (truncatedDilation q f K) D α v)‖ := congrArg norm he + _ ≤ _ := norm_add_le _ _ + _ ≤ _ := add_le_add hs (truncated_window_error hfb q K D Y hq hK α) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SourceDeletionTerms.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SourceDeletionTerms.lean new file mode 100644 index 0000000000000000000000000000000000000000..679baf8ab225e18ab72502c568f5a368dd71eabe --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SourceDeletionTerms.lean @@ -0,0 +1,143 @@ +import OAI.NumberTheory.TwoPoint.Bounds.DeletionRowSplit +import OAI.NumberTheory.TwoPoint.Bounds.VariableWindowComparison +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedRowComparison + +namespace OAI + +/-! The three source deletions at the actual, possibly bin-dependent, +integer sampling sites. Extra pair eligibility is retained in the rare +term and may be discarded in the two nonnegative numerical terms. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma uniformAverage_finset_sum {α ι : Type*} [Fintype α] + (S : Finset ι) (f : ι → α → ℝ) : + uniformAverage (fun x => ∑ i ∈ S, f i x) = ∑ i ∈ S, uniformAverage (f i) := by + unfold uniformAverage + rw [sum_comm, sum_div] + +lemma uniformAverage_prohibitedPositiveRow {α : Type*} [Fintype α] {h J M : ℕ} + (data : ProhibitedPrimeFamily h J M) (s : ℕ) (D : Finset ℕ) + (padding : ℕ → Finset ℕ) (f : α → ℤ) : + uniformAverage (fun x => prohibitedPositiveRow data s D padding (f x)) = + ∑ d ∈ D, ∑ q ∈ padding d, uniformAverage (fun x => + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors (f x) * + if (q : ℤ) ∣ f x ∧ ProhibitedSite h s (fun d q => (d, q) ∈ data.pairs) (f x) + then 1 else 0) := by + simp only [prohibitedPositiveRow, uniformAverage_finset_sum] + +noncomputable def positiveDeletionAtom (P Q R : Finset ℕ) + (η : ℝ) (c : ℕ → ℝ) (L K W : ℝ) (eligible : ℤ → ℕ → ℕ → Prop) + (bad : ℤ → ℤ → Prop) (j : ℤ) (d q : ℕ) (n : ℤ) : ℝ := + if eligible j d q then + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors n * + if (q : ℤ) ∣ n ∧ + (¬integerEdgeKeep R actualPaddingCoefficient (actualPaddingBin η (c d) j) + (actualPaddingVertex Q) L K (actualPaddingDegreeCut Q L) n ∨ + 6 * W * d.primeFactors.card < (actualPaddingDegree P n : ℝ) ∨ bad j n) + then 1 else 0 + else 0 + +lemma positiveDeletionAtom_le (P Q R : Finset ℕ) (η : ℝ) (c : ℕ → ℝ) + (L K W : ℝ) (eligible : ℤ → ℕ → ℕ → Prop) (bad : ℤ → ℤ → Prop) + (j : ℤ) (d q : ℕ) (n : ℤ) + (he : eligible j d q → actualPaddingBin η (c d) j q) : + positiveDeletionAtom P Q R η c L K W eligible bad j d q n ≤ + paddingRejectionAtom Q d.primeFactors R (actualPaddingBin η (c d) j) L K q n + + (if actualPaddingBin η (c d) j q then positiveDegreeCost P d.primeFactors W q n else 0) + + (if eligible j d q then actualPaddingCoefficient q * positivePrimeWeight d.primeFactors n * + (if (q : ℤ) ∣ n ∧ bad j n then 1 else 0) else 0) := by + have hw := mul_nonneg (actualPaddingCoefficient_nonneg q) (positivePrimeWeight_nonneg d.primeFactors n) + by_cases h : eligible j d q + · have hb := he h + simp only [positiveDeletionAtom, h, hb, paddingRejectionAtom, positiveDegreeCost, ite_true] + simpa using weighted_three_deletions _ hw ((q : ℤ) ∣ n) + (¬integerEdgeKeep R actualPaddingCoefficient (actualPaddingBin η (c d) j) + (actualPaddingVertex Q) L K (actualPaddingDegreeCut Q L) n) + (6 * W * d.primeFactors.card < (actualPaddingDegree P n : ℝ)) (bad j n) + · simp only [positiveDeletionAtom, h, ite_false, add_zero] + unfold paddingRejectionAtom positiveDegreeCost + split_ifs <;> positivity + +lemma variable_source_deletion_split (P Q D R : Finset ℕ) (bins : Finset ℤ) + (η : ℝ) (c : ℕ → ℝ) (L K W : ℝ) + (eligible : ℤ → ℕ → ℕ → Prop) (bad : ℤ → ℤ → Prop) + (he : ∀ j ∈ bins, ∀ d ∈ D, ∀ q ∈ R, + eligible j d q → actualPaddingBin η (c d) j q) + (site : ℤ) (a N : ℤ → ℕ) : + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R, uniformAverage (fun x : Fin (N j) => + positiveDeletionAtom P Q R η c L K W eligible bad j d q ((a j + x.val : ℤ) + site))) ≤ + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R, uniformAverage (fun x : Fin (N j) => + paddingRejectionAtom Q d.primeFactors R (actualPaddingBin η (c d) j) L K q + ((a j + x.val : ℤ) + site))) + + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R.filter (actualPaddingBin η (c d) j), + uniformAverage (fun x : Fin (N j) => + positiveDegreeCost P d.primeFactors W q ((a j + x.val : ℤ) + site))) + + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R.filter (eligible j d), + uniformAverage (fun x : Fin (N j) => + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors ((a j + x.val : ℤ) + site) * + if (q : ℤ) ∣ ((a j + x.val : ℤ) + site) ∧ bad j ((a j + x.val : ℤ) + site) + then 1 else 0)) := by + have hi (j : ℤ) (pred : Prop) (f : Fin (N j) → ℝ) : + uniformAverage (fun x => if pred then f x else 0) = + if pred then uniformAverage f else 0 := by + by_cases hp : pred <;> simp only [hp, ite_true, ite_false] + simp only [uniformAverage, sum_const_zero, zero_div] + have hs (j : ℤ) (hj : j ∈ bins) (d : ℕ) (hd : d ∈ D) (q : ℕ) (hq : q ∈ R) := + uniformAverage_mono (fun x : Fin (N j) => + positiveDeletionAtom_le P Q R η c L K W eligible bad j d q + ((a j + x.val : ℤ) + site) (he j hj d hd q hq)) + have hadd (j : ℤ) (f g k : Fin (N j) → ℝ) : + uniformAverage (fun x => f x + g x + k x) = + uniformAverage f + uniformAverage g + uniformAverage k := by + simp only [uniformAverage, sum_add_distrib, add_div] + simp only [hadd, hi] at hs + have hs' := sum_le_sum (fun j hj => sum_le_sum (fun d hd => + sum_le_sum (fun q hq => hs j hj d hd q hq))) + simp only [sum_add_distrib] at hs' + simpa only [sum_filter] using hs' + +lemma shifted_source_deletion_split (P Q D R : Finset ℕ) (bins : Finset ℤ) + (η : ℝ) (c : ℕ → ℝ) (L K W : ℝ) + (eligible : ℤ → ℕ → ℕ → Prop) (bad : ℤ → ℤ → Prop) + (he : ∀ j ∈ bins, ∀ d ∈ D, ∀ q ∈ R, + eligible j d q → actualPaddingBin η (c d) j q) + (site : ℤ → ℕ → ℕ → ℤ) (a N : ℤ → ℕ) : + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R, uniformAverage (fun x : Fin (N j) => + positiveDeletionAtom P Q R η c L K W eligible bad j d q ((a j + x.val : ℤ) + site j d q))) ≤ + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R, uniformAverage (fun x : Fin (N j) => + paddingRejectionAtom Q d.primeFactors R (actualPaddingBin η (c d) j) L K q + ((a j + x.val : ℤ) + site j d q))) + + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R.filter (actualPaddingBin η (c d) j), + uniformAverage (fun x : Fin (N j) => + positiveDegreeCost P d.primeFactors W q ((a j + x.val : ℤ) + site j d q))) + + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ R.filter (eligible j d), + uniformAverage (fun x : Fin (N j) => + actualPaddingCoefficient q * positivePrimeWeight d.primeFactors ((a j + x.val : ℤ) + site j d q) * + if (q : ℤ) ∣ ((a j + x.val : ℤ) + site j d q) ∧ bad j ((a j + x.val : ℤ) + site j d q) + then 1 else 0)) := by + have hi (j : ℤ) (pred : Prop) (f : Fin (N j) → ℝ) : + uniformAverage (fun x => if pred then f x else 0) = + if pred then uniformAverage f else 0 := by + by_cases hp : pred <;> simp only [hp, ite_true, ite_false] + simp only [uniformAverage, sum_const_zero, zero_div] + have hs (j : ℤ) (hj : j ∈ bins) (d : ℕ) (hd : d ∈ D) (q : ℕ) (hq : q ∈ R) := + uniformAverage_mono (fun x : Fin (N j) => + positiveDeletionAtom_le P Q R η c L K W eligible bad j d q + ((a j + x.val : ℤ) + site j d q) (he j hj d hd q hq)) + have hadd (j : ℤ) (f g k : Fin (N j) → ℝ) : + uniformAverage (fun x => f x + g x + k x) = + uniformAverage f + uniformAverage g + uniformAverage k := by + simp only [uniformAverage, sum_add_distrib, add_div] + simp only [hadd, hi] at hs + have hs' := sum_le_sum (fun j hj => sum_le_sum (fun d hd => + sum_le_sum (fun q hq => hs j hj d hd q hq))) + simp only [sum_add_distrib] at hs' + simpa only [sum_filter] using hs' + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SpectralScale.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SpectralScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac085286d7dbdb5f15b31c2959640d55cbb0e43e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SpectralScale.lean @@ -0,0 +1,45 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MatrixSpectralTail + +namespace OAI + +/-! The trace spectral threshold also dominates the single-edge and +square-function scales needed for the noncommuting transfer. -/ + +namespace TwoPointCorrelations + +lemma actual_spectral_scale_bounds (J : ℕ) (K W : ℝ) (hK : 0 ≤ K) (hW : 1 ≤ W) : + let R := Real.exp 1 * (2 * (K * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + 0 ≤ R ∧ 2 * K ≤ R ∧ 4 * K ^ 2 * (8 * W) ^ J ≤ R ^ 2 := by + dsimp only + let C := 2 * Real.exp 150 * Real.sqrt W + have hs : 1 ≤ Real.sqrt W := by simpa using Real.sqrt_le_sqrt hW + have he : 2 ≤ Real.exp 150 := by linarith [Real.add_one_le_exp (150 : ℝ)] + have hC : 1 ≤ C := by + dsimp [C] + nlinarith [Real.exp_pos (150 : ℝ)] + have hCJ : 1 ≤ C ^ J := one_le_pow₀ hC + have he1 : 1 ≤ Real.exp 1 := Real.one_le_exp (by norm_num) + have hbase : 8 * W ≤ C ^ 2 := by + have hW0 : 0 ≤ W := by linarith + have hx : 0 ≤ (4 * (Real.exp 150) ^ 2 - 8) * W := + mul_nonneg (by nlinarith) hW0 + have hsq := Real.sq_sqrt hW0 + dsimp [C] + nlinarith + have hpower : (8 * W) ^ J ≤ (C ^ J) ^ 2 := by + have hp := pow_le_pow_left₀ (by positivity : 0 ≤ 8 * W) hbase J + simpa only [← pow_mul, Nat.mul_comm 2 J] using hp + have hlarge : 2 * K * C ^ J ≤ Real.exp 1 * (2 * (K * C ^ J)) := by + have hp := mul_le_mul_of_nonneg_right he1 (show 0 ≤ 2 * (K * C ^ J) by positivity) + simpa only [one_mul, mul_assoc] using hp + refine ⟨by positivity, ?_, ?_⟩ + · exact (le_mul_of_one_le_right (by positivity : 0 ≤ 2 * K) hCJ).trans hlarge + · calc + 4 * K ^ 2 * (8 * W) ^ J ≤ (2 * K * C ^ J) ^ 2 := by + have hp := mul_le_mul_of_nonneg_left hpower (show 0 ≤ 4 * K ^ 2 by positivity) + nlinarith + _ ≤ _ := (sq_le_sq₀ (by positivity) (by positivity)).mpr hlarge + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SpectralTransfer.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SpectralTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..186b667c835608c88c892b6e3671f2b86bd3ada9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SpectralTransfer.lean @@ -0,0 +1,142 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ResolventBounds + +namespace OAI + +/-! +# Noncommuting spectral transfer + +The manuscript's Lemma `q:noncommuting`, in a form with any common upper +bound on the single-edge norms, the square function, and the spectral +radius. No commutation between distinct edges is assumed. +-/ + +open scoped BigOperators NNReal ENNReal + +namespace TwoPointCorrelations + +variable {ι E : Type*} [Fintype ι] [DecidableEq ι] + [NormedAddCommGroup E] [InnerProductSpace ℂ E] [FiniteDimensional ℂ E] + +lemma projection_norm_apply_le (P : E →L[ℂ] E) (hP : IsSelfAdjoint P) + (hPP : P * P = P) (v : E) : ‖P v‖ ≤ ‖v‖ := by + have heq : inner ℂ (P v) (P v) = inner ℂ (P v) v := by + have h := congrArg (fun T : E →L[ℂ] E => T v) hPP + calc + _ = inner ℂ (P (P v)) v := (hP.isSymmetric _ _).symm + _ = _ := by + simpa only [mul_apply_eq_comp] using congrArg (fun w => inner ℂ w v) h + have hi := Complex.abs_re_le_norm (inner ℂ (P v) v) + have hj := norm_inner_le_norm (𝕜 := ℂ) (P v) v + have heq' : (inner ℂ (P v) v).re = ‖P v‖ ^ 2 := by + rw [← heq, inner_self_eq_norm_sq_to_K] + simp [← Complex.ofReal_pow] + rw [heq', abs_of_nonneg (sq_nonneg _)] at hi + by_cases hzero : ‖P v‖ = 0 + · simp [hzero] + · have hp : 0 < ‖P v‖ := lt_of_le_of_ne (norm_nonneg _) (Ne.symm hzero) + nlinarith [hi.trans hj] + +lemma compression_norm_le_of_quadratic (S P : E →L[ℂ] E) + (hS : IsSelfAdjoint S) (hP : IsSelfAdjoint P) (hPP : P * P = P) + (c : ℝ) (hc : 0 ≤ c) + (hform : ∀ v : E, P v = v → |(inner ℂ (S v) v).re| ≤ c * ‖v‖ ^ 2) : + ‖P * S * P‖ ≤ c := by + have hself : IsSelfAdjoint (P * S * P) := by + change star (P * S * P) = P * S * P + simp only [star_mul, hP.star_eq, hS.star_eq, mul_assoc] + rw [ContinuousLinearMap.norm_eq_iSup_rayleighQuotient _ hself.isSymmetric] + apply ciSup_le + intro v + have hPv : P (P v) = P v := by + simpa only [mul_apply_eq_comp] using + congrArg (fun T : E →L[ℂ] E => T v) hPP + have hbound := hform (P v) hPv + have hnorm := projection_norm_apply_le P hP hPP v + have heq : inner ℂ ((P * S * P) v) v = inner ℂ (S (P v)) (P v) := by + simp only [mul_apply_eq_comp] + exact hP.isSymmetric _ _ + by_cases hv : v = 0 + · simpa [hv] using hc + · have hvp : 0 < ‖v‖ ^ 2 := sq_pos_of_pos (norm_pos_iff.mpr hv) + simp only [ContinuousLinearMap.rayleighQuotient, + ContinuousLinearMap.reApplyInnerSelf_apply, heq, abs_div, abs_sq] + apply (div_le_iff₀ hvp).mpr + exact hbound.trans (mul_le_mul_of_nonneg_left + (sq_le_sq₀ (norm_nonneg _) (norm_nonneg _) |>.mpr hnorm) hc) + +/-- A common-bound version of the noncommuting transfer lemma. -/ +theorem noncommuting_spectral_transfer + (B : ι → E →L[ℂ] E) (hB : ∀ i, IsSelfAdjoint (B i)) + (P : E →L[ℂ] E) (hP : IsSelfAdjoint P) (hPP : P * P = P) + (m : ℝ≥0) (hnorm : ∀ i, ‖B i‖ ≤ (m : ℝ)) + (hsq : ∀ v : E, P v = v → ∑ i, ‖B i v‖ ^ 2 ≤ (m : ℝ) ^ 2 * ‖v‖ ^ 2) + (hrad : spectralRadius ℂ (nonbacktrackingContinuous B) ≤ (m : ℝ≥0∞)) : + ‖P * (∑ i, B i) * P‖ ≤ 3 * (m : ℝ) := by + nontriviality E + by_cases hm : m = 0 + · have hzero (i : ι) : B i = 0 := norm_eq_zero.mp (le_antisymm (by simpa [hm] using hnorm i) (norm_nonneg _)) + simp [hzero, hm] + have hmpos : 0 < m := pos_iff_ne_zero.mpr hm + have hmr : 0 < (m : ℝ) := by exact_mod_cast hmpos + let t : ℝ := (2 * (m : ℝ))⁻¹ + have ht : 0 < t := by positivity + have htm : t * (m : ℝ) = 1 / 2 := by dsimp [t]; field_simp + have htinv : t < (m : ℝ)⁻¹ := by + dsimp [t] + exact (inv_lt_inv₀ (by positivity) hmr).mpr (by linarith) + have hsmall (u : ℝ) (hu : |u| ≤ t) (i : ι) : ‖u • B i‖ ≤ 1 / 2 := by + rw [norm_smul, Real.norm_eq_abs] + calc + |u| * ‖B i‖ ≤ t * (m : ℝ) := mul_le_mul hu (hnorm i) (norm_nonneg _) ht.le + _ = _ := htm + have hform (v : E) (hv : P v = v) : + |(inner ℂ (∑ i, B i v) v).re| ≤ 3 * (m : ℝ) * ‖v‖ ^ 2 := by + have hpositive (u : ℝ) (hu : |u| = t) (w : E) : + 0 ≤ (inner ℂ (transferResolvent B u w) w).re := by + by_cases hw : w = 0 + · simp [hw] + · apply (transferResolvent_positive_abs B hB u + (fun s hs i => (hsmall s (hs.trans_eq hu) i).trans_lt (by norm_num)) + (fun s hs => nonbacktracking_resolvent_isUnit B m hmpos hrad s + ((hs.trans_eq hu).trans_lt htinv)) w hw).le + have h := edge_sum_quadratic_bound B hB t m ht (hsmall t (by rw [abs_of_pos ht])) + (hpositive t (abs_of_pos ht)) + (hpositive (-t) (by simp [abs_of_pos ht])) v (hsq v hv) + have hc : (1 + 2 * t ^ 2 * (m : ℝ) ^ 2) / t = 3 * (m : ℝ) := by + dsimp [t] + field_simp + ring + simpa only [hc] using h + apply compression_norm_le_of_quadratic (∑ i, B i) P + (isSelfAdjoint_sum _ (fun i _ => hB i)) hP hPP (3 * (m : ℝ)) (by positivity) + intro v hv + simpa only [sum_apply] using hform v hv + +/-- Lemma `q:noncommuting`, with its three separate bounds. The spectral +radius is finite because the operator is bounded. -/ +theorem noncommuting_spectral_transfer_max + (B : ι → E →L[ℂ] E) (hB : ∀ i, IsSelfAdjoint (B i)) + (P : E →L[ℂ] E) (hP : IsSelfAdjoint P) (hPP : P * P = P) + (a b : ℝ≥0) (hnorm : ∀ i, ‖B i‖ ≤ (a : ℝ)) + (hsq : ∀ v : E, P v = v → ∑ i, ‖B i v‖ ^ 2 ≤ (b : ℝ) ^ 2 * ‖v‖ ^ 2) : + ‖P * (∑ i, B i) * P‖ ≤ + 3 * ((max (max a b) ((spectralRadius ℂ (nonbacktrackingContinuous B)).toNNReal) : ℝ≥0) : ℝ) := by + let ρ := (spectralRadius ℂ (nonbacktrackingContinuous B)).toNNReal + let m := max (max a b) ρ + have ha : (a : ℝ) ≤ (m : ℝ) := NNReal.coe_le_coe.mpr + ((le_max_left a b).trans (le_max_left (max a b) ρ)) + have hb : (b : ℝ) ≤ (m : ℝ) := NNReal.coe_le_coe.mpr + ((le_max_right a b).trans (le_max_left (max a b) ρ)) + have hfinite : spectralRadius ℂ (nonbacktrackingContinuous B) ≠ ⊤ := + ne_of_lt ((spectralRadius_le_nnnorm (𝕜 := ℂ) (nonbacktrackingContinuous B)).trans_lt + ENNReal.coe_lt_top) + apply noncommuting_spectral_transfer B hB P hP hPP m (fun i => (hnorm i).trans ha) + · intro v hv + apply (hsq v hv).trans + exact mul_le_mul_of_nonneg_right ((sq_le_sq₀ b.coe_nonneg m.coe_nonneg).mpr hb) (sq_nonneg _) + · rw [← ENNReal.coe_toNNReal hfinite] + exact ENNReal.coe_le_coe.mpr (le_max_right (max a b) ρ) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SplitBadWordSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SplitBadWordSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..d025ebbfc15d9d92e4548beca045161f85ce3426 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SplitBadWordSum.lean @@ -0,0 +1,137 @@ +import OAI.NumberTheory.TwoPoint.Bounds.BadWordRelations +import OAI.NumberTheory.TwoPoint.Bounds.IndependentSampling +import OAI.NumberTheory.TwoPoint.Bounds.PrimeSlotClasses + +namespace OAI + +/-! +# Summing tuple and padding classes in the required order + +The padding assignment is frozen before applying the nondegenerate tuple +relation. It is then averaged with one reciprocal per padding class. The +statement permits different symbolic words for different padding choices, +since every bound is uniform in those choices. +-/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma sum_reciprocal_assignments {ι : Type*} [Fintype ι] [DecidableEq ι] (P : Finset ℕ) : + (∑ x : ι → P, ∏ i, ((x i).val : ℝ)⁻¹) = primeHarmonicMass P ^ Fintype.card ι := by + simpa only [prod_const, card_univ, primeHarmonicMass] using + (Fintype.prod_sum (fun (_ : ι) (p : P) => (p.val : ℝ)⁻¹)).symm + +/-- Splitting the class set preserves the original reciprocal product. -/ +lemma reciprocal_product_join {ι : Type*} [Fintype ι] [DecidableEq ι] + (S : Finset ι) (a : S → ℕ) (b : {i // i ∉ S} → ℕ) : + (∏ i, ((joinCoordinates S a b i : ℕ) : ℝ)⁻¹) = + (∏ i : S, (a i : ℝ)⁻¹) * ∏ i : {i // i ∉ S}, (b i : ℝ)⁻¹ := by + rw [← Fintype.prod_subtype_mul_prod_subtype (fun i => i ∈ S)] + simp only [joinCoordinates_mem, joinCoordinates_notMem] + have hinst : Subtype.fintype (fun i : ι => i ∈ S) = (inferInstance : Fintype S) := + Subsingleton.elim _ _ + rw [hinst] + +/-- The complete finite weighted estimate for one fixed equality pattern. +Tuple and padding labels remain separate even after numerical enlargement. -/ +theorem split_prohibited_reciprocal_bound {ι κ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] + {s J : ℕ} {supply : ℕ → ℕ → Prop} + (R h : ℕ) (P Q : Finset ℕ) (word : (κ → Q) → LabeledPrimeWord ι) + (hlen : ∀ b, (word b).word.length ≤ R) + (hP : ∀ p ∈ P, p.Prime) (hVP : 1 ≤ primeHarmonicMass P) + (H B : ℕ) (hH : 0 < H) (hB : 1 ≤ B) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ B) : + (∑ b : κ → Q, (∏ j, ((b j).val : ℝ)⁻¹) * + ∑ a : ι → P, if ResampledProhibitedEvent (word b) h s J supply (fun i => (a i).val) + then ∏ i, ((a i).val : ℝ)⁻¹ else 0) ≤ + (Fintype.card ι ^ 2 * (R + 1) ^ 2 : ℕ) * + primeHarmonicMass P ^ Fintype.card ι * primeHarmonicMass Q ^ Fintype.card κ * + ((H : ℝ)⁻¹ + (1 + Real.log B) / H) := by + let C : ℝ := (Fintype.card ι ^ 2 * (R + 1) ^ 2 : ℕ) * + primeHarmonicMass P ^ Fintype.card ι * ((H : ℝ)⁻¹ + (1 + Real.log B) / H) + have hinner (b : κ → Q) : + (∑ a : ι → P, if ResampledProhibitedEvent (word b) h s J supply (fun i => (a i).val) + then ∏ i, ((a i).val : ℝ)⁻¹ else 0) ≤ C := + resampled_prohibited_reciprocal_bound R h (word b) (hlen b) + P hP hVP H B hH hB hlo hhi + calc + _ ≤ ∑ b : κ → Q, (∏ j, ((b j).val : ℝ)⁻¹) * C := by + exact sum_le_sum (fun b _ => mul_le_mul_of_nonneg_left (hinner b) + (prod_nonneg (fun j _ => by positivity))) + _ = (∑ b : κ → Q, ∏ j, ((b j).val : ℝ)⁻¹) * C := (sum_mul _ _ _).symm + _ = primeHarmonicMass Q ^ Fintype.card κ * C := by + rw [sum_reciprocal_assignments (ι := κ) Q] + _ = _ := by dsimp [C]; ring + +/-- An actual admissible fiber may contain additional bin, distinctness, +or positivity conditions. Their removal only enlarges this positive sum. -/ +theorem split_prohibited_fiber_bound {ι κ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] + {s J : ℕ} {supply : ℕ → ℕ → Prop} + (R h : ℕ) (P Q : Finset ℕ) (word : (κ → Q) → LabeledPrimeWord ι) + (hlen : ∀ b, (word b).word.length ≤ R) + (E : (ι → P) → (κ → Q) → Prop) + (hE : ∀ a b, E a b → + ResampledProhibitedEvent (word b) h s J supply (fun i => (a i).val)) + (hP : ∀ p ∈ P, p.Prime) (hVP : 1 ≤ primeHarmonicMass P) + (H B : ℕ) (hH : 0 < H) (hB : 1 ≤ B) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ B) : + (∑ b : κ → Q, ∑ a : ι → P, if E a b then + (∏ i, ((a i).val : ℝ)⁻¹) * (∏ j, ((b j).val : ℝ)⁻¹) else 0) ≤ + (Fintype.card ι ^ 2 * (R + 1) ^ 2 : ℕ) * + primeHarmonicMass P ^ Fintype.card ι * primeHarmonicMass Q ^ Fintype.card κ * + ((H : ℝ)⁻¹ + (1 + Real.log B) / H) := by + apply le_trans _ (split_prohibited_reciprocal_bound (s := s) (J := J) (supply := supply) + R h P Q word hlen + hP hVP H B hH hB hlo hhi) + apply sum_le_sum + intro b _ + rw [mul_sum] + apply sum_le_sum + intro a _ + by_cases he : E a b + · simp only [ite_eq_left he, ite_eq_left (hE a b he)] + exact le_of_eq (mul_comm _ _) + · simp only [ite_eq_right he] + split_ifs <;> positivity + +/-- Concrete application to the complete tuple/padding equality code. The +input conditions concern its reconstructed numerical word; the resampling +identity exchanges the order of the two weighted sums. -/ +theorem CrudeWordCode.prohibited_fiber_reciprocal_bound {R N s J h : ℕ} + {supply : ℕ → ℕ → Prop} (c : CrudeWordCode R N R) + (hc : c.KindConsistent) (hi : c.RowInjective) (P Q : Finset ℕ) + (E : (c.tupleClasses → P) → ({z : c.usedClasses // z ∉ c.tupleClasses} → Q) → Prop) + (hE : ∀ a b, E a b → + let w := c.numericalWord (joinCoordinates c.tupleClasses + (fun i => (a i).val) (fun j => (b j).val)) + Function.Injective (fun i => (a i).val) ∧ + ForwardProhibited h s supply w ∧ + (∀ t ∈ w, Squarefree t.tuple) ∧ + (∀ t ∈ w, t.tuple.primeFactors.card = J) ∧ + (∀ p j, TuplePrimeAt w p j → ¬p ∣ h ∧ ∀ t ∈ w, ¬p ∣ t.padding)) + (hP : ∀ p ∈ P, p.Prime) (hVP : 1 ≤ primeHarmonicMass P) + (H B : ℕ) (hH : 0 < H) (hB : 1 ≤ B) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ B) : + (∑ b : {z : c.usedClasses // z ∉ c.tupleClasses} → Q, + ∑ a : c.tupleClasses → P, if E a b then + (∏ i, ((a i).val : ℝ)⁻¹) * (∏ j, ((b j).val : ℝ)⁻¹) else 0) ≤ + (Fintype.card c.tupleClasses ^ 2 * (R + 1) ^ 2 : ℕ) * + primeHarmonicMass P ^ Fintype.card c.tupleClasses * + primeHarmonicMass Q ^ Fintype.card {z : c.usedClasses // z ∉ c.tupleClasses} * + ((H : ℝ)⁻¹ + (1 + Real.log B) / H) := by + apply split_prohibited_fiber_bound (s := s) (J := J) (supply := supply) R h P Q + (fun b => c.labeledWord (fun j => (b j).val)) + (fun b => (c.labeledWord_length _).le) E ?_ hP hVP H B hH hB hlo hhi + intro a b hab + have he := hE a b hab + unfold ResampledProhibitedEvent + rw [c.labeledWord_resample hc hi] + exact ⟨he.1, fun i => hP (a i).val (a i).property, he.2⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SplitWitnessSum.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SplitWitnessSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9db51a6dd75c7dc0ad2735a6738e1b083d47832 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SplitWitnessSum.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ExistentialWitnesses +import OAI.NumberTheory.TwoPoint.Bounds.SplitBadWordSum + +namespace OAI + +/-! Integrate padding after the singleton witness relations, with distinct-prime weights. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem split_witness_reciprocal_bound {n K h s J N : ℕ} + {supply : ℕ → ℕ → Prop} {ι κ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] + (P Q : Finset ℕ) (main : (κ → Q) → LabeledPrimeWord ι) + (word : (κ → Q) → Fin n → LabeledPrimeWord ι) + (hsize : 8 * K ≤ n) (hmain : ∀ b, (main b).word.length ≤ N) + (hword : ∀ b i, (word b i).word.length ≤ N) + (E : (ι → P) → (κ → Q) → Prop) + (hE : ∀ a b, E a b → HasResampledWitnesses (main b) (word b) h s J supply + (fun z => (a z).val)) + (hP : ∀ p ∈ P, p.Prime) (hV : 1 ≤ primeHarmonicMass P) + (H B : ℕ) (hH : 0 < H) (hB : 1 ≤ B) + (hlo : ∀ p ∈ P, H ≤ p) (hhi : ∀ p ∈ P, p ≤ B) + (hdelta : (H : ℝ)⁻¹ + (1 + Real.log B) / H ≤ 1) : + (∑ b : κ → Q, ∑ a : ι → P, if E a b then + (∏ i, ((a i).val : ℝ)⁻¹) * (∏ j, ((b j).val : ℝ)⁻¹) else 0) ≤ + (Fintype.card (WitnessSystemData n N ι) : ℝ) * + primeHarmonicMass P ^ Fintype.card ι * primeHarmonicMass Q ^ Fintype.card κ * + ((H : ℝ)⁻¹ + (1 + Real.log B) / H) ^ K := by + let C : ℝ := (Fintype.card (WitnessSystemData n N ι) : ℝ) * + primeHarmonicMass P ^ Fintype.card ι * ((H : ℝ)⁻¹ + (1 + Real.log B) / H) ^ K + have hb (b : κ → Q) : (∑ a : ι → P, if E a b then ∏ i, ((a i).val : ℝ)⁻¹ else 0) ≤ C := by + apply le_trans _ (has_resampled_witnesses_reciprocal_bound (h := h) (s := s) (J := J) + (supply := supply) (main b) (word b) + hsize (hmain b) (hword b) P hP hV H B hH hB hlo hhi hdelta) + apply sum_le_sum + intro a _ + by_cases he : E a b + · simp only [ite_eq_left he, ite_eq_left (hE a b he)] + exact le_rfl + · simp only [he, ite_false] + split_ifs <;> positivity + calc + _ = ∑ b : κ → Q, (∏ j, ((b j).val : ℝ)⁻¹) * + (∑ a : ι → P, if E a b then ∏ i, ((a i).val : ℝ)⁻¹ else 0) := by + apply sum_congr rfl + intro b _ + rw [mul_sum] + apply sum_congr rfl + intro a _ + split_ifs <;> ring + _ ≤ ∑ b : κ → Q, (∏ j, ((b j).val : ℝ)⁻¹) * C := + sum_le_sum (fun b _ => mul_le_mul_of_nonneg_left (hb b) (by positivity)) + _ = (∑ b : κ → Q, ∏ j, ((b j).val : ℝ)⁻¹) * C := (sum_mul _ _ _).symm + _ = _ := by rw [sum_reciprocal_assignments]; dsimp [C]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/StateCostComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/StateCostComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..836772f678e2e1ab8a110cab101c67679e374c5c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/StateCostComparison.lean @@ -0,0 +1,109 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingCutCircuit +import OAI.NumberTheory.TwoPoint.Bounds.PositivePrimeCostComparison + +namespace OAI + +/-! Exact finite-interval comparison for any bounded Q-state event, +including the literal density cutoff after the low-degree test. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem BravermanDepth22Input.eventually_state_cost_comparison + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M) + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (S : Finset ℕ), S ⊆ data.P ∪ data.Q → (S.card : ℝ) ≤ L ^ 2 → + ∀ (q : ℕ), q ∈ retainedPrimeDivisors data.Q → + (q.primeFactors.card : ℝ) ≤ 100 * Real.log L → + ∀ (D : ℕ), (D : ℝ) ≤ 400 * Real.log L → + ∀ (E : Finset (Fin (Fintype.card data.Q)) → Prop) (site : ℤ) (a N : ℕ), + Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let F := fun n : ℤ => actualPaddingCoefficient q * positivePrimeWeight S (n + site) * + if (q : ℤ) ∣ n + site ∧ actualPaddingDegree data.Q (n + site) ≤ D ∧ + E (paddingActiveState data.Q (Fintype.equivFin data.Q).symm (n + site)) + then 1 else 0 + |uniformAverage (fun x : Fin N => F (a + x.val)) - + (data.residueLaw B hB).average (fun x => F (data.residueOrigin x))| ≤ + Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_positive_prime_cost_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hb, eventually_ge_atTop (4800 : ℝ)] with L hb hL + intro h J M B data hB hpool hBL S hS hSL q hq hqdegree D hD E site a N hN + let U := data.P ∪ data.Q + let hQU : data.Q ⊆ U := subset_union_right + let literal : Fin (Fintype.card U) → U × ℤ := + fun i => ((Fintype.equivFin U).symm i, site) + let index := primeSubsetIndex U S hS + let qindex := primeSubsetIndex U data.Q hQU + let dindex := primeSubsetIndex U q.primeFactors + ((retainedPrimeDivisor_factors data.Q data.primeQ hq).trans hQU) + let c := stateDivisorCircuit qindex dindex D E + let bad := fun n : ℤ => (q : ℤ) ∣ n + site ∧ actualPaddingDegree data.Q (n + site) ≤ D ∧ + E (paddingActiveState data.Q (Fintype.equivFin data.Q).symm (n + site)) + have hindex (i : Fin (Fintype.card S)) : + (literal (index i)).1.val = ((Fintype.equivFin S).symm i).val ∧ + (literal (index i)).2 = site := + ⟨primeSubsetIndex_value U S hS i, rfl⟩ + have hQcard : (Fintype.card data.Q : ℝ) ≤ Real.exp L := by + have hbound : data.Q.card ≤ B := (card_le_card hQU).trans + (primePool_card_bound U (fun p hp => data.prime ⟨p, hp⟩) B hB) + have hbound' : (data.Q.card : ℝ) ≤ B := by exact_mod_cast hbound + simpa only [Fintype.card_coe] using hbound'.trans hBL + have hqcard : (Fintype.card q.primeFactors : ℝ) ≤ 100 * Real.log L := by + simpa only [Fintype.card_coe] using hqdegree + have hsize : (c.size : ℝ) ≤ Real.exp (L ^ 3) := + stateDivisorCircuit_size_exp qindex dindex D E L hL hQcard hqcard hD + have hc : c.depth ≤ 19 := (stateDivisorCircuit_depth qindex dindex D E).trans (by norm_num) + have hbad (n : ℤ) : c.eval + (fun i => decide (((literal i).1.val : ℤ) ∣ n + (literal i).2)) = true ↔ bad n := + stateDivisorCircuit_integer U data.Q hQU data.primeQ q hq D E (n + site) + have hh := hb h J M B data hB hpool hBL S hS hSL q.primeFactors.card + (Fintype.card U) hqdegree literal index site hindex c hc hsize bad hbad a N hN + simpa [actualPaddingCoefficient, bad] using hh + +theorem BravermanDepth22Input.eventually_density_cost_comparison + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M) + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (S : Finset ℕ), S ⊆ data.P ∪ data.Q → (S.card : ℝ) ≤ L ^ 2 → + ∀ (q : ℕ), q ∈ retainedPrimeDivisors data.Q → + (q.primeFactors.card : ℝ) ≤ 100 * Real.log L → + ∀ (D : Finset ℕ), D ⊆ retainedPrimeDivisors data.Q → + ∀ (eligible : ℕ → Prop) (K : ℝ) (site : ℤ) (a N : ℕ), + Real.exp (L ^ A / 2) ≤ (N : ℝ) → + let F := fun n : ℤ => actualPaddingCoefficient q * positivePrimeWeight S (n + site) * + if (q : ℤ) ∣ n + site ∧ actualPaddingDegreeCut data.Q L (n + site) ∧ + K / L < paddingDensity D actualPaddingCoefficient eligible + (actualPaddingVertex data.Q) (n + site) then 1 else 0 + |uniformAverage (fun x : Fin N => F (a + x.val)) - + (data.residueLaw B hB).average (fun x => F (data.residueOrigin x))| ≤ + Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_state_cost_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hb, eventually_ge_atTop (1 : ℝ)] with L hb hL + intro h J M B data hB hpool hBL S hS hSL q hq hqdegree D hD eligible K site a N hN + have hlog : 0 ≤ 400 * Real.log L := + mul_nonneg (by norm_num) (Real.log_nonneg hL) + let E := fun T : Finset (Fin (Fintype.card data.Q)) => + K / L < paddingStateDensity data.Q D (Fintype.equivFin data.Q).symm eligible T + have hh := hb h J M B data hB hpool hBL S hS hSL q hq hqdegree + ⌊400 * Real.log L⌋₊ (Nat.floor_le hlog) E site a N hN + have he (n : ℤ) : (actualPaddingDegree data.Q n ≤ ⌊400 * Real.log L⌋₊ ∧ + E (paddingActiveState data.Q (Fintype.equivFin data.Q).symm n)) ↔ + (actualPaddingDegreeCut data.Q L n ∧ + K / L < paddingDensity D actualPaddingCoefficient eligible (actualPaddingVertex data.Q) n) := by + rw [Nat.le_floor_iff hlog, paddingDensity_eq_state data.Q D data.primeQ hD + (Fintype.equivFin data.Q).symm eligible n] + rfl + simpa only [he] using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SuppliedTupleWords.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SuppliedTupleWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..90c60fa19101d0ab408ff3722127959c12faadd0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SuppliedTupleWords.lean @@ -0,0 +1,129 @@ +import OAI.NumberTheory.TwoPoint.Bounds.AmbientTupleLabels +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedDensity +import OAI.NumberTheory.TwoPoint.Bounds.MainPaddingTests + +namespace OAI + +/-! The literal supplied tuple words discharge the ambient support and padding-test hypotheses. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma columnTupleWord_pairs {h J M R : ℕ} {P : Fin J → Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (w : ColumnPrimeAssignment J R P) + (forward : Fin R → Bool) (padding : Fin R → ℕ) + (hpairs : ∀ i, (columnTuple w i, padding i) ∈ data.pairs) : + ∀ a ∈ columnTupleWord w forward padding, (a.tuple, a.padding) ∈ data.pairs := by + intro a ha + obtain ⟨i, rfl⟩ := List.mem_ofFn.mp ha + exact hpairs i + +lemma ProhibitedPrimeFamily.supplied_word_support_subset {h J M : ℕ} + (data : ProhibitedPrimeFamily h J M) (word : List SignedStep) + (hpairs : ∀ a ∈ word, (a.tuple, a.padding) ∈ data.pairs) : + wordDivisorPrimeSupport word ⊆ data.P ∪ data.Q := by + intro p hp + obtain ⟨a, ha, hpa⟩ := mem_biUnion.mp hp + have hpair := hpairs a (List.mem_toFinset.mp ha) + rw [Nat.primeFactors_mul (data.padding_squarefree _ hpair).ne_zero + (data.tuple_squarefree _ hpair).ne_zero, mem_union] at hpa + rcases hpa with hp | hp + · exact mem_union_right _ (data.padding_pool _ hpair hp) + · exact mem_union_left _ (data.tuple_pool _ hpair hp) + +lemma supplied_tuple_support {h J M R : ℕ} {P : Fin J → Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (w : ColumnPrimeAssignment J R P) + (padding : Fin R → ℕ) (hpairs : ∀ i, (columnTuple w i, padding i) ∈ data.pairs) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) : + tuplePrimeSupport w ⊆ data.P ∧ paddingPrimeSupport padding ⊆ data.Q := by + constructor + · intro p hp + obtain ⟨j, i, rfl⟩ := (mem_tuplePrimeSupport w p).mp hp + apply data.tuple_pool _ (hpairs i) + rw [columnTuple_primeFactors w i hprime hdisjoint] + exact mem_image.mpr ⟨j, mem_univ _, rfl⟩ + · intro p hp + obtain ⟨i, _, hp⟩ := mem_biUnion.mp hp + exact data.padding_pool _ (hpairs i) hp + +lemma supplied_tuple_padding_disjoint {h J M R : ℕ} {P : Fin J → Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (w : ColumnPrimeAssignment J R P) + (padding : Fin R → ℕ) (hpairs : ∀ i, (columnTuple w i, padding i) ∈ data.pairs) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) : + Disjoint (tuplePrimeSupport w) (paddingPrimeSupport padding) := by + have hs := supplied_tuple_support data w padding hpairs hprime hdisjoint + exact data.disjoint.mono hs.1 hs.2 + +lemma supplied_tuple_label_pool {h J M R : ℕ} {P : Fin J → Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (w : ColumnPrimeAssignment J R P) + (padding : Fin R → ℕ) (hpairs : ∀ i, (columnTuple w i, padding i) ∈ data.pairs) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (hlabel : ∀ i j, (label (i, j)).val = (w j i).val) : + ∀ i ∈ univ.image label, i.val ∈ data.P := by + intro i hi + apply (supplied_tuple_support data w padding hpairs hprime hdisjoint).1 + exact (tuple_label_support w Subtype.val Subtype.val_injective label hlabel i).mp hi + +lemma supplied_tuple_label_seen {h J M R : ℕ} {P : Fin J → Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (w : ColumnPrimeAssignment J R P) + (forward : Fin R → Bool) (padding : Fin R → ℕ) + (hpairs : ∀ i, (columnTuple w i, padding i) ∈ data.pairs) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (hlabel : ∀ i j, (label (i, j)).val = (w j i).val) : + ∀ i ∈ univ.image label, i.val ∈ wordDivisorPrimeSupport (columnTupleWord w forward padding) := by + intro i hi + rw [tupleWord_primeSupport w forward padding hprime hdisjoint + (fun i => (data.padding_squarefree _ (hpairs i)).ne_zero)] + exact mem_union_left _ ((tuple_label_support w Subtype.val Subtype.val_injective label hlabel i).mp hi) + +lemma supplied_tuple_label_cover {h J M R : ℕ} {P : Fin J → Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (w : ColumnPrimeAssignment J R P) + (forward : Fin R → Bool) (padding : Fin R → ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (hlabel : ∀ i j, (label (i, j)).val = (w j i).val) : + ∀ (k : Fin (columnTupleWord w forward padding).length) (p : ↥(data.P ∪ data.Q)), + p.val ∈ ((columnTupleWord w forward padding).get k).tuple.primeFactors → + p ∈ univ.image label := by + intro k p hp + have hk : k.val < R := by simpa only [columnTupleWord, List.length_ofFn] using k.isLt + let i : Fin R := ⟨k.val, hk⟩ + have hi : ((columnTupleWord w forward padding).get k).tuple = columnTuple w i := by + change ((List.ofFn (fun i => SignedStep.mk (forward i) (columnTuple w i) (padding i)))[k.val]).tuple = _ + simp only [List.getElem_ofFn] + rfl + rw [hi, columnTuple_primeFactors w i hprime hdisjoint] at hp + obtain ⟨j, _, hj⟩ := mem_image.mp hp + exact mem_image.mpr ⟨(i, j), mem_univ _, Subtype.ext ((hlabel i j).trans hj)⟩ + +theorem supplied_tuple_padding_retained {h J M R B : ℕ} {P : Fin J → Finset ℕ} + (data : ProhibitedPrimeFamily h J M) (w : ColumnPrimeAssignment J R P) + (forward : Fin R → Bool) (padding : Fin R → ℕ) + (hpairs : ∀ i, (columnTuple w i, padding i) ∈ data.pairs) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (label : Fin R × Fin J → ↥(data.P ∪ data.Q)) + (hlabel : ∀ i j, (label (i, j)).val = (w j i).val) + (x : ↥(data.P ∪ data.Q) → Fin B) + (hx : MainPaddingTests Subtype.val h B (columnTupleWord w forward padding) x) : + RetainedMainTests Subtype.val (univ.image label) h B (columnTupleWord w forward padding) x := by + apply mainPaddingTests_retained Subtype.val (univ.image label) h B + (columnTupleWord w forward padding) x + (fun a ha => (data.padding_squarefree _ + (columnTupleWord_pairs data w forward padding hpairs a ha)).ne_zero) + (fun a ha => (data.tuple_squarefree _ + (columnTupleWord_pairs data w forward padding hpairs a ha)).ne_zero) + (supplied_tuple_label_cover data w forward padding hprime hdisjoint label hlabel) hx + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/SymmetricEdgeTesting.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/SymmetricEdgeTesting.lean new file mode 100644 index 0000000000000000000000000000000000000000..30353044cf9930bdc5d1d45e41428360d8d12a9a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/SymmetricEdgeTesting.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TwoPoint.Bounds.GraphTesting +import OAI.NumberTheory.TwoPoint.Bounds.IntegerLiouville + +namespace OAI + +/-! A real symmetric edge test counts each retained directed edge twice. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem symmetric_kernel_quadratic {V : Type*} [Fintype V] [DecidableEq V] + (a : V → V → ℝ) (v : EuclideanSpace ℂ V) (hv : ∀ i, star (v i) = v i) : + inner ℂ v (matrixOperator (fun i j => ((a i j + a j i : ℝ) : ℂ)) v) = + 2 * ∑ i, ∑ j, (a i j : ℂ) * v i * v j := by + change (∑ i, (∑ j, ((a i j + a j i : ℝ) : ℂ) * v j) * star (v i)) = _ + have hf : (∑ i, ∑ j, (a i j : ℂ) * v j * v i) = + ∑ i, ∑ j, (a i j : ℂ) * v i * v j := by + apply sum_congr rfl + intro i _ + apply sum_congr rfl + intro j _ + ring + have hr : (∑ i, ∑ j, (a j i : ℂ) * v j * v i) = + ∑ i, ∑ j, (a i j : ℂ) * v i * v j := by + rw [sum_comm] + calc + _ = (∑ i, ∑ j, (a i j : ℂ) * v j * v i) + + (∑ i, ∑ j, (a j i : ℂ) * v j * v i) := by + simp only [hv, Complex.ofReal_add, add_mul, sum_add_distrib, sum_mul] + _ = _ := by rw [hf, hr]; ring + +lemma maskedIntegerEdgeMatrix_directed {V : Type*} [Fintype V] + (site : V → ℤ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → Prop) + (g center : ℤ → ℝ) (L K : ℝ) (extra : ℤ → Prop) (h d : ℕ) + (gate : V → V → Prop) (hgate : ∀ i j, gate i j ↔ gate j i) (i j : V) : + maskedIntegerEdgeMatrix site Q u eligible g center L K extra h d gate i j = + ((if gate i j then ∑ q ∈ Q, directedIntegerEdge Q u eligible g center L K extra h d q + (site i) (site j) else 0) + + (if gate j i then ∑ q ∈ Q, directedIntegerEdge Q u eligible g center L K extra h d q + (site j) (site i) else 0) : ℝ) := by + simp only [maskedIntegerEdgeMatrix, maskMatrix, integerEdgeMatrix, + hgate i j, sum_add_distrib] + split_ifs <;> simp + +theorem maskedIntegerEdgeMatrix_quadratic {V : Type*} [Fintype V] [DecidableEq V] + (site : V → ℤ) (Q : Finset ℕ) (u : ℕ → ℝ) (eligible : ℕ → Prop) + (g center : ℤ → ℝ) (L K : ℝ) (extra : ℤ → Prop) (h d : ℕ) + (gate : V → V → Prop) (hgate : ∀ i j, gate i j ↔ gate j i) + (v : EuclideanSpace ℂ V) (hv : ∀ i, star (v i) = v i) : + inner ℂ v (matrixOperator + (maskedIntegerEdgeMatrix site Q u eligible g center L K extra h d gate) v) = + 2 * ∑ i, ∑ j, + ((if gate i j then ∑ q ∈ Q, directedIntegerEdge Q u eligible g center L K extra h d q + (site i) (site j) else 0) : ℝ) * v i * v j := by + have hm : maskedIntegerEdgeMatrix site Q u eligible g center L K extra h d gate = + fun i j => (((if gate i j then ∑ q ∈ Q, + directedIntegerEdge Q u eligible g center L K extra h d q (site i) (site j) else 0) + + (if gate j i then ∑ q ∈ Q, + directedIntegerEdge Q u eligible g center L K extra h d q (site j) (site i) else 0) : ℝ) : ℂ) := by + funext i j + exact maskedIntegerEdgeMatrix_directed site Q u eligible g center L K extra h d gate hgate i j + rw [hm] + exact symmetric_kernel_quadratic _ v hv + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ThetaLogError.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ThetaLogError.lean new file mode 100644 index 0000000000000000000000000000000000000000..107985427fab270ff663a4909989327e4efbbe50 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ThetaLogError.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePrimes + +namespace OAI + +/-! An integrable logarithmic error bound obtained from the stated exponential +prime-number error. It also pays exactly for finite exceptional prime sets. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma exp_neg_sqrt_log_le (c x : ℝ) (hc : 0 < c) (hx : 1 < x) : + Real.exp (-c * Real.sqrt (Real.log x)) ≤ 24 / (c ^ 4 * Real.log x ^ 2) := by + have hl : 0 < Real.log x := Real.log_pos hx + have hsq := Real.sq_sqrt hl.le + have hpow : (c * Real.sqrt (Real.log x)) ^ 4 = c ^ 4 * Real.log x ^ 2 := by + calc + _ = c ^ 4 * ((Real.sqrt (Real.log x)) ^ 2) ^ 2 := by ring + _ = _ := by rw [hsq] + have he := Real.pow_div_factorial_le_exp (c * Real.sqrt (Real.log x)) + (mul_nonneg hc.le (Real.sqrt_nonneg (Real.log x))) 4 + norm_num at he + rw [hpow] at he + have hmul := mul_le_mul_of_nonneg_right he + (Real.exp_pos (-c * Real.sqrt (Real.log x))).le + have hexp : Real.exp (c * Real.sqrt (Real.log x)) * + Real.exp (-c * Real.sqrt (Real.log x)) = 1 := by + rw [← Real.exp_add] + ring_nf + exact Real.exp_zero + rw [hexp] at hmul + apply (le_div_iff₀ (by positivity : 0 < c ^ 4 * Real.log x ^ 2)).mpr + nlinarith [hmul] + +lemma log_sq_le_two_mul (x : ℝ) (hx : 1 ≤ x) : Real.log x ^ 2 ≤ 2 * x := by + have hh := Real.pow_div_factorial_le_exp (Real.log x) (Real.log_nonneg hx) 2 + norm_num at hh + rw [Real.exp_log (zero_lt_one.trans_le hx)] at hh + linarith + +/-- A single constant controls the logarithmic PNT error for both residue +selections and every real endpoint at least two. -/ +theorem ModFiveThetaInput.log_error (hP : ModFiveThetaInput) : + ∃ K : ℝ, 0 ≤ K ∧ ∀ (one : Bool) (x : ℝ), 2 ≤ x → + |modFiveTheta one x - modFiveDensity one * x| ≤ K * x / Real.log x ^ 2 := by + obtain ⟨c, C, hc, hC, h⟩ := hP + refine ⟨24 * C / c ^ 4, by positivity, fun one x hx => ?_⟩ + apply (h one x hx).trans + have hh := mul_le_mul_of_nonneg_left (exp_neg_sqrt_log_le c x hc (by linarith)) + (mul_nonneg hC (by linarith : 0 ≤ x)) + convert hh using 1 + ring + +theorem ModFiveThetaInput.deleted_log_error (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ K : ℝ, 0 ≤ K ∧ ∀ (one : Bool) (x : ℝ), 2 ≤ x → + |deletedModFiveTheta E one x - modFiveDensity one * x| ≤ + K * x / Real.log x ^ 2 := by + obtain ⟨K, hK, h⟩ := hP.log_error + let D : ℝ := ∑ p ∈ E, Real.log p + have hD : 0 ≤ D := sum_nonneg (fun p _ => log_nat_nonneg p) + refine ⟨K + 2 * D, by positivity, fun one x hx => ?_⟩ + have hl : 0 < Real.log x := Real.log_pos (by linarith) + have hd : D ≤ 2 * D * x / Real.log x ^ 2 := by + apply (le_div_iff₀ (sq_pos_of_pos hl)).mpr + have hh := mul_le_mul_of_nonneg_left (log_sq_le_two_mul x (by linarith)) hD + nlinarith [hh] + calc + _ ≤ |modFiveTheta one x - modFiveDensity one * x| + D := by + calc + _ = |(modFiveTheta one x - modFiveDensity one * x) + + (deletedModFiveTheta E one x - modFiveTheta one x)| := by congr 1; ring + _ ≤ _ := abs_add_le _ _ + _ ≤ _ := add_le_add (le_refl _) (deletedModFiveTheta_error E one x) + _ ≤ K * x / Real.log x ^ 2 + 2 * D * x / Real.log x ^ 2 := + add_le_add (h one x hx) hd + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceCatalogMaps.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceCatalogMaps.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d82f0c6054943f25c893b4b35a56976a5334740 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceCatalogMaps.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.TwoPoint.Walks.TupleWordPrimeSupport +import OAI.NumberTheory.TwoPoint.Walks.ManyUnlitNumericalWords + +namespace OAI + +/-! Injective encodings of the same trace catalog. Numerical-word estimates +and column-wise forest estimates therefore have identical multiplicities. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def columnNatCode {J R : ℕ} {P : Fin J → Finset ℕ} {Q : Finset ℕ} + (a : ColumnPrimeAssignment J R P × (Fin R → Q)) : + ColumnPrimeAssignment J R P × (Fin R → ℕ) := + (a.1, fun i => (a.2 i).val) + +lemma columnNatCode_injective {J R : ℕ} {P : Fin J → Finset ℕ} {Q : Finset ℕ} : + Function.Injective (columnNatCode (P := P) (Q := Q) (R := R)) := by + intro a b hab + dsimp only [columnNatCode] at hab + apply Prod.ext + · exact congrArg (@Prod.fst (ColumnPrimeAssignment J R P) (Fin R → ℕ)) hab + · funext i + exact Subtype.ext (congrFun + (congrArg (@Prod.snd (ColumnPrimeAssignment J R P) (Fin R → ℕ)) hab) i) + +def columnStepCode {J R : ℕ} {P : Fin J → Finset ℕ} {Q : Finset ℕ} + (forward : Fin R → Bool) (a : ColumnPrimeAssignment J R P × (Fin R → Q)) : + Fin R → SignedStep := + fun i => ⟨forward i, columnTuple a.1 i, (a.2 i).val⟩ + +lemma columnStepCode_word {J R : ℕ} {P : Fin J → Finset ℕ} {Q : Finset ℕ} + (forward : Fin R → Bool) (a : ColumnPrimeAssignment J R P × (Fin R → Q)) : + List.ofFn (columnStepCode forward a) = + columnTupleWord a.1 forward (fun i => (a.2 i).val) := rfl + +lemma columnStepCode_injective {J R : ℕ} {P : Fin J → Finset ℕ} {Q : Finset ℕ} + (forward : Fin R → Bool) (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) : + Function.Injective (columnStepCode (P := P) (Q := Q) forward) := by + intro a b hab + apply columnNatCode_injective + apply columnTupleWord_injective forward hprime hdisjoint + exact congrArg List.ofFn hab + +lemma largeUnlitCatalog_sum {R J : ℕ} {ι : Type} [Fintype ι] [DecidableEq ι] + (F : Finset (Fin R → SignedStep)) + (label : (Fin R → SignedStep) → Fin R × Fin J → ι) (L : ℝ) (hL : 0 ≤ L) + (term : (Fin R → SignedStep) → Finset (Fin R × Fin J) → ℝ) : + (∑ a ∈ largeUnlitCatalog F label L, term a.1 a.2) = + ∑ w ∈ F, ∑ U ∈ (nonsingletonSlots (label w)).powerset.filter + (fun U => ⌊L ^ (1 / 50 : ℝ)⌋₊ < U.card), term w U := by + rw [largeUnlitCatalog, sum_sigma] + apply sum_congr rfl + intro w _ + apply sum_congr + · ext U + simp only [mem_filter, Nat.floor_lt (Real.rpow_nonneg hL _)] + · intro U _ + rfl + +lemma trace_sum_image {α β : Type*} (F : Finset α) (encode : α → β) + (hinj : Function.Injective encode) (decode : β → α) + (hdecode : ∀ a ∈ F, decode (encode a) = a) (term : α → ℝ) : + (∑ b ∈ F.image encode, term (decode b)) = ∑ a ∈ F, term a := by + rw [sum_image (fun _ _ _ _ h => hinj h)] + apply sum_congr rfl + intro a ha + rw [hdecode a ha] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceClassPartition.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceClassPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..68e20dc81684e2fd97511d7f0c71bc808e851c64 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceClassPartition.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedTraceTerms + +namespace OAI + +/-! Partition the actual trace majorant into singleton, many-unlit, high-rank and good classes. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem prohibited_trace_class_bound {α : Type*} {h J M R B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (s D : ℕ) (F : Finset α) (word : α → List SignedStep) + (label : α → Fin R × Fin J → ↥(data.P ∪ data.Q)) + (base : ↥(data.P ∪ data.Q) → Fin B) + (weight : α → (↥(data.P ∪ data.Q) → Fin B) → ℝ) + (hw : ∀ a ∈ F, ∀ x, 0 ≤ weight a x) + (hdep : ∀ a ∈ F, ∀ x y, (∀ i, i ∉ univ.image (label a) → x i = y i) → + weight a x = weight a y) + (Smax Umax : ℕ) (rankBad : α → Finset (Fin R × Fin J) → Prop) : + (∑ a ∈ F, |prohibitedCenteredAverage data hB s D (word a) (label a) (weight a)|) ≤ + (∑ a ∈ F.filter (fun a => Smax < (singletonLabels (label a)).card), + |prohibitedCenteredAverage data hB s D (word a) (label a) (weight a)|) + + (∑ a ∈ F.filter (fun a => (singletonLabels (label a)).card ≤ Smax), + ∑ U ∈ (nonsingletonSlots (label a)).powerset.filter (fun U => Umax < U.card), + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U) + + (∑ a ∈ F.filter (fun a => (singletonLabels (label a)).card ≤ Smax), + ∑ U ∈ (nonsingletonSlots (label a)).powerset.filter + (fun U => U.card ≤ Umax ∧ rankBad a U), + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U) + + (∑ a ∈ F.filter (fun a => (singletonLabels (label a)).card ≤ Smax), + ∑ U ∈ (nonsingletonSlots (label a)).powerset.filter + (fun U => U.card ≤ Umax ∧ ¬rankBad a U), + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U) := by + let A (a : α) := |prohibitedCenteredAverage data hB s D (word a) (label a) (weight a)| + let T (a : α) (U : Finset (Fin R × Fin J)) := + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U + have hp (a : α) : (∑ U ∈ (nonsingletonSlots (label a)).powerset, T a U) = + (∑ U ∈ (nonsingletonSlots (label a)).powerset.filter (fun U => Umax < U.card), T a U) + + (∑ U ∈ (nonsingletonSlots (label a)).powerset.filter + (fun U => U.card ≤ Umax ∧ rankBad a U), T a U) + + (∑ U ∈ (nonsingletonSlots (label a)).powerset.filter + (fun U => U.card ≤ Umax ∧ ¬rankBad a U), T a U) := by + simp only [sum_filter, ← sum_add_distrib] + apply sum_congr rfl + intro U _ + by_cases hu : Umax < U.card <;> by_cases hr : rankBad a U + · simp [hu, Nat.not_le.mpr hu] + · simp [hu, Nat.not_le.mpr hu] + · simp [hu, Nat.le_of_not_gt hu, hr] + · simp [hu, Nat.le_of_not_gt hu, hr] + change (∑ a ∈ F, A a) ≤ _ + calc + _ = (∑ a ∈ F.filter (fun a => Smax < (singletonLabels (label a)).card), A a) + + (∑ a ∈ F.filter (fun a => (singletonLabels (label a)).card ≤ Smax), A a) := by + rw [sum_filter, sum_filter, ← sum_add_distrib] + apply sum_congr rfl + intro a _ + by_cases ha : Smax < (singletonLabels (label a)).card + · simp [ha, Nat.not_le.mpr ha] + · simp [ha, Nat.le_of_not_gt ha] + _ ≤ (∑ a ∈ F.filter (fun a => Smax < (singletonLabels (label a)).card), A a) + + (∑ a ∈ F.filter (fun a => (singletonLabels (label a)).card ≤ Smax), + ∑ U ∈ (nonsingletonSlots (label a)).powerset, T a U) := by + apply add_le_add_right + apply sum_le_sum + intro a ha + exact prohibited_centering_bound data hB s D (word a) (label a) base + (weight a) (hw a (mem_filter.mp ha).1) (hdep a (mem_filter.mp ha).1) + _ = _ := by + simp_rw [hp, sum_add_distrib] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceDesignationSlices.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceDesignationSlices.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0f3378fd8f971e1e1aa33b44a860fb6838e32e2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceDesignationSlices.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.TwoPoint.Walks.ProhibitedTraceTerms + +namespace OAI + +/-! Exact finite reindexing of designated trace terms by their lit/unlit choice. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem prohibited_designation_sum_eq_slices {α : Type*} {h J M R B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (s D : ℕ) (F : Finset α) (word : α → List SignedStep) + (label : α → Fin R × Fin J → ↥(data.P ∪ data.Q)) + (base : ↥(data.P ∪ data.Q) → Fin B) + (weight : α → (↥(data.P ∪ data.Q) → Fin B) → ℝ) + (keep : α → Finset (Fin R × Fin J) → Prop) : + (∑ a ∈ F, ∑ U ∈ (nonsingletonSlots (label a)).powerset.filter (keep a), + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U) = + ∑ U : Finset (Fin R × Fin J), + ∑ a ∈ F.filter (fun a => U ⊆ nonsingletonSlots (label a) ∧ keep a U), + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U := by + symm + simp only [sum_filter] + rw [sum_comm] + apply sum_congr rfl + intro a _ + have hset : (univ : Finset (Finset (Fin R × Fin J))).filter + (fun U => U ⊆ nonsingletonSlots (label a) ∧ keep a U) = + (nonsingletonSlots (label a)).powerset.filter (keep a) := by + ext U + simp only [mem_filter, mem_univ, true_and, mem_powerset] + rw [← sum_filter, hset, sum_filter] + +theorem prohibited_designated_sum_eq_lit_filter {α : Type*} {h J M R B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (s D : ℕ) (F : Finset α) (word : α → List SignedStep) + (label : α → Fin R × Fin J → ↥(data.P ∪ data.Q)) + (base : ↥(data.P ∪ data.Q) → Fin B) + (weight : α → (↥(data.P ∪ data.Q) → Fin B) → ℝ) (U : Finset (Fin R × Fin J)) : + (∑ a ∈ F, prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U) = + ∑ a ∈ F.filter (fun a => LitConsistent (nonsingletonSlots (label a) \ U) (label a) + (tupleForcedTarget data hB (word a) (label a))), + designatedReciprocal (fun p : ↥(data.P ∪ data.Q) => p.val) + (singletonLabels (label a)) (nonsingletonSlots (label a) \ U) U (label a) * + (data.residueLaw B hB).average + (fun x => weight a x * |prohibitedWordDifference data hB s D (word a) (label a) base U x|) := by + simp only [prohibitedDesignatedTerm, sum_filter] + +theorem prohibited_designation_sum_le {α : Type*} {h J M R B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (s D : ℕ) (F : Finset α) (word : α → List SignedStep) + (label : α → Fin R × Fin J → ↥(data.P ∪ data.Q)) + (base : ↥(data.P ∪ data.Q) → Fin B) + (weight : α → (↥(data.P ∪ data.Q) → Fin B) → ℝ) + (keep : α → Finset (Fin R × Fin J) → Prop) (A : ℝ) + (hA : ∀ U : Finset (Fin R × Fin J), + (∑ a ∈ F.filter (fun a => U ⊆ nonsingletonSlots (label a) ∧ keep a U), + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U) ≤ A) : + (∑ a ∈ F, ∑ U ∈ (nonsingletonSlots (label a)).powerset.filter (keep a), + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U) ≤ + (2 : ℝ) ^ (R * J) * A := by + calc + _ = ∑ U : Finset (Fin R × Fin J), + ∑ a ∈ F.filter (fun a => U ⊆ nonsingletonSlots (label a) ∧ keep a U), + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U := + prohibited_designation_sum_eq_slices data hB s D F word label base weight keep + _ ≤ ∑ _U : Finset (Fin R × Fin J), A := sum_le_sum (fun U _ => hA U) + _ = _ := by + simp only [sum_const, card_univ, nsmul_eq_mul, Fintype.card_finset, Fintype.card_prod, + Fintype.card_fin, Nat.cast_pow, Nat.cast_ofNat] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceDesignations.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceDesignations.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d9f595911873f48b47e2f27fadc25013fe23c8a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceDesignations.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.TwoPoint.Bounds.LitConsistency + +namespace OAI + +/-! Exact lit-consistency reduction and centering for a designated trace word. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι τ A : Type*} [Fintype ι] [DecidableEq ι] [Fintype A] [DecidableEq A] + +omit [Fintype ι] [DecidableEq ι] [Fintype A] in +/-- Expand only the designated nonsingleton occurrences, retaining all signs. -/ +lemma centered_occurrence_expansion [DecidableEq τ] (S : Finset τ) + (label : τ → ι) (target : τ → A) (θ : ι → ℝ) (x : ι → A) : + (∏ t ∈ S, ((if x (label t) = target t then (1 : ℝ) else 0) - θ (label t))) = + ∑ U ∈ S.powerset, ((-1 : ℝ) ^ U.card * ∏ t ∈ U, θ (label t)) * + ∏ t ∈ S \ U, if x (label t) = target t then (1 : ℝ) else 0 := by + rw [Finset.prod_sub] + apply sum_congr rfl + intro U _ + ring + +/-- The signed finite expansion is integrated before taking absolute values. -/ +lemma centered_occurrence_expectation [DecidableEq τ] (μ : FiniteLaw (ι → A)) + (S : Finset τ) (label : τ → ι) (target : τ → A) (θ : ι → ℝ) + (F : (ι → A) → ℝ) : + μ.average (fun x => + (∏ t ∈ S, ((if x (label t) = target t then (1 : ℝ) else 0) - θ (label t))) * F x) = + ∑ U ∈ S.powerset, μ.average (fun x => + ((-1 : ℝ) ^ U.card * ∏ t ∈ U, θ (label t)) * + ((∏ t ∈ S \ U, if x (label t) = target t then (1 : ℝ) else 0) * F x)) := by + simp only [FiniteLaw.average] + simp_rw [centered_occurrence_expansion S label target θ, sum_mul, mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro U _ + apply sum_congr rfl + intro x _ + ring + +/-- A contradictory pair of lit offsets annihilates the term exactly. -/ +lemma designated_residue_zero (μ : ι → FiniteLaw A) (S : Finset ι) (L : Finset τ) + (label : τ → ι) (target : τ → A) (a : ι → A) (c : ℝ) (F : (ι → A) → ℝ) + (hL : ¬LitConsistent L label target) : + (FiniteLaw.independent μ).average (fun x => c * + ((∏ t ∈ L, if x (label t) = target t then (1 : ℝ) else 0) * + ((∏ i ∈ S, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i))) * F x))) = 0 := by + simp only [lit_indicator_product_eq_zero L label target hL, zero_mul, mul_zero] + exact FiniteLaw.average_const _ 0 + +/-- This is the designated-term mixed-difference bound with literal lit +occurrences, including the scalar sign and every residue-independent factor. -/ +theorem designated_residue_bound (μ : ι → FiniteLaw A) (S : Finset ι) (L : Finset τ) + (label : τ → ι) (target : τ → A) (a base : ι → A) (c : ℝ) (F : (ι → A) → ℝ) + (hL : LitConsistent L label target) (hSL : Disjoint S (L.image label)) : + |(FiniteLaw.independent μ).average (fun x => c * + ((∏ t ∈ L, if x (label t) = target t then (1 : ℝ) else 0) * + ((∏ i ∈ S, ((if x i = a i then (1 : ℝ) else 0) - (μ i).weight (a i))) * F x)))| ≤ + |c| * (∏ i ∈ L.image label, (μ i).weight (litForcedTarget L label target base i)) * + (∏ i ∈ S, (μ i).weight (a i)) * + (FiniteLaw.independent μ).average (fun x => + |selectedMixedDifference S a + (fun x => F (forceCoordinates (L.image label) (litForcedTarget L label target base) x)) x|) := by + simp_rw [lit_indicator_product L label target base hL] + rw [FiniteLaw.average_const_mul, abs_mul] + calc + _ ≤ |c| * ((∏ i ∈ L.image label, (μ i).weight (litForcedTarget L label target base i)) * + (∏ i ∈ S, (μ i).weight (a i)) * + (FiniteLaw.independent μ).average (fun x => + |selectedMixedDifference S a + (fun x => F (forceCoordinates (L.image label) (litForcedTarget L label target base) x)) x|)) := + mul_le_mul_of_nonneg_left (FiniteLaw.selected_designation_bound μ S (L.image label) hSL a + (litForcedTarget L label target base) F) (abs_nonneg c) + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceErrorAbsorption.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceErrorAbsorption.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb43db406629ed6c62cbf02a319a82580c3cb5a3 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceErrorAbsorption.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.TwoPoint.Bounds.GoodTraceCost + +namespace OAI + +/-! The three exceptional trace classes are absorbed by an absolute change +of the square-root harmonic-mass constant. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma eventually_trace_exceptional_cost : + ∀ᶠ L : ℝ in atTop, + Real.exp (108 * L) * (Real.exp (-L ^ (21 / 20 : ℝ)) + + 2 * Real.exp (-L ^ (101 / 100 : ℝ))) ≤ 1 := by + have hgrow := (tendsto_rpow_atTop (show 0 < (1 / 100 : ℝ) by norm_num)).eventually + (eventually_ge_atTop 110) + filter_upwards [eventually_ge_atTop (1 : ℝ), hgrow] with L hL hgrow + have hLp : 0 < L := by linarith + have hpower : L * L ^ (1 / 100 : ℝ) = L ^ (101 / 100 : ℝ) := by + rw [show (101 / 100 : ℝ) = 1 + 1 / 100 by norm_num, + Real.rpow_add hLp, Real.rpow_one] + have hlarge : 110 * L ≤ L ^ (101 / 100 : ℝ) := by + have hb := mul_le_mul_of_nonneg_left hgrow hLp.le + rw [hpower] at hb + linarith + have hs : Real.exp (-L ^ (21 / 20 : ℝ)) ≤ Real.exp (-L ^ (101 / 100 : ℝ)) := by + apply Real.exp_le_exp.mpr + exact neg_le_neg (Real.rpow_le_rpow_of_exponent_le hL (by norm_num)) + have hthree : (3 : ℝ) ≤ Real.exp (2 * L) := by + apply le_trans (show (3 : ℝ) ≤ Real.exp 2 by linarith [Real.add_one_le_exp (2 : ℝ)]) + exact Real.exp_le_exp.mpr (by linarith) + calc + _ ≤ Real.exp (108 * L) * (Real.exp (-L ^ (101 / 100 : ℝ)) + + 2 * Real.exp (-L ^ (101 / 100 : ℝ))) := + mul_le_mul_of_nonneg_left (add_le_add hs le_rfl) (Real.exp_pos _).le + _ = 3 * Real.exp (108 * L - L ^ (101 / 100 : ℝ)) := by + rw [sub_eq_add_neg, Real.exp_add] + ring + _ ≤ 3 * Real.exp (-(2 * L)) := + mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) (by norm_num) + _ ≤ Real.exp (2 * L) * Real.exp (-(2 * L)) := + mul_le_mul_of_nonneg_right hthree (Real.exp_pos _).le + _ = 1 := by rw [← Real.exp_add]; simp + +lemma trace_base_double_absorbs_one (J k : ℕ) (K W : ℝ) + (hJ : 1 ≤ J) (hk : 1 ≤ k) (hK : 1 ≤ K) (hW : 1 ≤ W) : + 1 + (K * (Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * k) ≤ + (K * (2 * Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * k) := by + let b := Real.exp 150 * Real.sqrt W + have hb : 1 ≤ b := by + have he : (1 : ℝ) ≤ Real.exp 150 := Real.one_le_exp (by norm_num) + have hw : (1 : ℝ) ≤ Real.sqrt W := by + simpa only [Real.sqrt_one] using Real.sqrt_le_sqrt hW + exact one_le_mul_of_one_le_of_one_le he hw + have hA : 1 ≤ (K * b ^ J) ^ (2 * k) := + one_le_pow₀ (one_le_mul_of_one_le_of_one_le hK (one_le_pow₀ hb)) + have ht : 2 ≤ (2 : ℝ) ^ (J * (2 * k)) := by + have hn : 1 ≤ J * (2 * k) := Nat.one_le_iff_ne_zero.mpr + (Nat.mul_ne_zero (by omega) (by omega)) + simpa only [pow_one] using pow_le_pow_right₀ (by norm_num : 1 ≤ (2 : ℝ)) hn + calc + _ = 1 + (K * b ^ J) ^ (2 * k) := rfl + _ ≤ 2 * (K * b ^ J) ^ (2 * k) := by linarith + _ ≤ 2 ^ (J * (2 * k)) * (K * b ^ J) ^ (2 * k) := + mul_le_mul_of_nonneg_right ht (by positivity) + _ = (K * (2 * Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * k) := by + rw [pow_mul, ← mul_pow] + congr 1 + dsimp [b] + simp only [mul_pow] + ring + +theorem eventually_trace_absorption : + ∀ᶠ L : ℝ in atTop, ∀ (J k : ℕ) (K W M : ℝ), + 1 ≤ J → 1 ≤ k → 1 ≤ K → 1 ≤ W → + M ≤ Real.exp (108 * L) * (Real.exp (-L ^ (21 / 20 : ℝ)) + + 2 * Real.exp (-L ^ (101 / 100 : ℝ))) + + (K * (Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * k) → + M ≤ (K * (2 * Real.exp 150 * Real.sqrt W) ^ J) ^ (2 * k) := by + filter_upwards [eventually_trace_exceptional_cost] with L herr + intro J k K W M hJ hk hK hW hM + exact (hM.trans (add_le_add herr le_rfl)).trans (trace_base_double_absorbs_one J k K W hJ hk hK hW) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceFourBounds.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceFourBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..cfd5827452ca3bcdbfc4dcc85488ef37be6bbd6e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceFourBounds.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.TwoPoint.Bounds.TraceClassPartition + +namespace OAI + +/-! Combine the four estimates on one literal word catalog. The bad classes +may be estimated on the larger catalog before the earlier restrictions. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem prohibited_trace_four_bounds {α : Type*} {h J M R B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (s D : ℕ) (F : Finset α) (word : α → List SignedStep) + (label : α → Fin R × Fin J → ↥(data.P ∪ data.Q)) + (base : ↥(data.P ∪ data.Q) → Fin B) + (weight : α → (↥(data.P ∪ data.Q) → Fin B) → ℝ) + (hw : ∀ a ∈ F, ∀ x, 0 ≤ weight a x) + (hdep : ∀ a ∈ F, ∀ x y, (∀ i, i ∉ univ.image (label a) → x i = y i) → + weight a x = weight a y) + (Smax Umax : ℕ) (rankBad : α → Finset (Fin R × Fin J) → Prop) + (single unlit rank good : ℝ) + (hsingle : (∑ a ∈ F.filter (fun a => Smax < (singletonLabels (label a)).card), + |prohibitedCenteredAverage data hB s D (word a) (label a) (weight a)|) ≤ single) + (hunlit : (∑ a ∈ F.filter (fun a => (singletonLabels (label a)).card ≤ Smax), + ∑ U ∈ (nonsingletonSlots (label a)).powerset.filter + (fun U => Umax < U.card), + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U) ≤ unlit) + (hrank : (∑ a ∈ F, ∑ U ∈ (nonsingletonSlots (label a)).powerset.filter (rankBad a), + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U) ≤ rank) + (hgood : (∑ a ∈ F.filter (fun a => (singletonLabels (label a)).card ≤ Smax), + ∑ U ∈ (nonsingletonSlots (label a)).powerset.filter + (fun U => U.card ≤ Umax ∧ ¬rankBad a U), + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U) ≤ good) : + (∑ a ∈ F, |prohibitedCenteredAverage data hB s D (word a) (label a) (weight a)|) ≤ + single + unlit + rank + good := by + have hnonneg (a : α) (ha : a ∈ F) (U : Finset (Fin R × Fin J)) : + 0 ≤ prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U := + prohibitedDesignatedTerm_nonneg data hB s D (word a) (label a) base (weight a) (hw a ha) U + have hr : (∑ a ∈ F.filter (fun a => (singletonLabels (label a)).card ≤ Smax), + ∑ U ∈ (nonsingletonSlots (label a)).powerset.filter + (fun U => U.card ≤ Umax ∧ rankBad a U), + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U) ≤ rank := by + apply le_trans _ hrank + calc + _ ≤ ∑ a ∈ F.filter (fun a => (singletonLabels (label a)).card ≤ Smax), + ∑ U ∈ (nonsingletonSlots (label a)).powerset.filter (rankBad a), + prohibitedDesignatedTerm data hB s D (word a) (label a) base (weight a) U := by + apply sum_le_sum + intro a ha + apply sum_le_sum_of_subset_of_nonneg + · intro U hU + exact mem_filter.mpr ⟨(mem_filter.mp hU).1, (mem_filter.mp hU).2.2⟩ + · intro U _ _ + exact hnonneg a (mem_filter.mp ha).1 U + _ ≤ _ := by + apply sum_le_sum_of_subset_of_nonneg (filter_subset _ _) + intro a ha _ + exact sum_nonneg (fun U _ => hnonneg a ha U) + exact (prohibited_trace_class_bound data hB s D F word label base weight hw hdep + Smax Umax rankBad).trans (add_le_add (add_le_add (add_le_add hsingle hunlit) hr) hgood) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceIntervalError.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceIntervalError.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea0f6ac8fbef86a54898aa1e89345ef74a6a3afe --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceIntervalError.lean @@ -0,0 +1,41 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PhysicalMatrixComparison + +namespace OAI + +/-! The finite word-comparison error absorbs the full physical trace +catalog, including every initial vertex and both words of the pair. -/ + +namespace TwoPointCorrelations + +lemma trace_interval_error_le_one (L : ℝ) (k : ℕ) (v e : ℝ) + (hL : 4800 ≤ L) (hk : (k : ℝ) ≤ L) (he0 : 0 ≤ e) + (hv : v ≤ Real.exp (106 * L)) (he : e ≤ Real.exp (L ^ 4)) : + v * e ^ (2 * k) * Real.exp (-(L ^ 9)) ≤ 1 := by + have hL0 : 0 ≤ L := by linarith + have hL1 : 1 ≤ L := by linarith + have hL2 : 106 ≤ L ^ 2 := by nlinarith + have hL4 : 106 ≤ L ^ 4 := hL2.trans (pow_le_pow_right₀ hL1 (by norm_num)) + have h15 : 106 * L ≤ L ^ 5 := by + have hh := mul_le_mul_of_nonneg_right hL4 hL0 + nlinarith + have h59 : 3 * L ^ 5 ≤ L ^ 9 := by + have hh := mul_le_mul_of_nonneg_right (show 3 ≤ L ^ 4 by linarith) (pow_nonneg hL0 5) + nlinarith + calc + _ ≤ Real.exp (106 * L) * (Real.exp (L ^ 4)) ^ (2 * k) * Real.exp (-(L ^ 9)) := by + apply mul_le_mul_of_nonneg_right _ (Real.exp_pos _).le + exact mul_le_mul hv (pow_le_pow_left₀ he0 he _) (pow_nonneg he0 _) (Real.exp_pos _).le + _ = Real.exp (106 * L + (2 * k : ℕ) * L ^ 4 - L ^ 9) := by + rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_add] + congr 1 + _ ≤ Real.exp (106 * L + 2 * L ^ 5 - L ^ 9) := by + apply Real.exp_le_exp.mpr + have hh := mul_le_mul_of_nonneg_right hk (pow_nonneg hL0 4) + push_cast + nlinarith + _ ≤ Real.exp 0 := Real.exp_le_exp.mpr (by linarith) + _ = 1 := Real.exp_zero + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceParameterBudget.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceParameterBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..59edac961e69b923a3b413fedcbef845d8a61287 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/TraceParameterBudget.lean @@ -0,0 +1,109 @@ +import OAI.NumberTheory.TwoPoint.Walks.WitnessScaleParameters + +namespace OAI + +/-! Elementary bounds for the actual trace and witness lengths. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma eventually_trace_slot_budgets (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ k J M : ℕ, + (k : ℝ) ≤ L → (J + M : ℕ) ≤ C * Real.log L → + ((⌊L ^ (1 / 4 : ℝ)⌋₊ + 2 * k * J : ℕ) : ℝ) ≤ + (2 * C + 1) * L * Real.log L ∧ + ((2 * k * (J + M) : ℕ) : ℝ) + 1 ≤ L ^ 2 ∧ + ((2 * k : ℕ) : ℝ) + 1 ≤ L ^ 2 := by + have hs := (isLittleO_log_rpow_atTop (show (0 : ℝ) < 1 by norm_num)).bound + (show 0 < 1 / (4 * (C + 1)) by positivity) + filter_upwards [eventually_ge_atTop (3 : ℝ), + Real.tendsto_log_atTop.eventually (eventually_ge_atTop 1), hs] with L hL hlog hs + intro k J M hk hJM + have hLp : 0 < L := by linarith + rw [Real.norm_eq_abs, abs_of_nonneg (by linarith : 0 ≤ Real.log L), + Real.norm_eq_abs, Real.rpow_one, abs_of_pos hLp] at hs + have hs' : 4 * (C + 1) * Real.log L ≤ L := by + have ht : Real.log L ≤ L / (4 * (C + 1)) := by + simpa only [div_eq_mul_inv, one_mul, mul_comm] using hs + have ht' := (le_div_iff₀ (show 0 < 4 * (C + 1) by positivity)).mp ht + nlinarith + have hJ : (J : ℝ) ≤ C * Real.log L := by + exact (show (J : ℝ) ≤ (J + M : ℕ) by exact_mod_cast Nat.le_add_right J M).trans hJM + have hf : (⌊L ^ (1 / 4 : ℝ)⌋₊ : ℝ) ≤ L := by + apply (Nat.floor_le (Real.rpow_nonneg hLp.le _)).trans + simpa using Real.rpow_le_rpow_of_exponent_le (by linarith : 1 ≤ L) + (show (1 / 4 : ℝ) ≤ 1 by norm_num) + have hprod : (2 * k * J : ℕ) ≤ 2 * L * (C * Real.log L) := by + push_cast + exact mul_le_mul (mul_le_mul_of_nonneg_left hk (by norm_num)) hJ + (by positivity) (by positivity) + have hprod' : (2 * k * (J + M) : ℕ) ≤ 2 * L * (C * Real.log L) := by + push_cast at hJM ⊢ + exact mul_le_mul (mul_le_mul_of_nonneg_left hk (by norm_num)) hJM + (by positivity) (by positivity) + have hCL : C * Real.log L ≤ L / 4 := by nlinarith + have hlogL : L ≤ L * Real.log L := by nlinarith + refine ⟨?_, ?_, ?_⟩ + · push_cast + nlinarith + · have hm := mul_le_mul_of_nonneg_left hCL (show 0 ≤ 2 * L by positivity) + nlinarith + · push_cast + nlinarith + +lemma eventually_trace_witness_budgets (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, + L / 2 ≤ (⌊L⌋₊ : ℝ) ∧ (⌊L⌋₊ : ℝ) ≤ L ∧ + 0 < ⌊L ^ (1 / 10 : ℝ)⌋₊ ∧ + L ^ (1 / 10 : ℝ) / 2 ≤ (⌊L ^ (1 / 10 : ℝ)⌋₊ : ℝ) ∧ + 0 < ⌊L ^ (1 / 12 : ℝ)⌋₊ ∧ + (⌊L ^ (1 / 12 : ℝ)⌋₊ : ℝ) ≤ 4 * L ∧ + 8 * (⌊L ^ (1 / 12 : ℝ)⌋₊ / 8) ≤ ⌊L ^ (1 / 12 : ℝ)⌋₊ ∧ + L ^ (1 / 12 : ℝ) / 32 ≤ ((⌊L ^ (1 / 12 : ℝ)⌋₊ / 8 : ℕ) : ℝ) ∧ + ((⌊L ^ (1 / 12 : ℝ)⌋₊ / 8 : ℕ) : ℝ) ≤ L ∧ + ((2 * ⌊L⌋₊ + ⌊L ^ (1 / 12 : ℝ)⌋₊ * ⌊L ^ (1 / 10 : ℝ)⌋₊ : ℕ) : ℝ) ≤ 4 * L ∧ + ∀ J S : ℕ, (J : ℝ) ≤ C * Real.log L → ⌊L ^ (1 / 4 : ℝ)⌋₊ < S → + ⌊L ^ (1 / 12 : ℝ)⌋₊ * (⌊L ^ (1 / 10 : ℝ)⌋₊ * J) < S := by + have hs := (tendsto_rpow_atTop (show (0 : ℝ) < 1 / 10 by norm_num)).eventually + (eventually_ge_atTop 2) + have hn := (tendsto_rpow_atTop (show (0 : ℝ) < 1 / 12 by norm_num)).eventually + (eventually_ge_atTop 2) + filter_upwards [eventually_ge_atTop (2 : ℝ), hs, hn, + eventually_singleton_floor_bounds, eventually_witness_cover_budget C hC] with + L hL hs hn hfloor hcover + have hLp : 0 < L := by linarith + have hk : (⌊L⌋₊ : ℝ) ≤ L := Nat.floor_le hLp.le + have hklo : L / 2 ≤ (⌊L⌋₊ : ℝ) := by + have ht := Nat.lt_floor_add_one L + linarith + have hslo : L ^ (1 / 10 : ℝ) / 2 ≤ (⌊L ^ (1 / 10 : ℝ)⌋₊ : ℝ) := by + have ht := Nat.lt_floor_add_one (L ^ (1 / 10 : ℝ)) + linarith + have hspos : 0 < ⌊L ^ (1 / 10 : ℝ)⌋₊ := by + have ht : (0 : ℝ) < (⌊L ^ (1 / 10 : ℝ)⌋₊ : ℝ) := by linarith + exact_mod_cast ht + have hnpos : 0 < ⌊L ^ (1 / 12 : ℝ)⌋₊ := by + have ht := Nat.lt_floor_add_one (L ^ (1 / 12 : ℝ)) + have hp : (0 : ℝ) < (⌊L ^ (1 / 12 : ℝ)⌋₊ : ℝ) := by linarith + exact_mod_cast hp + have hnhi : (⌊L ^ (1 / 12 : ℝ)⌋₊ : ℝ) ≤ 4 * L := by + have hp : L ^ (1 / 12 : ℝ) ≤ L := by + simpa using Real.rpow_le_rpow_of_exponent_le (by linarith : 1 ≤ L) + (show (1 / 12 : ℝ) ≤ 1 by norm_num) + have ht := Nat.floor_le (Real.rpow_nonneg hLp.le (1 / 12 : ℝ)) + linarith + have hsbound := Nat.floor_le (Real.rpow_nonneg hLp.le (1 / 10 : ℝ)) + have hR : ((2 * ⌊L⌋₊ : ℕ) : ℝ) ≤ 2 * L := by push_cast; linarith + have hD := (hcover ⌊L ^ (1 / 10 : ℝ)⌋₊ 0 (⌊L ^ (1 / 4 : ℝ)⌋₊ + 1) + (2 * ⌊L⌋₊) hsbound (by simpa using mul_nonneg hC (Real.log_nonneg (by linarith))) + (by simpa using Nat.lt_floor_add_one (L ^ (1 / 4 : ℝ))) hR).2 + refine ⟨hklo, hk, hspos, hslo, hnpos, hnhi, Nat.mul_div_le _ _, + hfloor.1, hfloor.2, hD, ?_⟩ + intro J S hJ hS + apply (hcover _ J S _ hsbound hJ _ hR).1 + exact (Nat.floor_lt (Real.rpow_nonneg hLp.le _)).mp hS + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/TriangleKernel.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/TriangleKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..3bee0118fda7163c17c1ee44a3239b1508b21c6b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/TriangleKernel.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteProbability +import Mathlib.Analysis.SpecialFunctions.Integrals.Basic +import Mathlib.Analysis.SpecialFunctions.Trigonometric.Bounds + +namespace OAI + +/-! A direct finite-law small-ball inequality using a nonnegative triangular +Fourier kernel. This replaces any need for an external concentration theorem. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +noncomputable def triangleKernel (x : ℝ) : ℝ := + ∫ t in (0 : ℝ)..1, (1 - t) * Real.cos (t * x) + +lemma triangleKernel_zero : triangleKernel 0 = 1 / 2 := by + unfold triangleKernel + simp only [mul_zero, Real.cos_zero, mul_one] + rw [intervalIntegral.integral_sub (f := fun _ : ℝ => 1) (g := fun t : ℝ => t) + intervalIntegrable_const (continuous_id.intervalIntegrable _ _)] + norm_num [integral_id] + +lemma triangleKernel_eq {x : ℝ} (hx : x ≠ 0) : triangleKernel x = (1 - Real.cos x) / x ^ 2 := by + let F : ℝ → ℝ := fun t => (1 - t) * Real.sin (t * x) / x - Real.cos (t * x) / x ^ 2 + have hF (t : ℝ) : HasDerivAt F ((1 - t) * Real.cos (t * x)) t := by + have hs := (Real.hasDerivAt_sin (t * x)).comp t ((hasDerivAt_id t).mul_const x) + have hc := (Real.hasDerivAt_cos (t * x)).comp t ((hasDerivAt_id t).mul_const x) + have hh := ((((hasDerivAt_id t).const_sub 1).mul hs).div_const x).sub (hc.div_const (x ^ 2)) + convert hh using 1 + · rfl + · simp only [Function.comp_apply, id_eq] + field_simp + ring + have hh := intervalIntegral.integral_eq_sub_of_hasDerivAt + (fun t (_ : t ∈ Set.uIcc (0 : ℝ) 1) => hF t) + ((by fun_prop : Continuous (fun t : ℝ => (1 - t) * Real.cos (t * x))).intervalIntegrable _ _) + change triangleKernel x = _ at hh + simp [F] at hh + rw [hh] + ring + +lemma triangleKernel_nonneg (x : ℝ) : 0 ≤ triangleKernel x := by + by_cases hx : x = 0 + · rw [hx, triangleKernel_zero]; norm_num + · rw [triangleKernel_eq hx] + exact div_nonneg (sub_nonneg.mpr (Real.cos_le_one x)) (sq_nonneg x) + +lemma triangleKernel_unit_lower (x : ℝ) (hx : |x| ≤ 1) : 1 / 4 ≤ triangleKernel x := by + have hmono : (∫ t in (0 : ℝ)..1, (1 - t) / 2) ≤ triangleKernel x := by + apply intervalIntegral.integral_mono_on (by norm_num) + ((by fun_prop : Continuous (fun t : ℝ => (1 - t) / 2)).intervalIntegrable _ _) + ((by fun_prop : Continuous (fun t : ℝ => (1 - t) * Real.cos (t * x))).intervalIntegrable _ _) + intro t ht + have htx : |t * x| ≤ 1 := by + rw [abs_mul, abs_of_nonneg ht.1] + simpa using mul_le_mul ht.2 hx (abs_nonneg x) (by norm_num : (0 : ℝ) ≤ 1) + have htx' := abs_le.mp htx + have hsq : (t * x) ^ 2 ≤ 1 := by + nlinarith [mul_nonneg (by linarith : 0 ≤ 1 - t * x) (by linarith : 0 ≤ 1 + t * x)] + have hcos : 1 / 2 ≤ Real.cos (t * x) := by + have hh := Real.one_sub_sq_div_two_le_cos (x := t * x) + linarith + have hh := mul_le_mul_of_nonneg_left hcos (sub_nonneg.mpr ht.2) + nlinarith + have hi : (∫ t in (0 : ℝ)..1, (1 - t) / 2) = 1 / 4 := by + rw [intervalIntegral.integral_div, intervalIntegral.integral_sub + (f := fun _ : ℝ => 1) (g := fun t : ℝ => t) + intervalIntegrable_const (continuous_id.intervalIntegrable _ _)] + norm_num [integral_id] + rwa [hi] at hmono + +lemma FiniteLaw.average_triangleKernel {Ω : Type*} [Fintype Ω] + (μ : FiniteLaw Ω) (Z : Ω → ℝ) : + μ.average (fun x => triangleKernel (Z x)) = + ∫ t in (0 : ℝ)..1, (1 - t) * μ.average (fun x => Real.cos (t * Z x)) := by + unfold FiniteLaw.average triangleKernel + calc + _ = ∑ x, ∫ t in (0 : ℝ)..1, μ.weight x * ((1 - t) * Real.cos (t * Z x)) := by + apply sum_congr rfl + intro x _ + rw [intervalIntegral.integral_const_mul] + _ = ∫ t in (0 : ℝ)..1, ∑ x, μ.weight x * ((1 - t) * Real.cos (t * Z x)) := by + exact (intervalIntegral.integral_finsetSum (fun x _ => + (by fun_prop : Continuous (fun t : ℝ => μ.weight x * ((1 - t) * Real.cos (t * Z x)))).intervalIntegrable _ _)).symm + _ = _ := by + apply intervalIntegral.integral_congr + intro t _ + change (∑ x, μ.weight x * ((1 - t) * Real.cos (t * Z x))) = + (1 - t) * ∑ x, μ.weight x * Real.cos (t * Z x) + rw [mul_sum] + apply sum_congr rfl + intro x _ + ring + +/-- The exact finite-law small-ball reduction. The characteristic function +can now be bounded inside a compact ordinary integral. -/ +theorem FiniteLaw.unit_small_ball_le {Ω : Type*} [Fintype Ω] + (μ : FiniteLaw Ω) (Z : Ω → ℝ) : + μ.probability (fun x => |Z x| ≤ 1) ≤ + 4 * (∫ t in (0 : ℝ)..1, (1 - t) * μ.average (fun x => Real.cos (t * Z x))) := by + calc + _ ≤ μ.average (fun x => triangleKernel (Z x) * 4) := by + apply μ.average_mono + intro x + by_cases hx : |Z x| ≤ 1 + · simp only [hx, ↓reduceIte] + linarith [triangleKernel_unit_lower (Z x) hx] + · simp only [hx, ↓reduceIte] + exact mul_nonneg (triangleKernel_nonneg _) (by norm_num) + _ = _ := by rw [μ.average_mul_const, μ.average_triangleKernel]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/TriangularElimination.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/TriangularElimination.lean new file mode 100644 index 0000000000000000000000000000000000000000..d938a83ae01f53d87162f8293ab52773dcbd48b3 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/TriangularElimination.lean @@ -0,0 +1,167 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MixedDifference +import Mathlib.Logic.Equiv.Prod + +namespace OAI + +/-! Successive elimination for finite product laws and triangular events. -/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι A : Type*} [Fintype ι] [DecidableEq ι] [Fintype A] + +def restoreCoordinate (i : ι) (a : A) (y : {j : ι // j ≠ i} → A) (j : ι) : A := + if h : j = i then a else y ⟨j, h⟩ + +omit [Fintype ι] [Fintype A] in +@[simp] lemma restoreCoordinate_same (i : ι) (a : A) (y : {j : ι // j ≠ i} → A) : + restoreCoordinate i a y i = a := by simp [restoreCoordinate] + +omit [Fintype ι] [Fintype A] in +@[simp] lemma restoreCoordinate_other (i : ι) (a : A) (y : {j : ι // j ≠ i} → A) + (j : {j : ι // j ≠ i}) : restoreCoordinate i a y j = y j := by + simp [restoreCoordinate, j.property] + +omit [Fintype ι] [Fintype A] in +lemma restoreCoordinate_update (i : ι) (a b : A) (y : {j : ι // j ≠ i} → A) : + Function.update (restoreCoordinate i a y) i b = restoreCoordinate i b y := by + funext j + by_cases hj : j = i <;> simp [restoreCoordinate, hj] + +namespace FiniteLaw + +lemma independent_weight_restore (μ : ι → FiniteLaw A) (i : ι) + (a : A) (y : {j : ι // j ≠ i} → A) : + (independent μ).weight (restoreCoordinate i a y) = + (μ i).weight a * (independent (fun j : {j : ι // j ≠ i} => μ j)).weight y := by + change (∏ j, (μ j).weight (restoreCoordinate i a y j)) = _ + rw [Finset.prod_eq_mul_prod_sdiff_singleton_of_mem (mem_univ i)] + rw [restoreCoordinate_same] + congr 1 + rw [Finset.prod_subtype (p := fun j : ι => j ≠ i) (univ \ {i}) (by intro j; simp)] + apply prod_congr rfl + intro j _ + rw [restoreCoordinate_other] + +/-- Expose one original independent coordinate, keeping all other variables +fixed and retaining their original product law. -/ +lemma independent_average_one_coordinate (μ : ι → FiniteLaw A) (i : ι) + (F : (ι → A) → ℝ) : + (independent μ).average F = + (independent (fun j : {j : ι // j ≠ i} => μ j)).average (fun y => + (μ i).average (fun a => F (restoreCoordinate i a y))) := by + let e := Equiv.funSplitAt i A + have he (a : A) (y : {j : ι // j ≠ i} → A) : e.symm (a, y) = restoreCoordinate i a y := by + funext j + by_cases hj : j = i <;> simp [e, Equiv.funSplitAt, Equiv.piSplitAt, restoreCoordinate, hj] + calc + _ = ∑ z : A × ({j : ι // j ≠ i} → A), + (independent μ).weight (restoreCoordinate i z.1 z.2) * F (restoreCoordinate i z.1 z.2) := by + simpa only [he, average] using (e.symm.sum_comp (fun x => (independent μ).weight x * F x)).symm + _ = _ := by + rw [Fintype.sum_prod_type] + simp only [independent_weight_restore, average, mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro y _ + apply sum_congr rfl + intro a _ + ring + +/-- One elimination step. All retained events ignore the variable being +summed; only its own event is charged its conditional probability bound. -/ +theorem eliminate_coordinate [Nonempty A] (μ : ι → FiniteLaw A) (i : ι) + (E F : (ι → A) → Prop) (δ : ℝ) + (hE : ∀ x a, E (Function.update x i a) ↔ E x) + (hF : ∀ x, (μ i).probability (fun a => F (Function.update x i a)) ≤ δ) : + (independent μ).probability (fun x => E x ∧ F x) ≤ + δ * (independent μ).probability E := by + classical + let a₀ : A := Classical.choice inferInstance + let ν := independent (fun j : {j : ι // j ≠ i} => μ j) + have hE' (y : {j : ι // j ≠ i} → A) (a : A) : + E (restoreCoordinate i a y) ↔ E (restoreCoordinate i a₀ y) := by + simpa only [restoreCoordinate_update] using hE (restoreCoordinate i a₀ y) a + have hF' (y : {j : ι // j ≠ i} → A) : + (μ i).probability (fun a => F (restoreCoordinate i a y)) ≤ δ := by + simpa only [restoreCoordinate_update] using hF (restoreCoordinate i a₀ y) + have hrest : (independent μ).probability E = + ν.average (fun y => if E (restoreCoordinate i a₀ y) then 1 else 0) := by + rw [probability, independent_average_one_coordinate μ i] + apply congrArg ν.average + funext y + simp only [hE'] + exact (μ i).average_const _ + rw [hrest, ← average_const_mul] + unfold probability + rw [independent_average_one_coordinate μ i] + apply ν.average_mono + intro y + by_cases hy : E (restoreCoordinate i a₀ y) + · simpa only [probability, hE', hy, true_and, ite_true, mul_one] using hF' y + · simp only [hE', hy, false_and, ite_false, average_const, mul_zero] + exact le_rfl + +/-- Simultaneous triangular events cost one conditional factor per selected +coordinate. The retained earlier events explicitly ignore every later +coordinate, including any appearance as a controlling modulus. -/ +theorem triangular_probability_bound [LinearOrder ι] [Nonempty A] + (μ : ι → FiniteLaw A) (E : ι → (ι → A) → Prop) (δ : ℝ) (hδ : 0 ≤ δ) + (R : Finset ι) + (hdepends : ∀ i ∈ R, ∀ j ∈ R, i < j → ∀ x a, + E i (Function.update x j a) ↔ E i x) + (hconditional : ∀ i ∈ R, ∀ x, + (μ i).probability (fun a => E i (Function.update x i a)) ≤ δ) : + (independent μ).probability (fun x => ∀ i ∈ R, E i x) ≤ δ ^ R.card := by + classical + revert hdepends hconditional + induction R using Finset.strongInductionOn with + | _ R ih => + intro hdepends hconditional + by_cases hR : R.Nonempty + · let i := R.max' hR + have hi : i ∈ R := max'_mem R hR + have hjlt (j : ι) (hj : j ∈ R.erase i) : j < i := by + have hjR := (mem_erase.mp hj).2 + have hji := (mem_erase.mp hj).1 + exact lt_of_le_of_ne (le_max' R j hjR) hji + have hretained : ∀ x a, + (∀ j ∈ R.erase i, E j (Function.update x i a)) ↔ ∀ j ∈ R.erase i, E j x := by + intro x a + constructor <;> intro hx j hj + · exact (hdepends j (mem_erase.mp hj).2 i hi (hjlt j hj) x a).mp (hx j hj) + · exact (hdepends j (mem_erase.mp hj).2 i hi (hjlt j hj) x a).mpr (hx j hj) + have hstep := eliminate_coordinate μ i (fun x => ∀ j ∈ R.erase i, E j x) + (E i) δ hretained (hconditional i hi) + have hevent : (fun x => ∀ j ∈ R, E j x) = + (fun x => (∀ j ∈ R.erase i, E j x) ∧ E i x) := by + funext x + apply propext + constructor + · intro hx + exact ⟨fun j hj => hx j (mem_erase.mp hj).2, hx i hi⟩ + · rintro ⟨hx, hxi⟩ j hj + by_cases hji : j = i + · simpa only [hji] using hxi + · exact hx j (mem_erase.mpr ⟨hji, hj⟩) + rw [hevent] + apply hstep.trans + have hrest := ih (R.erase i) (Finset.erase_ssubset hi) + (fun j hj k hk hjk x a => hdepends j (mem_erase.mp hj).2 k (mem_erase.mp hk).2 hjk x a) + (fun j hj => hconditional j (mem_erase.mp hj).2) + have hmul := mul_le_mul_of_nonneg_left hrest hδ + have hcard : R.card = (R.erase i).card + 1 := by + rw [card_erase_of_mem hi] + have hpos := card_pos.mpr hR + omega + simpa only [hcard, pow_succ, mul_comm] using hmul + · have hzero : R = ∅ := not_nonempty_iff_eq_empty.mp hR + rw [hzero, card_empty, pow_zero] + exact probability_le_one _ _ + +end FiniteLaw + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/TruncatedDilation.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/TruncatedDilation.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c18397255cfd1daadc9f0b9b1e7c2d784d035a9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/TruncatedDilation.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.TwoPoint.Bounds.SmoothDivisorDecomposition +import OAI.NumberTheory.TwoPoint.Bounds.DivisibilityPrefix + +namespace OAI + +/-! A fixed dilation is approximated by finitely many smooth-divisor +components. The discarded values lie in a literal smooth-divisor tail. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def smoothDilationTerm (q : ℕ) (f : ℕ → ℂ) (a n : ℕ) : ℂ := + if a.primeFactors ⊆ q.primeFactors ∧ a ∣ n then + f (q * a) * coprimeRestriction q f (n / a) else 0 + +lemma smoothDilationTerm_eq_zero (q n a : ℕ) (f : ℕ → ℂ) + (hq : 0 < q) (hn : 0 < n) (ha : a ≠ primeSmoothPart q.primeFactors n) : + smoothDilationTerm q f a n = 0 := by + unfold smoothDilationTerm coprimeRestriction + split_ifs with has hc + · exact False.elim (ha (primeSmoothPart_unique q n a hq hn has.2 has.1 hc)) + · exact mul_zero _ + · rfl + +lemma smoothDilationTerm_at_part {f : ℕ → ℂ} (hf : Multiplicative f) + (q n : ℕ) (hq : 0 < q) (hn : 0 < n) : + smoothDilationTerm q f (primeSmoothPart q.primeFactors n) n = f (q * n) := by + let a := primeSmoothPart q.primeFactors n + let r := primeRoughPart q.primeFactors n + have ha : 0 < a := primeSmoothPart_pos _ _ hn + have hr : 0 < r := primeRoughPart_pos _ _ hn + have he : a * r = n := primeSmoothPart_mul_primeRoughPart _ _ hn + have hc : q.Coprime r := primeRoughPart_coprime q n hq + have hac := coprime_of_primeFactors_subset ha (primeSmoothPart_support _ _) hc + have hd : a ∣ n := ⟨r, he.symm⟩ + have hquot : n / a = r := by rw [← he, Nat.mul_div_cancel_left _ ha] + change smoothDilationTerm q f a n = _ + rw [smoothDilationTerm, ite_eq_left ⟨primeSmoothPart_support _ _, hd⟩, + hquot, coprimeRestriction, ite_eq_left hc, + ← hf (q * a) r (Nat.mul_pos hq ha) hr (hc.mul_left hac)] + congr 1 + rw [mul_assoc, he] + +noncomputable def truncatedDilation (q : ℕ) (f : ℕ → ℂ) (K n : ℕ) : ℂ := + if primeSmoothPart q.primeFactors n ≤ K then f (q * n) else 0 + +lemma truncatedDilation_eq_sum {f : ℕ → ℂ} (hf : Multiplicative f) + (q n K : ℕ) (hq : 0 < q) (hn : 0 < n) : + truncatedDilation q f K n = ∑ a ∈ Icc 1 K, smoothDilationTerm q f a n := by + let a := primeSmoothPart q.primeFactors n + have ha : 0 < a := primeSmoothPart_pos _ _ hn + have hsum : (∑ b ∈ Icc 1 K, smoothDilationTerm q f b n) = + if a ∈ Icc 1 K then smoothDilationTerm q f a n else 0 := by + by_cases hak : a ∈ Icc 1 K + · rw [ite_eq_left hak] + apply sum_eq_single a + · intro b _ hba + exact smoothDilationTerm_eq_zero q n b f hq hn hba + · exact fun h => False.elim (h hak) + · rw [ite_eq_right hak] + apply sum_eq_zero + intro b hb + apply smoothDilationTerm_eq_zero q n b f hq hn + intro hba + change b = a at hba + exact hak (hba ▸ hb) + rw [hsum, smoothDilationTerm_at_part hf q n hq hn] + have ha1 : 1 ≤ a := ha + change (if a ≤ K then f (q * n) else 0) = _ + simp only [mem_Icc, ha1, true_and] + +lemma norm_truncatedDilation_error {f : ℕ → ℂ} (hf : OneBounded f) + (q n K : ℕ) (hq : 0 < q) (hn : 0 < n) : + ‖f (q * n) - truncatedDilation q f K n‖ ≤ + if K < primeSmoothPart q.primeFactors n then (1 : ℝ) else 0 := by + unfold truncatedDilation + by_cases hs : primeSmoothPart q.primeFactors n ≤ K + · simp only [hs, ite_true, sub_self, norm_zero, Nat.not_lt.mpr hs, ite_false, le_refl] + · simp only [hs, ite_false, sub_zero, Nat.lt_of_not_ge hs, ite_true] + exact hf _ (Nat.mul_pos hq hn) + +lemma smoothPart_tail_indicator (q n K : ℕ) (hn : 0 < n) : + (if K < primeSmoothPart q.primeFactors n then (1 : ℝ) else 0) ≤ + ∑ a ∈ (Icc (K + 1) n).filter (fun a => a.primeFactors ⊆ q.primeFactors), + if a ∣ n then (1 : ℝ) else 0 := by + split_ifs with htail + · let a := primeSmoothPart q.primeFactors n + have hd : a ∣ n := ⟨primeRoughPart q.primeFactors n, + (primeSmoothPart_mul_primeRoughPart _ _ hn).symm⟩ + have hm : a ∈ (Icc (K + 1) n).filter (fun a => a.primeFactors ⊆ q.primeFactors) := by + exact mem_filter.mpr ⟨mem_Icc.mpr ⟨htail, Nat.le_of_dvd hn hd⟩, + primeSmoothPart_support _ _⟩ + have h := single_le_sum (f := fun b : ℕ => if b ∣ n then (1 : ℝ) else 0) + (fun b _ => by split_ifs <;> positivity) hm + simpa only [ite_eq_left hd] using h + · exact sum_nonneg (fun _ _ => by split_ifs <;> positivity) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/UncutCenteredProfile.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/UncutCenteredProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d6c84e58f035d0df94d72b7443c77251c470546 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/UncutCenteredProfile.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.TwoPoint.Walks.CanonicalCorrelationDeletion +import OAI.NumberTheory.TwoPoint.Bounds.CenteredTupleProfiles + +namespace OAI + +/-! Identify the uncut graph sum with the literal centered-divisor +correlation, including the original (possibly nonunit) progression class. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma uncutNumericalEdge_progression (R : Finset ℕ) (eligible : ℕ → ℕ → Prop) + (h l b d q n : ℕ) [NeZero l] (hh : 0 < h) (hd : 0 < d) (hq : 0 < q) + (hqR : q ∈ R) : + uncutNumericalEdge R eligible h (progressionEdgeGate h l b) d q n + ((n : ℤ) + (h * q * d : ℕ)) = + if eligible d q then + (actualPaddingCoefficient q : ℂ) * natDivisibilityIndicator q n * + (centeredTuple d.primeFactors (n : ℤ) : ℂ) * + (progressionSequence liouville l ((b : ZMod l) * ((q * d : ℕ) : ZMod l)) n * + liouville (n + h * (q * d))) + else 0 := by + have hg : progressionEdgeGate h l b d (n : ℤ) ((n : ℤ) + (h * q * d : ℕ)) ↔ + (n : ZMod l) = (b : ZMod l) * ((q * d : ℕ) : ZMod l) := by + rw [progressionEdgeGate_on_edge h l b d q hh hd hq] + rw [← ZMod.intCast_eq_intCast_iff] + simp only [Int.cast_mul, Int.cast_natCast, Nat.cast_mul, mul_assoc] + have hm : (n : ℤ) + (h * q * d : ℕ) = ((n + h * (q * d) : ℕ) : ℤ) := by + push_cast + ring + simp only [uncutNumericalEdge, hqR, and_true, hm, integerLiouville_natCast, + Int.natCast_dvd_natCast, Complex.ofReal_mul] + unfold natDivisibilityIndicator progressionSequence + split_ifs <;> simp_all + ring + +lemma uncutPrimePrefix_centered {J : ℕ} (P : Fin J → Finset ℕ) + (hprime : ∀ j, ∀ p ∈ P j, p.Prime) + (hdisjoint : ∀ j k, k ≠ j → Disjoint (P j) (P k)) + (R : Finset ℕ) (hR : ∀ q ∈ R, 0 < q) (eligible : ℕ → ℕ → Prop) + (h l b N : ℕ) [NeZero l] (hh : 0 < h) : + uncutPrimePrefix P R eligible h (progressionEdgeGate h l b) N = + positivePrefix (fun n => ∑ q ∈ R, (actualPaddingCoefficient q : ℂ) * + tupleCenteredProfile P q eligible l (b : ZMod l) h n) N / (N : ℂ) := by + unfold uncutPrimePrefix + congr 2 + funext n + rw [primeTupleDivisors, sum_image] + · rw [sum_comm] + apply sum_congr rfl + intro q hq + simp only [tupleCenteredProfile, mul_sum] + apply sum_congr rfl + intro x _ + have hd : 0 < ∏ j, (x j).val := prod_pos (fun j _ => (hprime j _ (x j).property).pos) + rw [uncutNumericalEdge_progression R eligible h l b _ q n hh hd (hR q hq) hq] + by_cases he : eligible (∏ j, (x j).val) q + · simp only [he, ite_true] + ring + · simp only [he, ite_false, mul_zero] + · intro x _ y _ hxy + exact primeTuple_injective hprime hdisjoint hxy + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/UniformResidueTranslation.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/UniformResidueTranslation.lean new file mode 100644 index 0000000000000000000000000000000000000000..0765a253c3d708f6911c58082069f06490e8399b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/UniformResidueTranslation.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteLawMapping +import OAI.NumberTheory.TwoPoint.Bounds.PositiveWordProbability +import OAI.NumberTheory.TwoPoint.Bounds.PrimeResidueLift + +namespace OAI + +/-! Translation invariance of the actual product law on the padded carrier. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def translateResidue (B p : ℕ) [NeZero p] (hpB : p ≤ B) + (c : ℤ) (x : Fin B) : Fin B := + ⟨((x.val : ZMod p) + (c : ZMod p)).val, (ZMod.val_lt _).trans_le hpB⟩ + +lemma translateResidue_cast (B p : ℕ) [NeZero p] (hpB : p ≤ B) + (c : ℤ) (x : Fin B) : + ((translateResidue B p hpB c x).val : ZMod p) = (x.val : ZMod p) + (c : ZMod p) := by + exact ZMod.natCast_zmod_val _ + +theorem uniformResidueLaw_translate (B p : ℕ) [NeZero p] (hp : 0 < p) (hpB : p ≤ B) + (c : ℤ) (y : Fin B) : + (uniformResidueLaw B p hp hpB).probability + (fun x => translateResidue B p hpB c x = y) = + (uniformResidueLaw B p hp hpB).weight y := by + by_cases hy : y.val < p + · have he (x : Fin B) : translateResidue B p hpB c x = y ↔ + (x.val : ZMod p) = (y.val : ZMod p) - (c : ZMod p) := by + rw [eq_sub_iff_add_eq] + constructor + · intro hxy + rw [← translateResidue_cast B p hpB c x, hxy] + · intro hxy + apply Fin.ext + have hv := congrArg ZMod.val hxy + simpa only [translateResidue, ZMod.val_natCast_of_lt hy] using hv + have heq : (fun x => translateResidue B p hpB c x = y) = + (fun x : Fin B => (x.val : ZMod p) = (y.val : ZMod p) - (c : ZMod p)) := + funext (fun x => propext (he x)) + rw [heq, uniformResidueLaw_mod_eq, uniformResidueLaw_weight B p hp hpB y hy] + · have hn (x : Fin B) : translateResidue B p hpB c x ≠ y := by + intro hxy + have hx : (translateResidue B p hpB c x).val < p := ZMod.val_lt _ + exact hy (hxy ▸ hx) + simp [FiniteLaw.probability, FiniteLaw.average, hn, uniformResidueLaw, hy] + +theorem independent_residue_translate {ι : Type*} [Fintype ι] [DecidableEq ι] + (B : ℕ) (p : ι → ℕ) [∀ i, NeZero (p i)] + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) (c : ℤ) + (f : (ι → Fin B) → ℝ) : + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => f (fun i => translateResidue B (p i) (hpB i) c (x i))) = + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average f := by + exact FiniteLaw.independent_average_map _ _ _ + (fun i y => uniformResidueLaw_translate B (p i) (hp i) (hpB i) c y) f + +theorem ProhibitedPrimeFamily.residue_average_translate {h J M B : ℕ} + (data : ProhibitedPrimeFamily h J M) (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B) + (f : ℤ → ℝ) + (hf : ∀ n m, (∀ p : ↥(data.P ∪ data.Q), (n : ZMod p.val) = (m : ZMod p.val)) → + f n = f m) (c : ℤ) : + (data.residueLaw B hB).average (fun x => f (data.residueOrigin x + c)) = + (data.residueLaw B hB).average (fun x => f (data.residueOrigin x)) := by + let (p : ↥(data.P ∪ data.Q)) : NeZero p.val := ⟨(data.prime p).ne_zero⟩ + let translate (x : ↥(data.P ∪ data.Q) → Fin B) (p : ↥(data.P ∪ data.Q)) := + translateResidue B p.val (hB _ p.property) c (x p) + calc + _ = (data.residueLaw B hB).average (fun x => f (data.residueOrigin (translate x))) := by + apply congrArg (data.residueLaw B hB).average + funext x + apply hf + intro p + rw [Int.cast_add, data.residueOrigin_spec, data.residueOrigin_spec] + exact (translateResidue_cast B p.val (hB _ p.property) c (x p)).symm + _ = _ := independent_residue_translate B (fun p : ↥(data.P ∪ data.Q) => p.val) + (fun p => (data.prime p).pos) (fun p => hB _ p.property) c + (fun x => f (data.residueOrigin x)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/UniformResidues.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/UniformResidues.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea8e2e68cc8fb48395fb496e3662252ea92cc286 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/UniformResidues.lean @@ -0,0 +1,50 @@ +import OAI.NumberTheory.TwoPoint.Bounds.TraceDesignations +import Mathlib.Data.Fintype.Fin + +namespace OAI + +/-! Uniform residue coordinates realized on one common finite carrier. -/ + +namespace TwoPointCorrelations + +open Finset + +/-- A uniform residue modulo `p`, embedded into `Fin B`. The zero-weight +padding allows different prime moduli to share the same sample type. -/ +noncomputable def uniformResidueLaw (B p : ℕ) (hp : 0 < p) (hpB : p ≤ B) : + FiniteLaw (Fin B) where + weight x := if x.val < p then (p : ℝ)⁻¹ else 0 + nonneg x := by split_ifs <;> positivity + total := by + rw [← sum_filter] + simp [Fin.card_filter_val_lt, min_eq_right hpB, ne_of_gt hp] + +@[simp] lemma uniformResidueLaw_weight (B p : ℕ) (hp : 0 < p) (hpB : p ≤ B) + (x : Fin B) (hx : x.val < p) : + (uniformResidueLaw B p hp hpB).weight x = (p : ℝ)⁻¹ := by + simp [uniformResidueLaw, hx] + +lemma uniformResidueLaw_support (B p : ℕ) (hp : 0 < p) (hpB : p ≤ B) + (x : Fin B) : + (uniformResidueLaw B p hp hpB).weight x ≠ 0 ↔ x.val < p := by + simp [uniformResidueLaw, ne_of_gt hp] + +@[simp] lemma uniformResidueLaw_castLE (B p : ℕ) (hp : 0 < p) (hpB : p ≤ B) + (x : Fin p) : + (uniformResidueLaw B p hp hpB).weight (Fin.castLE hpB x) = (p : ℝ)⁻¹ := by + exact uniformResidueLaw_weight B p hp hpB _ x.isLt + +/-- Every actual residue assignment with nonzero product mass lies below +its coordinate's modulus. This applies to the very same sample used for +the mixed-difference identity. -/ +lemma uniformResidueLaw_independent_support {ι : Type*} [Fintype ι] [DecidableEq ι] + (B : ℕ) (p : ι → ℕ) (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (x : ι → Fin B) : + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).weight x ≠ 0 ↔ + ∀ i, (x i).val < p i := by + simp only [FiniteLaw.independent, prod_ne_zero_iff, mem_univ, true_implies, + uniformResidueLaw_support] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/VariableDegreeDeletion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/VariableDegreeDeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..efc371378c218e6d451d123369fa26a475baf9e1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/VariableDegreeDeletion.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.TwoPoint.Walks.TupleDegreeDeletion +import OAI.NumberTheory.TwoPoint.Bounds.DeletionRowSplit + +namespace OAI + +/-! The tuple-degree deletion summed over disjoint logarithmic bins, +each sampled on its own integer interval. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma padding_bin_reciprocal_sum_le (Q R : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (hR : R ⊆ retainedPrimeDivisors Q) (bins : Finset ℤ) (η c : ℝ) (hη : 0 < η) : + (∑ j ∈ bins, ∑ q ∈ R.filter (actualPaddingBin η c j), + actualPaddingCoefficient q / (q : ℝ)) ≤ paddingTiltNormalizer Q := by + simp only [sum_filter] + rw [sum_comm] + calc + _ ≤ ∑ q ∈ R, actualPaddingCoefficient q / (q : ℝ) := by + apply sum_le_sum + intro q _ + exact actualPaddingBin_sum_le bins η c hη q _ + (div_nonneg (actualPaddingCoefficient_nonneg q) (Nat.cast_nonneg q)) + _ ≤ _ := retained_padding_mass_le Q R hQ hR + +theorem BravermanDepth22Input.eventually_variable_tuple_degree_deletion + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M) + (_hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (P : Fin J → Finset ℕ), primeTuplePool P = data.P → + (∀ j, ∀ p ∈ P j, p.Prime) → + (∀ j l, l ≠ j → Disjoint (P j) (P l)) → + ∀ W : ℝ, 10 ≤ W → (∀ j, primeHarmonicMass (P j) ≤ 2 * W) → + (J : ℝ) ≤ L ^ 2 → 6 * W * J ≤ 400 * Real.log L → + ∀ (D : Finset ℕ), D ⊆ primeTupleDivisors P → + ∀ (Q : Finset ℕ), Q ⊆ retainedPrimeDivisors data.Q → + (∀ q ∈ Q, (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) → + ∀ (bins : Finset ℤ) (η : ℝ) (c : ℕ → ℝ), 0 < η → + ∀ (site : ℤ) (a N : ℤ → ℕ), (∀ j ∈ bins, Real.exp (L ^ A / 2) ≤ (N j : ℝ)) → + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ Q.filter (actualPaddingBin η (c d) j), + uniformAverage (fun x : Fin (N j) => + positiveDegreeCost data.P d.primeFactors W q ((a j + x.val : ℤ) + site))) ≤ + (2 : ℝ) ^ J * (∏ j, primeHarmonicMass (P j)) * paddingTiltNormalizer data.Q * + Real.exp (-2 * W * J) + + bins.card * D.card * Q.card * Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_integer_degree_sum + refine ⟨A, hA, ?_⟩ + filter_upwards [hb] with L hb + intro h J M B data hB hpool hBL P hP hprime hdisjoint W hW hV hJ hTL D hD Q hQ + hqdegree bins η c hη site a N hN + have hmass : (∑ p ∈ data.P, 1 / (p : ℝ)) ≤ 2 * W * J := by + rw [← primeHarmonicMass_eq_sum, ← hP, primeTuplePool_mass P hdisjoint] + calc + _ ≤ ∑ _j : Fin J, 2 * W := sum_le_sum (fun j _ => hV j) + _ = _ := by simp; ring + have ht (d : ℕ) (hd : d ∈ D) : + (∑ j ∈ bins, ∑ q ∈ Q.filter (actualPaddingBin η (c d) j), + uniformAverage (fun x : Fin (N j) => + positiveDegreeCost data.P d.primeFactors W q ((a j + x.val : ℤ) + site))) ≤ + positivePrimeNormalizer d.primeFactors * Real.exp (-2 * W * J) * paddingTiltNormalizer data.Q + + bins.card * Q.card * Real.exp (-(L ^ 9)) := by + have ha := primeTupleDivisors_arithmetic P hprime hdisjoint (hD hd) + have heach (j : ℤ) (hj : j ∈ bins) : + (∑ q ∈ Q.filter (actualPaddingBin η (c d) j), + uniformAverage (fun x : Fin (N j) => + positiveDegreeCost data.P d.primeFactors W q ((a j + x.val : ℤ) + site))) ≤ + positivePrimeNormalizer d.primeFactors * Real.exp (-2 * W * J) * + (∑ q ∈ Q.filter (actualPaddingBin η (c d) j), actualPaddingCoefficient q / q) + + Q.card * Real.exp (-(L ^ 9)) := by + have hx := hb h J M B data hB hpool hBL d.primeFactors (ha.2.2.trans_eq hP) + (by simpa only [ha.2.1] using hJ) W hW (by simpa only [ha.2.1] using hTL) + (by simpa only [ha.2.1] using hmass) (Q.filter (actualPaddingBin η (c d) j)) + ((filter_subset _ _).trans hQ) (fun q hq => hqdegree q (mem_filter.mp hq).1) + site (a j) (N j) (hN j hj) + have hcard : ((Q.filter (actualPaddingBin η (c d) j)).card : ℝ) ≤ Q.card := by + exact_mod_cast card_filter_le Q (actualPaddingBin η (c d) j) + have herr := mul_le_mul_of_nonneg_right hcard (Real.exp_pos (-(L ^ 9))).le + simp only [ha.2.1] at hx + linarith + calc + _ ≤ ∑ j ∈ bins, (positivePrimeNormalizer d.primeFactors * Real.exp (-2 * W * J) * + (∑ q ∈ Q.filter (actualPaddingBin η (c d) j), actualPaddingCoefficient q / q) + + Q.card * Real.exp (-(L ^ 9))) := sum_le_sum heach + _ = positivePrimeNormalizer d.primeFactors * Real.exp (-2 * W * J) * + (∑ j ∈ bins, ∑ q ∈ Q.filter (actualPaddingBin η (c d) j), actualPaddingCoefficient q / q) + + bins.card * Q.card * Real.exp (-(L ^ 9)) := by + simp only [sum_add_distrib, ← mul_sum, sum_const, nsmul_eq_mul] + ring + _ ≤ _ := by + have hm := mul_le_mul_of_nonneg_left + (padding_bin_reciprocal_sum_le data.Q Q data.primeQ hQ bins η (c d) hη) + (show 0 ≤ positivePrimeNormalizer d.primeFactors * Real.exp (-2 * W * J) by + unfold positivePrimeNormalizer; positivity) + linarith + rw [sum_comm] + calc + _ ≤ ∑ d ∈ D, (positivePrimeNormalizer d.primeFactors * Real.exp (-2 * W * J) * + paddingTiltNormalizer data.Q + bins.card * Q.card * Real.exp (-(L ^ 9))) := sum_le_sum ht + _ = (∑ d ∈ D, positivePrimeNormalizer d.primeFactors) * Real.exp (-2 * W * J) * + paddingTiltNormalizer data.Q + bins.card * D.card * Q.card * Real.exp (-(L ^ 9)) := by + simp only [sum_add_distrib, ← sum_mul, sum_const, nsmul_eq_mul] + ring + _ ≤ _ := by + have hm := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (tuple_normalizer_sum_le P hprime hdisjoint D hD) + (Real.exp_pos (-2 * W * J)).le) (paddingTiltNormalizer_pos data.Q).le + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/VariablePaddingDeletion.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/VariablePaddingDeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..24a609dead730589514379bf0ff1071f23e68d93 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/VariablePaddingDeletion.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.TwoPoint.Bounds.VariableWindowComparison +import OAI.NumberTheory.TwoPoint.Walks.TuplePaddingDeletion + +namespace OAI + +/-! Padding deletion with the bin-dependent integer interval lengths +used in the manuscript. The product model is summed only after each +bin has been transferred separately. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem BravermanDepth22Input.eventually_variable_padding_comparison + (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M) + (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + (data.P ∪ data.Q).Nonempty → (B : ℝ) ≤ Real.exp L → + ∀ (D : Finset ℕ), + (∀ d ∈ D, d.primeFactors ⊆ data.P ∪ data.Q) → + (∀ d ∈ D, (d.primeFactors.card : ℝ) ≤ L ^ 2) → + ∀ (Q : Finset ℕ), Q ⊆ retainedPrimeDivisors data.Q → + (∀ q ∈ Q, (q.primeFactors.card : ℝ) ≤ 100 * Real.log L) → + ∀ (bins : Finset ℤ) (η K : ℝ) (c : ℕ → ℝ) (site : ℤ) (a N : ℤ → ℕ), + (∀ j ∈ bins, Real.exp (L ^ A / 2) ≤ (N j : ℝ)) → + |(∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ Q, uniformAverage (fun x : Fin (N j) => + paddingRejectionAtom data.Q d.primeFactors Q (actualPaddingBin η (c d) j) L K q + ((a j + x.val : ℤ) + site))) - + (data.residueLaw B hB).average (fun x => ∑ d ∈ D, + positivePrimeWeight d.primeFactors (data.residueOrigin x + site) * + paddingRejectedMass data.Q Q bins η (c d) L K (data.residueOrigin x + site))| ≤ + 2 * bins.card * D.card * Q.card * Real.exp (-(L ^ 9)) := by + obtain ⟨A, hA, hb⟩ := hBr.eventually_padding_atom_comparison + refine ⟨A, hA, ?_⟩ + filter_upwards [hb] with L hb + intro h J M B data hB hpool hBL D hD hcard Q hQ hqdegree bins η K c site a N hN + let I := bins ×ˢ (D ×ˢ Q) + let f := fun (i : ℤ × (ℕ × ℕ)) (n : ℤ) => + paddingRejectionAtom data.Q i.2.1.primeFactors Q (actualPaddingBin η (c i.2.1) i.1) + L K i.2.2 (n + site) + let g := fun (i : ℤ × (ℕ × ℕ)) (x : ↥(data.P ∪ data.Q) → Fin B) => f i (data.residueOrigin x) + have hs := finite_interval_family_error I (data.residueLaw B hB) + (fun i => a i.1) (fun i => N i.1) f g (fun _ => 2 * Real.exp (-(L ^ 9))) (by + intro i hi + obtain ⟨hj, hdq⟩ := mem_product.mp hi + obtain ⟨hd, hq⟩ := mem_product.mp hdq + exact hb h J M B data hB hpool hBL i.2.1.primeFactors (hD _ hd) (hcard _ hd) + i.2.2 (hQ hq) (hqdegree _ hq) Q hQ (actualPaddingBin η (c i.2.1) i.1) + K site (a i.1) (N i.1) (hN _ hj)) + have he : (∑ _i ∈ I, 2 * Real.exp (-(L ^ 9))) = + 2 * bins.card * D.card * Q.card * Real.exp (-(L ^ 9)) := by + simp only [sum_const, nsmul_eq_mul, I, card_product, Nat.cast_mul] + ring + rw [he] at hs + simp only [I, sum_product, f, g] at hs + have hmodel (x : ↥(data.P ∪ data.Q) → Fin B) : + (∑ j ∈ bins, ∑ d ∈ D, ∑ q ∈ Q, + paddingRejectionAtom data.Q d.primeFactors Q (actualPaddingBin η (c d) j) L K q + (data.residueOrigin x + site)) = + ∑ d ∈ D, positivePrimeWeight d.primeFactors (data.residueOrigin x + site) * + paddingRejectedMass data.Q Q bins η (c d) L K (data.residueOrigin x + site) := by + rw [sum_comm] + apply sum_congr rfl + intro d _ + exact (padding_rejection_bin_identity data.Q d.primeFactors Q bins η (c d) L K _).symm + simpa only [hmodel] using hs + +theorem ModFiveThetaInput.eventually_model_tuple_padding_deletion + (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℝ in atTop, + ∀ (h J M B : ℕ) (data : ProhibitedPrimeFamily h J M), + data.Q = paddingPrimeSupply E L → + ∀ (hB : ∀ p ∈ data.P ∪ data.Q, p ≤ B), + ∀ (P : Fin J → Finset ℕ), primeTuplePool P = data.P → + (∀ j, ∀ p ∈ P j, p.Prime) → + (∀ j l, l ≠ j → Disjoint (P j) (P l)) → + ∀ (D : Finset ℕ), D ⊆ primeTupleDivisors P → + ∀ (Q : Finset ℕ), Q ⊆ retainedPrimeDivisors data.Q → + ∀ (bins : Finset ℤ) (η K : ℝ) (c : ℕ → ℝ), 0 < η → η ≤ 1 → 0 < K → ∀ site : ℤ, + (data.residueLaw B hB).average (fun x => ∑ d ∈ D, + positivePrimeWeight d.primeFactors (data.residueOrigin x + site) * + paddingRejectedMass data.Q Q bins η (c d) L K (data.residueOrigin x + site)) / + paddingTiltNormalizer data.Q ≤ + (2 : ℝ) ^ J * (∏ j, primeHarmonicMass (P j)) * (C / K + L ^ (-100 : ℝ)) := by + obtain ⟨C, hC, hb⟩ := hP.eventually_positive_padding_cut_cost E + refine ⟨C, hC, ?_⟩ + filter_upwards [hb, eventually_ge_atTop (1 : ℝ)] with L hb hL + intro h J M B data hQ hB P hPeq hprime hdisjoint D hD Q hQsub bins η K c hη hηone hK site + have heach (d : ℕ) (hmem : d ∈ D) : + (data.residueLaw B hB).average (fun x => + positivePrimeWeight d.primeFactors (data.residueOrigin x + site) * + paddingRejectedMass data.Q Q bins η (c d) L K (data.residueOrigin x + site)) / + paddingTiltNormalizer data.Q ≤ + positivePrimeNormalizer d.primeFactors * (C / K + L ^ (-100 : ℝ)) := by + have hd := primeTupleDivisors_arithmetic P hprime hdisjoint (hD hmem) + exact hb η (c d) K h J M B data hQ hB site bins hη hηone hK Q hQsub + d.primeFactors (hd.2.2.trans_eq hPeq) + rw [(data.residueLaw B hB).average_finset_sum, sum_div] + calc + _ ≤ ∑ d ∈ D, positivePrimeNormalizer d.primeFactors * (C / K + L ^ (-100 : ℝ)) := + sum_le_sum heach + _ = (∑ d ∈ D, positivePrimeNormalizer d.primeFactors) * (C / K + L ^ (-100 : ℝ)) := + (sum_mul _ _ _).symm + _ ≤ _ := mul_le_mul_of_nonneg_right (tuple_normalizer_sum_le P hprime hdisjoint D hD) + (add_nonneg (div_nonneg hC.le hK.le) (Real.rpow_nonneg (by linarith) _)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/VariableWindowComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/VariableWindowComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..c23c40b34d6ab43029d1cbe9ca537ca743d84a8e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/VariableWindowComparison.lean @@ -0,0 +1,31 @@ +import OAI.NumberTheory.TwoPoint.Bounds.PaddingDeletionComparison + +namespace OAI + +/-! Finite families of interval comparisons may use a different integer +length in every bin. No common probability space for the sampled +integer intervals is needed. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma finite_interval_family_error {ι β : Type*} [Fintype β] + (I : Finset ι) (μ : FiniteLaw β) (a N : ι → ℕ) + (f : ι → ℤ → ℝ) (g : ι → β → ℝ) (ε : ι → ℝ) + (h : ∀ i ∈ I, |uniformAverage (fun x : Fin (N i) => f i (a i + x.val)) - + μ.average (g i)| ≤ ε i) : + |(∑ i ∈ I, uniformAverage (fun x : Fin (N i) => f i (a i + x.val))) - + μ.average (fun x => ∑ i ∈ I, g i x)| ≤ ∑ i ∈ I, ε i := by + rw [μ.average_finset_sum, ← sum_sub_distrib] + exact (abs_sum_le_sum_abs _ _).trans (sum_le_sum h) + +lemma finset_sum_error {ι : Type*} (I : Finset ι) (f g ε : ι → ℝ) + (h : ∀ i ∈ I, |f i - g i| ≤ ε i) : + |(∑ i ∈ I, f i) - ∑ i ∈ I, g i| ≤ ∑ i ∈ I, ε i := by + rw [← sum_sub_distrib] + exact (abs_sum_le_sum_abs _ _).trans (sum_le_sum h) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedCenteredWord.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedCenteredWord.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a0bf13cbc3591954bfe46f1c65e59cf2edffe6a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedCenteredWord.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CenteredWordMajorant +import OAI.NumberTheory.TwoPoint.Bounds.ForcedSingletonDifference + +namespace OAI + +/-! Keep the nonnegative weight inside the expectation when it is independent of tuple residues. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem uniform_weighted_centered_word_majorant {ι τ : Type*} + [Fintype ι] [Fintype τ] [DecidableEq ι] + (B : ℕ) (p : ι → ℕ) (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (label : τ → ι) (target : τ → Fin B) (base : ι → Fin B) + (htarget : ∀ t, (target t).val < p (label t)) + (R G : (ι → Fin B) → ℝ) (hR : ∀ x, 0 ≤ R x) + (hRdep : ∀ x y, (∀ i, i ∉ univ.image label → x i = y i) → R x = R y) : + |(FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => R x * (∏ t, + ((if x (label t) = target t then (1 : ℝ) else 0) - (p (label t) : ℝ)⁻¹)) * G x)| ≤ + ∑ U ∈ (nonsingletonSlots label).powerset, + if LitConsistent (nonsingletonSlots label \ U) label target then + designatedReciprocal p (singletonLabels label) (nonsingletonSlots label \ U) U label * + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => R x * |selectedMixedDifference (singletonLabels label) + (singletonTarget label target base) + (fun y => G (forceCoordinates ((nonsingletonSlots label \ U).image label) + (litForcedTarget (nonsingletonSlots label \ U) label target base) y)) x|) + else 0 := by + have hS : singletonLabels label ⊆ univ.image label := by + intro i hi + obtain ⟨t, ht⟩ := singleton_occurrence_exists label ⟨i, hi⟩ + exact mem_image.mpr ⟨t, mem_univ _, ht⟩ + have hforce (U : Finset τ) (x : ι → Fin B) : + R (forceCoordinates ((nonsingletonSlots label \ U).image label) + (litForcedTarget (nonsingletonSlots label \ U) label target base) x) = R x := by + apply hRdep + intro i hi + have hiT : i ∉ (nonsingletonSlots label \ U).image label := by + intro hit + obtain ⟨t, _, ht⟩ := mem_image.mp hit + exact hi (mem_image.mpr ⟨t, mem_univ _, ht⟩) + simp only [forceCoordinates_apply, hiT, ite_false] + have hdelta (U : Finset τ) (x : ι → Fin B) : + selectedMixedDifference (singletonLabels label) (singletonTarget label target base) + (fun y => R (forceCoordinates ((nonsingletonSlots label \ U).image label) + (litForcedTarget (nonsingletonSlots label \ U) label target base) y) * + G (forceCoordinates ((nonsingletonSlots label \ U).image label) + (litForcedTarget (nonsingletonSlots label \ U) label target base) y)) x = + R x * selectedMixedDifference (singletonLabels label) (singletonTarget label target base) + (fun y => G (forceCoordinates ((nonsingletonSlots label \ U).image label) + (litForcedTarget (nonsingletonSlots label \ U) label target base) y)) x := by + simp_rw [hforce] + exact selectedMixedDifference_invariant_factor _ _ hS _ x R _ hRdep + have he : (fun x => R x * (∏ t, + ((if x (label t) = target t then (1 : ℝ) else 0) - (p (label t) : ℝ)⁻¹)) * G x) = + (fun x => (1 : ℝ) * (∏ t, + ((if x (label t) = target t then (1 : ℝ) else 0) - (p (label t) : ℝ)⁻¹)) * (R x * G x)) := by + funext x + ring + rw [he] + apply (uniform_centered_word_majorant B p hp hpB label target base htarget + 1 (by norm_num) (fun x => R x * G x)).trans_eq + apply sum_congr rfl + intro U _ + split_ifs + · simp only [one_mul, hdelta, abs_mul, abs_of_nonneg (hR _)] + · rfl + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedDesignationBound.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedDesignationBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..078ffb4a814a2ef05603f43e8688756e86ebb62b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedDesignationBound.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.TwoPoint.Bounds.WeightedCenteredWord +import OAI.NumberTheory.TwoPoint.Bounds.ObservedReciprocalBound +import OAI.NumberTheory.TwoPoint.Walks.RetainedMainProbability +import OAI.NumberTheory.TwoPoint.Bounds.FiniteSupportAverage +import OAI.NumberTheory.TwoPoint.Bounds.ForcedSingletonDifference + +namespace OAI + +/-! A designated trace term retains its extra-reciprocal saving and pays actual padding tests. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem weighted_designation_bound {ι τ : Type*} [Fintype ι] [Fintype τ] [DecidableEq ι] + (B h : ℕ) (p : ι → ℕ) (hinj : Function.Injective p) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (main : List SignedStep) (label : τ → ι) (target : τ → Fin B) (base : ι → Fin B) + (U : Finset τ) (hU : U ⊆ nonsingletonSlots label) (H C : ℝ) + (hH : 0 < H) (hC : 0 ≤ C) (hpH : ∀ i ∈ nonsingletonLabels label, H ≤ p i) + (hS : ∀ i ∈ univ.image label, p i ∈ wordDivisorPrimeSupport main) + (hcover : ∀ q ∈ wordDivisorPrimeSupport main, ∃ i, p i = q) + (R G : (ι → Fin B) → ℝ) (hR : ∀ x, 0 ≤ R x) (hRC : ∀ x, R x ≤ C) + (hG : ∀ x, |G x| ≤ 1) + (hretain : ∀ x, R x ≠ 0 → RetainedMainTests p (univ.image label) h B main x) : + designatedReciprocal p (singletonLabels label) (nonsingletonSlots label \ U) U label * + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => R x * |selectedMixedDifference (singletonLabels label) + (singletonTarget label target base) + (fun y => G (forceCoordinates ((nonsingletonSlots label \ U).image label) + (litForcedTarget (nonsingletonSlots label \ U) label target base) y)) x|) ≤ + (C * 2 ^ (singletonLabels label).card) * + H⁻¹ ^ (∑ i ∈ nonsingletonLabels label, + extraReciprocalExponent (litOccurrences label (designationLit U) i).card + (unlitOccurrences label (designationLit U) i).card) * + ∏ q ∈ wordDivisorPrimeSupport main, (q : ℝ)⁻¹ := by + let μ := FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i)) + let delta := selectedMixedDifference (singletonLabels label) (singletonTarget label target base) + (fun y => G (forceCoordinates ((nonsingletonSlots label \ U).image label) + (litForcedTarget (nonsingletonSlots label \ U) label target base) y)) + let E := ∑ i ∈ nonsingletonLabels label, + extraReciprocalExponent (litOccurrences label (designationLit U) i).card + (unlitOccurrences label (designationLit U) i).card + have hdelta (x : ι → Fin B) : |delta x| ≤ 2 ^ (singletonLabels label).card := + selectedMixedDifference_bound _ _ _ (fun _ => hG _) x + have habs (x : ι → Fin B) : |R x * delta x| = R x * |delta x| := by + rw [abs_mul, abs_of_nonneg (hR x)] + have hav : μ.average (fun x => R x * |delta x|) ≤ + (C * 2 ^ (singletonLabels label).card) * + μ.probability (RetainedMainTests p (univ.image label) h B main) := by + have hf := μ.average_abs_le_support (fun x => R x * delta x) + (RetainedMainTests p (univ.image label) h B main) (C * 2 ^ (singletonLabels label).card) + (fun x => by rw [habs]; exact mul_le_mul (hRC x) (hdelta x) (abs_nonneg _) hC) + (fun x hx => hretain x (fun hr => hx (by rw [hr, zero_mul]))) + simpa only [habs] using hf + have hc := full_word_designated_reciprocal_bound_on_support label U hU p H hH hpH + have hprob := tuple_weight_mul_retained_main_probability_le B h p hinj hp hpB + (univ.image label) main hS hcover + calc + _ ≤ ((∏ i ∈ univ.image label, (p i : ℝ)⁻¹) * H⁻¹ ^ E) * + ((C * 2 ^ (singletonLabels label).card) * + μ.probability (RetainedMainTests p (univ.image label) h B main)) := by + apply mul_le_mul hc hav + · exact μ.average_nonneg (fun x => mul_nonneg (hR x) (abs_nonneg _)) + · positivity + _ = ((C * 2 ^ (singletonLabels label).card) * H⁻¹ ^ E) * + ((∏ i ∈ univ.image label, (p i : ℝ)⁻¹) * + μ.probability (RetainedMainTests p (univ.image label) h B main)) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left hprob (by positivity) + +theorem uniform_weighted_word_lit_bound {ι τ : Type*} + [Fintype ι] [Fintype τ] [DecidableEq ι] + (B h : ℕ) (p : ι → ℕ) (hinj : Function.Injective p) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (main : List SignedStep) (label : τ → ι) (target : τ → Fin B) (base : ι → Fin B) + (htarget : ∀ t, (target t).val < p (label t)) (H C : ℝ) + (hH : 0 < H) (hC : 0 ≤ C) (hpH : ∀ i ∈ nonsingletonLabels label, H ≤ p i) + (hS : ∀ i ∈ univ.image label, p i ∈ wordDivisorPrimeSupport main) + (hcover : ∀ q ∈ wordDivisorPrimeSupport main, ∃ i, p i = q) + (R G : (ι → Fin B) → ℝ) (hR : ∀ x, 0 ≤ R x) (hRC : ∀ x, R x ≤ C) + (hG : ∀ x, |G x| ≤ 1) + (hRdep : ∀ x y, (∀ i, i ∉ univ.image label → x i = y i) → R x = R y) + (hretain : ∀ x, R x ≠ 0 → RetainedMainTests p (univ.image label) h B main x) : + |(FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => R x * (∏ t, + ((if x (label t) = target t then (1 : ℝ) else 0) - (p (label t) : ℝ)⁻¹)) * G x)| ≤ + ∑ U ∈ (nonsingletonSlots label).powerset, + if LitConsistent (nonsingletonSlots label \ U) label target then + (C * 2 ^ (singletonLabels label).card) * + H⁻¹ ^ (∑ i ∈ nonsingletonLabels label, + extraReciprocalExponent (litOccurrences label (designationLit U) i).card + (unlitOccurrences label (designationLit U) i).card) * + ∏ q ∈ wordDivisorPrimeSupport main, (q : ℝ)⁻¹ + else 0 := by + apply (uniform_weighted_centered_word_majorant B p hp hpB label target base + htarget R G hR hRdep).trans + apply sum_le_sum + intro U hU + split_ifs + · exact weighted_designation_bound B h p hinj hp hpB main label target base U + (mem_powerset.mp hU) H C hH hC hpH hS hcover R G hR hRC hG hretain + · exact le_rfl + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedDivisorWord.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedDivisorWord.lean new file mode 100644 index 0000000000000000000000000000000000000000..3414abdefd4dfac3770f462f967cee2dd0a30889 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedDivisorWord.lean @@ -0,0 +1,47 @@ +import OAI.NumberTheory.TwoPoint.Bounds.WeightedCenteredWord +import OAI.NumberTheory.TwoPoint.Bounds.ResidueCentering + +namespace OAI + +/-! Convert the full residue-weighted divisor word to its exact centered form. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem uniform_weighted_divisor_word_average {ι τ : Type*} + [Fintype ι] [Fintype τ] [DecidableEq ι] + (B : ℕ) (p : ι → ℕ) (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (label : τ → ι) (offset : τ → ℤ) (R G : (ι → Fin B) → ℝ) : + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun z => R z * (∏ t, + ((if (p (label t) : ℤ) ∣ (z (label t)).val + offset t then (1 : ℝ) else 0) - + (p (label t) : ℝ)⁻¹)) * G z) = + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun z => R z * (∏ t, + ((if z (label t) = forcedResidue B (p (label t)) (hp _) (hpB _) (offset t) + then (1 : ℝ) else 0) - (p (label t) : ℝ)⁻¹)) * G z) := by + have he := uniform_divisor_word_average B p hp hpB label offset 1 (fun z => R z * G z) + have hl : (fun z : ι → Fin B => R z * (∏ t, + ((if (p (label t) : ℤ) ∣ (z (label t)).val + offset t then (1 : ℝ) else 0) - + (p (label t) : ℝ)⁻¹)) * G z) = + (fun z => (1 : ℝ) * (∏ t, + ((if (p (label t) : ℤ) ∣ (z (label t)).val + offset t then (1 : ℝ) else 0) - + (p (label t) : ℝ)⁻¹)) * (R z * G z)) := by + funext z + ring + have hr : (fun z : ι → Fin B => R z * (∏ t, + ((if z (label t) = forcedResidue B (p (label t)) (hp _) (hpB _) (offset t) + then (1 : ℝ) else 0) - (p (label t) : ℝ)⁻¹)) * G z) = + (fun z => (1 : ℝ) * (∏ t, + ((if z (label t) = forcedResidue B (p (label t)) (hp _) (hpB _) (offset t) + then (1 : ℝ) else 0) - (p (label t) : ℝ)⁻¹)) * (R z * G z)) := by + funext z + ring + rw [hl, hr] + exact he + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedFourierIntegration.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedFourierIntegration.lean new file mode 100644 index 0000000000000000000000000000000000000000..c24d5e9f50133caa911717d49cea51892704a7c9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedFourierIntegration.lean @@ -0,0 +1,67 @@ +import Mathlib.MeasureTheory.Integral.Bochner.Basic +import Mathlib.MeasureTheory.Measure.Lebesgue.Basic + +namespace OAI + +/-! Exact finite-sum interchange and the two `L¹` costs in the cutoff +Fourier inversion step. The uniform estimate is used after summing in the +integer variable, so no frequency supremum enters the short sum. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory Filter +open scoped Classical + +theorem finite_two_integrals {ι : Type*} (S : Finset ι) (c : ι → ℂ) + (A B : ι → ℝ → ℂ) (hA : ∀ i ∈ S, Integrable (A i)) + (hB : ∀ i ∈ S, Integrable (B i)) : + (∑ i ∈ S, c i * (∫ t, A i t) * (∫ s, B i s)) = + ∫ t, ∫ s, ∑ i ∈ S, c i * A i t * B i s := by + symm + calc + _ = ∫ t, ∑ i ∈ S, (c i * A i t) * (∫ s, B i s) := by + apply integral_congr_ae + exact Eventually.of_forall (fun t => by + dsimp only + rw [integral_finsetSum _ (fun i hi => (hB i hi).const_mul (c i * A i t))] + apply sum_congr rfl + intro i _ + exact integral_const_mul _ _) + _ = ∑ i ∈ S, ∫ t, (c i * A i t) * (∫ s, B i s) := by + exact integral_finsetSum _ (fun i hi => + ((hA i hi).const_mul (c i)).mul_const (∫ s, B i s)) + _ = _ := by + apply sum_congr rfl + intro i _ + rw [integral_mul_const, integral_const_mul] + +/-- A bound uniform in both Fourier parameters incurs exactly the product +of the two `L¹` coefficient masses. -/ +theorem norm_two_weighted_integrals (w₁ w₂ : ℝ → ℂ) + (hw₁ : Integrable w₁) (hw₂ : Integrable w₂) + (F : ℝ → ℝ → ℂ) (E : ℝ) + (hF : ∀ t s, ‖F t s‖ ≤ E) : + ‖∫ t, ∫ s, w₁ t * w₂ s * F t s‖ ≤ + E * (∫ t, ‖w₁ t‖) * (∫ s, ‖w₂ s‖) := by + have hinner (t : ℝ) : ‖∫ s, w₁ t * w₂ s * F t s‖ ≤ + (‖w₁ t‖ * E) * (∫ s, ‖w₂ s‖) := by + calc + _ ≤ ∫ s, (‖w₁ t‖ * E) * ‖w₂ s‖ := by + apply norm_integral_le_of_norm_le (hw₂.norm.const_mul (‖w₁ t‖ * E)) + exact Eventually.of_forall (fun s => by + rw [norm_mul, norm_mul] + calc + _ ≤ ‖w₁ t‖ * ‖w₂ s‖ * E := + mul_le_mul_of_nonneg_left (hF t s) (by positivity) + _ = _ := by ring) + _ = _ := integral_const_mul _ _ + calc + _ ≤ ∫ t, (‖w₁ t‖ * E) * (∫ s, ‖w₂ s‖) := by + apply norm_integral_le_of_norm_le + ((hw₁.norm.mul_const E).mul_const (∫ s, ‖w₂ s‖)) + exact Eventually.of_forall hinner + _ = _ := by rw [integral_mul_const, integral_mul_const]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedMatrixTest.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedMatrixTest.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ccaee365a45184ba76252c2427b551bc0daa218 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedMatrixTest.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MatrixAction + +namespace OAI + +/-! Deterministic testing of a weighted matrix. Only rows on the support +of the test vector enter the estimate. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma weighted_matrix_test_le {V : Type*} [Fintype V] [DecidableEq V] + (A : V → V → ℂ) (g R : V → ℝ) (hg : ∀ i, 0 < g i) + (v : EuclideanSpace ℂ V) (hv : ∀ i, ‖v i‖ ≤ g i) + (hrow : ∀ i, v i ≠ 0 → ∑ j, ‖A i j‖ * g j / g i ≤ R i) : + ‖inner ℂ v (matrixOperator A v)‖ ≤ + ∑ i, if v i = 0 then 0 else R i * (g i) ^ 2 := by + rw [PiLp.inner_apply] + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro i _ + by_cases hi : v i = 0 + · simp [hi] + · rw [ite_eq_right hi] + calc + ‖inner ℂ (v i) (matrixOperator A v i)‖ ≤ ‖v i‖ * ‖matrixOperator A v i‖ := + norm_inner_le_norm _ _ + _ ≤ g i * (∑ j, ‖A i j‖ * g j) := by + apply mul_le_mul (hv i) _ (norm_nonneg _) (hg i).le + rw [matrixOperator_apply] + apply (norm_sum_le _ _).trans + exact sum_le_sum (fun j _ => by + rw [norm_mul] + exact mul_le_mul_of_nonneg_left (hv j) (norm_nonneg _)) + _ = (∑ j, ‖A i j‖ * g j / g i) * (g i) ^ 2 := by + rw [← sum_div] + field_simp [(hg i).ne'] + _ ≤ _ := mul_le_mul_of_nonneg_right (hrow i hi) (sq_nonneg _) + +lemma weighted_matrix_test_uniform {V : Type*} [Fintype V] [DecidableEq V] + (A : V → V → ℂ) (g : V → ℝ) (R G : ℝ) + (hg : ∀ i, 0 < g i) (hR : 0 ≤ R) (hGnonneg : 0 ≤ G) + (v : EuclideanSpace ℂ V) (hv : ∀ i, ‖v i‖ ≤ g i) + (hrow : ∀ i, v i ≠ 0 → ∑ j, ‖A i j‖ * g j / g i ≤ R) + (hG : ∀ i, v i ≠ 0 → (g i) ^ 2 ≤ G) : + ‖inner ℂ v (matrixOperator A v)‖ ≤ Fintype.card V * R * G := by + apply (weighted_matrix_test_le A g (fun _ => R) hg v hv hrow).trans + calc + (∑ i, if v i = 0 then 0 else R * (g i) ^ 2) ≤ ∑ _i : V, R * G := by + apply sum_le_sum + intro i _ + by_cases hi : v i = 0 + · rw [ite_eq_left hi] + exact mul_nonneg hR hGnonneg + · rw [ite_eq_right hi] + exact mul_le_mul_of_nonneg_left (hG i hi) hR + _ = _ := by simp; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedRetainedBins.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedRetainedBins.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5063fe40bce36bf5c179be64d64c00282e2f8f8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedRetainedBins.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.TwoPoint.Walks.CanonicalBinSummation + +namespace OAI + +/-! Real bin endpoints introduce factors floor(T)/T of norm at most one. +The per-bin spectral bounds remain valid with these factors. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem ModFiveThetaInput.eventually_canonical_weighted_bin_sum_uniform + (hprime : ModFiveThetaInput) (hBr : BravermanDepth22Input) : + ∃ A : ℕ, 1000 ≤ A ∧ + ∀ (h l : ℕ) (_hh : 0 < h) (_hl : 0 < l) (E : Finset ℕ) + (hE : ∀ p, p.Prime → p ∣ h → p ∈ E) + (_hEl : ∀ p, p.Prime → p ∣ l → p ∈ E) (W : ℝ) (hW : 1 ≤ W), + ∀ᶠ L : ℝ in atTop, + ∀ (hL : 1 ≤ L) (η : ℝ), 0 < η → η ≤ 1 → + ∀ (bins : Finset ℤ) (eligible : ℤ → ℕ → ℕ → Prop), + (∀ j ∈ bins, ∀ d q, eligible j d q → PaddingPairEligible L η d q) → + ∀ (b : ℕ) (N : ℤ → ℕ) (v : ℤ → ℂ), + (∀ j ∈ bins, Real.exp (L ^ A / 2) ≤ (N j : ℝ)) → + (∀ j ∈ bins, ‖v j‖ ≤ 1) → + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let R := Real.exp 1 * (2 * (Real.exp (4 * J) * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + ‖∑ j ∈ bins, v j * canonicalRetainedPrefix h l b E W L (eligible j) hL hW hE (N j)‖ / + totalPaddingBinMass (primeTupleDivisors P) (paddingPrimeSupply E L) L η ≤ + (6 * bins.card * (l : ℝ) ^ 2 / L) * (R / W ^ J) + + 6 * bins.card * Real.exp (-L) := by + obtain ⟨A, hA, hb⟩ := hprime.eventually_actual_retained_bin_uniform hBr + refine ⟨A, hA, ?_⟩ + intro h l hh hl E hE hEl W hW + filter_upwards [hb h l hh hl E hE hEl W hW, + hprime.eventually_canonical_retained_mass E W hW] with L hb hm + intro hL η hη hηone bins eligible he b N v hN hv + dsimp only + let J := primeSupplyCount W L + let P := centeredPrimeBands E (L ^ (199 / 200 : ℝ)) W J + let S := paddingTiltNormalizer (paddingPrimeSupply E L) + let V := ∏ j, primeHarmonicMass (P j) + let R := Real.exp 1 * (2 * (Real.exp (4 * J) * (2 * Real.exp 150 * Real.sqrt W) ^ J)) + have hmass := hm hL η hη + have hbound (j : ℤ) (hj : j ∈ bins) : + ‖v j * canonicalRetainedPrefix h l b E W L (eligible j) hL hW hE (N j)‖ ≤ + 3 * (l : ℝ) ^ 2 * S * R / L + 3 * Real.exp (-L) := by + rw [norm_mul] + calc + _ ≤ 1 * ‖canonicalRetainedPrefix h l b E W L (eligible j) hL hW hE (N j)‖ := + mul_le_mul_of_nonneg_right (hv j hj) (norm_nonneg _) + _ = ‖canonicalRetainedPrefix h l b E W L (eligible j) hL hW hE (N j)‖ := one_mul _ + _ ≤ _ := hb hL η hη hηone (eligible j) (he j hj) b (N j) (hN j hj) + exact retained_bin_sum_mass_lower bins + (fun j => v j * canonicalRetainedPrefix h l b E W L (eligible j) hL hW hE (N j)) + S V (totalPaddingBinMass (primeTupleDivisors P) (paddingPrimeSupply E L) L η) + L l R (Real.exp (-L)) W J (paddingTiltNormalizer_one_le _) hW hmass.1 + (by linarith) hmass.2 (by positivity) (Real.exp_pos _).le hbound + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedRoughFourier.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedRoughFourier.lean new file mode 100644 index 0000000000000000000000000000000000000000..21371e273f6958215f39f250d4b53f991c4692f5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedRoughFourier.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughSieveCounts + +namespace OAI + +/-! Arbitrary bounded complex coefficients on the same rough support. +These are needed for the qualitative Fourier multiplier. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped ComplexConjugate Classical + +noncomputable def weightedRoughFourier (Z : Finset ℕ) (c : ℕ → ℂ) (h : ℕ) : + AddCircle (1 : ℝ) → ℂ := + fourierPolynomial Z (fun z => (h : ℤ) * z) (fun z => c z / (z : ℂ)) + +lemma rough_coefficient_norm_le (Z : Finset ℕ) (c : ℕ → ℂ) (D : ℝ) + (hD : 0 < D) (hZ : ∀ z ∈ Z, D ≤ (z : ℝ)) (hc : ∀ z ∈ Z, ‖c z‖ ≤ 1) + (z : ℕ) (hz : z ∈ Z) : ‖c z / (z : ℂ)‖ ≤ D⁻¹ := by + rw [norm_div, Complex.norm_natCast] + calc + _ ≤ 1 / (z : ℝ) := div_le_div_of_nonneg_right (hc z hz) (Nat.cast_nonneg _) + _ ≤ _ := by simpa only [one_div] using inv_anti₀ hD (hZ z hz) + +theorem norm_weightedRoughFourier_le (Z : Finset ℕ) (c : ℕ → ℂ) (h : ℕ) + (D : ℝ) (hD : 0 < D) (hZ : ∀ z ∈ Z, D ≤ (z : ℝ)) + (hc : ∀ z ∈ Z, ‖c z‖ ≤ 1) (θ : AddCircle (1 : ℝ)) : + ‖weightedRoughFourier Z c h θ‖ ≤ Z.card / D := by + apply (norm_fourierPolynomial_le Z _ _ θ).trans + calc + _ ≤ ∑ _z ∈ Z, D⁻¹ := sum_le_sum (rough_coefficient_norm_le Z c D hD hZ hc) + _ = _ := by simp [div_eq_mul_inv] + +theorem weightedRoughFourier_fourth_le (Z : Finset ℕ) (c : ℕ → ℂ) (h : ℕ) + (hh : 0 < h) (D : ℝ) (hD : 0 < D) (hZ : ∀ z ∈ Z, D ≤ (z : ℝ)) + (hc : ∀ z ∈ Z, ‖c z‖ ≤ 1) : + (∫ θ, ‖weightedRoughFourier Z c h θ‖ ^ 4 ∂AddCircle.haarAddCircle) ≤ + (additiveQuadruples Z).card * (D⁻¹) ^ 4 := by + have hrel (q : (ℕ × ℕ) × (ℕ × ℕ)) : + (h : ℤ) * q.1.1 + (h : ℤ) * q.1.2 = + (h : ℤ) * q.2.1 + (h : ℤ) * q.2.2 ↔ + q.1.1 + q.1.2 = q.2.1 + q.2.2 := by + rw [← mul_add, ← mul_add, + mul_right_inj' (show (h : ℤ) ≠ 0 by exact_mod_cast hh.ne')] + exact_mod_cast Iff.rfl + rw [weightedRoughFourier, integral_norm_fourierPolynomial_fourth] + simp_rw [hrel] + rw [← sum_filter] + calc + _ ≤ ∑ _q ∈ additiveQuadruples Z, (D⁻¹) ^ 4 := by + apply sum_le_sum + intro q hq + have hm := mem_additiveQuadruples hq + have h₁ := rough_coefficient_norm_le Z c D hD hZ hc q.1.1 hm.1 + have h₂ := rough_coefficient_norm_le Z c D hD hZ hc q.1.2 hm.2.1 + have h₃ := rough_coefficient_norm_le Z c D hD hZ hc q.2.1 hm.2.2.1 + have h₄ := rough_coefficient_norm_le Z c D hD hZ hc q.2.2 hm.2.2.2.1 + calc + _ ≤ ‖c q.1.1 / (q.1.1 : ℂ) * (c q.1.2 / (q.1.2 : ℂ)) * + conj (c q.2.1 / (q.2.1 : ℂ) * (c q.2.2 / (q.2.2 : ℂ)))‖ := + Complex.re_le_norm _ + _ ≤ D⁻¹ * D⁻¹ * (D⁻¹ * D⁻¹) := by + simp only [Complex.norm_conj, norm_mul] + gcongr + _ = _ := by ring + _ = _ := by simp + +theorem weightedRoughFourier_bounds_of_sieve (P Z : Finset ℕ) (c : ℕ → ℂ) + (D h : ℕ) [NeZero D] (hh : 0 < h) (A B : ℝ) + (hZ : ∀ z ∈ Z, D ≤ z ∧ z < D + D ∧ avoidsPrimeSet P z) + (hc : ∀ z ∈ Z, ‖c z‖ ≤ 1) + (h₁ : (uniformFiniteLaw (Fin D)).probability + (fun j => avoidsPrimeSet P (D + j.val)) ≤ A) + (h₄ : (uniformFiniteLaw (Fin D × Fin D × Fin D)).probability + (fun j => fourFormsAvoidPrimeSet P + (D + j.1.val, D + j.2.1.val, D + j.2.2.val)) ≤ B) : + (∀ θ, ‖weightedRoughFourier Z c h θ‖ ≤ A) ∧ + (∫ θ, ‖weightedRoughFourier Z c h θ‖ ^ 4 ∂AddCircle.haarAddCircle) ≤ B / D := by + have hD : (0 : ℝ) < D := by exact_mod_cast NeZero.pos D + have hzr (z : ℕ) (hz : z ∈ Z) : (D : ℝ) ≤ z := by exact_mod_cast (hZ z hz).1 + have hcard : (Z.card : ℝ) ≤ (D : ℝ) * A := by + calc + _ ≤ ((roughIntervalSamples P D D).card : ℝ) := by + exact_mod_cast rough_subset_card_le P Z D D hZ + _ = _ := roughIntervalSamples_probability P D D + _ ≤ _ := mul_le_mul_of_nonneg_left h₁ hD.le + have hquad : ((additiveQuadruples Z).card : ℝ) ≤ (D : ℝ) ^ 3 * B := by + calc + _ ≤ ((roughCubeSamples P (D, D, D) D).card : ℝ) := by + exact_mod_cast rough_additiveQuadruples_card_le P Z D D hZ + _ = _ := roughCubeSamples_probability P (D, D, D) D + _ ≤ _ := mul_le_mul_of_nonneg_left h₄ (by positivity) + constructor + · intro θ + apply (norm_weightedRoughFourier_le Z c h (D : ℝ) hD hzr hc θ).trans + exact (div_le_iff₀ hD).mpr (by nlinarith only [hcard]) + · calc + _ ≤ ((additiveQuadruples Z).card : ℝ) * ((D : ℝ)⁻¹) ^ 4 := + weightedRoughFourier_fourth_le Z c h hh (D : ℝ) hD hzr hc + _ ≤ ((D : ℝ) ^ 3 * B) * ((D : ℝ)⁻¹) ^ 4 := + mul_le_mul_of_nonneg_right hquad (by positivity) + _ = _ := by field_simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedRows.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9c9d7d0230477321a4101ce07bf5f8a39bafc20 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedRows.lean @@ -0,0 +1,158 @@ +import OAI.NumberTheory.TwoPoint.Bounds.FiniteProbability +import Mathlib.Analysis.InnerProductSpace.PiL2 + +namespace OAI + +/-! +# Weighted rows and the localized square estimate + +Finite weighted Cauchy--Schwarz proves the localized Schur estimate in +`q:weighted-rows`. Constancy of the site factor on the support replaces a +level-set decomposition. Summing the localized estimates only uses a bound +at the support of the vector; no commutation with a projection is needed. +-/ + +namespace TwoPointCorrelations + +open Finset + +variable {ι δ : Type*} [Fintype ι] [Fintype δ] + +lemma weighted_row_square (B : ι → ι → ℝ) (g a : ι → ℝ) (c : ℝ) + (hB : ∀ i j, 0 ≤ B i j) (hg : ∀ i, 0 < g i) + (hrow : ∀ i, ∑ j, B i j * g j / g i ≤ c * a i) + (v : ι → ℝ) (i : ι) : + (∑ j, B i j * v j) ^ 2 ≤ + (c * a i) * ∑ j, B i j * g i / g j * (v j) ^ 2 := by + have hcs := sum_sq_le_sum_mul_sum_of_sq_le_mul univ + (f := fun j => B i j * g j / g i) + (g := fun j => B i j * g i / g j * (v j) ^ 2) + (r := fun j => B i j * v j) + (fun j _ => div_nonneg (mul_nonneg (hB i j) (hg j).le) (hg i).le) + (fun j _ => mul_nonneg (div_nonneg (mul_nonneg (hB i j) (hg i).le) (hg j).le) (sq_nonneg _)) + (fun j _ => le_of_eq (by field_simp [(hg i).ne', (hg j).ne'])) + exact hcs.trans (mul_le_mul_of_nonneg_right (hrow i) + (sum_nonneg (fun j _ => mul_nonneg + (div_nonneg (mul_nonneg (hB i j) (hg i).le) (hg j).le) (sq_nonneg _)))) + +lemma weighted_column_bound (B : ι → ι → ℝ) (g a : ι → ℝ) (c : ℝ) + (ha : ∀ i, 0 ≤ a i) + (hsymm : ∀ i j, B i j = B j i) + (hlevel : ∀ i j, B i j ≠ 0 → a i = a j) + (hrow : ∀ i, ∑ j, B i j * g j / g i ≤ c * a i) (j : ι) : + ∑ i, a i * B i j * g i / g j ≤ c * (a j) ^ 2 := by + have heq : (∑ i, a i * B i j * g i / g j) = + a j * ∑ i, B j i * g i / g j := by + rw [mul_sum] + apply sum_congr rfl + intro i _ + by_cases hij : B i j = 0 + · simp [hij, ← hsymm i j] + · rw [hlevel i j hij, hsymm i j] + ring + rw [heq] + calc + _ ≤ a j * (c * a j) := mul_le_mul_of_nonneg_left (hrow j) (ha j) + _ = _ := by ring + +/-- The finite localized square bound. The input kernel is nonnegative, +so it can in particular be the entrywise norm of a Hermitian matrix. -/ +theorem weighted_kernel_localized_square (B : ι → ι → ℝ) + (g a : ι → ℝ) (c : ℝ) (hc : 0 ≤ c) + (hB : ∀ i j, 0 ≤ B i j) (hg : ∀ i, 0 < g i) (ha : ∀ i, 0 ≤ a i) + (hsymm : ∀ i j, B i j = B j i) + (hlevel : ∀ i j, B i j ≠ 0 → a i = a j) + (hrow : ∀ i, ∑ j, B i j * g j / g i ≤ c * a i) + (v : ι → ℝ) : + ∑ i, (∑ j, B i j * v j) ^ 2 ≤ c ^ 2 * ∑ i, (a i) ^ 2 * (v i) ^ 2 := by + calc + _ ≤ ∑ i, (c * a i) * ∑ j, B i j * g i / g j * (v j) ^ 2 := + sum_le_sum (fun i _ => weighted_row_square B g a c hB hg hrow v i) + _ = c * ∑ j, (∑ i, a i * B i j * g i / g j) * (v j) ^ 2 := by + simp only [mul_sum, sum_mul] + rw [sum_comm] + apply sum_congr rfl + intro j _ + apply sum_congr rfl + intro i _ + ring + _ ≤ c * ∑ j, (c * (a j) ^ 2) * (v j) ^ 2 := by + apply mul_le_mul_of_nonneg_left _ hc + apply sum_le_sum + intro j _ + exact mul_le_mul_of_nonneg_right + (weighted_column_bound B g a c ha hsymm hlevel hrow j) (sq_nonneg _) + _ = _ := by + simp only [mul_sum] + apply sum_congr rfl + intro j _ + ring + +/-- The manuscript's localized square bound for a complex matrix. -/ +theorem weighted_matrix_localized_square (A : ι → ι → ℂ) + (g a : ι → ℝ) (c : ℝ) (hc : 0 ≤ c) + (hg : ∀ i, 0 < g i) (ha : ∀ i, 0 ≤ a i) + (hsymm : ∀ i j, ‖A i j‖ = ‖A j i‖) + (hlevel : ∀ i j, A i j ≠ 0 → a i = a j) + (hrow : ∀ i, ∑ j, ‖A i j‖ * g j / g i ≤ c * a i) + (v : ι → ℂ) : + ∑ i, ‖∑ j, A i j * v j‖ ^ 2 ≤ c ^ 2 * ∑ i, (a i) ^ 2 * ‖v i‖ ^ 2 := by + apply le_trans _ (weighted_kernel_localized_square (fun i j => ‖A i j‖) g a c hc + (fun i j => norm_nonneg _) hg ha hsymm + (fun i j hij => hlevel i j (fun hz => hij (by simp [hz]))) hrow (fun i => ‖v i‖)) + apply sum_le_sum + intro i _ + apply (sq_le_sq₀ (norm_nonneg _) + (sum_nonneg (fun j _ => mul_nonneg (norm_nonneg _) (norm_nonneg _)))).mpr + simpa only [norm_mul] using norm_sum_le univ (fun j => A i j * v j) + +/-- Summing localized bounds only requires degree control where the +vector is nonzero. This is the support condition supplied by `v = E v`. -/ +theorem localized_square_sum (A : δ → ι → ι → ℂ) (a : δ → ι → ℝ) + (c M : ℝ) (v : ι → ℂ) + (hlocal : ∀ d, ∑ i, ‖∑ j, A d i j * v j‖ ^ 2 ≤ + c ^ 2 * ∑ i, (a d i) ^ 2 * ‖v i‖ ^ 2) + (hdegree : ∀ i, v i ≠ 0 → ∑ d, (a d i) ^ 2 ≤ M) : + ∑ d, ∑ i, ‖∑ j, A d i j * v j‖ ^ 2 ≤ c ^ 2 * M * ∑ i, ‖v i‖ ^ 2 := by + calc + _ ≤ ∑ d, c ^ 2 * ∑ i, (a d i) ^ 2 * ‖v i‖ ^ 2 := sum_le_sum (fun d _ => hlocal d) + _ = c ^ 2 * ∑ i, (∑ d, (a d i) ^ 2) * ‖v i‖ ^ 2 := by + rw [← mul_sum, sum_comm] + simp only [sum_mul] + _ ≤ c ^ 2 * ∑ i, M * ‖v i‖ ^ 2 := by + apply mul_le_mul_of_nonneg_left _ (sq_nonneg _) + apply sum_le_sum + intro i _ + by_cases hi : v i = 0 + · simp [hi] + · exact mul_le_mul_of_nonneg_right (hdegree i hi) (sq_nonneg _) + _ = _ := by rw [← mul_sum, mul_assoc] + +/-- Entrywise application identity lets the matrix estimate feed directly +into the finite-dimensional Hilbert-space spectral transfer. -/ +theorem weighted_operator_norm_le + (T : EuclideanSpace ℂ ι →L[ℂ] EuclideanSpace ℂ ι) + (A : ι → ι → ℂ) (hT : ∀ v i, T v i = ∑ j, A i j * v j) + (g a : ι → ℝ) (c : ℝ) (hc : 0 ≤ c) + (hg : ∀ i, 0 < g i) (ha : ∀ i, 0 ≤ a i) (ha1 : ∀ i, a i ≤ 1) + (hsymm : ∀ i j, ‖A i j‖ = ‖A j i‖) + (hlevel : ∀ i j, A i j ≠ 0 → a i = a j) + (hrow : ∀ i, ∑ j, ‖A i j‖ * g j / g i ≤ c * a i) : ‖T‖ ≤ c := by + apply ContinuousLinearMap.opNorm_le_bound _ hc + intro v + have hlocal := weighted_matrix_localized_square A g a c hc hg ha hsymm hlevel hrow + (fun i => v i) + have hsum : (∑ i, (a i) ^ 2 * ‖v i‖ ^ 2) ≤ ∑ i, ‖v i‖ ^ 2 := by + apply sum_le_sum + intro i _ + have hi : (a i) ^ 2 ≤ 1 := by nlinarith [ha i, ha1 i] + exact (mul_le_mul_of_nonneg_right hi (sq_nonneg _)).trans_eq (one_mul _) + have hs : ‖T v‖ ^ 2 ≤ c ^ 2 * ‖v‖ ^ 2 := by + rw [EuclideanSpace.norm_sq_eq, EuclideanSpace.norm_sq_eq] + simpa only [hT] using hlocal.trans (mul_le_mul_of_nonneg_left hsum (sq_nonneg _)) + have hn : 0 ≤ c * ‖v‖ := mul_nonneg hc (norm_nonneg _) + nlinarith [norm_nonneg (T v)] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedShiftAverage.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedShiftAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..45a969195b1da2a6cee771bb4ee6e5a76985ea66 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedShiftAverage.lean @@ -0,0 +1,126 @@ +import OAI.NumberTheory.TwoPoint.Bounds.WeightedShiftConvolution +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftAverage + +namespace OAI + +/-! The finite correlation inequality for the arbitrary coefficients in +the qualitative rough multiplier. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +noncomputable def weightedRoughShiftProfile (f g : ℕ → ℂ) (Z : Finset ℕ) (c : ℕ → ℂ) (h n : ℕ) : ℂ := + ∑ z ∈ Z, (c z / (z : ℂ)) * (f n * g (n + h * z)) + +noncomputable def weightedRoughShiftAverage (f g : ℕ → ℂ) (Z : Finset ℕ) (c : ℕ → ℂ) (h Y : ℕ) : ℂ := + positivePrefix (weightedRoughShiftProfile f g Z c h) Y / (Y : ℂ) + +lemma norm_weightedRoughShiftProfile_le (f g : ℕ → ℂ) (hf : OneBounded f) (hg : OneBounded g) + (Z : Finset ℕ) (c : ℕ → ℂ) (h n : ℕ) (hn : 0 < n) : + ‖weightedRoughShiftProfile f g Z c h n‖ ≤ ∑ z ∈ Z, ‖c z / (z : ℂ)‖ := by + have hh := norm_weightedShiftProfile_le Z (fun z => (c z / (z : ℂ))) + (fun z => h * z) f g hf hg 1 0 n hn + simpa only [weightedShiftProfile, weightedRoughShiftProfile, Nat.mod_one, ite_true] using hh + +lemma translated_weightedRoughShiftProfile_eq (f g : ℕ → ℂ) (Z : Finset ℕ) (c : ℕ → ℂ) (D h Y : ℕ) + (hZ : ∀ z ∈ Z, z ≤ 2 * D) : + translatedPrefixAverage (weightedRoughShiftProfile f g Z c h) Y D = + (D : ℂ)⁻¹ * ∑ v ∈ range Y, ∫ θ, + weightedRoughFourier Z c h θ * forwardWindowPolynomial f D (v + 1) θ * + backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ + ∂AddCircle.haarAddCircle := by + unfold translatedPrefixAverage + congr 1 + calc + _ = ∑ m ∈ Icc 1 D, + positivePrefix (fun n => weightedRoughShiftProfile f g Z c h (n + m)) Y := by + simpa only [Nat.zero_add] using (sum_Icc_shift + (fun m => positivePrefix (fun n => weightedRoughShiftProfile f g Z c h (n + m)) Y) 0 D).symm + _ = _ := by + rw [summed_weighted_rough_shift_convolution f g Z c D h Y hZ] + rfl + +/-- All Fourier ingredients are now attached to the concrete two windows. -/ +theorem weighted_rough_convolution_sum_bound (f g : ℕ → ℂ) (hf : OneBounded f) + (hg : OneBounded g) (Z : Finset ℕ) (c : ℕ → ℂ) (D h Y : ℕ) + (ε U V K : ℝ) (hε : 0 < ε) (hU : 0 ≤ U) (hK : 0 ≤ K) + (hB : ∀ θ, ‖weightedRoughFourier Z c h θ‖ ≤ U) + (hV : (∫ θ, ‖weightedRoughFourier Z c h θ‖ ^ 4 + ∂AddCircle.haarAddCircle) ≤ V) + (hF : ∀ θ, (∑ v ∈ range Y, ‖forwardWindowPolynomial f D (v + 1) θ‖) ≤ K) : + ‖∑ v ∈ range Y, ∫ θ, + weightedRoughFourier Z c h θ * forwardWindowPolynomial f D (v + 1) θ * + backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ + ∂AddCircle.haarAddCircle‖ ≤ + ε * ((Y : ℝ) * (Real.sqrt D * Real.sqrt ((2 * h + 1) * D))) + + (U * ((2 * h + 1) * D) * K / ε ^ 4) * V := by + have hh := fourier_region_bound (range Y) (weightedRoughFourier Z c h) + (fun v => forwardWindowPolynomial f D (v + 1)) + (fun v => backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1)) + (continuous_fourierPolynomial _ _ _) + (fun v _ => continuous_forwardWindowPolynomial f D (v + 1)) + (fun v _ => continuous_backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1)) + ε U ((2 * h + 1) * D) K hε hU (by positivity) hK hB + (fun v _ θ => by + simpa only [Nat.cast_mul, Nat.cast_add, Nat.cast_ofNat, Nat.cast_one] using + norm_backwardWindowPolynomial_le g hg ((2 * h + 1) * D) (v + 1) θ) hF + apply hh.trans + apply add_le_add + · apply mul_le_mul_of_nonneg_left _ hε.le + simpa only [Nat.cast_mul, Nat.cast_add, Nat.cast_ofNat, Nat.cast_one] using + rough_window_energy_sum_bound f g hf hg D ((2 * h + 1) * D) Y + · exact mul_le_mul_of_nonneg_left hV (by positivity) + +lemma normalized_translated_weightedRoughShift_bound (f g : ℕ → ℂ) + (Z : Finset ℕ) (c : ℕ → ℂ) (D h Y : ℕ) (hD : 0 < D) (hY : 0 < Y) + (hZ : ∀ z ∈ Z, z ≤ 2 * D) (W : ℝ) + (hW : ‖∑ v ∈ range Y, ∫ θ, + weightedRoughFourier Z c h θ * forwardWindowPolynomial f D (v + 1) θ * + backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ + ∂AddCircle.haarAddCircle‖ ≤ W) : + ‖translatedPrefixAverage (weightedRoughShiftProfile f g Z c h) Y D / (Y : ℂ)‖ ≤ + W / ((Y : ℝ) * D) := by + rw [translated_weightedRoughShiftProfile_eq f g Z c D h Y hZ, + norm_div, norm_mul, norm_inv, Complex.norm_natCast, Complex.norm_natCast] + have hDr : (0 : ℝ) < D := by exact_mod_cast hD + have hYr : (0 : ℝ) < Y := by exact_mod_cast hY + calc + _ ≤ (D : ℝ)⁻¹ * W / Y := + div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hW (by positivity)) hYr.le + _ = _ := by simp only [div_eq_mul_inv, mul_inv_rev]; ring + +/-- The finite correlation bound before inserting the sieve estimates and +the size estimates for the published MRT error. -/ +theorem weighted_rough_shift_average_bound (f g : ℕ → ℂ) (hf : OneBounded f) + (hg : OneBounded g) (Z : Finset ℕ) (c : ℕ → ℂ) (D h Y : ℕ) (hD : 0 < D) (hY : 0 < Y) + (hZ : ∀ z ∈ Z, z ≤ 2 * D) + (ε U V K : ℝ) (hε : 0 < ε) (hU : 0 ≤ U) (hK : 0 ≤ K) + (hB : ∀ θ, ‖weightedRoughFourier Z c h θ‖ ≤ U) + (hV : (∫ θ, ‖weightedRoughFourier Z c h θ‖ ^ 4 + ∂AddCircle.haarAddCircle) ≤ V) + (hF : ∀ θ, (∑ v ∈ range Y, ‖forwardWindowPolynomial f D (v + 1) θ‖) ≤ K) : + ‖weightedRoughShiftAverage f g Z c h Y‖ ≤ + 2 * (D : ℝ) / Y * (∑ z ∈ Z, ‖c z / (z : ℂ)‖) + + (ε * ((Y : ℝ) * (Real.sqrt D * Real.sqrt ((2 * h + 1) * D))) + + (U * ((2 * h + 1) * D) * K / ε ^ 4) * V) / ((Y : ℝ) * D) := by + let u := weightedRoughShiftProfile f g Z c h + have he := norm_normalized_translation_error u Y D hY hD + (∑ z ∈ Z, ‖c z / (z : ℂ)‖) (sum_nonneg (fun z _ => by positivity)) + (fun n hn => norm_weightedRoughShiftProfile_le f g hf hg Z c h n hn) + have hc := normalized_translated_weightedRoughShift_bound f g Z c D h Y hD hY hZ _ + (weighted_rough_convolution_sum_bound f g hf hg Z c D h Y ε U V K hε hU hK hB hV hF) + calc + ‖weightedRoughShiftAverage f g Z c h Y‖ = ‖translatedPrefixAverage u Y D / (Y : ℂ) - + (translatedPrefixAverage u Y D - positivePrefix u Y) / (Y : ℂ)‖ := by + congr 1 + dsimp [weightedRoughShiftAverage, u] + ring + _ ≤ ‖translatedPrefixAverage u Y D / (Y : ℂ)‖ + + ‖(translatedPrefixAverage u Y D - positivePrefix u Y) / (Y : ℂ)‖ := norm_sub_le _ _ + _ ≤ _ := by simpa only [add_comm] using add_le_add hc he + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedShiftConvolution.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedShiftConvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..80b6ea2cca61c716df7c40df2acde54b84a175ac --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedShiftConvolution.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftConvolution +import OAI.NumberTheory.TwoPoint.Bounds.WeightedRoughFourier + +namespace OAI + +/-! Exact convolution with arbitrary complex coefficients on the rough +support. The coefficient choice is kept outside the short-sum supremum. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +/-- Orthogonality imposes precisely `a=m+hz`; the long window contains +every selected frequency, so there is no further truncation error. -/ +theorem weighted_rough_shift_convolution (f g : ℕ → ℂ) (Z : Finset ℕ) (c : ℕ → ℂ) (D h v : ℕ) + (hZ : ∀ z ∈ Z, z ≤ 2 * D) : + (∫ θ, weightedRoughFourier Z c h θ * forwardWindowPolynomial f D v θ * + backwardWindowPolynomial g ((2 * h + 1) * D) v θ ∂AddCircle.haarAddCircle) = + ∑ z ∈ Z, (c z / (z : ℂ)) * ∑ m ∈ Icc 1 D, f (v + m) * g (v + m + h * z) := by + unfold weightedRoughFourier forwardWindowPolynomial backwardWindowPolynomial + simp_rw [fourierPolynomial_mul] + rw [integral_fourierPolynomial] + simp only [sum_product] + apply sum_congr rfl + intro z hz + rw [mul_sum] + apply sum_congr rfl + intro m hm + have hm1 : 1 ≤ m := (mem_Icc.mp hm).1 + have hmD : m ≤ D := (mem_Icc.mp hm).2 + have ha : m + h * z ∈ Icc 1 ((2 * h + 1) * D) := by + simp only [mem_Icc] + constructor + · omega + · nlinarith [Nat.mul_le_mul_left h (hZ z hz)] + rw [sum_eq_single (m + h * z)] + · have he : (h : ℤ) * z + m + -(↑(m + h * z) : ℤ) = 0 := by + push_cast + ring + rw [ite_eq_left he] + rw [show v + (m + h * z) = v + m + h * z by omega] + ring + · intro a _ hne + have he : ¬((h : ℤ) * z + m + -(a : ℤ) = 0) := by + intro hh + apply hne + exact_mod_cast (show (a : ℤ) = m + h * z by linarith) + exact ite_eq_right he + · exact fun hnot => False.elim (hnot ha) + +/-- Summing the convolution identity gives the exact translated average +used before the endpoint comparison. -/ +theorem summed_weighted_rough_shift_convolution (f g : ℕ → ℂ) (Z : Finset ℕ) (c : ℕ → ℂ) + (D h Y : ℕ) (hZ : ∀ z ∈ Z, z ≤ 2 * D) : + (∑ v ∈ range Y, ∫ θ, + weightedRoughFourier Z c h θ * forwardWindowPolynomial f D (v + 1) θ * + backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ + ∂AddCircle.haarAddCircle) = + ∑ m ∈ Icc 1 D, ∑ v ∈ range Y, ∑ z ∈ Z, + (c z / (z : ℂ)) * (f (v + 1 + m) * g (v + 1 + m + h * z)) := by + simp_rw [weighted_rough_shift_convolution f g Z c D h _ hZ, mul_sum] + calc + _ = ∑ v ∈ range Y, ∑ m ∈ Icc 1 D, ∑ z ∈ Z, + (c z / (z : ℂ)) * (f (v + 1 + m) * g (v + 1 + m + h * z)) := by + apply sum_congr rfl + intro v _ + rw [sum_comm] + _ = _ := sum_comm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedShiftParameters.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedShiftParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..800cd8c2fc22e07f290e1432cc66840d35be7ba3 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedShiftParameters.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TwoPoint.Bounds.WeightedShiftAverage +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftScale + +namespace OAI + +/-! The three quantitative terms in the qualitative weighted shift +argument, separated from their eventual scale estimates. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +lemma rough_coefficient_mass_le_one (Z : Finset ℕ) (c : ℕ → ℂ) (D : ℕ) + (hD : 0 < D) (hZ : ∀ z ∈ Z, D ≤ z ∧ z < D + D) + (hc : ∀ z ∈ Z, ‖c z‖ ≤ 1) : + (∑ z ∈ Z, ‖c z / (z : ℂ)‖) ≤ 1 := by + have hDr : (0 : ℝ) < D := by exact_mod_cast hD + have hcard : Z.card ≤ D := by + have ht := card_le_card (show Z ⊆ Ico D (D + D) from + fun z hz => mem_Ico.mpr (hZ z hz)) + simpa using ht + calc + _ ≤ ∑ _z ∈ Z, (D : ℝ)⁻¹ := sum_le_sum + (rough_coefficient_norm_le Z c D hDr + (fun z hz => by exact_mod_cast (hZ z hz).1) hc) + _ = Z.card / (D : ℝ) := by simp [div_eq_mul_inv] + _ ≤ 1 := (div_le_one hDr).mpr (by exact_mod_cast hcard) + +lemma weighted_shift_high_identity (D h Y : ℕ) (hD : 0 < D) (hY : 0 < Y) + (q η U V K : ℝ) (hη : 0 < η) : + (((U * q) * ((2 * (h : ℝ) + 1) * D) * + (K * Y * D * q) / η ^ 4) * (V / D * q ^ 4)) / ((Y : ℝ) * D) = + ((2 * (h : ℝ) + 1) * U * V * K) * (q ^ 6 / η ^ 4) := by + have hDr : (D : ℝ) ≠ 0 := by exact_mod_cast hD.ne' + have hYr : (Y : ℝ) ≠ 0 := by exact_mod_cast hY.ne' + field_simp + +/-- The high-frequency cost is controlled by `q^6 ≤ η^5`; all actual +correlation, boundary and short-window terms remain explicit. -/ +theorem weighted_rough_shift_parameter_bound (f g : ℕ → ℂ) (hf : OneBounded f) + (hg : OneBounded g) (Z : Finset ℕ) (c : ℕ → ℂ) (D h Y : ℕ) + (hD : 0 < D) (hY : 0 < Y) (hZ : ∀ z ∈ Z, z ≤ 2 * D) + (q η U V K : ℝ) (hq : 0 ≤ q) (hη : 0 < η) + (hU : 0 ≤ U) (hV : 0 ≤ V) (hK : 0 ≤ K) + (hmass : (∑ z ∈ Z, ‖c z / (z : ℂ)‖) ≤ 1) + (hendpoint : (D : ℝ) / Y ≤ η) (hgap : q ^ 6 ≤ η ^ 5) + (hB : ∀ θ, ‖weightedRoughFourier Z c h θ‖ ≤ U * q) + (hfourth : (∫ θ, ‖weightedRoughFourier Z c h θ‖ ^ 4 + ∂AddCircle.haarAddCircle) ≤ V / D * q ^ 4) + (hF : ∀ θ, (∑ v ∈ range Y, ‖forwardWindowPolynomial f D (v + 1) θ‖) ≤ + K * Y * D * q) : + ‖weightedRoughShiftAverage f g Z c h Y‖ ≤ + (2 + (2 * (h : ℝ) + 1) + (2 * (h : ℝ) + 1) * U * V * K) * η := by + have he : 2 * (D : ℝ) / Y * (∑ z ∈ Z, ‖c z / (z : ℂ)‖) ≤ 2 * η := by + calc + _ = 2 * ((D : ℝ) / Y) * (∑ z ∈ Z, ‖c z / (z : ℂ)‖) := by ring + _ ≤ 2 * η * 1 := mul_le_mul + (mul_le_mul_of_nonneg_left hendpoint (by norm_num)) hmass + (sum_nonneg (fun _ _ => norm_nonneg _)) (by positivity) + _ = _ := mul_one _ + have hraw := weighted_rough_shift_average_bound f g hf hg Z c D h Y hD hY hZ + η (U * q) (V / D * q ^ 4) (K * Y * D * q) hη (by positivity) (by positivity) + hB hfourth hF + have hlow := rough_low_term_bound D h Y hD hY η hη.le + have hhigh := weighted_shift_high_identity D h Y hD hY q η U V K hη + have hfrac : q ^ 6 / η ^ 4 ≤ η := by + apply (div_le_iff₀ (pow_pos hη 4)).mpr + convert hgap using 1 + ring + have ht := mul_le_mul_of_nonneg_left hfrac + (show 0 ≤ (2 * (h : ℝ) + 1) * U * V * K by positivity) + apply hraw.trans + rw [add_div, hhigh] + nlinarith only [he, hlow, ht] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedShiftRight.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedShiftRight.lean new file mode 100644 index 0000000000000000000000000000000000000000..cab6d6b8f34aafcd120a640f2b0fed4728b82207 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedShiftRight.lean @@ -0,0 +1,141 @@ +import OAI.NumberTheory.TwoPoint.Bounds.WeightedShiftParameters + +namespace OAI + +/-! The same finite Fourier argument when the nonpretentious function is +in the second factor. No supremum is moved inside a sum over origins. -/ + +namespace TwoPointCorrelations + +open Finset Filter MeasureTheory +open scoped Classical + +lemma backwardWindowPolynomial_eq_forward_neg (g : ℕ → ℂ) (Q v : ℕ) + (θ : AddCircle (1 : ℝ)) : + backwardWindowPolynomial g Q v θ = forwardWindowPolynomial g Q v (-θ) := by + simp only [backwardWindowPolynomial, forwardWindowPolynomial, fourierPolynomial, + fourier_apply, smul_neg, neg_smul] + +theorem weighted_rough_convolution_sum_bound_right (f g : ℕ → ℂ) (hf : OneBounded f) + (hg : OneBounded g) (Z : Finset ℕ) (c : ℕ → ℂ) (D h Y : ℕ) + (ε U V K : ℝ) (hε : 0 < ε) (hU : 0 ≤ U) (hK : 0 ≤ K) + (hB : ∀ θ, ‖weightedRoughFourier Z c h θ‖ ≤ U) + (hV : (∫ θ, ‖weightedRoughFourier Z c h θ‖ ^ 4 + ∂AddCircle.haarAddCircle) ≤ V) + (hG : ∀ θ, (∑ v ∈ range Y, + ‖backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ‖) ≤ K) : + ‖∑ v ∈ range Y, ∫ θ, + weightedRoughFourier Z c h θ * forwardWindowPolynomial f D (v + 1) θ * + backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ + ∂AddCircle.haarAddCircle‖ ≤ + ε * ((Y : ℝ) * (Real.sqrt D * Real.sqrt ((2 * h + 1) * D))) + + (U * D * K / ε ^ 4) * V := by + have he : (∑ v ∈ range Y, ∫ θ, + weightedRoughFourier Z c h θ * forwardWindowPolynomial f D (v + 1) θ * + backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ + ∂AddCircle.haarAddCircle) = + ∑ v ∈ range Y, ∫ θ, + weightedRoughFourier Z c h θ * backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ * + forwardWindowPolynomial f D (v + 1) θ ∂AddCircle.haarAddCircle := by + apply sum_congr rfl + intro v _ + apply integral_congr_ae + exact Eventually.of_forall (fun θ => by ring) + rw [he] + have hh := fourier_region_bound (range Y) (weightedRoughFourier Z c h) + (fun v => backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1)) + (fun v => forwardWindowPolynomial f D (v + 1)) + (continuous_fourierPolynomial _ _ _) + (fun v _ => continuous_backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1)) + (fun v _ => continuous_forwardWindowPolynomial f D (v + 1)) + ε U D K hε hU (by positivity) hK hB + (fun v _ θ => norm_forwardWindowPolynomial_le f hf D (v + 1) θ) hG + apply hh.trans + apply add_le_add + · apply mul_le_mul_of_nonneg_left _ hε.le + calc + _ = ∑ v ∈ range Y, + Real.sqrt (∫ θ, ‖forwardWindowPolynomial f D (v + 1) θ‖ ^ 2 + ∂AddCircle.haarAddCircle) * + Real.sqrt (∫ θ, ‖backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ‖ ^ 2 + ∂AddCircle.haarAddCircle) := sum_congr rfl (fun _ _ => mul_comm _ _) + _ ≤ _ := by + simpa only [Nat.cast_mul, Nat.cast_add, Nat.cast_ofNat, Nat.cast_one] using + rough_window_energy_sum_bound f g hf hg D ((2 * h + 1) * D) Y + · exact mul_le_mul_of_nonneg_left hV (by positivity) + +/-- The second-factor version of the complete finite three-term bound. -/ +theorem weighted_rough_shift_average_bound_right (f g : ℕ → ℂ) (hf : OneBounded f) + (hg : OneBounded g) (Z : Finset ℕ) (c : ℕ → ℂ) (D h Y : ℕ) (hD : 0 < D) (hY : 0 < Y) + (hZ : ∀ z ∈ Z, z ≤ 2 * D) + (ε U V K : ℝ) (hε : 0 < ε) (hU : 0 ≤ U) (hK : 0 ≤ K) + (hB : ∀ θ, ‖weightedRoughFourier Z c h θ‖ ≤ U) + (hV : (∫ θ, ‖weightedRoughFourier Z c h θ‖ ^ 4 + ∂AddCircle.haarAddCircle) ≤ V) + (hG : ∀ θ, (∑ v ∈ range Y, + ‖backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ‖) ≤ K) : + ‖weightedRoughShiftAverage f g Z c h Y‖ ≤ + 2 * (D : ℝ) / Y * (∑ z ∈ Z, ‖c z / (z : ℂ)‖) + + (ε * ((Y : ℝ) * (Real.sqrt D * Real.sqrt ((2 * h + 1) * D))) + + (U * D * K / ε ^ 4) * V) / ((Y : ℝ) * D) := by + let u := weightedRoughShiftProfile f g Z c h + have he := norm_normalized_translation_error u Y D hY hD + (∑ z ∈ Z, ‖c z / (z : ℂ)‖) (sum_nonneg (fun _ _ => by positivity)) + (fun n hn => norm_weightedRoughShiftProfile_le f g hf hg Z c h n hn) + have hc := normalized_translated_weightedRoughShift_bound f g Z c D h Y hD hY hZ _ + (weighted_rough_convolution_sum_bound_right f g hf hg Z c D h Y ε U V K hε hU hK hB hV hG) + calc + _ = ‖translatedPrefixAverage u Y D / (Y : ℂ) - + (translatedPrefixAverage u Y D - positivePrefix u Y) / (Y : ℂ)‖ := by + congr 1 + dsimp [weightedRoughShiftAverage, u] + ring + _ ≤ ‖translatedPrefixAverage u Y D / (Y : ℂ)‖ + + ‖(translatedPrefixAverage u Y D - positivePrefix u Y) / (Y : ℂ)‖ := norm_sub_le _ _ + _ ≤ _ := by simpa only [add_comm] using add_le_add hc he + +/-- The sixth-power condition has the same exponent for either factor. -/ +theorem weighted_rough_shift_parameter_bound_right (f g : ℕ → ℂ) (hf : OneBounded f) + (hg : OneBounded g) (Z : Finset ℕ) (c : ℕ → ℂ) (D h Y : ℕ) + (hD : 0 < D) (hY : 0 < Y) (hZ : ∀ z ∈ Z, z ≤ 2 * D) + (q η U V K : ℝ) (hq : 0 ≤ q) (hη : 0 < η) + (hU : 0 ≤ U) (hV : 0 ≤ V) (hK : 0 ≤ K) + (hmass : (∑ z ∈ Z, ‖c z / (z : ℂ)‖) ≤ 1) + (hendpoint : (D : ℝ) / Y ≤ η) (hgap : q ^ 6 ≤ η ^ 5) + (hB : ∀ θ, ‖weightedRoughFourier Z c h θ‖ ≤ U * q) + (hfourth : (∫ θ, ‖weightedRoughFourier Z c h θ‖ ^ 4 + ∂AddCircle.haarAddCircle) ≤ V / D * q ^ 4) + (hG : ∀ θ, (∑ v ∈ range Y, + ‖backwardWindowPolynomial g ((2 * h + 1) * D) (v + 1) θ‖) ≤ + K * Y * ((2 * (h : ℝ) + 1) * D) * q) : + ‖weightedRoughShiftAverage f g Z c h Y‖ ≤ + (2 + (2 * (h : ℝ) + 1) + (2 * (h : ℝ) + 1) * U * V * K) * η := by + have he : 2 * (D : ℝ) / Y * (∑ z ∈ Z, ‖c z / (z : ℂ)‖) ≤ 2 * η := by + calc + _ = 2 * ((D : ℝ) / Y) * (∑ z ∈ Z, ‖c z / (z : ℂ)‖) := by ring + _ ≤ 2 * η * 1 := mul_le_mul + (mul_le_mul_of_nonneg_left hendpoint (by norm_num)) hmass + (sum_nonneg (fun _ _ => norm_nonneg _)) (by positivity) + _ = _ := mul_one _ + have hraw := weighted_rough_shift_average_bound_right f g hf hg Z c D h Y hD hY hZ + η (U * q) (V / D * q ^ 4) (K * Y * ((2 * (h : ℝ) + 1) * D) * q) + hη (by positivity) (by positivity) hB hfourth hG + have hlow := rough_low_term_bound D h Y hD hY η hη.le + have hhigh : (((U * q) * D * (K * Y * ((2 * (h : ℝ) + 1) * D) * q) / η ^ 4) * + (V / D * q ^ 4)) / ((Y : ℝ) * D) = + ((2 * (h : ℝ) + 1) * U * V * K) * (q ^ 6 / η ^ 4) := by + convert weighted_shift_high_identity D h Y hD hY q η U V K hη using 1 + ring + have hfrac : q ^ 6 / η ^ 4 ≤ η := by + apply (div_le_iff₀ (pow_pos hη 4)).mpr + convert hgap using 1 + ring + have ht := mul_le_mul_of_nonneg_left hfrac + (show 0 ≤ (2 * (h : ℝ) + 1) * U * V * K by positivity) + apply hraw.trans + rw [add_div, hhigh] + nlinarith only [he, hlow, ht] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedThetaError.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedThetaError.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc65eb606efee823a2259a2cf92cb00854cc6d9f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedThetaError.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ReciprocalPrimeBands + +namespace OAI + +/-! The bounded-error form of partial summation needed for the padding +oscillation. The constants retain the uniform derivative bounds explicitly. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +theorem weighted_theta_error (c : ℕ → ℝ) (α K F D a b : ℝ) + (hK : 0 ≤ K) (hF : 0 ≤ F) (hD : 0 ≤ D) + (ha : Real.exp 1 ≤ a) (hab : a ≤ b) (f : ℝ → ℝ) + (hf : ∀ x ∈ Set.Icc a b, DifferentiableAt ℝ f x) + (hdf : ContinuousOn (deriv f) (Set.Icc a b)) + (hsize : ∀ x ∈ Set.Icc a b, |f x| ≤ F / x) + (hdsize : ∀ x ∈ Set.Icc a b, |deriv f x| ≤ D / x ^ 2) + (hE : ∀ x ∈ Set.Icc a b, + |partialCoefficientSum c x - α * x| ≤ K * x / Real.log x ^ 2) : + |(∑ n ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, f n * c n) - α * (∫ x in a..b, f x)| ≤ + (2 * F + D) * K / Real.log a := by + have ha1 : 1 < a := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le ha + have ha0 : 0 < a := zero_lt_one.trans ha1 + have hb1 : 1 < b := ha1.trans_le hab + have hla : 1 ≤ Real.log a := by simpa using Real.log_le_log (Real.exp_pos 1) ha + have hlap : 0 < Real.log a := Real.log_pos ha1 + have hxp (x : ℝ) (hx : x ∈ Set.Icc a b) : 0 < x := ha0.trans_le hx.1 + have hlx (x : ℝ) (hx : x ∈ Set.Icc a b) : 1 ≤ Real.log x := + hla.trans (Real.log_le_log ha0 hx.1) + have hln (x : ℝ) (hx : x ∈ Set.Icc a b) : Real.log x ≠ 0 := + (zero_lt_one.trans_le (hlx x hx)).ne' + have hbound (x : ℝ) (hx : x ∈ Set.Icc a b) : + |f x * (partialCoefficientSum c x - α * x)| ≤ F * K / Real.log a := by + have hx0 := hxp x hx + have hl0 := hln x hx + rw [abs_mul] + calc + _ ≤ (F / x) * (K * x / Real.log x ^ 2) := + mul_le_mul (hsize x hx) (hE x hx) (abs_nonneg _) (by positivity) + _ = F * K / Real.log x ^ 2 := by field_simp + _ ≤ F * K / Real.log a := by + apply div_le_div_of_nonneg_left (mul_nonneg hF hK) hlap + have hm := Real.log_le_log ha0 hx.1 + nlinarith [sq_nonneg (Real.log x - 1), hlx x hx] + have hderror (x : ℝ) (hx : x ∈ Set.Icc a b) : + |deriv f x * (partialCoefficientSum c x - α * x)| ≤ + (D * K) * (x⁻¹ / Real.log x ^ 2) := by + have hx0 := hxp x hx + have hl0 := hln x hx + rw [abs_mul] + calc + _ ≤ (D / x ^ 2) * (K * x / Real.log x ^ 2) := + mul_le_mul (hdsize x hx) (hE x hx) (abs_nonneg _) (by positivity) + _ = _ := by field_simp + have hclog : ContinuousOn Real.log (Set.Icc a b) := + fun x hx => (Real.continuousAt_log (hxp x hx).ne').continuousWithinAt + have hg : IntervalIntegrable (fun x : ℝ => (D * K) * (x⁻¹ / Real.log x ^ 2)) volume a b := by + apply ContinuousOn.intervalIntegrable_of_Icc (h := hab) + exact ((continuousOn_id.inv₀ (fun x hx => (hxp x hx).ne')).div + (hclog.pow 2) (fun x hx => pow_ne_zero 2 (hln x hx))).const_mul (D * K) + have hi : |∫ x in a..b, deriv f x * (partialCoefficientSum c x - α * x)| ≤ + D * K / Real.log a := by + have hh := intervalIntegral.norm_integral_le_of_norm_le hab + (Filter.Eventually.of_forall (fun x hx => by + rw [Real.norm_eq_abs] + exact hderror x ⟨hx.1.le, hx.2⟩)) hg + rw [Real.norm_eq_abs, intervalIntegral.integral_const_mul, + integral_inv_div_log_sq ha1 hb1] at hh + apply hh.trans + have hbnonneg : 0 ≤ (Real.log b)⁻¹ := inv_nonneg.mpr (Real.log_pos hb1).le + simp only [div_eq_mul_inv] + nlinarith [mul_nonneg (mul_nonneg hD hK) hbnonneg] + rw [centered_partial_summation c α a b ha0.le hab f hf hdf] + calc + _ ≤ |f b * (partialCoefficientSum c b - α * b)| + + |f a * (partialCoefficientSum c a - α * a)| + + |∫ t in a..b, deriv f t * (partialCoefficientSum c t - α * t)| := + (abs_sub _ _).trans (add_le_add (abs_sub _ _) (le_refl _)) + _ ≤ F * K / Real.log a + F * K / Real.log a + D * K / Real.log a := + add_le_add (add_le_add (hbound b ⟨hab, le_rfl⟩) (hbound a ⟨le_rfl, hab⟩)) hi + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedTupleDesignation.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedTupleDesignation.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb1a1bee7473ff191d3fb85386f662bf55fc85cf --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WeightedTupleDesignation.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.TwoPoint.Bounds.WeightedDesignationBound +import OAI.NumberTheory.TwoPoint.Walks.TupleWordPrimeSupport + +namespace OAI + +/-! The actual designated tuple-word majorant has precisely the weight used by column rank. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem weighted_designation_le_tuple_weight {ι : Type*} [Fintype ι] [DecidableEq ι] + {J R : ℕ} {P : Fin J → Finset ℕ} + (w : ColumnPrimeAssignment J R P) (forward : Fin R → Bool) (q : Fin R → ℕ) + (hprime : ∀ j, ∀ r ∈ P j, r.Prime) + (hdisjoint : ∀ j l, l ≠ j → Disjoint (P j) (P l)) + (hq : ∀ i, q i ≠ 0) (hsep : Disjoint (tuplePrimeSupport w) (paddingPrimeSupport q)) + (B h : ℕ) (p : ι → ℕ) (hinj : Function.Injective p) + (hp : ∀ i, 0 < p i) (hpB : ∀ i, p i ≤ B) + (label : Fin R × Fin J → ι) (target : Fin R × Fin J → Fin B) (base : ι → Fin B) + (U : Finset (Fin R × Fin J)) (hU : U ⊆ nonsingletonSlots label) (H C : ℝ) + (hH : 1 ≤ H) (hC : 0 ≤ C) (hpH : ∀ i ∈ nonsingletonLabels label, H ≤ p i) + (hS : ∀ i ∈ univ.image label, p i ∈ wordDivisorPrimeSupport (columnTupleWord w forward q)) + (hcover : ∀ r ∈ wordDivisorPrimeSupport (columnTupleWord w forward q), ∃ i, p i = r) + (weight G : (ι → Fin B) → ℝ) (hw : ∀ x, 0 ≤ weight x) (hwC : ∀ x, weight x ≤ C) + (hG : ∀ x, |G x| ≤ 1) + (hretain : ∀ x, weight x ≠ 0 → + RetainedMainTests p (univ.image label) h B (columnTupleWord w forward q) x) : + designatedReciprocal p (singletonLabels label) (nonsingletonSlots label \ U) U label * + (FiniteLaw.independent (fun i => uniformResidueLaw B (p i) (hp i) (hpB i))).average + (fun x => weight x * |selectedMixedDifference (singletonLabels label) + (singletonTarget label target base) + (fun y => G (forceCoordinates ((nonsingletonSlots label \ U).image label) + (litForcedTarget (nonsingletonSlots label \ U) label target base) y)) x|) ≤ + (C * 2 ^ (singletonLabels label).card) * columnReciprocalWeight w * + ∏ r ∈ paddingPrimeSupport q, (r : ℝ)⁻¹ := by + have hHp : 0 < H := zero_lt_one.trans_le hH + have hb := weighted_designation_bound B h p hinj hp hpB (columnTupleWord w forward q) + label target base U hU H C hHp hC hpH hS hcover weight G hw hwC hG hretain + have he : H⁻¹ ^ (∑ i ∈ nonsingletonLabels label, + extraReciprocalExponent (litOccurrences label (designationLit U) i).card + (unlitOccurrences label (designationLit U) i).card) ≤ 1 := + pow_le_one₀ (by positivity) ((inv_le_one₀ hHp).mpr hH) + rw [designation_sdiff_decidable (fun a b => Classical.propDecidable (a = b)) + (inferInstance : DecidableEq (Fin R × Fin J)) _ _] at hb + apply hb.trans + calc + _ ≤ (C * 2 ^ (singletonLabels label).card) * 1 * + ∏ r ∈ wordDivisorPrimeSupport (columnTupleWord w forward q), (r : ℝ)⁻¹ := by + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left he (by positivity)) (by positivity) + _ = _ := by + rw [mul_one, ← tupleWord_reciprocal w forward q hprime hdisjoint hq hsep] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/WindowPolynomialBounds.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/WindowPolynomialBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef4136eb00ad50c5b5bdc330dfce18f964410a5b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/WindowPolynomialBounds.lean @@ -0,0 +1,160 @@ +import OAI.NumberTheory.TwoPoint.Bounds.RoughShiftConvolution +import OAI.NumberTheory.TwoPoint.Bounds.FourierRegionBound + +namespace OAI + +/-! Concrete Parseval and short-sum bounds for the two window polynomials. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical ComplexConjugate + +lemma integral_fourierPolynomial_sq_injective {ι : Type*} (S : Finset ι) + (frequency : ι → ℤ) (coefficient : ι → ℂ) (hinj : Set.InjOn frequency S) : + (∫ θ, ‖fourierPolynomial S frequency coefficient θ‖ ^ 2 + ∂AddCircle.haarAddCircle) = ∑ i ∈ S, ‖coefficient i‖ ^ 2 := by + rw [integral_norm_fourierPolynomial_sq, sum_product] + apply sum_congr rfl + intro i hi + rw [sum_eq_single i] + · simp only [ite_true, Complex.mul_conj', ← Complex.ofReal_pow, Complex.ofReal_re] + · intro j hj hji + have hf : frequency i ≠ frequency j := fun he => hji (hinj hi hj he).symm + exact ite_eq_right hf + · exact fun hnot => False.elim (hnot hi) + +lemma integral_fourierPolynomial_sq_le_card {ι : Type*} (S : Finset ι) + (frequency : ι → ℤ) (coefficient : ι → ℂ) (hinj : Set.InjOn frequency S) + (hbound : ∀ i ∈ S, ‖coefficient i‖ ≤ 1) : + (∫ θ, ‖fourierPolynomial S frequency coefficient θ‖ ^ 2 + ∂AddCircle.haarAddCircle) ≤ S.card := by + rw [integral_fourierPolynomial_sq_injective S frequency coefficient hinj] + calc + _ ≤ ∑ _i ∈ S, (1 : ℝ) := by + apply sum_le_sum + intro i hi + have hh := hbound i hi + have hn := norm_nonneg (coefficient i) + nlinarith + _ = _ := by simp + +lemma continuous_forwardWindowPolynomial (f : ℕ → ℂ) (D v : ℕ) : + Continuous (forwardWindowPolynomial f D v) := continuous_fourierPolynomial _ _ _ + +lemma continuous_backwardWindowPolynomial (g : ℕ → ℂ) (Q v : ℕ) : + Continuous (backwardWindowPolynomial g Q v) := continuous_fourierPolynomial _ _ _ + +lemma norm_forwardWindowPolynomial_le (f : ℕ → ℂ) (hf : OneBounded f) (D v : ℕ) + (θ : AddCircle (1 : ℝ)) : ‖forwardWindowPolynomial f D v θ‖ ≤ D := by + apply (norm_fourierPolynomial_le _ _ _ θ).trans + calc + _ ≤ ∑ _m ∈ Icc 1 D, (1 : ℝ) := by + apply sum_le_sum + intro m hm + have hm1 := (mem_Icc.mp hm).1 + exact hf _ (by omega) + _ = _ := by simp + +lemma norm_backwardWindowPolynomial_le (g : ℕ → ℂ) (hg : OneBounded g) (Q v : ℕ) + (θ : AddCircle (1 : ℝ)) : ‖backwardWindowPolynomial g Q v θ‖ ≤ Q := by + apply (norm_fourierPolynomial_le _ _ _ θ).trans + calc + _ ≤ ∑ _a ∈ Icc 1 Q, (1 : ℝ) := by + apply sum_le_sum + intro a ha + have ha1 := (mem_Icc.mp ha).1 + exact hg _ (by omega) + _ = _ := by simp + +lemma integral_forwardWindowPolynomial_sq_le (f : ℕ → ℂ) (hf : OneBounded f) + (D v : ℕ) : + (∫ θ, ‖forwardWindowPolynomial f D v θ‖ ^ 2 ∂AddCircle.haarAddCircle) ≤ D := by + have hi : Set.InjOn (fun m : ℕ => (m : ℤ)) (Icc 1 D) := by + intro a _ b _ he + change (a : ℤ) = (b : ℤ) at he + exact_mod_cast he + have hb : ∀ m ∈ Icc 1 D, ‖f (v + m)‖ ≤ 1 := by + intro m hm + have hm1 := (mem_Icc.mp hm).1 + exact hf _ (by omega) + simpa only [forwardWindowPolynomial, Nat.card_Icc, Nat.add_sub_cancel, + Nat.cast_id] using integral_fourierPolynomial_sq_le_card (Icc 1 D) + (fun m : ℕ => (m : ℤ)) (fun m => f (v + m)) hi hb + +lemma integral_backwardWindowPolynomial_sq_le (g : ℕ → ℂ) (hg : OneBounded g) + (Q v : ℕ) : + (∫ θ, ‖backwardWindowPolynomial g Q v θ‖ ^ 2 ∂AddCircle.haarAddCircle) ≤ Q := by + have hi : Set.InjOn (fun a : ℕ => -(a : ℤ)) (Icc 1 Q) := by + intro a _ b _ he + exact_mod_cast neg_injective he + have hb : ∀ a ∈ Icc 1 Q, ‖g (v + a)‖ ≤ 1 := by + intro a ha + have ha1 := (mem_Icc.mp ha).1 + exact hg _ (by omega) + simpa only [backwardWindowPolynomial, Nat.card_Icc, Nat.add_sub_cancel, + Nat.cast_id] using integral_fourierPolynomial_sq_le_card (Icc 1 Q) + (fun a : ℕ => -(a : ℤ)) (fun a => g (v + a)) hi hb + +lemma fourier_nat_at_real (m : ℕ) (θ : ℝ) : + fourier (m : ℤ) (θ : AddCircle (1 : ℝ)) = additiveCharacter θ m := by + rw [fourier_coe_apply] + unfold additiveCharacter + congr 1 + push_cast + ring + +lemma forwardWindowPolynomial_at_real (f : ℕ → ℂ) (D v : ℕ) (θ : ℝ) : + forwardWindowPolynomial f D v (θ : AddCircle (1 : ℝ)) = shortWindowSum f D θ v := by + unfold forwardWindowPolynomial fourierPolynomial + simp_rw [fourier_nat_at_real] + simpa only [Nat.zero_add, Nat.add_assoc, shortWindowSum] using + (sum_Icc_shift (fun m => f (v + m) * additiveCharacter θ m) 0 D) + +/-- Applying a progression mask to the original values preserves their unit bound. -/ +noncomputable def progressionSequence (f : ℕ → ℂ) (l : ℕ) [NeZero l] + (a : ZMod l) (n : ℕ) : ℂ := if (n : ZMod l) = a then f n else 0 + +lemma OneBounded.progressionSequence {f : ℕ → ℂ} (hf : OneBounded f) + (l : ℕ) [NeZero l] (a : ZMod l) : OneBounded (progressionSequence f l a) := by + intro n hn + unfold TwoPointCorrelations.progressionSequence + split_ifs + · exact hf n hn + · simp + +/-- Every circle frequency is represented by a real frequency, and the +unimodular origin phase disappears before applying MRT. -/ +theorem progression_window_sum_from_integral (f : ℕ → ℂ) (D Y l : ℕ) + [NeZero l] (a : ZMod l) (K : ℝ) + (hK : ∀ α, shortExponentialIntegral f (Y + 1) D α ≤ K) + (θ : AddCircle (1 : ℝ)) : + (∑ v ∈ range Y, + ‖forwardWindowPolynomial (progressionSequence f l a) D (v + 1) θ‖) ≤ K := by + obtain ⟨α, rfl⟩ := QuotientAddGroup.mk_surjective θ + calc + _ = ∑ v ∈ range Y, ‖∑ n ∈ Icc (v + 2) (v + 1 + D), + if (n : ZMod l) = a then f n * additiveCharacter α n else 0‖ := by + apply sum_congr rfl + intro v _ + rw [forwardWindowPolynomial_at_real, ← norm_shortExponentialSum_eq_window, + shortExponentialSum_at_nat] + simp only [progressionSequence, ite_mul, zero_mul] + _ ≤ K := progression_short_sum_from_integral f D Y l a α K hK + +theorem MRTLiouvilleShortInput.progression_window_polynomials + (hMRT : MRTLiouvilleShortInput) : + ∃ C : ℝ, 0 < C ∧ ∀ (Y D l : ℕ), 10 ≤ D → D ≤ Y + 1 → + ∀ [NeZero l] (a : ZMod l) (θ : AddCircle (1 : ℝ)), + (∑ v ∈ range Y, + ‖forwardWindowPolynomial (progressionSequence liouville l a) D (v + 1) θ‖) ≤ + C * (D : ℝ) * (Y + 1 : ℕ) * mrtShortError (Y + 1) D := by + obtain ⟨C, hC, hbound⟩ := hMRT + refine ⟨C, hC, ?_⟩ + intro Y D l hD hDY _ a θ + exact progression_window_sum_from_integral liouville D Y l a _ + (fun α => hbound (Y + 1) D hD hDY α) θ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Bounds/ZeroRows.lean b/lean/OAI/NumberTheory/TwoPoint/Bounds/ZeroRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a85a42d4c21dd04918d67e1f12315f537935b82 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Bounds/ZeroRows.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.TwoPoint.Bounds.IndependentSampling +import Mathlib.LinearAlgebra.Matrix.NonsingularInverse +import Mathlib.Data.Rat.Cast.CharZero + +namespace OAI + +/-! The zero-row estimate used in the random-prime rank lemma. -/ + +namespace TwoPointCorrelations + +open Finset Matrix + +variable {ι A : Type*} [Fintype ι] [DecidableEq ι] [Fintype A] + +noncomputable def rationalRows (B : Matrix ι ι ℤ) (S : Finset ι) : + (ι → ℚ) →ₗ[ℚ] (S → ℚ) := + LinearMap.pi (fun i : S => (LinearMap.proj i.val).comp + (B.map (Int.castRingHom ℚ)).mulVecLin) + +lemma rationalRows_surjective (B : Matrix ι ι ℤ) (hB : B.det ≠ 0) (S : Finset ι) : + Function.Surjective (rationalRows B S) := by + have hdet : (B.map (Int.castRingHom ℚ)).det ≠ 0 := by + change ((Int.castRingHom ℚ).mapMatrix B).det ≠ 0 + rw [← (Int.castRingHom ℚ).map_det] + change (B.det : ℚ) ≠ 0 + exact_mod_cast hB + have hu : IsUnit (B.map (Int.castRingHom ℚ)) := + (Matrix.isUnit_iff_isUnit_det _).mpr (isUnit_iff_ne_zero.mpr hdet) + have hsurj := Matrix.mulVec_surjective_iff_isUnit.mpr hu + intro z + let w : ι → ℚ := fun i => if hi : i ∈ S then z ⟨i, hi⟩ else 0 + obtain ⟨x, hx⟩ := hsurj w + refine ⟨x, ?_⟩ + ext i + change ((B.map (Int.castRingHom ℚ)) *ᵥ x) i.val = z i + rw [hx] + simp [w, i.property] + +omit [DecidableEq ι] in +lemma rationalRows_eq_iff (B : Matrix ι ι ℤ) (S : Finset ι) (x y : ι → ℤ) : + rationalRows B S (fun i => (x i : ℚ)) = rationalRows B S (fun i => (y i : ℚ)) ↔ + ∀ i ∈ S, (B *ᵥ (x - y)) i = 0 := by + have hi (i : ι) : + (((B *ᵥ (x - y)) i : ℤ) : ℚ) = + ((B.map (Int.castRingHom ℚ)) *ᵥ (fun j => (x j : ℚ))) i - + ((B.map (Int.castRingHom ℚ)) *ᵥ (fun j => (y j : ℚ))) i := by + simp [Matrix.mulVec, dotProduct, mul_sub, sum_sub_distrib] + constructor + · intro h i hiS + have hx := congrFun h ⟨i, hiS⟩ + change ((B.map (Int.castRingHom ℚ)) *ᵥ (fun j => (x j : ℚ))) i = + ((B.map (Int.castRingHom ℚ)) *ᵥ (fun j => (y j : ℚ))) i at hx + have hz : (((B *ᵥ (x - y)) i : ℤ) : ℚ) = 0 := by rw [hi, hx, sub_self] + exact_mod_cast hz + · intro h + ext i + change ((B.map (Int.castRingHom ℚ)) *ᵥ (fun j => (x j : ℚ))) i.val = + ((B.map (Int.castRingHom ℚ)) *ᵥ (fun j => (y j : ℚ))) i.val + apply sub_eq_zero.mp + rw [← hi i.val, h i.val i.property] + simp + +/-- Any specified `a` rows of an invertible integral matrix vanish with +probability at most `α^a` under independent atoms bounded by `α`. -/ +theorem FiniteLaw.zero_rows_probability + (μ : ι → FiniteLaw A) (value : A → ℤ) (hvalue : Function.Injective value) + (B : Matrix ι ι ℤ) (hB : B.det ≠ 0) (S : Finset ι) (y : ι → A) + (α : ℝ) (hα : 0 ≤ α) (hatom : ∀ i x, (μ i).weight x ≤ α) : + (FiniteLaw.independent μ).probability (fun x => + ∀ i ∈ S, (B *ᵥ ((fun j => value (x j)) - (fun j => value (y j)))) i = 0) ≤ + α ^ S.card := by + have hv : Function.Injective (fun a => (value a : ℚ)) := + Int.cast_injective.comp hvalue + have h := FiniteLaw.probability_linear_equations μ (fun a => (value a : ℚ)) hv + (rationalRows B S) (rationalRows_surjective B hB S) + (rationalRows B S (fun j => (value (y j) : ℚ))) α hα hatom + simpa only [rationalRows_eq_iff, Fintype.card_coe] using h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/BitEncoding.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/BitEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..a745dff97e25bb0472b0fa91de26aa5857410fee --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/BitEncoding.lean @@ -0,0 +1,142 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CRTComparison +import OAI.NumberTheory.TwoPoint.Circuits.FourierCorrection +import Mathlib.Logic.Equiv.Fin.Basic +import Mathlib.Data.Fintype.EquivFin +import Mathlib.Algebra.BigOperators.Ring.Finset + +namespace OAI + +/-! +# Exact finite jitter encoding + +For `Q = 2^B`, the integer code `⌊(r Q + j)/s⌋`, with `j` uniform in +`{0,…,Q-1}`, has exactly the distribution of the first `B` binary digits +of `(r + U)/s` for uniform `U` in `[0,1)`. This finite construction avoids +continuous auxiliary probability spaces. Jointly uniform residue and +jitter give a uniform code. Decoding can fail for at most `s` jitter values +at each fixed residue, giving the stronger bound `s/Q`. +-/ + +open Finset + +namespace TwoPointCorrelations + +/-- Regroup the `s Q` equally likely elementary outcomes into `Q` blocks of +size `s`. -/ +def jitterPermutation (s Q : ℕ) : Fin s × Fin Q ≃ Fin Q × Fin s := + finProdFinEquiv.trans ((finCongr (Nat.mul_comm s Q)).trans finProdFinEquiv.symm) + +/-- Finite version of a uniformly jittered residue, encoded in `Q` cells. -/ +def jitterCode {s Q : ℕ} (r : Fin s) (j : Fin Q) : Fin Q := + (jitterPermutation s Q (r, j)).1 + +lemma jitterCode_val {s Q : ℕ} (r : Fin s) (j : Fin Q) : + (jitterCode r j).val = (j.val + Q * r.val) / s := rfl + +/-- Exact averaging identity for uniform residue and independent jitter. -/ +lemma jitterCode_sum (s Q : ℕ) (F : Fin Q → ℝ) : + (∑ r : Fin s, ∑ j : Fin Q, F (jitterCode r j)) = + (s : ℝ) * ∑ k : Fin Q, F k := by + rw [← Fintype.sum_prod_type'] + change (∑ x : Fin s × Fin Q, + (fun y : Fin Q × Fin s => F y.1) (jitterPermutation s Q x)) = _ + rw [(jitterPermutation s Q).sum_comp (fun y : Fin Q × Fin s => F y.1), + Fintype.sum_prod_type] + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + rw [← Finset.mul_sum] + +/-- The induced code kernel sends the uniform residue law to the uniform +code law, exactly. -/ +lemma jitterCode_uniform {s Q : ℕ} (hs : 0 < s) (hQ : 0 < Q) (k : Fin Q) : + (∑ r : Fin s, (1 / (s : ℝ)) * finiteRandomKernel (@jitterCode s Q) r k) = + 1 / (Q : ℝ) := by + let : Nonempty (Fin Q) := ⟨⟨0, hQ⟩⟩ + have hs0 : (s : ℝ) ≠ 0 := by exact_mod_cast hs.ne' + have hQ0 : (Q : ℝ) ≠ 0 := by exact_mod_cast hQ.ne' + unfold finiteRandomKernel + rw [← Finset.mul_sum, ← Finset.sum_div] + rw [jitterCode_sum s Q (fun z => if z = k then (1 : ℝ) else 0)] + simp only [Finset.sum_ite_eq', Finset.mem_univ, ite_true, Fintype.card_fin] + field_simp + +/-- Decode the residue from the left endpoint of a code cell. -/ +def jitterDecode {s Q : ℕ} (hs : 0 < s) (hQ : 0 < Q) (k : Fin Q) : Fin s := + ⟨s * k.val / Q, (Nat.div_lt_iff_lt_mul hQ).mpr + (Nat.mul_lt_mul_of_pos_left k.isLt hs)⟩ + +/-- All jitter positions outside the first `s` positions decode correctly. -/ +lemma jitterDecode_code {s Q : ℕ} (hs : 0 < s) (hQ : 0 < Q) + (r : Fin s) (j : Fin Q) (hj : s ≤ j.val) : + jitterDecode hs hQ (jitterCode r j) = r := by + apply Fin.ext + change s * (jitterCode r j).val / Q = r.val + rw [jitterCode_val] + have hmod := Nat.mod_lt (j.val + Q * r.val) hs + have hsplit := Nat.mod_add_div (j.val + Q * r.val) s + have hmod0 := Nat.zero_le ((j.val + Q * r.val) % s) + apply Nat.div_eq_of_lt_le + · nlinarith + · have hjQ := j.isLt + nlinarith + +/-- Conditional decoding error for every fixed residue, independent of the +law from which that residue was sampled. -/ +theorem jitterDecode_error {s Q : ℕ} (hs : 0 < s) (hQ : 0 < Q) (r : Fin s) : + (∑ j : Fin Q, if jitterDecode hs hQ (jitterCode r j) ≠ r then (1 : ℝ) else 0) / + (Q : ℝ) ≤ (s : ℝ) / Q := by + let E : Finset (Fin Q) := Finset.univ.filter + (fun j => jitterDecode hs hQ (jitterCode r j) ≠ r) + have hsmall (j : E) : j.val.val < s := by + have he := (Finset.mem_filter.mp j.property).2 + by_contra h + exact he (jitterDecode_code hs hQ r j.val (Nat.le_of_not_gt h)) + let emb : E → Fin s := fun j => ⟨j.val.val, hsmall j⟩ + have hinj : Function.Injective emb := by + intro j k h + apply Subtype.ext + apply Fin.ext + simpa only [emb] using congrArg (fun z : Fin s => z.val) h + have hcard : E.card ≤ s := by + simpa using Fintype.card_le_of_injective emb hinj + have hsum : (∑ j : Fin Q, + if jitterDecode hs hQ (jitterCode r j) ≠ r then (1 : ℝ) else 0) = (E.card : ℝ) := by + exact Finset.sum_boole _ _ + rw [hsum] + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg Q) + exact_mod_cast hcard + +/-- Any fixed bijective labeling of the `2^B` cells by `B` bits suffices: +the decoded equalities are represented by their truth tables. -/ +noncomputable def binaryCellEquiv (B : ℕ) : Fin (2 ^ B) ≃ BooleanCube B := + Fintype.equivOfCardEq (by simp [BooleanCube]) + +noncomputable def jitterBits {s B : ℕ} (r : Fin s) (j : Fin (2 ^ B)) : BooleanCube B := + binaryCellEquiv B (jitterCode r j) + +noncomputable def decodeBits {s B : ℕ} (hs : 0 < s) (x : BooleanCube B) : Fin s := + jitterDecode hs (by positivity) ((binaryCellEquiv B).symm x) + +@[simp] lemma decode_jitterBits {s B : ℕ} (hs : 0 < s) (r : Fin s) (j : Fin (2 ^ B)) : + decodeBits hs (jitterBits r j) = jitterDecode hs (by positivity) (jitterCode r j) := by + simp [decodeBits, jitterBits] + +/-- Exact independent uniformity of the encoded bits under uniform residues. -/ +lemma jitterBits_uniform {s B : ℕ} (hs : 0 < s) (x : BooleanCube B) : + (∑ r : Fin s, (1 / (s : ℝ)) * finiteRandomKernel (@jitterBits s B) r x) = + 1 / (2 ^ B : ℕ) := by + have heq (r : Fin s) : finiteRandomKernel (@jitterBits s B) r x = + finiteRandomKernel (@jitterCode s (2 ^ B)) r ((binaryCellEquiv B).symm x) := by + unfold finiteRandomKernel + congr 1 + apply Finset.sum_congr rfl + intro j _ + have heq : jitterBits r j = x ↔ jitterCode r j = (binaryCellEquiv B).symm x := by + change binaryCellEquiv B (jitterCode r j) = x ↔ _ + exact (binaryCellEquiv B).eq_symm_apply.symm + simp only [heq] + simp_rw [heq] + exact jitterCode_uniform hs (by positivity) _ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/BitMarginals.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/BitMarginals.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ae53e0a074086c6ef5852fbe5c428bc96b08ad6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/BitMarginals.lean @@ -0,0 +1,159 @@ +import OAI.NumberTheory.TwoPoint.Circuits.BitEncoding +import OAI.NumberTheory.TwoPoint.Bounds.FiniteAverages + +namespace OAI + +/-! +# Joint finite jitter and independent uniform bit blocks + +The permutation underlying one-coordinate jitter acts independently in +every coordinate. This proves exact joint uniformity before selecting any +bits; together with CRT contraction it gives finite quantitative marginal +comparison, including arbitrary fixed non-squarefree moduli. +-/ + +namespace TwoPointCorrelations + +open Finset + +/-- Split a family of pairs into a pair of families. -/ +def coordinatePairEquiv {ι : Type*} (α β : ι → Type*) : + (∀ i, α i × β i) ≃ (∀ i, α i) × (∀ i, β i) where + toFun x := (fun i => (x i).1, fun i => (x i).2) + invFun x i := (x.1 i, x.2 i) + left_inv _ := rfl + right_inv _ := rfl + +def jointJitterPermutation {ι : Type*} (s : ι → ℕ) (Q : ℕ) : + ((∀ i, Fin (s i)) × (ι → Fin Q)) ≃ ((ι → Fin Q) × (∀ i, Fin (s i))) := + (coordinatePairEquiv (fun i => Fin (s i)) (fun _ => Fin Q)).symm.trans + ((Equiv.piCongrRight (fun i => jitterPermutation (s i) Q)).trans + (coordinatePairEquiv (fun _ => Fin Q) (fun i => Fin (s i)))) + +def jointJitterCode {ι : Type*} {s : ι → ℕ} {Q : ℕ} + (r : ∀ i, Fin (s i)) (j : ι → Fin Q) : ι → Fin Q := + fun i => jitterCode (r i) (j i) + +lemma jointJitterCode_sum {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) (Q : ℕ) (F : (ι → Fin Q) → ℝ) : + (∑ r : ∀ i, Fin (s i), ∑ j : ι → Fin Q, F (jointJitterCode r j)) = + (∏ i, s i : ℕ) * ∑ k : ι → Fin Q, F k := by + rw [← Fintype.sum_prod_type'] + change (∑ x : (∀ i, Fin (s i)) × (ι → Fin Q), + (fun y : (ι → Fin Q) × (∀ i, Fin (s i)) => F y.1) (jointJitterPermutation s Q x)) = _ + rw [(jointJitterPermutation s Q).sum_comp + (fun y : (ι → Fin Q) × (∀ i, Fin (s i)) => F y.1), Fintype.sum_prod_type] + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_pi, Fintype.card_fin, + nsmul_eq_mul] + rw [← Finset.mul_sum] + +/-- Exact uniformity of all code coordinates under uniform residues. -/ +lemma jointJitterCode_uniform {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] {Q : ℕ} (hQ : 0 < Q) (k : ι → Fin Q) : + (∑ r : ∀ i, Fin (s i), (1 / (∏ i, s i : ℕ)) * + finiteRandomKernel (@jointJitterCode ι s Q) r k) = + 1 / (Fintype.card (ι → Fin Q) : ℝ) := by + let : Nonempty (Fin Q) := ⟨⟨0, hQ⟩⟩ + have hJ : (Fintype.card (ι → Fin Q) : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + have hD : ((∏ i, s i : ℕ) : ℝ) ≠ 0 := by exact_mod_cast NeZero.ne (∏ i, s i) + unfold finiteRandomKernel + rw [← Finset.mul_sum, ← Finset.sum_div] + rw [jointJitterCode_sum s Q (fun z => if z = k then (1 : ℝ) else 0)] + simp only [Finset.sum_ite_eq', Finset.mem_univ, ite_true] + field_simp + +/-- Evaluate joint finite jitter directly on CRT residue coordinates. -/ +noncomputable def crtJitterCode {ι : Type*} (s : ι → ℕ) [∀ i, NeZero (s i)] {Q : ℕ} + (r : ∀ i, ZMod (s i)) (j : ι → Fin Q) : ι → Fin Q := + jointJitterCode (fun i => (ZMod.finEquiv (s i)).symm (r i)) j + +lemma crtJitterCode_uniform {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] {Q : ℕ} (hQ : 0 < Q) (k : ι → Fin Q) : + kernelTransport (finiteRandomKernel (@crtJitterCode ι s _ Q)) (crtUniform s) k = + 1 / (Fintype.card (ι → Fin Q) : ℝ) := by + let e : (∀ i, Fin (s i)) ≃ (∀ i, ZMod (s i)) := + Equiv.piCongrRight (fun i => (ZMod.finEquiv (s i)).toEquiv) + calc + _ = ∑ r : ∀ i, Fin (s i), (1 / (∏ i, s i : ℕ)) * + finiteRandomKernel (@jointJitterCode ι s Q) r k := by + unfold kernelTransport crtUniform + rw [← e.sum_comp] + apply Finset.sum_congr rfl + intro r _ + congr 1 + unfold finiteRandomKernel crtJitterCode + simp [e] + _ = _ := jointJitterCode_uniform s hQ k + +/-- A selected family of residue coordinates, encoded jointly, differs from +independent uniform code coordinates by at most `D/(2N)` in total variation. -/ +theorem crtJitterCode_totalVariation {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ZMod (∏ i, s i)) (N : ℕ) (hN : 0 < N) {Q : ℕ} (hQ : 0 < Q) : + finiteTotalVariation + (kernelTransport (finiteRandomKernel (@crtJitterCode ι s _ Q)) + (crtJointProbability s hcop A N)) + (fun _ => 1 / (Fintype.card (ι → Fin Q) : ℝ)) ≤ + (∏ i, s i : ℕ) / (2 * (N : ℝ)) := by + let : Nonempty (Fin Q) := ⟨⟨0, hQ⟩⟩ + have h := crt_random_projection_totalVariation s hcop A N hN (@crtJitterCode ι s _ Q) + have heq : kernelTransport (finiteRandomKernel (@crtJitterCode ι s _ Q)) (crtUniform s) = + (fun _ => 1 / (Fintype.card (ι → Fin Q) : ℝ)) := + funext (crtJitterCode_uniform s hQ) + rw [heq] at h + exact h + +/-- Coordinatewise conversion of uniform integer cells into bit blocks. -/ +noncomputable def jointBitEquiv (ι : Type*) (B : ℕ) : + (ι → Fin (2 ^ B)) ≃ (ι → BooleanCube B) := + Equiv.piCongrRight (fun _ => binaryCellEquiv B) + +noncomputable def crtJitterBits {ι : Type*} (s : ι → ℕ) [∀ i, NeZero (s i)] (B : ℕ) + (r : ∀ i, ZMod (s i)) (j : ι → Fin (2 ^ B)) : ι → BooleanCube B := + jointBitEquiv ι B (crtJitterCode s r j) + +lemma crtJitterBits_uniform {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] (B : ℕ) (x : ι → BooleanCube B) : + kernelTransport (finiteRandomKernel (crtJitterBits s B)) (crtUniform s) x = + 1 / (Fintype.card (ι → BooleanCube B) : ℝ) := by + have heq (r : ∀ i, ZMod (s i)) : + finiteRandomKernel (crtJitterBits s B) r x = + finiteRandomKernel (@crtJitterCode ι s _ (2 ^ B)) r ((jointBitEquiv ι B).symm x) := by + unfold finiteRandomKernel + congr 1 + apply Finset.sum_congr rfl + intro j _ + have heq : crtJitterBits s B r j = x ↔ + crtJitterCode s r j = (jointBitEquiv ι B).symm x := by + change jointBitEquiv ι B (crtJitterCode s r j) = x ↔ _ + exact (jointBitEquiv ι B).eq_symm_apply.symm + simp only [heq] + unfold kernelTransport + simp_rw [heq] + change kernelTransport (finiteRandomKernel (@crtJitterCode ι s _ (2 ^ B))) + (crtUniform s) ((jointBitEquiv ι B).symm x) = _ + rw [crtJitterCode_uniform s (by positivity)] + rw [Fintype.card_congr (jointBitEquiv ι B)] + +/-- Exact joint uniform bit law and the interval comparison error, before +projecting to any subset of these bits. -/ +theorem crtJitterBits_totalVariation {ι : Type*} [Fintype ι] [DecidableEq ι] + (s : ι → ℕ) [∀ i, NeZero (s i)] + (hcop : Pairwise (fun i j => (s i).Coprime (s j))) + (A : ZMod (∏ i, s i)) (N : ℕ) (hN : 0 < N) (B : ℕ) : + finiteTotalVariation + (kernelTransport (finiteRandomKernel (crtJitterBits s B)) (crtJointProbability s hcop A N)) + (fun _ => 1 / (Fintype.card (ι → BooleanCube B) : ℝ)) ≤ + (∏ i, s i : ℕ) / (2 * (N : ℝ)) := by + let : Nonempty (Fin (2 ^ B)) := ⟨⟨0, by positivity⟩⟩ + have h := crt_random_projection_totalVariation s hcop A N hN (crtJitterBits s B) + have heq : kernelTransport (finiteRandomKernel (crtJitterBits s B)) (crtUniform s) = + (fun _ => 1 / (Fintype.card (ι → BooleanCube B) : ℝ)) := + funext (crtJitterBits_uniform s B) + rw [heq] at h + exact h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/BravermanDepth22Theorem.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/BravermanDepth22Theorem.lean new file mode 100644 index 0000000000000000000000000000000000000000..83e086842fed3360fb75ff9bfda799552574f7fc --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/BravermanDepth22Theorem.lean @@ -0,0 +1,20 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitDyadicComparison +import OAI.NumberTheory.TwoPoint.Circuits.CircuitLogarithmicBudget + +namespace OAI + +/-! Braverman’s bounded-independence theorem at depth twenty-two follows +from finite circuit approximation and switching estimates. -/ + +namespace TwoPointCorrelations + +theorem bravermanDepth22Input : BravermanDepth22Input := by + obtain ⟨K, C, hK, hC, hbudget⟩ := bravermanDegree_logarithmic_budget + refine ⟨K, C, hK, hC, ?_⟩ + intro n c hc ε hε hεhalf t ht g hg hmean hwise + obtain ⟨j, hmj, hεj, htj⟩ := hbudget c.size c.size_pos ε hε hεhalf t ht + exact (c.dyadic_comparison hc hmj htj g hg hmean hwise).trans hεj + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitAndCertificate.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitAndCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd6d9d913a27d1554566da188e5e7edb1f892c78 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitAndCertificate.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitCertificateBounds + +namespace OAI + +/-! An AND gate preserves the full approximation certificate: polynomial, +small Boolean error circuit, and pointwise norm bound. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def CircuitCertificate.andGate {n k : ℕ} + (ν : FiniteLaw (BooleanCube n)) (s : ℕ) (c : Fin k → AC0Circuit n) + (H : ∀ i, CircuitCertificate ν s (c i)) : + CircuitCertificate ν s (.andGate c) := by + let P := fun i => (H i).polynomial + let E := fun i => (H i).error + let hs := exists_certified_and_sample ν s c E P + (fun i => ((c i).size : ℝ) * (7 / 8 : ℝ) ^ s) + (fun i => (H i).error_probability) (fun i => (H i).exact_off_error) + let sample := Classical.choose hs + have hprob := (Classical.choose_spec hs).1 + have hexact := (Classical.choose_spec hs).2 + refine + { polynomial := fun x => sampledAndPolynomial sample (fun i => P i x) + error := AC0Circuit.combineGateException sample c E + degree_bound := ?_ + error_depth := ?_ + error_size := ?_ + error_probability := ?_ + exact_off_error := hexact + norm_bound := ?_ } + · exact sampledAndPolynomial_degree sample P _ (fun i => + ((H i).degree_bound).mono + (le_sup (f := fun j => (c j).approximationDegree s) (mem_univ i))) + · let D := univ.sup (fun i => (c i).depth) + have hc (i : Fin k) : (c i).depth ≤ D := + le_sup (f := fun j => (c j).depth) (mem_univ i) + have hE (i : Fin k) : (E i).depth ≤ 4 * D + 4 := by + have hh := (H i).error_depth + have hd := hc i + dsimp only [E] + omega + have hh := AC0Circuit.combineGateException_depth sample c E hc hE (by omega) + change (AC0Circuit.combineGateException sample c E).depth ≤ 4 * (1 + D) + 1 + omega + · rw [AC0Circuit.combineGateException_size] + have hs := AC0Circuit.gateSamplingException_size sample c + have he : ∑ i, (E i).size ≤ ∑ i, (c i).exceptionSizeBound s := + sum_le_sum (fun i _ => (H i).error_size) + change 1 + (AC0Circuit.gateSamplingException sample c).size + ∑ i, (E i).size ≤ + 4 + (∑ i, (c i).size) + s * (Nat.log 2 k + 3) * + (1 + k * (1 + ∑ i, (c i).size)) + ∑ i, (c i).exceptionSizeBound s + omega + · convert hprob using 1 + simp only [AC0Circuit.size, Nat.cast_add, Nat.cast_one, Nat.cast_sum, add_mul, + one_mul, sum_mul] + · intro x + let B := ∑ i, (c i).sampleNormBound s + have hB : 0 ≤ B := sum_nonneg (fun i _ => AC0Circuit.sampleNormBound_nonneg s (c i)) + have hP (i : Fin k) : |P i x| ≤ B := + ((H i).norm_bound x).trans + (single_le_sum (fun j _ => AC0Circuit.sampleNormBound_nonneg s (c j)) (mem_univ i)) + have hb := sampledAndPolynomial_abs_le sample (fun i => P i x) hB hP + have hp : (1 + (k : ℝ) * (1 + B)) ^ (s * (Nat.log 2 k + 3)) ≤ + (1 + (k : ℝ) * (2 + B)) ^ (s * (Nat.log 2 k + 3)) := + pow_le_pow_left₀ (by positivity) (by nlinarith) _ + change |sampledAndPolynomial sample (fun i => P i x)| ≤ + 1 + (1 + (k : ℝ) * (2 + B)) ^ (s * (Nat.log 2 k + 3)) + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitApproximationComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitApproximationComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..f87649df714466abcc59c0d94595f2f8c745b878 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitApproximationComparison.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitErrorCutoff +import OAI.NumberTheory.TwoPoint.Circuits.CircuitMixedLaw +import OAI.NumberTheory.TwoPoint.Circuits.CircuitApproximationDegree + +namespace OAI + +/-! Braverman's final finite expectation argument. The combinatorial +approximation and an L² approximation to its small error event imply a +one-sided bounded-independence comparison. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +lemma exceptionalExtension_gap {n : ℕ} {F : BooleanCube n → ℝ} + (hF : ∀ x, F x = 0 ∨ F x = 1) (E : BooleanCube n → Bool) (x : BooleanCube n) : + |F x - exceptionalExtension F E x| ≤ if E x then (1 : ℝ) else 0 := by + cases hE : E x + · simp [exceptionalExtension, hE] + · rcases hF x with h | h <;> simp [exceptionalExtension, hE, h] + +theorem TWiseUniformDensity.approximation_lower {n p q t : ℕ} + {g F P T : BooleanCube n → ℝ} {E : BooleanCube n → Bool} + (hwise : TWiseUniformDensity g t) (hg : ∀ x, 0 ≤ g x) (hmean : cubeAverage g = 1) + (hF : ∀ x, F x = 0 ∨ F x = 1) + (hP : WalshDegreeLE P p) (hT : WalshDegreeLE T q) (ht : (p + q) + (p + q) ≤ t) + (houtside : ∀ x, E x = false → P x = F x) + {B δ ε : ℝ} (hB : 1 ≤ B) (hbound : ∀ x, |P x| ≤ B) + (hE : (mixedCubeLaw g hg hmean).probability (fun x => E x = true) ≤ δ) + (herror : cubeAverage (fun x => ((if E x then (1 : ℝ) else 0) - T x) ^ 2) ≤ ε) : + cubeAverage F - (8 * δ + 2 * B ^ 2 * ε) ≤ cubeAverage (fun x => g x * F x) := by + have hmix := mixedCubeLaw_exception_bounds g hg hmean (fun x => E x = true) hE + have hU : cubeAverage (fun x => if E x then (1 : ℝ) else 0) ≤ 2 * δ := by + convert hmix.2 using 1 + congr 1 + funext x + by_cases h : E x = true <;> simp [h] + have hG : cubeAverage (fun x => g x * (if E x then (1 : ℝ) else 0)) ≤ 2 * δ := by + have hm := hmix.1 + rw [FiniteLaw.probability, cubeDensityLaw_average] at hm + convert hm using 1 + congr 1 + funext x + by_cases h : E x = true <;> simp [h] + have hu : cubeAverage (fun x => |F x - exceptionalExtension F E x|) ≤ 2 * δ := + (cubeAverage_mono (exceptionalExtension_gap hF E)).trans hU + have hm : cubeAverage (fun x => g x * |F x - exceptionalExtension F E x|) ≤ 2 * δ := + (cubeAverage_mono (fun x => mul_le_mul_of_nonneg_left + (exceptionalExtension_gap hF E x) (hg x))).trans hG + have hs := errorCutoffPolynomial_mean_sq hF houtside hB hbound hU herror + have hdeg := ((errorCutoffPolynomial_degree hP hT).minorant).mono ht + have hh := hwise.semiExact_lower hg (exceptionalExtension_boolean hF E) + (errorCutoffPolynomial_zero houtside) hdeg hu hm hs + convert hh using 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitApproximationDegree.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitApproximationDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c574eee4d0d7a3abe2440e83eadac36350d237f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitApproximationDegree.lean @@ -0,0 +1,55 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitGateComposition + +namespace OAI + +/-! Degree bookkeeping for the random polynomial construction. The recursive +degree uses the largest child degree, rather than the number of leaves. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma WalshDegreeLE.mono {n p q : ℕ} {F : BooleanCube n → ℝ} + (hF : WalshDegreeLE F p) (hpq : p ≤ q) : WalshDegreeLE F q := by + obtain ⟨a, ha⟩ := hF + refine ⟨fun S => if S.card ≤ p then a S else 0, ?_⟩ + intro x + rw [ha] + rw [sum_filter, sum_filter] + apply sum_congr rfl + intro S _ + by_cases hS : S.card ≤ p + · simp [hS, hS.trans hpq] + · simp [hS] + +lemma literal_indicator_degree {n : ℕ} (i : Fin n) (b : Bool) : + WalshDegreeLE (AC0Circuit.literal i b).indicator 1 := by + have hw : WalshDegreeLE (walsh {i}) 1 := WalshDegreeLE.of_walsh {i} (by simp) + have hp := (WalshDegreeLE.const (n := n) (1 / 2) 1).sub (hw.smul (1 / 2)) + have hn := (WalshDegreeLE.const (n := n) 1 1).sub hp + cases b + · convert hn using 1 + funext x + simp only [AC0Circuit.indicator, AC0Circuit.eval, Bool.false_eq_true, ite_false, + walsh, prod_singleton] + cases x i <;> norm_num [booleanSign] + · convert hp using 1 + funext x + simp only [AC0Circuit.indicator, AC0Circuit.eval, ite_true, walsh, prod_singleton] + cases x i <;> norm_num [booleanSign] + +namespace AC0Circuit + +def approximationDegree {n : ℕ} (s : ℕ) : AC0Circuit n → ℕ + | .literal _ _ => 1 + | .andGate (k := k) children => + (univ.sup fun i => approximationDegree s (children i)) * s * (Nat.log 2 k + 3) + | .orGate (k := k) children => + (univ.sup fun i => approximationDegree s (children i)) * s * (Nat.log 2 k + 3) + +end AC0Circuit + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitAssignmentUpdates.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitAssignmentUpdates.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c6f275ae2948428a7603ffe3b7331d0b2539353 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitAssignmentUpdates.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitPartialAssignment + +namespace OAI + +/-! Updates along the disjoint blocks of a canonical DNF path. These lemmas +also justify recovering the original restriction after decoding a block. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace PartialAssignment + +lemma free_assign {n : ℕ} (ρ : PartialAssignment n) (S : Finset (Fin n)) + (x : BooleanCube n) : (ρ.assign S x).free = ρ.free \ S := by + ext i + simp only [free, mem_filter, mem_univ, true_and, mem_sdiff] + by_cases hi : i ∈ S <;> simp [assign, hi] + +lemma assign_comm {n : ℕ} (ρ : PartialAssignment n) (S T : Finset (Fin n)) + (hST : Disjoint S T) (x y : BooleanCube n) : + (ρ.assign S x).assign T y = (ρ.assign T y).assign S x := by + funext i + by_cases hiS : i ∈ S <;> by_cases hiT : i ∈ T + · exact False.elim (Finset.disjoint_left.mp hST hiS hiT) + all_goals simp [assign, hiS, hiT] + +lemma assign_injective_of_free {n : ℕ} (ρ τ : PartialAssignment n) + (S : Finset (Fin n)) (hρ : S ⊆ ρ.free) (hτ : S ⊆ τ.free) + (x y : BooleanCube n) (h : ρ.assign S x = τ.assign S y) : ρ = τ := by + funext i + by_cases hi : i ∈ S + · exact (mem_filter.mp (hρ hi)).2.trans (mem_filter.mp (hτ hi)).2.symm + · have he := congrFun h i + simpa [assign, hi] using he + +lemma assign_congr_on {n : ℕ} (ρ : PartialAssignment n) (S : Finset (Fin n)) + (x y : BooleanCube n) (h : ∀ i ∈ S, x i = y i) : ρ.assign S x = ρ.assign S y := by + funext i + by_cases hi : i ∈ S <;> simp [assign, hi, h i] + +end PartialAssignment + +namespace CubeTerm + +lemma live_update_disjoint {n : ℕ} (C : CubeTerm n) (ρ : PartialAssignment n) + (x : BooleanCube n) : Disjoint C.support (ρ.assign (C.live ρ) x).free := by + apply Finset.disjoint_left.mpr + intro i hi hf + rw [PartialAssignment.free_assign] at hf + have hn := (mem_filter.mp (mem_sdiff.mp hf).1).2 + exact (mem_sdiff.mp hf).2 (mem_filter.mpr ⟨hi, hn⟩) + +lemma compatible_assign_disjoint {n : ℕ} (C : CubeTerm n) + (ρ : PartialAssignment n) (S : Finset (Fin n)) (hS : Disjoint C.support S) + (x : BooleanCube n) (hC : C.Compatible ρ) : C.Compatible (ρ.assign S x) := by + intro i hi + have hn : i ∉ S := fun hs => Finset.disjoint_left.mp hS hi hs + simpa [PartialAssignment.assign, hn] using hC i hi + +lemma satisfied_mono {n : ℕ} (C : CubeTerm n) {ρ τ : PartialAssignment n} + (hC : C.Satisfied ρ) (h : ρ.Extends τ) : C.Satisfied τ := + fun i hi => h i (C.value i) (hC i hi) + +end CubeTerm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitBernoulli.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitBernoulli.lean new file mode 100644 index 0000000000000000000000000000000000000000..177f1817c0bd02ed472d54250717d3f2c5143f0f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitBernoulli.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitSemiExact +import OAI.NumberTheory.TwoPoint.Bounds.PaddingSelectionLaw + +namespace OAI + +/-! The finite sampling calculation in the circuit approximation: a random +subset hits a prescribed nonempty set exactly once with probability +`k*p*(1-p)^(k-1)`. No asymptotic input is used. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def bernoulliCubeLaw (n : ℕ) (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) : + FiniteLaw (BooleanCube n) := + FiniteLaw.independent (fun _ : Fin n => booleanLaw p hp hp1) + +lemma bernoulliCubeLaw_pattern (n : ℕ) (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) + (S : Finset (Fin n)) (z : BooleanCube n) : + (bernoulliCubeLaw n p hp hp1).average (cubePattern S z) = + ∏ i ∈ S, (if z i then p else 1 - p) := by + let F := fun i : Fin n => fun b : Bool => + if i ∈ S then (if b = z i then (1 : ℝ) else 0) else 1 + have heq (x : BooleanCube n) : cubePattern S z x = ∏ i, F i (x i) := by + dsimp only [F] + rw [Fintype.prod_ite_mem, prod_boole] + unfold cubePattern + split_ifs <;> rfl + have hlocal (i : Fin n) : (booleanLaw p hp hp1).average (F i) = + if i ∈ S then (if z i then p else 1 - p) else 1 := by + by_cases hi : i ∈ S + · cases hz : z i <;> simp [FiniteLaw.average, booleanLaw, F, hi, hz] + · simp [F, hi] + have hfun : cubePattern S z = fun x => ∏ i, F i (x i) := funext heq + rw [hfun] + change (FiniteLaw.independent (fun _ : Fin n => booleanLaw p hp hp1)).average + (fun x => ∏ i, F i (x i)) = _ + rw [FiniteLaw.independent_average_product] + simp_rw [hlocal] + exact Fintype.prod_ite_mem S _ + +def singleBitPattern {n : ℕ} (i : Fin n) : BooleanCube n := fun j => decide (j = i) + +noncomputable def singleHitScore {n : ℕ} (S : Finset (Fin n)) (x : BooleanCube n) : ℝ := + ∑ i ∈ S, cubePattern S (singleBitPattern i) x + +lemma bernoulliCubeLaw_singleHitScore (n : ℕ) (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) + (S : Finset (Fin n)) : + (bernoulliCubeLaw n p hp hp1).average (singleHitScore S) = + (S.card : ℝ) * p * (1 - p) ^ (S.card - 1) := by + have hterm (i : Fin n) (hi : i ∈ S) : + (bernoulliCubeLaw n p hp hp1).average (cubePattern S (singleBitPattern i)) = + p * (1 - p) ^ (S.card - 1) := by + rw [bernoulliCubeLaw_pattern, ← prod_erase_mul _ _ hi] + have hprod : (∏ j ∈ S.erase i, if singleBitPattern i j then p else 1 - p) = + (1 - p) ^ (S.card - 1) := by + have heq : (∏ j ∈ S.erase i, if singleBitPattern i j then p else 1 - p) = + ∏ _j ∈ S.erase i, (1 - p) := by + apply prod_congr rfl + intro j hj + simp [singleBitPattern, (mem_erase.mp hj).1] + rw [heq, prod_const, card_erase_of_mem hi] + rw [hprod] + simp [singleBitPattern, mul_comm] + have heq : (bernoulliCubeLaw n p hp hp1).average (singleHitScore S) = + ∑ i ∈ S, (bernoulliCubeLaw n p hp hp1).average (cubePattern S (singleBitPattern i)) := by + unfold singleHitScore FiniteLaw.average + simp only [mul_sum] + rw [sum_comm] + rw [heq, sum_congr rfl (fun i hi => hterm i hi)] + simp [mul_assoc] + +/-- A dyadic sampling scale with expected hit count between 1/4 and 1/2 +has a uniformly positive chance of isolating one marked coordinate. -/ +lemma single_hit_probability_lower (k : ℕ) (hk : 0 < k) (p : ℝ) + (hp : 0 ≤ p) (hsmall : (k : ℝ) * p ≤ 1 / 2) + (hlarge : 1 / 4 ≤ (k : ℝ) * p) : + 1 / 8 ≤ (k : ℝ) * p * (1 - p) ^ (k - 1) := by + have hkreal : (1 : ℝ) ≤ k := by exact_mod_cast hk + have hpone : p ≤ 1 := by nlinarith + have hbern := one_add_mul_le_pow (show (-2 : ℝ) ≤ -p by linarith) (k - 1) + have hkcast : ((k - 1 : ℕ) : ℝ) = (k : ℝ) - 1 := by + rw [Nat.cast_sub hk, Nat.cast_one] + have hpow : (1 / 2 : ℝ) ≤ (1 - p) ^ (k - 1) := by + rw [hkcast] at hbern + have heq : 1 + -p = 1 - p := by ring + rw [heq] at hbern + nlinarith + have hprod := mul_le_mul_of_nonneg_left hpow (mul_nonneg (Nat.cast_nonneg k) hp) + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitBlockCode.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitBlockCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..a442184c083e76877916331c77f2413bae3fb1db --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitBlockCode.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitQueryWalk + +namespace OAI + +/-! A query block is encoded by positions within its term, the path answers, +and one separator. Term indices are recovered from the modified restriction, +so the code alphabet is independent of the number of terms. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def CubeTerm.slot {n : ℕ} (C : CubeTerm n) (i : Fin n) : ℕ := + if hi : i ∈ C.support then (C.support.equivFin ⟨i, hi⟩).val + else C.support.card + +lemma CubeTerm.slot_le {n : ℕ} (C : CubeTerm n) (i : Fin n) : + C.slot i ≤ C.support.card := by + unfold slot + split_ifs with hi + · exact Nat.le_of_lt (Fin.isLt _) + · exact le_rfl + +lemma CubeTerm.slot_injective {n : ℕ} (C : CubeTerm n) {i j : Fin n} + (hi : i ∈ C.support) (hj : j ∈ C.support) (h : C.slot i = C.slot j) : i = j := by + have he : C.support.equivFin ⟨i, hi⟩ = C.support.equivFin ⟨j, hj⟩ := by + apply Fin.ext + simpa only [slot, dite_eq_left hi, dite_eq_left hj] using h + exact congrArg Subtype.val (C.support.equivFin.injective he) + +namespace DNFQueryBlock + +noncomputable def literalCode {n : ℕ} (b : DNFQueryBlock n) : List (ℕ × Bool) := + (b.queried.sort (· ≤ ·)).map (fun i => (b.term.slot i, b.answer i)) + +noncomputable def code {n : ℕ} (b : DNFQueryBlock n) : List (Option (ℕ × Bool)) := + b.literalCode.map some ++ [none] + +noncomputable def codes {n : ℕ} (bs : List (DNFQueryBlock n)) : List (Option (ℕ × Bool)) := + bs.flatMap code + +lemma code_length {n : ℕ} (b : DNFQueryBlock n) : b.code.length = b.queried.card + 1 := by + simp [code, literalCode, Finset.length_sort] + +lemma literalCode_injective {n : ℕ} (C : CubeTerm n) (S T : Finset (Fin n)) + (hS : S ⊆ C.support) (hT : T ⊆ C.support) (x y : BooleanCube n) + (h : literalCode ⟨C, S, x⟩ = literalCode ⟨C, T, y⟩) : + S = T ∧ ∀ i ∈ S, x i = y i := by + have hmem (i : Fin n) (hi : i ∈ S) : i ∈ T ∧ x i = y i := by + have hc : (C.slot i, x i) ∈ literalCode ⟨C, S, x⟩ := by + apply List.mem_map.mpr + exact ⟨i, (Finset.mem_sort _).mpr hi, rfl⟩ + rw [h] at hc + obtain ⟨j, hj, he⟩ := List.mem_map.mp hc + have hjT : j ∈ T := (Finset.mem_sort _).mp hj + have hji : j = i := C.slot_injective (hT hjT) (hS hi) (congrArg Prod.fst he) + subst j + exact ⟨hjT, (congrArg Prod.snd he).symm⟩ + refine ⟨?_, fun i hi => (hmem i hi).2⟩ + apply Finset.Subset.antisymm (fun i hi => (hmem i hi).1) + intro i hi + have hc : (C.slot i, y i) ∈ literalCode ⟨C, T, y⟩ := by + apply List.mem_map.mpr + exact ⟨i, (Finset.mem_sort _).mpr hi, rfl⟩ + rw [← h] at hc + obtain ⟨j, hj, he⟩ := List.mem_map.mp hc + have hjS : j ∈ S := (Finset.mem_sort _).mp hj + have hji : j = i := C.slot_injective (hS hjS) (hT hi) (congrArg Prod.fst he) + exact hji ▸ hjS + +end DNFQueryBlock + +lemma separated_option_lists_injective {α : Type*} (xs ys : List α) + (u v : List (Option α)) + (h : xs.map some ++ none :: u = ys.map some ++ none :: v) : xs = ys ∧ u = v := by + induction xs generalizing ys with + | nil => + cases ys with + | nil => exact ⟨rfl, List.cons.inj h |>.2⟩ + | cons y ys => simp at h + | cons x xs ih => + cases ys with + | nil => simp at h + | cons y ys => + have hp := List.cons.inj h + have hxy : x = y := Option.some.inj hp.1 + obtain ⟨hxs, huv⟩ := ih ys hp.2 + exact ⟨by rw [hxy, hxs], huv⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitBooleanOps.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitBooleanOps.lean new file mode 100644 index 0000000000000000000000000000000000000000..c9bc77ce953a3397f678a7985024212972487330 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitBooleanOps.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitEncoding + +namespace OAI + +/-! Relabel, complement and conjoin the residue circuits used in a +closed-word expansion without increasing their internal depth. -/ + +namespace TwoPointCorrelations.AC0Circuit + +open Finset + +def negate {n : ℕ} : AC0Circuit n → AC0Circuit n + | .literal i b => .literal i (!b) + | .andGate c => .orGate (fun i => negate (c i)) + | .orGate c => .andGate (fun i => negate (c i)) + +lemma negate_eval {n : ℕ} (c : AC0Circuit n) (x : BooleanCube n) : + c.negate.eval x = true ↔ c.eval x ≠ true := by + induction c with + | literal i b => cases b <;> cases hx : x i <;> simp [negate, eval, hx] + | andGate c ih => simp only [negate, eval, ne_eq, decide_eq_true_eq, ih, not_forall] + | orGate c ih => simp only [negate, eval, ne_eq, decide_eq_true_eq, ih, not_exists] + +lemma negate_depth {n : ℕ} (c : AC0Circuit n) : c.negate.depth = c.depth := by + induction c with + | literal i b => rfl + | andGate c ih => simp only [negate, depth, ih] + | orGate c ih => simp only [negate, depth, ih] + +lemma negate_size {n : ℕ} (c : AC0Circuit n) : c.negate.size = c.size := by + induction c with + | literal i b => rfl + | andGate c ih => simp only [negate, size, ih] + | orGate c ih => simp only [negate, size, ih] + +def relabel {n m : ℕ} (f : Fin n → Fin m) (c : AC0Circuit n) : AC0Circuit m := + substitute (fun i b => .literal (f i) b) c + +lemma relabel_eval {n m : ℕ} (f : Fin n → Fin m) (c : AC0Circuit n) (x : BooleanCube m) : + (relabel f c).eval x = c.eval (fun i => x (f i)) := + substitute_eval _ (fun x i => x (f i)) (fun _ _ _ => rfl) c x + +lemma relabel_depth {n m : ℕ} (f : Fin n → Fin m) (c : AC0Circuit n) : + (relabel f c).depth ≤ c.depth := by + simpa only [relabel, Nat.add_zero] using substitute_depth (fun i b => literal (f i) b) + (d := 0) (fun _ _ => Nat.le_refl 0) c + +lemma relabel_size {n m : ℕ} (f : Fin n → Fin m) (c : AC0Circuit n) : + (relabel f c).size ≤ c.size := by + simpa only [relabel, Nat.one_mul] using substitute_size (fun i b => literal (f i) b) + (K := 1) (by omega) (fun _ _ => Nat.le_refl 1) c + +noncomputable def conjunction {ι : Type*} [Fintype ι] {n : ℕ} + (c : ι → AC0Circuit n) : AC0Circuit n := + .andGate (fun i : Fin (Fintype.card ι) => c ((Fintype.equivFin ι).symm i)) + +lemma conjunction_eval {ι : Type*} [Fintype ι] {n : ℕ} + (c : ι → AC0Circuit n) (x : BooleanCube n) : + (conjunction c).eval x = true ↔ ∀ i, (c i).eval x = true := by + simp only [conjunction, eval, decide_eq_true_eq] + constructor + · intro h i + simpa only [Equiv.symm_apply_apply] using h ((Fintype.equivFin ι) i) + · intro h i + exact h _ + +lemma conjunction_depth {ι : Type*} [Fintype ι] {n d : ℕ} + (c : ι → AC0Circuit n) (hc : ∀ i, (c i).depth ≤ d) : + (conjunction c).depth ≤ d + 1 := by + simp only [conjunction, depth] + have hh : (univ.sup fun i : Fin (Fintype.card ι) => + (c ((Fintype.equivFin ι).symm i)).depth) ≤ d := + Finset.sup_le (fun i _ => hc _) + omega + +lemma conjunction_size {ι : Type*} [Fintype ι] {n : ℕ} + (c : ι → AC0Circuit n) : (conjunction c).size = 1 + ∑ i, (c i).size := by + simp only [conjunction, size] + congr 1 + exact (Fintype.equivFin ι).symm.sum_comp (fun i => (c i).size) + +end TwoPointCorrelations.AC0Circuit + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitBravermanApproximation.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitBravermanApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..3052b6a068d82e786e357a68fa5fa426a15c9056 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitBravermanApproximation.lean @@ -0,0 +1,32 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitNormBudget +import OAI.NumberTheory.TwoPoint.Circuits.CircuitDegreeBound + +namespace OAI + +/-! The combinatorial approximation stage of Braverman's proof, with a +fully explicit error circuit and coarse quantitative bounds. The depth +estimate is sufficient for the fixed-depth comparison. -/ + +namespace TwoPointCorrelations + +theorem AC0Circuit.polynomial_error_approximation {n : ℕ} + (ν : FiniteLaw (BooleanCube n)) (s : ℕ) (hs : 1 ≤ s) (c : AC0Circuit n) : + ∃ (P : BooleanCube n → ℝ) (E : AC0Circuit n), + WalshDegreeLE P ((s * (Nat.log 2 c.size + 3)) ^ c.depth) ∧ + E.depth ≤ 4 * c.depth + 1 ∧ + E.size ≤ exceptionPolynomialBound c.size s * c.size ∧ + ν.probability (fun x => E.eval x = true) ≤ (c.size : ℝ) * (7 / 8 : ℝ) ^ s ∧ + (∀ x, E.eval x ≠ true → P x = c.indicator x) ∧ + ∀ x, |P x| ≤ (2 * ((c.size : ℝ) + 1) ^ 2) ^ + ((2 * (s * (Nat.log 2 c.size + 3)) + 2) ^ c.depth) := by + let H := c.certificate ν s + refine ⟨H.polynomial, H.error, ?_, H.error_depth, ?_, H.error_probability, + H.exact_off_error, ?_⟩ + · exact H.degree_bound.mono (AC0Circuit.approximationDegree_le s hs c c.size le_rfl) + · exact H.error_size.trans (AC0Circuit.exceptionSizeBound_le s c c.size le_rfl) + · intro x + exact (H.norm_bound x).trans (AC0Circuit.sampleNormBound_le s c c.size le_rfl) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitCanonicalTree.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitCanonicalTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..5302886b6a2a68148b29e7524b0faf9ba5c207d3 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitCanonicalTree.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitPartialAssignment +import OAI.NumberTheory.TwoPoint.Circuits.CircuitDecisionTree + +namespace OAI + +/-! The canonical tree queries the unset variables of the first compatible +term, then continues through the remaining terms. This concrete tree is the +one encoded in the switching argument. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace BooleanDecisionTree + +def queryVariables {n : ℕ} : List (Fin n) → + (PartialAssignment n → BooleanDecisionTree n) → PartialAssignment n → BooleanDecisionTree n + | [], k, ρ => k ρ + | i :: is, k, ρ => .query i + (queryVariables is k (Function.update ρ i (some false))) + (queryVariables is k (Function.update ρ i (some true))) + +lemma queryVariables_eval {n : ℕ} (is : List (Fin n)) + (k : PartialAssignment n → BooleanDecisionTree n) (ρ : PartialAssignment n) + (x : BooleanCube n) : + (queryVariables is k ρ).eval x = (k (ρ.assign is.toFinset x)).eval x := by + induction is generalizing ρ with + | nil => simp [queryVariables] + | cons i is ih => + simp only [queryVariables, eval] + cases hx : x i <;> simp only [Bool.false_eq_true, ite_false, ite_true] + · rw [ih] + have ha := PartialAssignment.assign_insert ρ is.toFinset x i + rw [hx] at ha + simp only [List.toFinset_cons, ha] + · rw [ih] + have ha := PartialAssignment.assign_insert ρ is.toFinset x i + rw [hx] at ha + simp only [List.toFinset_cons, ha] + +lemma queryVariables_depth_le {n d : ℕ} (is : List (Fin n)) + (k : PartialAssignment n → BooleanDecisionTree n) + (hk : ∀ ρ, (k ρ).depth ≤ d) (ρ : PartialAssignment n) : + (queryVariables is k ρ).depth ≤ is.length + d := by + induction is generalizing ρ with + | nil => simpa only [queryVariables, List.length_nil, Nat.zero_add] using hk ρ + | cons i is ih => + change max _ _ + 1 ≤ _ + have hl := ih (Function.update ρ i (some false)) + have hh := ih (Function.update ρ i (some true)) + have hm := max_le hl hh + simpa only [List.length_cons, Nat.add_right_comm] using Nat.add_le_add_right hm 1 + +end BooleanDecisionTree + +def dnfEval {n : ℕ} (F : List (CubeTerm n)) (x : BooleanCube n) : Bool := + F.any (fun C => C.eval x) + +noncomputable def canonicalDNFTree {n : ℕ} : + List (CubeTerm n) → PartialAssignment n → BooleanDecisionTree n + | [], _ => .leaf false + | C :: F, ρ => + if C.Compatible ρ then + BooleanDecisionTree.queryVariables ((C.live ρ).sort (· ≤ ·)) + (fun τ => if C.Satisfied τ then .leaf true else canonicalDNFTree F τ) ρ + else canonicalDNFTree F ρ + +theorem canonicalDNFTree_eval {n : ℕ} (F : List (CubeTerm n)) + (ρ : PartialAssignment n) (x : BooleanCube n) : + (canonicalDNFTree F ρ).eval x = dnfEval F (ρ.apply x) := by + induction F generalizing ρ with + | nil => simp [canonicalDNFTree, dnfEval, BooleanDecisionTree.eval] + | cons C F ih => + by_cases hC : C.Compatible ρ + · rw [canonicalDNFTree, ite_eq_left hC, BooleanDecisionTree.queryVariables_eval] + simp only [Finset.sort_toFinset] + have happly := ρ.apply_assign_free (C.live ρ) (C.live_subset_free ρ) x + have hs := C.satisfied_assign_live_iff ρ hC x + by_cases hsat : C.Satisfied (ρ.assign (C.live ρ) x) + · have he := hs.mp hsat + simp [hsat, BooleanDecisionTree.eval, dnfEval, he] + · have he : C.eval (ρ.apply x) = false := Bool.eq_false_iff.mpr (mt hs.mpr hsat) + simp only [hsat, ite_false, ih, happly, dnfEval, List.any_cons, he, + Bool.false_or] + · have he := C.eval_apply_of_incompatible ρ hC x + simp only [canonicalDNFTree, hC, ite_false, ih, dnfEval, List.any_cons, he, + Bool.false_or] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitCertificateBounds.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitCertificateBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f575035373ff2d51d77bf0531dc38527aef3e14 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitCertificateBounds.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitCertifiedGate +import OAI.NumberTheory.TwoPoint.Circuits.CircuitSampleNorm +import OAI.NumberTheory.TwoPoint.Circuits.CircuitApproximationDegree + +namespace OAI + +/-! Numerical bounds carried by the recursive polynomial/error-circuit +construction. They retain explicit circuit dependence until the final +size and depth estimates. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace AC0Circuit + +noncomputable def sampleNormBound {n : ℕ} (s : ℕ) : AC0Circuit n → ℝ + | .literal _ _ => 1 + | .andGate (k := k) c => + 1 + (1 + (k : ℝ) * (2 + ∑ i, sampleNormBound s (c i))) ^ (s * (Nat.log 2 k + 3)) + | .orGate (k := k) c => + 1 + (1 + (k : ℝ) * (2 + ∑ i, sampleNormBound s (c i))) ^ (s * (Nat.log 2 k + 3)) + +def exceptionSizeBound {n : ℕ} (s : ℕ) : AC0Circuit n → ℕ + | .literal _ _ => 1 + | .andGate (k := k) c => + 4 + (∑ i, (c i).size) + s * (Nat.log 2 k + 3) * + (1 + k * (1 + ∑ i, (c i).size)) + ∑ i, exceptionSizeBound s (c i) + | .orGate (k := k) c => + 4 + (∑ i, (c i).size) + s * (Nat.log 2 k + 3) * + (1 + k * (1 + ∑ i, (c i).size)) + ∑ i, exceptionSizeBound s (c i) + +lemma sampleNormBound_nonneg {n : ℕ} (s : ℕ) (c : AC0Circuit n) : + 0 ≤ c.sampleNormBound s := by + induction c with + | literal i b => exact zero_le_one + | andGate c ih | orGate c ih => + have hh : 0 ≤ ∑ i, (c i).sampleNormBound s := sum_nonneg (fun i _ => ih i) + simp only [sampleNormBound] + positivity + +lemma negate_indicator {n : ℕ} (c : AC0Circuit n) (x : BooleanCube n) : + c.negate.indicator x = 1 - c.indicator x := by + have he : c.negate.eval x = !(c.eval x) := by + apply Bool.eq_iff_iff.mpr + rw [negate_eval] + simp + simp only [indicator, he] + cases c.eval x <;> norm_num + +end AC0Circuit + +structure CircuitCertificate {n : ℕ} (ν : FiniteLaw (BooleanCube n)) + (s : ℕ) (c : AC0Circuit n) where + polynomial : BooleanCube n → ℝ + error : AC0Circuit n + degree_bound : WalshDegreeLE polynomial (c.approximationDegree s) + error_depth : error.depth ≤ 4 * c.depth + 1 + error_size : error.size ≤ c.exceptionSizeBound s + error_probability : ν.probability (fun x => error.eval x = true) ≤ + (c.size : ℝ) * (7 / 8 : ℝ) ^ s + exact_off_error : ∀ x, error.eval x ≠ true → polynomial x = c.indicator x + norm_bound : ∀ x, |polynomial x| ≤ c.sampleNormBound s + +noncomputable def CircuitCertificate.literal {n : ℕ} + (ν : FiniteLaw (BooleanCube n)) (s : ℕ) (i : Fin n) (b : Bool) : + CircuitCertificate ν s (.literal i b) where + polynomial := (AC0Circuit.literal i b).indicator + error := AC0Circuit.falseCircuit n + degree_bound := literal_indicator_degree i b + error_depth := by simp [AC0Circuit.falseCircuit, AC0Circuit.depth] + error_size := by simp [AC0Circuit.falseCircuit, AC0Circuit.size, AC0Circuit.exceptionSizeBound] + error_probability := by + simp only [AC0Circuit.falseCircuit_eval, Bool.false_eq_true, FiniteLaw.probability, + ite_false, FiniteLaw.average_const] + positivity + exact_off_error := fun _ _ => rfl + norm_bound := by + intro x + unfold AC0Circuit.indicator + split_ifs <;> norm_num [AC0Circuit.sampleNormBound] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitCertifiedGate.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitCertifiedGate.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b07fbd6e9f35ed8010523fd3b0f622f520b1554 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitCertifiedGate.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitSamplingException +import OAI.NumberTheory.TwoPoint.Bounds.CrudeWordCounting + +namespace OAI + +/-! The sampled gate carries a Boolean certificate for all its errors: +the new single-hit failure test together with the child certificates. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace AC0Circuit + +noncomputable def combineGateException {n k s : ℕ} + (sample : GateSamplingChoices k k s) (c E : Fin k → AC0Circuit n) : AC0Circuit n := + certificateDisjunction (fun i : Option (Fin k) => match i with + | none => gateSamplingException sample c + | some i => E i) + +lemma combineGateException_eval {n k s : ℕ} + (sample : GateSamplingChoices k k s) (c E : Fin k → AC0Circuit n) + (x : BooleanCube n) : + (combineGateException sample c E).eval x = true ↔ + (gateSamplingException sample c).eval x = true ∨ ∃ i, (E i).eval x = true := by + simp only [combineGateException, certificateDisjunction_eval, Option.exists] + +lemma combineGateException_size {n k s : ℕ} + (sample : GateSamplingChoices k k s) (c E : Fin k → AC0Circuit n) : + (combineGateException sample c E).size = + 1 + (gateSamplingException sample c).size + ∑ i, (E i).size := by + simp only [combineGateException, certificateDisjunction_size, Fintype.sum_option] + omega + +lemma combineGateException_depth {n k s d D : ℕ} + (sample : GateSamplingChoices k k s) (c E : Fin k → AC0Circuit n) + (hc : ∀ i, (c i).depth ≤ d) (hE : ∀ i, (E i).depth ≤ D) + (hd : d + 4 ≤ D) : + (combineGateException sample c E).depth ≤ D + 1 := by + apply certificateDisjunction_depth + intro i + cases i with + | none => exact (gateSamplingException_depth sample c hc).trans hd + | some i => exact hE i + +end AC0Circuit + +theorem exists_certified_and_sample {n k : ℕ} + (ν : FiniteLaw (BooleanCube n)) (s : ℕ) (c E : Fin k → AC0Circuit n) + (P : Fin k → BooleanCube n → ℝ) (δ : Fin k → ℝ) + (hδ : ∀ i, ν.probability (fun x => (E i).eval x = true) ≤ δ i) + (hcorrect : ∀ i x, (E i).eval x ≠ true → P i x = (c i).indicator x) : + ∃ sample : GateSamplingChoices k k s, + ν.probability (fun x => (AC0Circuit.combineGateException sample c E).eval x = true) ≤ + (7 / 8 : ℝ) ^ s + ∑ i, δ i ∧ + ∀ x, (AC0Circuit.combineGateException sample c E).eval x ≠ true → + sampledAndPolynomial sample (fun i => P i x) = (AC0Circuit.andGate c).indicator x := by + obtain ⟨sample, hs⟩ := exists_gateSamplingException_small ν s c + refine ⟨sample, ?_, ?_⟩ + · let events : Option (Fin k) → BooleanCube n → Prop + | none => fun x => (AC0Circuit.gateSamplingException sample c).eval x = true + | some i => fun x => (E i).eval x = true + have hcover : ∀ x, + (AC0Circuit.combineGateException sample c E).eval x = true → ∃ i, events i x := by + intro x hx + rcases (AC0Circuit.combineGateException_eval sample c E x).mp hx with h | ⟨i, hi⟩ + · exact ⟨none, h⟩ + · exact ⟨some i, hi⟩ + calc + _ ≤ ν.probability (fun x => ∃ i, events i x) := ν.probability_mono hcover + _ ≤ ∑ i, ν.probability (events i) := ν.probability_exists_le events + _ = ν.probability (events none) + ∑ i : Fin k, ν.probability (events (some i)) := by + simp only [Fintype.sum_option] + _ ≤ _ := add_le_add hs (sum_le_sum (fun i _ => hδ i)) + · intro x hx + have hc : ∀ i, P i x = (c i).indicator x := by + intro i + apply hcorrect i x + intro hi + exact hx ((AC0Circuit.combineGateException_eval sample c E x).mpr (Or.inr ⟨i, hi⟩)) + have hp : (fun i => P i x) = fun i => (c i).indicator x := funext hc + rw [hp] + by_contra h + have hlocal := sampledAndPolynomial_error_detected sample c x h + exact hx ((AC0Circuit.combineGateException_eval sample c E x).mpr (Or.inl hlocal)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitClauseIndependence.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitClauseIndependence.lean new file mode 100644 index 0000000000000000000000000000000000000000..7193acece975e052a1d3f0a9200d86e25e1a8dfc --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitClauseIndependence.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitComparison + +namespace OAI + +/-! The first gate case of bounded-independence circuit fooling. A clause is +the complement of a Boolean cylinder. Restricting a wide clause to t distinct +coordinates makes both its exceptional probabilities at most 2⁻ᵗ. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {n : ℕ} + +lemma cubeAverage_pattern (S : Finset (Fin n)) (z : BooleanCube n) : + cubeAverage (cubePattern S z) = 1 / (2 : ℝ) ^ S.card := by + have hm : cubeAverage (fun _ : BooleanCube n => (1 : ℝ)) = 1 := cubeAverage_const 1 + have hc : ∀ T ⊆ S, T.Nonempty → walshCoefficient (fun _ => (1 : ℝ)) T = 0 := by + intro T _ hT + simpa only [walshCoefficient, one_mul] using cubeAverage_walsh hT + simpa only [one_mul] using cubeAverage_pattern_of_walsh (fun _ => 1) S z hm hc + +lemma cubePattern_nonneg (S : Finset (Fin n)) (z x : BooleanCube n) : + 0 ≤ cubePattern S z x := by + unfold cubePattern + split_ifs <;> norm_num + +lemma cubePattern_antitone {S T : Finset (Fin n)} (hTS : T ⊆ S) + (z x : BooleanCube n) : cubePattern S z x ≤ cubePattern T z x := by + unfold cubePattern + by_cases hS : ∀ i ∈ S, x i = z i + · have hT : ∀ i ∈ T, x i = z i := fun i hi => hS i (hTS hi) + rw [ite_eq_left hS, ite_eq_left hT] + · rw [ite_eq_right hS] + split_ifs <;> norm_num + +/-- Exact t-wise independence bounds a cylinder of at least t coordinates, +even when the cylinder uses more than t coordinates. -/ +lemma TWiseUniformDensity.large_pattern_bound {n t : ℕ} {g : BooleanCube n → ℝ} + (hg : TWiseUniformDensity g t) (hn : ∀ x, 0 ≤ g x) + (S : Finset (Fin n)) (ht : t ≤ S.card) (z : BooleanCube n) : + 0 ≤ cubeAverage (fun x => g x * cubePattern S z x) ∧ + cubeAverage (fun x => g x * cubePattern S z x) ≤ 1 / (2 : ℝ) ^ t := by + obtain ⟨T, hTS, hT⟩ := exists_subset_card_eq ht + refine ⟨?_, ?_⟩ + · have hh := cubeAverage_mono (fun x => mul_nonneg (hn x) (cubePattern_nonneg S z x)) + simpa only [cubeAverage_const] using hh + · calc + cubeAverage (fun x => g x * cubePattern S z x) ≤ + cubeAverage (fun x => g x * cubePattern T z x) := + cubeAverage_mono (fun x => mul_le_mul_of_nonneg_left + (cubePattern_antitone hTS z x) (hn x)) + _ = 1 / (2 : ℝ) ^ t := by rw [hg T (by omega) z, hT] + +/-- A clause, represented as the complement of its unique failing pattern, +is fooled to error 2⁻ᵗ, independently of its width. -/ +theorem TWiseUniformDensity.clause_error {n t : ℕ} {g : BooleanCube n → ℝ} + (hg : TWiseUniformDensity g t) (hn : ∀ x, 0 ≤ g x) + (hm : cubeAverage g = 1) (S : Finset (Fin n)) (z : BooleanCube n) : + |cubeAverage (fun x => g x * (1 - cubePattern S z x)) - + cubeAverage (fun x => 1 - cubePattern S z x)| ≤ 1 / (2 : ℝ) ^ t := by + have heq : cubeAverage (fun x => g x * (1 - cubePattern S z x)) - + cubeAverage (fun x => 1 - cubePattern S z x) = + cubeAverage (cubePattern S z) - cubeAverage (fun x => g x * cubePattern S z x) := by + simp_rw [mul_sub, mul_one] + rw [cubeAverage_sub, cubeAverage_sub, hm, cubeAverage_const] + ring + rw [heq] + by_cases hS : S.card ≤ t + · rw [hg S hS z, cubeAverage_pattern, sub_self, abs_zero] + positivity + · have hlarge := hg.large_pattern_bound hn S (by omega) z + have hsmall : 0 ≤ cubeAverage (cubePattern S z) := by + rw [cubeAverage_pattern] + positivity + have hbound : cubeAverage (cubePattern S z) ≤ 1 / (2 : ℝ) ^ t := by + rw [cubeAverage_pattern] + apply one_div_le_one_div_of_le (by positivity) + exact pow_le_pow_right₀ (by norm_num) (by omega) + exact abs_le.mpr ⟨by linarith [hlarge.2], by linarith [hlarge.1]⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..20bb63b93736cd6b3b8329483d92cd4289179389 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitComparison.lean @@ -0,0 +1,139 @@ +import OAI.NumberTheory.TwoPoint.Circuits.FourierCorrection + +namespace OAI + +/-! +# Bounded-independence circuit comparison after Fourier correction + +The comparison uses the fixed-depth specialization of Mark Braverman, +*Polylogarithmic independence fools AC⁰ circuits*, J. ACM 57 (2010), Article 28, +Corollary 2 in the author's version. We use depth 22, with absolute constants +and natural logarithms. Circuits below have actual finite syntax: literals +and arbitrary finite-fan-in AND/OR gates. They are tree circuits, a subclass +of the circuits covered by Braverman's theorem. The size counts both input +occurrences and gates; the depth counts AND/OR levels. +-/ + +namespace TwoPointCorrelations + +open Finset + +/-- Finite AC⁰ syntax in negation normal form. Sharing is not needed for the +finite residue tests; literals can have either polarity. -/ +inductive AC0Circuit (n : ℕ) where + | literal (i : Fin n) (positive : Bool) + | andGate {k : ℕ} (children : Fin k → AC0Circuit n) + | orGate {k : ℕ} (children : Fin k → AC0Circuit n) + +namespace AC0Circuit + +/-- Evaluation on a Boolean input vector. Empty AND/OR gates are true/false. -/ +def eval {n : ℕ} : AC0Circuit n → BooleanCube n → Bool + | .literal i positive, x => if positive then x i else !(x i) + | .andGate children, x => decide (∀ i, eval (children i) x = true) + | .orGate children, x => decide (∃ i, eval (children i) x = true) + +/-- AND/OR depth, with literals at depth zero. -/ +def depth {n : ℕ} : AC0Circuit n → ℕ + | .literal _ _ => 0 + | .andGate children => 1 + Finset.univ.sup (fun i => depth (children i)) + | .orGate children => 1 + Finset.univ.sup (fun i => depth (children i)) + +/-- Gates plus input occurrences. -/ +def size {n : ℕ} : AC0Circuit n → ℕ + | .literal _ _ => 1 + | .andGate children => 1 + ∑ i, size (children i) + | .orGate children => 1 + ∑ i, size (children i) + +lemma size_pos {n : ℕ} (c : AC0Circuit n) : 0 < c.size := by + cases c <;> simp [size] + +/-- Real indicator of the circuit accepting its input. -/ +noncomputable def indicator {n : ℕ} (c : AC0Circuit n) (x : BooleanCube n) : ℝ := + if c.eval x then 1 else 0 + +lemma abs_centered_indicator {n : ℕ} (c : AC0Circuit n) (x : BooleanCube n) : + |c.indicator x - 1 / 2| = (1 / 2 : ℝ) := by + unfold indicator + cases c.eval x <;> norm_num + +end AC0Circuit + +/-- Braverman's Corollary 2 at depth twenty-two. The constants absorb a +choice of logarithm base. Distributions are represented by nonnegative +densities relative to the uniform law on the Boolean cube. -/ +def BravermanDepth22Input : Prop := + ∃ K C : ℕ, 0 < K ∧ 0 < C ∧ ∀ (n : ℕ) (c : AC0Circuit n), c.depth ≤ 22 → + ∀ ε : ℝ, 0 < ε → ε ≤ 1 / 2 → ∀ t : ℕ, + (K : ℝ) * (Real.log ((c.size : ℝ) / ε)) ^ C ≤ (t : ℝ) → + ∀ g : BooleanCube n → ℝ, (∀ x, 0 ≤ g x) → cubeAverage g = 1 → + TWiseUniformDensity g t → + |cubeAverage (fun x => g x * c.indicator x) - cubeAverage c.indicator| ≤ ε + +lemma abs_cubeAverage_le {n : ℕ} (f : BooleanCube n → ℝ) : + |cubeAverage f| ≤ cubeAverage (fun x => |f x|) := by + unfold cubeAverage + rw [abs_div, show |(Fintype.card (BooleanCube n) : ℝ)| = + (Fintype.card (BooleanCube n) : ℝ) from abs_of_nonneg (Nat.cast_nonneg _)] + exact div_le_div_of_nonneg_right (Finset.abs_sum_le_sum_abs _ _) (Nat.cast_nonneg _) + +/-- For measures of equal total mass, an event difference is bounded by one +half of the mean absolute density difference. -/ +lemma circuit_event_le_totalVariation {n : ℕ} (c : AC0Circuit n) + (f g : BooleanCube n → ℝ) (hmass : cubeAverage f = cubeAverage g) : + |cubeAverage (fun x => f x * c.indicator x) - + cubeAverage (fun x => g x * c.indicator x)| ≤ + cubeAverage (fun x => |f x - g x|) / 2 := by + have hzero : cubeAverage (fun x => f x - g x) = 0 := by + rw [cubeAverage_sub, hmass, sub_self] + have heq : cubeAverage (fun x => f x * c.indicator x) - + cubeAverage (fun x => g x * c.indicator x) = + cubeAverage (fun x => (f x - g x) * (c.indicator x - 1 / 2)) := by + have hpoint : (fun x => (f x - g x) * (c.indicator x - 1 / 2)) = + (fun x => (f x * c.indicator x - g x * c.indicator x) - + (1 / 2 : ℝ) * (f x - g x)) := by + funext x + ring + rw [hpoint, cubeAverage_sub, cubeAverage_sub, cubeAverage_mul_const, hzero] + ring + rw [heq] + apply (abs_cubeAverage_le _).trans + have hpoint : (fun x => |(f x - g x) * (c.indicator x - 1 / 2)|) = + (fun x => (1 / 2 : ℝ) * |f x - g x|) := by + funext x + rw [abs_mul, c.abs_centered_indicator] + ring + rw [hpoint, cubeAverage_mul_const] + exact le_of_eq (by ring) + +/-- Fourier correction followed by Braverman's published theorem compares +the original density against uniform inputs, with the correction error +made explicit. -/ +theorem BravermanDepth22Input.fourier_comparison (hBraverman : BravermanDepth22Input) : + ∃ K C : ℕ, 0 < K ∧ 0 < C ∧ ∀ (n : ℕ) (c : AC0Circuit n), c.depth ≤ 22 → + ∀ ε : ℝ, 0 < ε → ε ≤ 1 / 2 → ∀ t : ℕ, + (K : ℝ) * (Real.log ((c.size : ℝ) / ε)) ^ C ≤ (t : ℝ) → + ∀ (f : BooleanCube n → ℝ) (a : ℝ), + (∀ x, 0 ≤ f x) → cubeAverage f = 1 → 0 ≤ a → lowWalshMass f t ≤ a → + |cubeAverage (fun x => f x * c.indicator x) - cubeAverage c.indicator| ≤ + 3 * a / 2 + ε := by + obtain ⟨K, C, hK, hC, hbound⟩ := hBraverman + refine ⟨K, C, hK, hC, ?_⟩ + intro n c hdepth ε hε hεmax t ht f a hf hmean ha hmass + let g := correctedCubeDensity f t a + have hcorr := fourierCorrection f t a hf hmean ha hmass + have hBrav := hbound n c hdepth ε hε hεmax t ht g hcorr.1 hcorr.2.1 hcorr.2.2.1 + have hTV := circuit_event_le_totalVariation c f g (hmean.trans hcorr.2.1.symm) + have hTVbound : cubeAverage (fun x => |f x - g x|) / 2 ≤ 3 * a / 2 := by + simpa only [abs_sub_comm] using hcorr.2.2.2 + calc + |cubeAverage (fun x => f x * c.indicator x) - cubeAverage c.indicator| ≤ + |cubeAverage (fun x => f x * c.indicator x) - + cubeAverage (fun x => g x * c.indicator x)| + + |cubeAverage (fun x => g x * c.indicator x) - cubeAverage c.indicator| := + abs_sub_le _ _ _ + _ ≤ 3 * a / 2 + ε := add_le_add (hTV.trans hTVbound) hBrav + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDecisionDNF.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDecisionDNF.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f68f60d3f0f13165fa1b03e9252131bb91cba8c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDecisionDNF.lean @@ -0,0 +1,136 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitCanonicalTree + +namespace OAI + +/-! A decision tree of depth r is a DNF of width at most r. Both Boolean +polarities have such a representation, so gates can be switched without +counting the number of clauses produced by earlier switches. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace BooleanDecisionTree + +def negate {n : ℕ} : BooleanDecisionTree n → BooleanDecisionTree n + | .leaf b => .leaf (!b) + | .query i low high => .query i low.negate high.negate + +@[simp] lemma negate_eval {n : ℕ} (T : BooleanDecisionTree n) (x : BooleanCube n) : + T.negate.eval x = !(T.eval x) := by + induction T with + | leaf b => rfl + | query i low high hl hh => + cases hx : x i <;> simp [negate, eval, hx, hl, hh] + +@[simp] lemma negate_depth {n : ℕ} (T : BooleanDecisionTree n) : T.negate.depth = T.depth := by + induction T with + | leaf b => rfl + | query i low high hl hh => simp [negate, depth, hl, hh] + +end BooleanDecisionTree + +def CubeTerm.withLiteral {n : ℕ} (C : CubeTerm n) (i : Fin n) (b : Bool) : CubeTerm n := + ⟨insert i C.support, Function.update C.value i b⟩ + +lemma CubeTerm.withLiteral_eval {n : ℕ} (C : CubeTerm n) (i : Fin n) (b : Bool) + (hc : i ∉ C.support ∨ C.value i = b) (x : BooleanCube n) : + (C.withLiteral i b).eval x = true ↔ x i = b ∧ C.eval x = true := by + simp only [eval, decide_eq_true_eq] + constructor + · intro h + have hi := h i (mem_insert_self _ _) + have hx : x i = b := by simpa [withLiteral] using hi + refine ⟨hx, ?_⟩ + intro j hj + by_cases hji : j = i + · subst j + exact hx.trans ((hc.resolve_left (not_not.mpr hj)).symm) + · have hh := h j (mem_insert_of_mem hj) + simpa [withLiteral, hji] using hh + · rintro ⟨hi, h⟩ j hj + rcases mem_insert.mp hj with rfl | hj + · simpa [withLiteral] using hi + · by_cases hji : j = i + · subst j + simpa [withLiteral] using hi + · simpa [withLiteral, hji] using h j hj + +def addDNFLiteral {n : ℕ} (F : List (CubeTerm n)) (i : Fin n) (b : Bool) : + List (CubeTerm n) := + F.flatMap (fun C => if i ∉ C.support ∨ C.value i = b then [C.withLiteral i b] else []) + +lemma dnfEval_eq_true {n : ℕ} (F : List (CubeTerm n)) (x : BooleanCube n) : + dnfEval F x = true ↔ ∃ C ∈ F, C.eval x = true := by + simp [dnfEval] + +lemma addDNFLiteral_eval {n : ℕ} (F : List (CubeTerm n)) (i : Fin n) (b : Bool) + (x : BooleanCube n) : + dnfEval (addDNFLiteral F i b) x = true ↔ x i = b ∧ dnfEval F x = true := by + simp only [dnfEval_eq_true, addDNFLiteral, List.mem_flatMap] + constructor + · rintro ⟨D, ⟨C, hC, hD⟩, he⟩ + split_ifs at hD with hc + · have hDC : D = C.withLiteral i b := by simpa using hD + subst D + have hh := (C.withLiteral_eval i b hc x).mp he + exact ⟨hh.1, C, hC, hh.2⟩ + · simp at hD + · rintro ⟨hxi, C, hC, he⟩ + have hc : i ∉ C.support ∨ C.value i = b := by + by_cases hi : i ∈ C.support + · right + have hh := (of_decide_eq_true he) i hi + exact hh.symm.trans hxi + · exact Or.inl hi + refine ⟨C.withLiteral i b, ⟨C, hC, ?_⟩, (C.withLiteral_eval i b hc x).mpr ⟨hxi, he⟩⟩ + simp [hc] + +lemma addDNFLiteral_width {n r : ℕ} (F : List (CubeTerm n)) + (hF : ∀ C ∈ F, C.support.card ≤ r) (i : Fin n) (b : Bool) : + ∀ C ∈ addDNFLiteral F i b, C.support.card ≤ r + 1 := by + intro D hD + obtain ⟨C, hC, hD⟩ := List.mem_flatMap.mp hD + split_ifs at hD with hc + · have hDC : D = C.withLiteral i b := by simpa using hD + subst D + exact (card_insert_le i C.support).trans (Nat.add_le_add_right (hF C hC) 1) + · simp at hD + +namespace BooleanDecisionTree + +def toDNF {n : ℕ} : BooleanDecisionTree n → List (CubeTerm n) + | .leaf false => [] + | .leaf true => [⟨∅, fun _ => false⟩] + | .query i low high => addDNFLiteral low.toDNF i false ++ addDNFLiteral high.toDNF i true + +theorem toDNF_eval {n : ℕ} (T : BooleanDecisionTree n) (x : BooleanCube n) : + dnfEval T.toDNF x = T.eval x := by + apply Bool.eq_iff_iff.mpr + induction T with + | leaf b => cases b <;> simp [toDNF, dnfEval, eval, CubeTerm.eval] + | query i low high hl hh => + simp only [toDNF, dnfEval, List.any_append, Bool.or_eq_true] + change (dnfEval (addDNFLiteral low.toDNF i false) x = true ∨ + dnfEval (addDNFLiteral high.toDNF i true) x = true) ↔ _ + rw [addDNFLiteral_eval, addDNFLiteral_eval, hl, hh] + cases hx : x i <;> simp [eval, hx] + +theorem toDNF_width {n : ℕ} (T : BooleanDecisionTree n) : + ∀ C ∈ T.toDNF, C.support.card ≤ T.depth := by + induction T with + | leaf b => cases b <;> simp [toDNF, depth] + | query i low high hl hh => + intro C hC + rcases List.mem_append.mp hC with hC | hC + · exact (addDNFLiteral_width low.toDNF hl i false C hC).trans + (Nat.add_le_add_right (Nat.le_max_left _ _) 1) + · exact (addDNFLiteral_width high.toDNF hh i true C hC).trans + (Nat.add_le_add_right (Nat.le_max_right _ _) 1) + +end BooleanDecisionTree + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDecisionRestriction.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDecisionRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..65d77ca7ff450eaf9417ed0199964071b11a3090 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDecisionRestriction.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitDecisionDNF + +namespace OAI + +/-! Decision-tree certificates are preserved by fixing additional coordinates. +We also package the two Boolean polarities of a certificate. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +namespace BooleanDecisionTree + +def restrict {n : ℕ} (ρ : PartialAssignment n) : + BooleanDecisionTree n → BooleanDecisionTree n + | .leaf b => .leaf b + | .query i low high => + match ρ i with + | none => .query i (low.restrict ρ) (high.restrict ρ) + | some false => low.restrict ρ + | some true => high.restrict ρ + +@[simp] theorem restrict_eval {n : ℕ} (T : BooleanDecisionTree n) + (ρ : PartialAssignment n) (x : BooleanCube n) : + (T.restrict ρ).eval x = T.eval (ρ.apply x) := by + induction T with + | leaf b => rfl + | query i low high hl hh => + cases hρ : ρ i with + | none => + cases hx : x i <;> simp [restrict, eval, PartialAssignment.apply, hρ, hx, hl, hh] + | some b => + cases b <;> simp [restrict, eval, PartialAssignment.apply, hρ, hl, hh] + +theorem restrict_depth_le {n : ℕ} (T : BooleanDecisionTree n) + (ρ : PartialAssignment n) : (T.restrict ρ).depth ≤ T.depth := by + induction T with + | leaf b => exact le_rfl + | query i low high hl hh => + cases hρ : ρ i with + | none => simpa [restrict, hρ, depth] using Nat.add_le_add_right (max_le_max hl hh) 1 + | some b => + cases b + · simpa only [restrict, hρ, depth] using + hl.trans ((Nat.le_max_left _ _).trans (Nat.le_succ _)) + · simpa only [restrict, hρ, depth] using + hh.trans ((Nat.le_max_right _ _).trans (Nat.le_succ _)) + +end BooleanDecisionTree + +def HasSmallDecisionTree {n : ℕ} (f : BooleanCube n → Bool) (r : ℕ) : Prop := + ∃ T : BooleanDecisionTree n, T.depth ≤ r ∧ ∀ x, T.eval x = f x + +theorem HasSmallDecisionTree.restrict {n r : ℕ} {f : BooleanCube n → Bool} + (h : HasSmallDecisionTree f r) (ρ : PartialAssignment n) : + HasSmallDecisionTree (fun x => f (ρ.apply x)) r := by + obtain ⟨T, hT, he⟩ := h + exact ⟨T.restrict ρ, (T.restrict_depth_le ρ).trans hT, fun x => by simp [he]⟩ + +theorem HasSmallDecisionTree.negate {n r : ℕ} {f : BooleanCube n → Bool} + (h : HasSmallDecisionTree f r) : HasSmallDecisionTree (fun x => !(f x)) r := by + obtain ⟨T, hT, he⟩ := h + exact ⟨T.negate, by simpa using hT, fun x => by simp [he]⟩ + +@[simp] theorem hasSmallDecisionTree_negate_iff {n r : ℕ} {f : BooleanCube n → Bool} : + HasSmallDecisionTree (fun x => !(f x)) r ↔ HasSmallDecisionTree f r := by + constructor + · intro h + simpa only [Bool.not_not] using h.negate + · exact HasSmallDecisionTree.negate + +theorem literal_hasSmallDecisionTree {n r : ℕ} (i : Fin n) (b : Bool) + (hr : 1 ≤ r) (ρ : PartialAssignment n) : + HasSmallDecisionTree (fun x => (AC0Circuit.literal i b).eval (ρ.apply x)) r := by + have h : HasSmallDecisionTree (AC0Circuit.literal i b).eval r := by + refine ⟨.query i (.leaf (!b)) (.leaf b), ?_, ?_⟩ + · simpa [BooleanDecisionTree.depth] using hr + · intro x + cases b <;> cases hx : x i <;> + simp [BooleanDecisionTree.eval, AC0Circuit.eval, hx] + exact h.restrict ρ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDecisionTree.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDecisionTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..50220d524d1ea685e692e460f30d3db5e235916b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDecisionTree.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitApproximationDegree + +namespace OAI + +/-! A decision tree making at most `d` queries on any branch has Walsh +degree at most `d`. This is the spectral consequence of circuit switching. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +lemma WalshDegreeLE.add {n d : ℕ} {F G : BooleanCube n → ℝ} + (hF : WalshDegreeLE F d) (hG : WalshDegreeLE G d) : + WalshDegreeLE (fun x => F x + G x) d := by + have h := hF.sub (hG.smul (-1)) + convert h using 1 + funext x + ring + +inductive BooleanDecisionTree (n : ℕ) where + | leaf (value : Bool) + | query (i : Fin n) (low high : BooleanDecisionTree n) + +namespace BooleanDecisionTree + +def eval {n : ℕ} : BooleanDecisionTree n → BooleanCube n → Bool + | .leaf b, _ => b + | .query i low high, x => if x i then high.eval x else low.eval x + +def depth {n : ℕ} : BooleanDecisionTree n → ℕ + | .leaf _ => 0 + | .query _ low high => max low.depth high.depth + 1 + +noncomputable def indicator {n : ℕ} (c : BooleanDecisionTree n) (x : BooleanCube n) : ℝ := + if c.eval x then 1 else 0 + +theorem indicator_degree {n : ℕ} (c : BooleanDecisionTree n) : + WalshDegreeLE c.indicator c.depth := by + induction c with + | leaf b => + cases b <;> exact WalshDegreeLE.const _ _ + | query i low high hl hh => + let d := max low.depth high.depth + have hlow : WalshDegreeLE low.indicator d := hl.mono (Nat.le_max_left _ _) + have hhigh : WalshDegreeLE high.indicator d := hh.mono (Nat.le_max_right _ _) + have hbit := literal_indicator_degree i true + have hnot := literal_indicator_degree i false + have h := (hnot.mul hlow).add (hbit.mul hhigh) + have heq : (fun x => (AC0Circuit.literal i false).indicator x * low.indicator x + + (AC0Circuit.literal i true).indicator x * high.indicator x) = + (query i low high).indicator := by + funext x + cases hx : x i <;> + simp [indicator, eval, AC0Circuit.indicator, AC0Circuit.eval, hx] + rw [heq] at h + simpa only [depth, d, Nat.add_comm 1] using h + +end BooleanDecisionTree + +lemma WalshDegreeLE.high_coefficient_zero {n d : ℕ} {F : BooleanCube n → ℝ} + (hF : WalshDegreeLE F d) (S : Finset (Fin n)) (hS : d < S.card) : + walshCoefficient F S = 0 := by + obtain ⟨a, ha⟩ := hF + unfold walshCoefficient + simp_rw [ha, Finset.sum_mul] + rw [cubeAverage_sum] + simp_rw [mul_assoc, cubeAverage_mul_const, cubeAverage_walsh_mul] + simp [Nat.not_le.mpr hS] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDegreeBound.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDegreeBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..88af2d3014c470d2d7d7fe5c65d9223ce56938a4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDegreeBound.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitRecursiveApproximation + +namespace OAI + +/-! At fixed depth, the sampled polynomial degree is a power of the +sampling count times the logarithm of the circuit size. -/ + +namespace TwoPointCorrelations.AC0Circuit + +open Finset +open scoped Classical + +theorem approximationDegree_le {n : ℕ} (s : ℕ) (hs : 1 ≤ s) + (c : AC0Circuit n) (m : ℕ) (hm : c.size ≤ m) : + c.approximationDegree s ≤ (s * (Nat.log 2 m + 3)) ^ c.depth := by + induction c generalizing m with + | literal i b => simp [approximationDegree, depth] + | @andGate k children ih | @orGate k children ih => + have hm' : 1 + ∑ i, (children i).size ≤ m := hm + have hsize (i : Fin k) : (children i).size ≤ m := by + have hh := single_le_sum (fun j _ => Nat.zero_le (children j).size) (mem_univ i) + omega + have hcount : k ≤ ∑ i, (children i).size := by + calc + k = ∑ _i : Fin k, 1 := by simp + _ ≤ _ := sum_le_sum (fun i _ => (children i).size_pos) + have hk : k ≤ m := by omega + let B := s * (Nat.log 2 m + 3) + let D := univ.sup (fun i => (children i).depth) + have hB : 0 < B := by dsimp [B]; positivity + have hsup : (univ.sup fun i => (children i).approximationDegree s) ≤ B ^ D := by + apply Finset.sup_le + intro i _ + exact (ih i m (hsize i)).trans + (Nat.pow_le_pow_right hB (le_sup (f := fun i => (children i).depth) (mem_univ i))) + have hlog : s * (Nat.log 2 k + 3) ≤ B := + Nat.mul_le_mul_left s (Nat.add_le_add_right (Nat.log_mono_right hk) 3) + change (univ.sup fun i => (children i).approximationDegree s) * s * + (Nat.log 2 k + 3) ≤ B ^ (1 + D) + calc + _ ≤ B ^ D * s * (Nat.log 2 k + 3) := by gcongr + _ = B ^ D * (s * (Nat.log 2 k + 3)) := by ring + _ ≤ B ^ D * B := Nat.mul_le_mul_left _ hlog + _ = B ^ (1 + D) := by rw [Nat.add_comm 1 D, pow_succ] + +end TwoPointCorrelations.AC0Circuit + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDepthSwitching.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDepthSwitching.lean new file mode 100644 index 0000000000000000000000000000000000000000..dab4a196723eb477c06c24817edf30658e29c287 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDepthSwitching.lean @@ -0,0 +1,121 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitGateSwitching +import OAI.NumberTheory.TwoPoint.Circuits.CircuitRestrictionComposition + +namespace OAI + +/-! Iterate switching through arbitrary AND/OR circuits. Each gate pays +one switching error, so the total loss is bounded by circuit size. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem FiniteLaw.average_probability_le_union {α β ι : Type*} + [Fintype α] [Fintype β] [Fintype ι] + (μ : FiniteLaw α) (ν : FiniteLaw β) (E : α → β → Prop) + (bad : ι → α → Prop) (δ : ℝ) (hδ : 0 ≤ δ) + (hgood : ∀ x, (∀ i, ¬ bad i x) → ν.probability (E x) ≤ δ) : + μ.average (fun x => ν.probability (E x)) ≤ + (∑ i, μ.probability (bad i)) + δ := by + calc + _ ≤ μ.average (fun x => (if ∃ i, bad i x then 1 else 0) + δ) := by + apply μ.average_mono + intro x + by_cases hx : ∃ i, bad i x + · simpa only [ite_eq_left hx] using + (ν.probability_le_one (E x)).trans (by linarith) + · simpa only [ite_eq_right hx, zero_add] using + hgood x (fun i hi => hx ⟨i, hi⟩) + _ = μ.probability (fun x => ∃ i, bad i x) + δ := by + simp only [FiniteLaw.probability, FiniteLaw.average, mul_add, + sum_add_distrib, ← sum_mul, μ.total, one_mul] + congr 1 + apply sum_congr rfl + intro x _ + by_cases hx : ∃ i, bad i x <;> simp [hx] + _ ≤ _ := add_le_add (μ.probability_exists_le bad) le_rfl + +namespace AC0Circuit + +theorem restriction_shallow {n : ℕ} (p : ℝ) (hp : 0 ≤ p) (hp1 : p < 1) + (r : ℕ) (hr : 1 ≤ r) + (hq : ((3 * (2 * r + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p)) ≤ 1 / 2) + (d : ℕ) (c : AC0Circuit n) (hc : c.depth ≤ d) : + (restrictionLaw n (p ^ d) (pow_nonneg hp _) (pow_le_one₀ hp hp1.le)).probability + (fun ρ => ¬ HasSmallDecisionTree (fun x => c.eval (ρ.apply x)) r) ≤ + (c.size : ℝ) * + (2 * (((3 * (2 * r + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p))) ^ (r + 1)) := by + let δ := 2 * (((3 * (2 * r + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p))) ^ (r + 1) + have hδ : 0 ≤ δ := by dsimp [δ]; positivity + induction d generalizing c with + | zero => + cases c with + | literal i b => + have he (ρ : PartialAssignment n) : + ¬ (¬ HasSmallDecisionTree (fun x => (literal i b).eval (ρ.apply x)) r) := + not_not.mpr (literal_hasSmallDecisionTree i b hr ρ) + simpa only [FiniteLaw.probability, he, ite_false, FiniteLaw.average_const, + size, Nat.cast_one, one_mul] using hδ + | andGate children => simp [depth] at hc + | orGate children => simp [depth] at hc + | succ d ih => + let μ := restrictionLaw n (p ^ d) (pow_nonneg hp _) (pow_le_one₀ hp hp1.le) + let ν := restrictionLaw n p hp hp1.le + have hcompose (E : PartialAssignment n → Prop) : + (restrictionLaw n (p ^ (d + 1)) (pow_nonneg hp _) + (pow_le_one₀ hp hp1.le)).probability E = + μ.average (fun ρ => ν.probability (fun τ => E (composeRestriction ρ τ))) := by + unfold FiniteLaw.probability + exact (restrictionLaw_compose (p ^ d) p (pow_nonneg hp _) + (pow_le_one₀ hp hp1.le) hp hp1.le (fun ρ => if E ρ then 1 else 0)).symm + cases c with + | literal i b => + have he (ρ : PartialAssignment n) : + ¬ (¬ HasSmallDecisionTree (fun x => (literal i b).eval (ρ.apply x)) r) := + not_not.mpr (literal_hasSmallDecisionTree i b hr ρ) + simpa only [FiniteLaw.probability, he, ite_false, FiniteLaw.average_const, + size, Nat.cast_one, one_mul] using hδ + | andGate children => + have hchild (i) : (children i).depth ≤ d := by + have hi := Finset.le_sup (f := fun i => (children i).depth) (mem_univ i) + simp only [depth] at hc + omega + rw [hcompose] + apply (FiniteLaw.average_probability_le_union μ ν _ + (fun i ρ => ¬ HasSmallDecisionTree (fun x => (children i).eval (ρ.apply x)) r) + δ hδ ?_).trans + · calc + _ ≤ (∑ i, ((children i).size : ℝ) * δ) + δ := by + exact add_le_add (sum_le_sum (fun i _ => ih (children i) (hchild i))) le_rfl + _ = _ := by simp only [size, Nat.cast_add, Nat.cast_one, Nat.cast_sum]; rw [← sum_mul]; ring + · intro ρ hρ + have hh := conjunction_restriction_switching + (fun i x => (children i).eval (ρ.apply x)) (fun i => not_not.mp (hρ i)) + p hp hp1 hq + simpa only [eval, composeRestriction_apply] using hh + | orGate children => + have hchild (i) : (children i).depth ≤ d := by + have hi := Finset.le_sup (f := fun i => (children i).depth) (mem_univ i) + simp only [depth] at hc + omega + rw [hcompose] + apply (FiniteLaw.average_probability_le_union μ ν _ + (fun i ρ => ¬ HasSmallDecisionTree (fun x => (children i).eval (ρ.apply x)) r) + δ hδ ?_).trans + · calc + _ ≤ (∑ i, ((children i).size : ℝ) * δ) + δ := by + exact add_le_add (sum_le_sum (fun i _ => ih (children i) (hchild i))) le_rfl + _ = _ := by simp only [size, Nat.cast_add, Nat.cast_one, Nat.cast_sum]; rw [← sum_mul]; ring + · intro ρ hρ + have hh := disjunction_restriction_switching + (fun i x => (children i).eval (ρ.apply x)) (fun i => not_not.mp (hρ i)) + p hp hp1 hq + simpa only [eval, composeRestriction_apply] using hh + + +end AC0Circuit + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicApproximation.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1bd550b9c63c747a48632266358a1cd11d4f18c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicApproximation.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitDyadicBudgets + +namespace OAI + +/-! Specialize the proved approximation construction to dyadic size +budgets and circuit depth twenty-two. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +lemma braverman_approx_degree_bound {m j d : ℕ} (hm : m ≤ 2 ^ j) (hd : d ≤ 22) : + (bravermanSamples j * (Nat.log 2 m + 3)) ^ d ≤ bravermanBase j ^ 22 := by + have hbase : bravermanSamples j * (Nat.log 2 m + 3) ≤ bravermanBase j := + Nat.mul_le_mul_left _ (Nat.add_le_add_right (nat_log_le_of_dyadic hm) 3) + exact (Nat.pow_le_pow_left hbase _).trans + (Nat.pow_le_pow_right (bravermanBase_pos j) hd) + +lemma braverman_norm_power_bound {m j d : ℕ} (hm : m ≤ 2 ^ j) (hd : d ≤ 22) : + (2 * (bravermanSamples j * (Nat.log 2 m + 3)) + 2) ^ d ≤ + (2 * bravermanBase j + 2) ^ 22 := by + have hbase : bravermanSamples j * (Nat.log 2 m + 3) ≤ bravermanBase j := + Nat.mul_le_mul_left _ (Nat.add_le_add_right (nat_log_le_of_dyadic hm) 3) + exact (Nat.pow_le_pow_left (Nat.add_le_add_right (Nat.mul_le_mul_left 2 hbase) 2) _).trans + (Nat.pow_le_pow_right (by omega) hd) + +lemma braverman_norm_base_bound {m j : ℕ} (hm : m ≤ 2 ^ j) : + 2 * ((m : ℝ) + 1) ^ 2 ≤ (2 : ℝ) ^ (2 * j + 3) := by + have hmreal : (m : ℝ) ≤ (2 : ℝ) ^ j := by exact_mod_cast hm + have htwo : (1 : ℝ) ≤ 2 ^ j := one_le_pow₀ (by norm_num) + have hsum : (m : ℝ) + 1 ≤ 2 * (2 : ℝ) ^ j := by linarith only [hmreal, htwo] + calc + _ ≤ 2 * (2 * (2 : ℝ) ^ j) ^ 2 := + mul_le_mul_of_nonneg_left + (pow_le_pow_left₀ (add_nonneg (Nat.cast_nonneg m) zero_le_one) hsum 2) (by norm_num) + _ = _ := by + rw [pow_add, show 2 * j = j * 2 by omega, pow_mul] + ring + +theorem AC0Circuit.dyadic_approximation {n j : ℕ} + (ν : FiniteLaw (BooleanCube n)) (c : AC0Circuit n) + (hc : c.depth ≤ 22) (hm : c.size ≤ 2 ^ j) : + ∃ (P : BooleanCube n → ℝ) (E : AC0Circuit n), + WalshDegreeLE P (bravermanBase j ^ 22) ∧ + E.depth ≤ 89 ∧ E.size ≤ 2 ^ bravermanErrorExponent j ∧ + ν.probability (fun x => E.eval x = true) ≤ + (2 : ℝ) ^ j * (7 / 8 : ℝ) ^ bravermanSamples j ∧ + (∀ x, E.eval x ≠ true → P x = c.indicator x) ∧ + ∀ x, |P x| ≤ (2 : ℝ) ^ bravermanNormExponent j := by + obtain ⟨P, E, hP, hd, hsize, hprob, he, hnorm⟩ := + c.polynomial_error_approximation ν (bravermanSamples j) (bravermanSamples_pos j) + have hmreal : (c.size : ℝ) ≤ (2 : ℝ) ^ j := by exact_mod_cast hm + have h89 : E.depth ≤ 89 := hd.trans (Nat.add_le_add_right (Nat.mul_le_mul_left 4 hc) 1) + refine ⟨P, E, hP.mono (braverman_approx_degree_bound hm hc), h89, + hsize.trans (braverman_error_size_budget hm), ?_, he, ?_⟩ + · exact hprob.trans (mul_le_mul_of_nonneg_right hmreal (by positivity)) + · intro x + calc + |P x| ≤ _ := hnorm x + _ ≤ ((2 : ℝ) ^ (2 * j + 3)) ^ + ((2 * (bravermanSamples j * (Nat.log 2 c.size + 3)) + 2) ^ c.depth) := + pow_le_pow_left₀ (by positivity) (braverman_norm_base_bound hm) _ + _ ≤ ((2 : ℝ) ^ (2 * j + 3)) ^ ((2 * bravermanBase j + 2) ^ 22) := + pow_le_pow_right₀ (one_le_pow₀ (by norm_num)) (braverman_norm_power_bound hm hc) + _ = _ := by rw [← pow_mul]; rfl + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicBudgets.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicBudgets.lean new file mode 100644 index 0000000000000000000000000000000000000000..89ada92f69743307fcd96386128b39923da1712a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicBudgets.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitBravermanApproximation +import OAI.NumberTheory.TwoPoint.Circuits.CircuitFourierDegree + +namespace OAI + +/-! Natural-number budgets for the fixed depth twenty-two application. +Using powers of two keeps the exponential error calculation elementary. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +def bravermanSamples (j : ℕ) : ℕ := 40 * (j + 1) +def bravermanBase (j : ℕ) : ℕ := bravermanSamples j * (j + 3) +def bravermanNormExponent (j : ℕ) : ℕ := + (2 * j + 3) * (2 * bravermanBase j + 2) ^ 22 +def bravermanErrorExponent (j : ℕ) : ℕ := 20 * (j + 3) +def bravermanSwitches (j : ℕ) : ℕ := + 2 * bravermanNormExponent j + bravermanErrorExponent j + j + 10 +def bravermanDegree (j : ℕ) : ℕ := + 2 * (bravermanBase j ^ 22 + switchingDegree 89 (bravermanSwitches j)) + +lemma bravermanSamples_pos (j : ℕ) : 1 ≤ bravermanSamples j := by + unfold bravermanSamples + omega + +lemma bravermanBase_pos (j : ℕ) : 1 ≤ bravermanBase j := by + unfold bravermanBase + have := bravermanSamples_pos j + nlinarith + +lemma bravermanSwitches_pos (j : ℕ) : 1 ≤ bravermanSwitches j := by + unfold bravermanSwitches + omega + +lemma nat_log_le_of_dyadic {m j : ℕ} (hm : m ≤ 2 ^ j) : Nat.log 2 m ≤ j := by + simpa only [Nat.log_pow (by norm_num : 1 < 2)] using Nat.log_mono_right (b := 2) hm + +lemma braverman_error_size_budget {m j : ℕ} (hm : m ≤ 2 ^ j) : + AC0Circuit.exceptionPolynomialBound m (bravermanSamples j) * m ≤ + 2 ^ bravermanErrorExponent j := by + have hj : j + 1 ≤ 2 ^ j := Nat.succ_le_of_lt j.lt_two_pow_self + have hs : bravermanSamples j ≤ 2 ^ (j + 6) := by + unfold bravermanSamples + calc + 40 * (j + 1) ≤ 64 * 2 ^ j := Nat.mul_le_mul (by norm_num) hj + _ = 2 ^ (j + 6) := by rw [pow_add]; ring + have hl : Nat.log 2 m + 3 ≤ 2 ^ (j + 2) := by + have hh := nat_log_le_of_dyadic hm + rw [pow_add] + norm_num + omega + have hp : 1 ≤ 2 ^ j := Nat.one_le_pow j 2 (by omega) + have hbracket : 1 + m * (1 + m) ≤ 2 ^ (2 * j + 2) := by + calc + 1 + m * (1 + m) ≤ 4 * (2 ^ j) ^ 2 := by nlinarith [hm] + _ = 2 ^ (2 * j + 2) := by + rw [pow_add, show 2 * j = j * 2 by omega, pow_mul] + ring + have hadd : 5 + m ≤ 2 ^ (4 * j + 10) := by + calc + 5 + m ≤ 8 * 2 ^ j := by omega + _ = 2 ^ (j + 3) := by rw [pow_add]; ring + _ ≤ _ := Nat.pow_le_pow_right (by omega) (by omega) + have hprod : bravermanSamples j * (Nat.log 2 m + 3) * (1 + m * (1 + m)) ≤ + 2 ^ (4 * j + 10) := by + calc + _ ≤ 2 ^ (j + 6) * 2 ^ (j + 2) * 2 ^ (2 * j + 2) := + Nat.mul_le_mul (Nat.mul_le_mul hs hl) hbracket + _ = _ := by simp only [← pow_add]; congr 1; omega + calc + _ ≤ (2 ^ (4 * j + 10) + 2 ^ (4 * j + 10)) * 2 ^ j := + Nat.mul_le_mul (Nat.add_le_add hadd hprod) hm + _ = 2 ^ (5 * j + 11) := by simp only [pow_succ]; ring + _ ≤ _ := Nat.pow_le_pow_right (by omega) (by unfold bravermanErrorExponent; omega) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicComparison.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b28f6003899591a853aa436be3bcc9cdf392d35 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicComparison.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitDyadicApproximation +import OAI.NumberTheory.TwoPoint.Circuits.CircuitDyadicErrors +import OAI.NumberTheory.TwoPoint.Circuits.CircuitApproximationComparison + +namespace OAI + +/-! The fixed-depth bounded-independence theorem with a completely +explicit polynomial budget, stated first at dyadic accuracy. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +theorem AC0Circuit.dyadic_comparison_lower {n j t : ℕ} (c : AC0Circuit n) + (hc : c.depth ≤ 22) (hm : c.size ≤ 2 ^ j) (ht : bravermanDegree j ≤ t) + (g : BooleanCube n → ℝ) (hg : ∀ x, 0 ≤ g x) (hmean : cubeAverage g = 1) + (hwise : TWiseUniformDensity g t) : + cubeAverage c.indicator - (1 / 2 : ℝ) ^ j ≤ + cubeAverage (fun x => g x * c.indicator x) := by + obtain ⟨P, E, hP, hdepth, hsize, hprob, hexact, hnorm⟩ := + c.dyadic_approximation (mixedCubeLaw g hg hmean) hc hm + let D := switchingDegree 89 (bravermanSwitches j) + have herror : cubeAverage (fun x => (E.indicator x - walshTruncation E.indicator D x) ^ 2) ≤ + 4 * (2 : ℝ) ^ bravermanErrorExponent j * + (1 / 2 : ℝ) ^ (bravermanSwitches j + 1) := by + apply (E.fourier_tail_polynomial_degree 89 (bravermanSwitches j) hdepth + (bravermanSwitches_pos j)).trans + have hreal : (E.size : ℝ) ≤ (2 : ℝ) ^ bravermanErrorExponent j := by + exact_mod_cast hsize + gcongr + have hF (x) : c.indicator x = 0 ∨ c.indicator x = 1 := by + cases he : c.eval x <;> simp [AC0Circuit.indicator, he] + have hbound : 1 ≤ (2 : ℝ) ^ bravermanNormExponent j := one_le_pow₀ (by norm_num) + have hdegree : (bravermanBase j ^ 22 + D) + (bravermanBase j ^ 22 + D) ≤ t := by + dsimp [bravermanDegree] at ht + dsimp [D] + omega + have hh := hwise.approximation_lower hg hmean hF hP + (walshTruncation_degree E.indicator D) hdegree + (fun x hx => hexact x (by simp [hx])) hbound hnorm hprob herror + have hloss := braverman_total_loss j + linarith + +theorem AC0Circuit.dyadic_comparison {n j t : ℕ} (c : AC0Circuit n) + (hc : c.depth ≤ 22) (hm : c.size ≤ 2 ^ j) (ht : bravermanDegree j ≤ t) + (g : BooleanCube n → ℝ) (hg : ∀ x, 0 ≤ g x) (hmean : cubeAverage g = 1) + (hwise : TWiseUniformDensity g t) : + |cubeAverage (fun x => g x * c.indicator x) - cubeAverage c.indicator| ≤ + (1 / 2 : ℝ) ^ j := by + have hlo := c.dyadic_comparison_lower hc hm ht g hg hmean hwise + have hhi := c.negate.dyadic_comparison_lower (by simpa [AC0Circuit.negate_depth] using hc) + (by simpa [AC0Circuit.negate_size] using hm) ht g hg hmean hwise + have hu : cubeAverage c.negate.indicator = 1 - cubeAverage c.indicator := by + change cubeAverage (fun x => c.negate.indicator x) = _ + simp_rw [AC0Circuit.negate_indicator] + rw [cubeAverage_sub, cubeAverage_const] + have hgneg : cubeAverage (fun x => g x * c.negate.indicator x) = + 1 - cubeAverage (fun x => g x * c.indicator x) := by + simp_rw [AC0Circuit.negate_indicator, mul_sub, mul_one] + rw [cubeAverage_sub, hmean] + rw [hu, hgneg] at hhi + exact abs_le.mpr ⟨by linarith, by linarith⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicErrors.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicErrors.lean new file mode 100644 index 0000000000000000000000000000000000000000..f18fc648822cdd1a96c996176eda53da8d2ad85c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicErrors.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitDyadicBudgets + +namespace OAI + +/-! The two losses in Braverman's comparison fit a common dyadic error +budget. These are scalar inequalities, independent of the circuit. -/ + +namespace TwoPointCorrelations + +lemma dyadic_cancel (a b : ℕ) : + (2 : ℝ) ^ a * (1 / 2 : ℝ) ^ (a + b) = (1 / 2 : ℝ) ^ b := by + rw [pow_add] + calc + _ = (2 * (1 / 2) : ℝ) ^ a * (1 / 2 : ℝ) ^ b := by rw [mul_pow]; ring + _ = _ := by norm_num + +lemma braverman_exception_loss (j : ℕ) : + 8 * ((2 : ℝ) ^ j * (7 / 8 : ℝ) ^ bravermanSamples j) ≤ + (1 / 2 : ℝ) ^ (j + 1) := by + have hsmall : (7 / 8 : ℝ) ^ bravermanSamples j ≤ (1 / 2 : ℝ) ^ (2 * j + 4) := by + calc + _ = ((7 / 8 : ℝ) ^ 40) ^ (j + 1) := by rw [← pow_mul]; rfl + _ ≤ ((1 / 2 : ℝ) ^ 5) ^ (j + 1) := + pow_le_pow_left₀ (by positivity) (by norm_num) _ + _ = (1 / 2 : ℝ) ^ (5 * (j + 1)) := by rw [pow_mul] + _ ≤ _ := pow_le_pow_of_le_one (by norm_num) (by norm_num) (by omega) + calc + _ ≤ 8 * ((2 : ℝ) ^ j * (1 / 2 : ℝ) ^ (2 * j + 4)) := by gcongr + _ = (2 : ℝ) ^ (j + 3) * (1 / 2 : ℝ) ^ ((j + 3) + (j + 1)) := by + have hcoef : 8 * (2 : ℝ) ^ j = (2 : ℝ) ^ (j + 3) := by rw [pow_add]; ring + rw [← mul_assoc, hcoef] + congr 2 + omega + _ = _ := dyadic_cancel _ _ + +lemma braverman_spectral_loss (j : ℕ) : + 2 * ((2 : ℝ) ^ bravermanNormExponent j) ^ 2 * + (4 * (2 : ℝ) ^ bravermanErrorExponent j * + (1 / 2 : ℝ) ^ (bravermanSwitches j + 1)) ≤ + (1 / 2 : ℝ) ^ (j + 1) := by + let a := 2 * bravermanNormExponent j + bravermanErrorExponent j + 3 + have he : bravermanSwitches j + 1 = a + (j + 8) := by + dsimp [bravermanSwitches, a] + omega + have hcoef : 2 * ((2 : ℝ) ^ bravermanNormExponent j) ^ 2 * + (4 * (2 : ℝ) ^ bravermanErrorExponent j) = (2 : ℝ) ^ a := by + dsimp [a] + rw [pow_add, pow_add, show 2 * bravermanNormExponent j = + bravermanNormExponent j * 2 by omega, pow_mul] + ring + calc + _ = (2 : ℝ) ^ a * (1 / 2 : ℝ) ^ (a + (j + 8)) := by + rw [he] + rw [← mul_assoc, hcoef] + _ = (1 / 2 : ℝ) ^ (j + 8) := dyadic_cancel _ _ + _ ≤ _ := pow_le_pow_of_le_one (by norm_num) (by norm_num) (by omega) + +lemma braverman_total_loss (j : ℕ) : + 8 * ((2 : ℝ) ^ j * (7 / 8 : ℝ) ^ bravermanSamples j) + + 2 * ((2 : ℝ) ^ bravermanNormExponent j) ^ 2 * + (4 * (2 : ℝ) ^ bravermanErrorExponent j * + (1 / 2 : ℝ) ^ (bravermanSwitches j + 1)) ≤ (1 / 2 : ℝ) ^ j := by + have h₁ := braverman_exception_loss j + have h₂ := braverman_spectral_loss j + have he : (1 / 2 : ℝ) ^ (j + 1) + (1 / 2 : ℝ) ^ (j + 1) = + (1 / 2 : ℝ) ^ j := by rw [pow_succ]; ring + exact (add_le_add h₁ h₂).trans_eq he + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicSampling.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicSampling.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b88571d2f0d08150f0aab6387b13a079e30c12f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitDyadicSampling.lean @@ -0,0 +1,40 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitBernoulli +import Mathlib.Data.Nat.Log + +namespace OAI + +/-! Only logarithmically many Bernoulli parameters are needed to isolate a +zero among the inputs of an AND gate. The success constant 1/8 is sufficient +for the application's unspecified absolute circuit constants. -/ + +namespace TwoPointCorrelations + +lemma exists_dyadic_single_hit (k z : ℕ) (hz : 0 < z) (hzk : z ≤ k) : + ∃ a : ℕ, a ≤ Nat.log 2 k + 2 ∧ + 1 / 8 ≤ (z : ℝ) * (1 / (2 : ℝ) ^ a) * + (1 - 1 / (2 : ℝ) ^ a) ^ (z - 1) := by + let l := Nat.log 2 z + have hlog := Nat.log_mono_right (b := 2) hzk + refine ⟨l + 2, by dsimp only [l]; omega, ?_⟩ + have hlow : (2 : ℝ) ^ l ≤ z := by + exact_mod_cast Nat.pow_log_le_self 2 (Nat.ne_of_gt hz) + have hhigh : (z : ℝ) < (2 : ℝ) ^ (l + 1) := by + exact_mod_cast (Nat.log_lt_iff_lt_pow (by norm_num : 1 < 2) + (Nat.ne_of_gt hz)).mp (Nat.lt_succ_self l) + have hpow : (2 : ℝ) ^ (l + 2) = 4 * (2 : ℝ) ^ l := by + rw [pow_add] + norm_num + ring + have hpow' : (2 : ℝ) ^ (l + 2) = 2 * (2 : ℝ) ^ (l + 1) := by + rw [show l + 2 = (l + 1) + 1 by omega, pow_add] + ring + have hpos : (0 : ℝ) < (2 : ℝ) ^ (l + 2) := by positivity + apply single_hit_probability_lower z hz _ (by positivity) + · rw [mul_one_div, div_le_iff₀ hpos, hpow'] + linarith + · rw [mul_one_div, le_div_iff₀ hpos, hpow] + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitEncoding.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..90ae221964c9fe1782ab852d764af188972fda60 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitEncoding.lean @@ -0,0 +1,180 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitComparison +import OAI.NumberTheory.TwoPoint.Circuits.BitEncoding + +namespace OAI + +/-! +# Truth-table encoding and substitution for residue circuits + +Any decoded residue equality is a Boolean function of its block of bits. +Its explicit disjunctive normal form has depth at most two and size at most +`1 + 2^B (1+B)`. Substituting such forms into the actual circuit syntax +increases depth by at most two and multiplies size by this bound. +-/ + +namespace TwoPointCorrelations.AC0Circuit + +open Finset + +/-- Replace each positive or negative input literal by a circuit. -/ +def substitute {n m : ℕ} (σ : Fin n → Bool → AC0Circuit m) : AC0Circuit n → AC0Circuit m + | .literal i positive => σ i positive + | .andGate children => .andGate (fun i => substitute σ (children i)) + | .orGate children => .orGate (fun i => substitute σ (children i)) + +lemma substitute_eval {n m : ℕ} (σ : Fin n → Bool → AC0Circuit m) + (F : BooleanCube m → BooleanCube n) + (hσ : ∀ i positive x, (σ i positive).eval x = if positive then F x i else !(F x i)) + (c : AC0Circuit n) (x : BooleanCube m) : (substitute σ c).eval x = c.eval (F x) := by + induction c with + | literal i positive => exact hσ i positive x + | andGate children ih => simp only [substitute, eval, ih] + | orGate children ih => simp only [substitute, eval, ih] + +lemma substitute_depth {n m d : ℕ} (σ : Fin n → Bool → AC0Circuit m) + (hσ : ∀ i positive, (σ i positive).depth ≤ d) (c : AC0Circuit n) : + (substitute σ c).depth ≤ c.depth + d := by + induction c with + | literal i positive => simpa [substitute, depth] using hσ i positive + | andGate children ih => + simp only [substitute, depth] + have hs : (Finset.univ.sup fun i => (substitute σ (children i)).depth) ≤ + (Finset.univ.sup fun i => (children i).depth) + d := by + apply Finset.sup_le + intro i hi + exact (ih i).trans (Nat.add_le_add_right (Finset.le_sup (f := fun i => (children i).depth) hi) d) + omega + | orGate children ih => + simp only [substitute, depth] + have hs : (Finset.univ.sup fun i => (substitute σ (children i)).depth) ≤ + (Finset.univ.sup fun i => (children i).depth) + d := by + apply Finset.sup_le + intro i hi + exact (ih i).trans (Nat.add_le_add_right (Finset.le_sup (f := fun i => (children i).depth) hi) d) + omega + +lemma substitute_size {n m K : ℕ} (σ : Fin n → Bool → AC0Circuit m) + (hK : 1 ≤ K) (hσ : ∀ i positive, (σ i positive).size ≤ K) (c : AC0Circuit n) : + (substitute σ c).size ≤ K * c.size := by + induction c with + | literal i positive => simpa [substitute, size] using hσ i positive + | andGate children ih => + simp only [substitute, size] + calc + 1 + ∑ i, (substitute σ (children i)).size ≤ K + ∑ i, K * (children i).size := + Nat.add_le_add hK (Finset.sum_le_sum (fun i _ => ih i)) + _ = K * (1 + ∑ i, (children i).size) := by rw [← Finset.mul_sum]; ring + | orGate children ih => + simp only [substitute, size] + calc + 1 + ∑ i, (substitute σ (children i)).size ≤ K + ∑ i, K * (children i).size := + Nat.add_le_add hK (Finset.sum_le_sum (fun i _ => ih i)) + _ = K * (1 + ∑ i, (children i).size) := by rw [← Finset.mul_sum]; ring + +/-- Conjunction specifying one assignment on a selected block of bits. -/ +def assignmentTerm {n B : ℕ} (v : Fin B → Fin n) (z : BooleanCube B) : AC0Circuit n := + .andGate (fun i => .literal (v i) (z i)) + +/-- The constant false circuit, used for rejected rows of a truth table. -/ +def falseCircuit (n : ℕ) : AC0Circuit n := .orGate (fun i : Fin 0 => Fin.elim0 i) + +lemma literal_eval_true {n : ℕ} (i : Fin n) (positive : Bool) (x : BooleanCube n) : + (.literal i positive : AC0Circuit n).eval x = true ↔ x i = positive := by + cases h : x i <;> cases positive <;> simp [eval, h] + +lemma assignmentTerm_eval_true {n B : ℕ} (v : Fin B → Fin n) + (z : BooleanCube B) (x : BooleanCube n) : + (assignmentTerm v z).eval x = true ↔ (fun i => x (v i)) = z := by + change (decide (∀ i : Fin B, (.literal (v i) (z i) : AC0Circuit n).eval x = true) = true) ↔ _ + constructor + · intro h + funext i + exact (literal_eval_true (v i) (z i) x).mp ((of_decide_eq_true h) i) + · intro h + apply decide_eq_true + intro i + exact (literal_eval_true (v i) (z i) x).mpr (congrFun h i) + +@[simp] lemma falseCircuit_eval (n : ℕ) (x : BooleanCube n) : + (falseCircuit n).eval x = false := by simp [falseCircuit, eval] + +/-- Explicit DNF with one possible conjunction for each of the `2^B` rows. -/ +noncomputable def truthTable {n B : ℕ} (v : Fin B → Fin n) + (F : BooleanCube B → Bool) : AC0Circuit n := + .orGate (fun k : Fin (2 ^ B) => + if F (binaryCellEquiv B k) then assignmentTerm v (binaryCellEquiv B k) + else falseCircuit n) + +lemma truthTable_eval {n B : ℕ} (v : Fin B → Fin n) (F : BooleanCube B → Bool) + (x : BooleanCube n) : (truthTable v F).eval x = F (fun i => x (v i)) := by + apply Bool.eq_iff_iff.mpr + simp only [truthTable, eval, decide_eq_true_eq] + constructor + · rintro ⟨k, hk⟩ + split_ifs at hk with hF + · have heq := (assignmentTerm_eval_true v (binaryCellEquiv B k) x).mp hk + rwa [heq] + · simp only [falseCircuit_eval, Bool.false_eq_true] at hk + · intro hF + refine ⟨(binaryCellEquiv B).symm (fun i => x (v i)), ?_⟩ + simp only [Equiv.apply_symm_apply, hF, ite_true] + exact (assignmentTerm_eval_true v _ x).mpr rfl + +lemma assignmentTerm_depth {n B : ℕ} (v : Fin B → Fin n) (z : BooleanCube B) : + (assignmentTerm v z).depth = 1 := by simp [assignmentTerm, depth] + +lemma assignmentTerm_size {n B : ℕ} (v : Fin B → Fin n) (z : BooleanCube B) : + (assignmentTerm v z).size = 1 + B := by simp [assignmentTerm, size] + +lemma truthTable_depth {n B : ℕ} (v : Fin B → Fin n) (F : BooleanCube B → Bool) : + (truthTable v F).depth ≤ 2 := by + change 1 + (Finset.univ.sup fun k : Fin (2 ^ B) => + (if F (binaryCellEquiv B k) then assignmentTerm v (binaryCellEquiv B k) + else falseCircuit n).depth) ≤ 2 + have hs : (Finset.univ.sup fun k : Fin (2 ^ B) => + (if F (binaryCellEquiv B k) then assignmentTerm v (binaryCellEquiv B k) + else falseCircuit n).depth) ≤ 1 := by + apply Finset.sup_le + intro k _ + split_ifs <;> simp [assignmentTerm_depth, falseCircuit, depth] + omega + +lemma truthTable_size {n B : ℕ} (v : Fin B → Fin n) (F : BooleanCube B → Bool) : + (truthTable v F).size ≤ 1 + 2 ^ B * (1 + B) := by + change 1 + (∑ k : Fin (2 ^ B), + (if F (binaryCellEquiv B k) then assignmentTerm v (binaryCellEquiv B k) + else falseCircuit n).size) ≤ _ + apply Nat.add_le_add_left + calc + _ ≤ ∑ _k : Fin (2 ^ B), (1 + B) := by + apply Finset.sum_le_sum + intro k _ + split_ifs <;> simp [assignmentTerm_size, falseCircuit, size] + _ = 2 ^ B * (1 + B) := by simp + +/-- Encode each residue input using a truth table on its own selected bits. -/ +noncomputable def encodeInputs {n m B : ℕ} (v : Fin n → Fin B → Fin m) + (F : Fin n → BooleanCube B → Bool) (c : AC0Circuit n) : AC0Circuit m := + substitute (fun i positive => truthTable (v i) + (fun z => if positive then F i z else !(F i z))) c + +lemma encodeInputs_eval {n m B : ℕ} (v : Fin n → Fin B → Fin m) + (F : Fin n → BooleanCube B → Bool) (c : AC0Circuit n) (x : BooleanCube m) : + (encodeInputs v F c).eval x = c.eval (fun i => F i (fun j => x (v i j))) := by + apply substitute_eval + intro i positive y + exact truthTable_eval _ _ y + +lemma encodeInputs_depth {n m B : ℕ} (v : Fin n → Fin B → Fin m) + (F : Fin n → BooleanCube B → Bool) (c : AC0Circuit n) : + (encodeInputs v F c).depth ≤ c.depth + 2 := + substitute_depth _ (fun _ _ => truthTable_depth _ _) c + +lemma encodeInputs_size {n m B : ℕ} (v : Fin n → Fin B → Fin m) + (F : Fin n → BooleanCube B → Bool) (c : AC0Circuit n) : + (encodeInputs v F c).size ≤ (1 + 2 ^ B * (1 + B)) * c.size := + substitute_size _ (by omega) (fun _ _ => truthTable_size _ _) c + +end TwoPointCorrelations.AC0Circuit + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitErrorCutoff.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitErrorCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..b12991b3a1bfd542025984d3abc63d4a213e99f0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitErrorCutoff.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitSemiExact + +namespace OAI + +/-! The algebraic error-cutoff step of Braverman's Lemma 10. A Fourier +approximation of the exceptional event suppresses the large polynomial +values on that event while preserving exact zeros. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +noncomputable def exceptionalExtension {n : ℕ} (F : BooleanCube n → ℝ) + (E : BooleanCube n → Bool) (x : BooleanCube n) : ℝ := + if E x then 1 else F x + +noncomputable def errorCutoffPolynomial {n : ℕ} (P T : BooleanCube n → ℝ) + (x : BooleanCube n) : ℝ := P x * (1 - T x) + +lemma exceptionalExtension_boolean {n : ℕ} {F : BooleanCube n → ℝ} + (hF : ∀ x, F x = 0 ∨ F x = 1) (E : BooleanCube n → Bool) (x : BooleanCube n) : + exceptionalExtension F E x = 0 ∨ exceptionalExtension F E x = 1 := by + unfold exceptionalExtension + split_ifs + · exact Or.inr rfl + · exact hF x + +lemma errorCutoffPolynomial_zero {n : ℕ} {F P T : BooleanCube n → ℝ} + {E : BooleanCube n → Bool} (he : ∀ x, E x = false → P x = F x) + (x : BooleanCube n) (hx : exceptionalExtension F E x = 0) : + errorCutoffPolynomial P T x = 0 := by + have hE : E x = false := by + cases h : E x <;> simp_all [exceptionalExtension] + have hF : F x = 0 := by simpa [exceptionalExtension, hE] using hx + simp [errorCutoffPolynomial, he x hE, hF] + +lemma errorCutoffPolynomial_degree {n p q : ℕ} {P T : BooleanCube n → ℝ} + (hP : WalshDegreeLE P p) (hT : WalshDegreeLE T q) : + WalshDegreeLE (errorCutoffPolynomial P T) (p + q) := + hP.mul ((WalshDegreeLE.const 1 q).sub hT) + +lemma errorCutoffPolynomial_sq_bound {n : ℕ} {F P T : BooleanCube n → ℝ} + {E : BooleanCube n → Bool} (hF : ∀ x, F x = 0 ∨ F x = 1) + (he : ∀ x, E x = false → P x = F x) {B : ℝ} (hB : 1 ≤ B) + (hP : ∀ x, |P x| ≤ B) (x : BooleanCube n) : + (exceptionalExtension F E x - errorCutoffPolynomial P T x) ^ 2 ≤ + 2 * (if E x then (1 : ℝ) else 0) + + 2 * B ^ 2 * ((if E x then (1 : ℝ) else 0) - T x) ^ 2 := by + have hp : (P x) ^ 2 ≤ B ^ 2 := by + have ha := abs_le.mp (hP x) + nlinarith + have hBsq : 1 ≤ B ^ 2 := by nlinarith + cases hE : E x + · have heq := he x hE + rcases hF x with hf | hf + · simp [exceptionalExtension, errorCutoffPolynomial, hE, heq, hf] + positivity + · simp only [exceptionalExtension, errorCutoffPolynomial, hE, + Bool.false_eq_true, ite_false, heq, hf, one_mul, mul_zero, zero_add] + have hh := mul_le_mul_of_nonneg_right hBsq (sq_nonneg (T x)) + nlinarith only [hh, sq_nonneg (T x)] + · simp only [exceptionalExtension, errorCutoffPolynomial, hE, ite_true] + have hh := mul_le_mul_of_nonneg_right hp (sq_nonneg (1 - T x)) + nlinarith only [hh, sq_nonneg (1 + P x * (1 - T x))] + +theorem errorCutoffPolynomial_mean_sq {n : ℕ} {F P T : BooleanCube n → ℝ} + {E : BooleanCube n → Bool} (hF : ∀ x, F x = 0 ∨ F x = 1) + (he : ∀ x, E x = false → P x = F x) {B δ ε : ℝ} (hB : 1 ≤ B) + (hP : ∀ x, |P x| ≤ B) + (hE : cubeAverage (fun x => if E x then (1 : ℝ) else 0) ≤ δ) + (hT : cubeAverage (fun x => ((if E x then (1 : ℝ) else 0) - T x) ^ 2) ≤ ε) : + cubeAverage (fun x => + (exceptionalExtension F E x - errorCutoffPolynomial P T x) ^ 2) ≤ + 2 * δ + 2 * B ^ 2 * ε := by + have hh := cubeAverage_mono (errorCutoffPolynomial_sq_bound (T := T) hF he hB hP) + rw [cubeAverage_add, cubeAverage_mul_const, cubeAverage_mul_const] at hh + exact hh.trans (add_le_add (mul_le_mul_of_nonneg_left hE (by norm_num)) + (mul_le_mul_of_nonneg_left hT (by positivity))) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitExceptionBudget.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitExceptionBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c4d76655a9e1a367ffbaa0d980a7b10d9df6484 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitExceptionBudget.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitOrCertificate + +namespace OAI + +/-! The recursive error certificate has polynomial size. Only this coarse +bound, rather than the detailed shape of its gates, is used by the next stage. -/ + +namespace TwoPointCorrelations.AC0Circuit + +open Finset +open scoped Classical + +def exceptionPolynomialBound (m s : ℕ) : ℕ := + 5 + m + s * (Nat.log 2 m + 3) * (1 + m * (1 + m)) + +theorem exceptionSizeBound_le {n : ℕ} (s : ℕ) (c : AC0Circuit n) + (m : ℕ) (hm : c.size ≤ m) : + c.exceptionSizeBound s ≤ exceptionPolynomialBound m s * c.size := by + induction c generalizing m with + | literal i b => + simp only [exceptionSizeBound, size, mul_one, exceptionPolynomialBound] + omega + | @andGate k c ih | @orGate k c ih => + have hm' : 1 + ∑ i, (c i).size ≤ m := hm + have hsize (i : Fin k) : (c i).size ≤ m := by + have hh := single_le_sum (fun j _ => Nat.zero_le (c j).size) (mem_univ i) + omega + have hcount : k ≤ ∑ i, (c i).size := by + calc + k = ∑ _i : Fin k, 1 := by simp + _ ≤ _ := sum_le_sum (fun i _ => (c i).size_pos) + have hk : k ≤ m := by omega + have hsum : ∑ i, (c i).exceptionSizeBound s ≤ + exceptionPolynomialBound m s * ∑ i, (c i).size := by + rw [mul_sum] + exact sum_le_sum (fun i _ => ih i m (hsize i)) + have hlocal : 4 + (∑ i, (c i).size) + s * (Nat.log 2 k + 3) * + (1 + k * (1 + ∑ i, (c i).size)) ≤ exceptionPolynomialBound m s := by + unfold exceptionPolynomialBound + have hsumsize : ∑ i, (c i).size ≤ m := by omega + have hlog := Nat.log_mono_right (b := 2) hk + gcongr + norm_num + change 4 + (∑ i, (c i).size) + s * (Nat.log 2 k + 3) * + (1 + k * (1 + ∑ i, (c i).size)) + ∑ i, (c i).exceptionSizeBound s ≤ + exceptionPolynomialBound m s * (1 + ∑ i, (c i).size) + calc + _ ≤ exceptionPolynomialBound m s + + exceptionPolynomialBound m s * ∑ i, (c i).size := Nat.add_le_add hlocal hsum + _ = _ := by ring + +end TwoPointCorrelations.AC0Circuit + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitFiniteCodes.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitFiniteCodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..0643e8cb1a83ce06a7af0b6552ac33a51329c5ed --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitFiniteCodes.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitBlockCode +import Mathlib.Data.List.OfFn + +namespace OAI + +/-! The finite alphabet for query positions and responses. Allowing one +separator per block at most doubles the length of a query code. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +abbrev BoundedRestrictionCode (w k : ℕ) := + Σ l : Fin (k + 1), Fin l.val → Option (Fin (w + 1) × Bool) + +def readRestrictionCode {w k : ℕ} (c : BoundedRestrictionCode w k) : + List (Option (ℕ × Bool)) := + List.ofFn (fun i => (c.2 i).map (fun z => (z.1.val, z.2))) + +noncomputable def packRestrictionSymbol (w : ℕ) (z : Option (ℕ × Bool)) + (hz : ∀ a b, z = some (a, b) → a ≤ w) : Option (Fin (w + 1) × Bool) := + match z with + | none => none + | some (a, b) => some (⟨a, Nat.lt_succ_of_le (hz a b rfl)⟩, b) + +lemma read_packRestrictionSymbol (w : ℕ) (z : Option (ℕ × Bool)) + (hz : ∀ a b, z = some (a, b) → a ≤ w) : + (packRestrictionSymbol w z hz).map (fun v => (v.1.val, v.2)) = z := by + cases z with + | none => rfl + | some z => cases z; rfl + +noncomputable def packRestrictionCode (w k : ℕ) (l : List (Option (ℕ × Bool))) + (hl : l.length ≤ k) + (hw : ∀ z ∈ l, ∀ a b, z = some (a, b) → a ≤ w) : BoundedRestrictionCode w k := + ⟨⟨l.length, Nat.lt_succ_of_le hl⟩, fun i => packRestrictionSymbol w (l.get i) + (hw (l.get i) (List.get_mem l i))⟩ + +lemma read_packRestrictionCode (w k : ℕ) (l : List (Option (ℕ × Bool))) + (hl : l.length ≤ k) + (hw : ∀ z ∈ l, ∀ a b, z = some (a, b) → a ≤ w) : + readRestrictionCode (packRestrictionCode w k l hl hw) = l := by + unfold readRestrictionCode packRestrictionCode + simp only [read_packRestrictionSymbol] + exact List.ofFn_get l + +lemma boundedRestrictionCode_card (w k : ℕ) : + Fintype.card (BoundedRestrictionCode w k) ≤ (k + 1) * (2 * w + 3) ^ k := by + rw [Fintype.card_sigma] + calc + _ = ∑ l : Fin (k + 1), (2 * w + 3) ^ l.val := by + apply sum_congr rfl + intro l _ + simp [Nat.add_mul, Nat.mul_comm, Nat.add_assoc] + _ ≤ ∑ _l : Fin (k + 1), (2 * w + 3) ^ k := by + apply sum_le_sum + intro l _ + exact Nat.pow_le_pow_right (by omega) (Nat.le_of_lt_succ l.isLt) + _ = _ := by simp + +lemma two_mul_add_one_le_three_pow (h : ℕ) : 2 * h + 1 ≤ 3 ^ h := by + induction h with + | zero => norm_num + | succ h ih => + have hp : 1 ≤ 3 ^ h := Nat.one_le_pow h 3 (by omega) + rw [pow_succ] + omega + +lemma boundedRestrictionCode_card_queries (w h : ℕ) : + Fintype.card (BoundedRestrictionCode w (2 * h)) ≤ + (3 * (2 * w + 3) ^ 2) ^ h := by + apply (boundedRestrictionCode_card w (2 * h)).trans + calc + (2 * h + 1) * (2 * w + 3) ^ (2 * h) ≤ 3 ^ h * (2 * w + 3) ^ (2 * h) := + Nat.mul_le_mul_right _ (two_mul_add_one_le_three_pow h) + _ = _ := by rw [mul_pow, ← pow_mul] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitFourierDegree.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitFourierDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c81a770c3fa23a81c6c977b0c3fe6e03ad39e1c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitFourierDegree.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitFourierSwitching + +namespace OAI + +/-! A polynomial degree bound and exponential Fourier error, with no +analytic parameter hypotheses left over from the switching argument. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +def switchingDenominator (r : ℕ) : ℕ := 24 * (2 * r + 3) ^ 2 + +def switchingDegree (d r : ℕ) : ℕ := 8 * (r + 1) * switchingDenominator r ^ d + +lemma switchingDenominator_pos (r : ℕ) : 0 < switchingDenominator r := by + unfold switchingDenominator + positivity + +theorem AC0Circuit.fourier_tail_polynomial_degree {n : ℕ} (c : AC0Circuit n) + (d r : ℕ) (hc : c.depth ≤ d) (hr : 1 ≤ r) : + cubeAverage (fun x => (c.indicator x - + walshTruncation c.indicator (switchingDegree d r) x) ^ 2) ≤ + 4 * (c.size : ℝ) * (1 / 2 : ℝ) ^ (r + 1) := by + let R : ℝ := switchingDenominator r + let p : ℝ := 1 / R + have hR : 0 < R := by + dsimp [R] + exact_mod_cast switchingDenominator_pos r + have hR2 : 2 ≤ R := by + dsimp [R, switchingDenominator] + push_cast + nlinarith [sq_nonneg (2 * (r : ℝ) + 2), show (0 : ℝ) ≤ r from Nat.cast_nonneg r] + have hp : 0 ≤ p := by dsimp [p]; positivity + have hphalf : p ≤ 1 / 2 := by + dsimp [p] + exact (div_le_div_iff₀ hR (by norm_num)).mpr (by linarith) + have hp1 : p < 1 := lt_of_le_of_lt hphalf (by norm_num) + have hRp : R * p = 1 := by dsimp [p]; field_simp + have hA : ((3 * (2 * r + 3) ^ 2 : ℕ) : ℝ) * 8 = R := by + dsimp [R, switchingDenominator] + push_cast + ring + have hq : ((3 * (2 * r + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p)) ≤ 1 / 2 := by + rw [← mul_div_assoc] + apply (div_le_iff₀ (show 0 < 1 - p by linarith)).mpr + rw [← hA] at hRp + nlinarith [hRp] + have hmain : p ^ d * (switchingDegree d r : ℝ) = 8 * (r + 1 : ℝ) := by + dsimp [switchingDegree, p, R] + push_cast + field_simp [ne_of_gt (show (0 : ℝ) < switchingDenominator r from hR)] + rw [← mul_pow] + simp [ne_of_gt (show (0 : ℝ) < switchingDenominator r from hR)] + have hprod : 8 * (r + 1 : ℝ) ≤ p ^ d * ((switchingDegree d r : ℝ) + 1) := by + calc + _ = p ^ d * (switchingDegree d r : ℝ) := hmain.symm + _ ≤ _ := mul_le_mul_of_nonneg_left (by linarith) (pow_nonneg hp _) + have hh := c.fourier_tail_switching p hp hp1 r hr hq d (switchingDegree d r) hc + (by nlinarith [show (0 : ℝ) ≤ r by positivity]) (by linarith) + apply hh.trans + exact mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (by positivity) hq _) + (by positivity) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitFourierSwitching.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitFourierSwitching.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d873e9f9568b39cd1c5ff5d5fc99c7ea2e93bc4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitFourierSwitching.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitDepthSwitching +import OAI.NumberTheory.TwoPoint.Circuits.CircuitRestrictionDecay + +namespace OAI + +/-! Quantitative Fourier concentration obtained from the proved switching +estimate. All parameters remain explicit for the fixed-depth application. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +theorem fourier_tail_le_small_tree_failure {n : ℕ} (f : BooleanCube n → Bool) + (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) (r D : ℕ) + (hr : 2 * (r : ℝ) ≤ p * (D + 1)) (hD : 8 ≤ p * (D + 1)) : + cubeAverage (fun x => ((if f x then (1 : ℝ) else 0) - + walshTruncation (fun y => if f y then 1 else 0) D x) ^ 2) ≤ + 2 * (restrictionLaw n p hp hp1).probability + (fun ρ => ¬ HasSmallDecisionTree (fun x => f (ρ.apply x)) r) := by + have hf (x) : (if f x then (1 : ℝ) else 0) = 0 ∨ + (if f x then (1 : ℝ) else 0) = 1 := by cases f x <;> simp + apply (fourier_tail_le_degree_failure _ hf p hp hp1 r D hr hD).trans + apply mul_le_mul_of_nonneg_left _ (by norm_num) + rw [FiniteLaw.probability, restrictionLaw_average] + apply FiniteLaw.average_mono + intro mask + apply cubeAverage_mono + intro y + by_cases h : HasSmallDecisionTree + (fun x => f ((partialAssignmentOfMask mask y).apply x)) r + · obtain ⟨T, hT, he⟩ := h + have hd : WalshDegreeLE + (fun x => if f (restrictCube (sampledCoordinates mask) y x) then (1 : ℝ) else 0) r := by + have hi : (fun x => if f (restrictCube (sampledCoordinates mask) y x) + then (1 : ℝ) else 0) = T.indicator := by + funext x + simp only [BooleanDecisionTree.indicator, he, partialAssignmentOfMask_apply] + rw [hi] + exact T.indicator_degree.mono hT + simp only [hd, ite_true] + split_ifs <;> norm_num + · simp only [h, not_false_eq_true, ite_true] + split_ifs <;> norm_num + +theorem AC0Circuit.fourier_tail_switching {n : ℕ} (c : AC0Circuit n) + (p : ℝ) (hp : 0 ≤ p) (hp1 : p < 1) (r : ℕ) (hr : 1 ≤ r) + (hq : ((3 * (2 * r + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p)) ≤ 1 / 2) + (d D : ℕ) (hc : c.depth ≤ d) + (hDr : 2 * (r : ℝ) ≤ p ^ d * (D + 1)) (hD : 8 ≤ p ^ d * (D + 1)) : + cubeAverage (fun x => (c.indicator x - walshTruncation c.indicator D x) ^ 2) ≤ + 4 * (c.size : ℝ) * + (((3 * (2 * r + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p))) ^ (r + 1) := by + have hf := fourier_tail_le_small_tree_failure c.eval (p ^ d) (pow_nonneg hp _) + (pow_le_one₀ hp hp1.le) r D hDr hD + apply hf.trans + have hh := c.restriction_shallow p hp hp1 r hr hq d hc + have hmul := mul_le_mul_of_nonneg_left hh (show (0 : ℝ) ≤ 2 by norm_num) + convert hmul using 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitFourierTruncation.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitFourierTruncation.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b5f1864d4ce19e682f16ef6b03282c4ebb83832 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitFourierTruncation.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitWalshExpansion + +namespace OAI + +/-! The canonical low-degree approximation and its exact Fourier-tail error. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def walshTruncation {n : ℕ} (f : BooleanCube n → ℝ) (t : ℕ) + (x : BooleanCube n) : ℝ := + ∑ S ∈ (univ : Finset (Finset (Fin n))).filter (fun S => S.card ≤ t), + walshCoefficient f S * walsh S x + +lemma walshTruncation_degree {n : ℕ} (f : BooleanCube n → ℝ) (t : ℕ) : + WalshDegreeLE (walshTruncation f t) t := ⟨walshCoefficient f, fun _ => rfl⟩ + +lemma walshTruncation_coefficient {n : ℕ} (f : BooleanCube n → ℝ) + (t : ℕ) (S : Finset (Fin n)) : + walshCoefficient (walshTruncation f t) S = + if S.card ≤ t then walshCoefficient f S else 0 := by + unfold walshCoefficient walshTruncation + simp only [sum_mul] + rw [cubeAverage_sum] + simp_rw [mul_assoc, cubeAverage_mul_const, cubeAverage_walsh_mul] + simp [walshCoefficient] + +lemma walshCoefficient_sub {n : ℕ} (f g : BooleanCube n → ℝ) + (S : Finset (Fin n)) : + walshCoefficient (fun x => f x - g x) S = + walshCoefficient f S - walshCoefficient g S := by + unfold walshCoefficient + simp only [sub_mul, cubeAverage_sub] + +theorem walshTruncation_error {n : ℕ} (f : BooleanCube n → ℝ) (t : ℕ) : + cubeAverage (fun x => (f x - walshTruncation f t x) ^ 2) = + ∑ S ∈ (univ : Finset (Finset (Fin n))).filter (fun S => t < S.card), + (walshCoefficient f S) ^ 2 := by + rw [walsh_parseval, sum_filter] + apply sum_congr rfl + intro S _ + rw [walshCoefficient_sub, walshTruncation_coefficient] + by_cases hS : S.card ≤ t + · simp [hS, Nat.not_lt.mpr hS] + · simp [hS, Nat.lt_of_not_ge hS] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitGateApproximation.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitGateApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..38f2386158a3c2ec4e1501d2f440d886706344f0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitGateApproximation.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitGateFailure + +namespace OAI + +/-! A single fixed polynomial approximates an arbitrarily wide AND gate +under any supplied finite input law. The sampling and its error bound are +explicit, and the polynomial degree is bounded by the number of sampled +linear factors. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma FiniteLaw.probability_mono {α : Type*} [Fintype α] + (μ : FiniteLaw α) {E F : α → Prop} (h : ∀ x, E x → F x) : + μ.probability E ≤ μ.probability F := by + unfold FiniteLaw.probability + apply μ.average_mono + intro x + by_cases he : E x + · simp [he, h x he] + · simp [he] + split_ifs <;> norm_num + +theorem gate_pointwise_failure (k s : ℕ) (b : Fin k → Bool) : + (gateSamplingLaw k k s).probability (fun x => + sampledAndPolynomial x (fun i => if b i then 1 else 0) ≠ boolAndValue b) ≤ + (7 / 8 : ℝ) ^ s := by + by_cases hb : ∀ i, b i = true + · have he (x : GateSamplingChoices k k s) : + sampledAndPolynomial x (fun i => if b i then 1 else 0) = boolAndValue b := by + rw [sampledAndPolynomial_all_true x b hb] + unfold boolAndValue + rw [ite_eq_left hb] + have hz : (gateSamplingLaw k k s).probability (fun x => + sampledAndPolynomial x (fun i => if b i then 1 else 0) ≠ boolAndValue b) = 0 := by + unfold FiniteLaw.probability + simp only [he, ne_eq, not_true_eq_false, ite_false] + exact FiniteLaw.average_const _ 0 + rw [hz] + positivity + · have hnonempty : (falseCoordinates b).Nonempty := by + push Not at hb + obtain ⟨i, hi⟩ := hb + refine ⟨i, ?_⟩ + simp only [falseCoordinates, mem_filter, mem_univ, true_and] + cases hbi : b i <;> simp_all + have hcard : (falseCoordinates b).card ≤ k := by + exact (card_le_card (filter_subset _ _)).trans_eq (card_fin k) + exact ((gateSamplingLaw k k s).probability_mono + (fun x hx => sampledAndPolynomial_failure x b hx)).trans + (gateSamplingLaw_failure k k s (falseCoordinates b) hnonempty hcard) + +/-- The probabilistic method fixes all samples simultaneously for the input +law, without imposing a condition on that law. -/ +theorem exists_and_gate_approximation {α : Type*} [Fintype α] + (ν : FiniteLaw α) (k s : ℕ) (b : α → Fin k → Bool) : + ∃ x : GateSamplingChoices k k s, + ν.probability (fun y => + sampledAndPolynomial x (fun i => if b y i then 1 else 0) ≠ boolAndValue (b y)) ≤ + (7 / 8 : ℝ) ^ s := by + exact exists_choice_of_pointwise_failure (gateSamplingLaw k k s) ν _ + (fun y => gate_pointwise_failure k s (b y)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitGateComposition.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitGateComposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..08831ecfca7050321be2e770b48b6b9bfc95038f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitGateComposition.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitGateApproximation +import OAI.NumberTheory.TwoPoint.Bounds.CrudeWordCounting + +namespace OAI + +/-! Recursive use of the sampled gate polynomial. Errors in the child +polynomials are charged by a finite union bound, in addition to the new +gate's sampling error. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem exists_composed_and_approximation {n : ℕ} + (ν : FiniteLaw (BooleanCube n)) (k s d : ℕ) + (b : Fin k → BooleanCube n → Bool) (P : Fin k → BooleanCube n → ℝ) + (hP : ∀ i, WalshDegreeLE (P i) d) (δ : Fin k → ℝ) + (hδ : ∀ i, ν.probability (fun y => P i y ≠ if b i y then 1 else 0) ≤ δ i) : + ∃ Q : BooleanCube n → ℝ, + WalshDegreeLE Q (d * s * (Nat.log 2 k + 3)) ∧ + ν.probability (fun y => Q y ≠ boolAndValue (fun i => b i y)) ≤ + (7 / 8 : ℝ) ^ s + ∑ i, δ i := by + obtain ⟨x, hx⟩ := exists_and_gate_approximation ν k s (fun y i => b i y) + let Q := fun y => sampledAndPolynomial x (fun i => P i y) + refine ⟨Q, sampledAndPolynomial_degree x P d hP, ?_⟩ + let E : Option (Fin k) → BooleanCube n → Prop + | none => fun y => sampledAndPolynomial x (fun i => if b i y then 1 else 0) ≠ + boolAndValue (fun i => b i y) + | some i => fun y => P i y ≠ if b i y then 1 else 0 + have hcover : ∀ y, Q y ≠ boolAndValue (fun i => b i y) → ∃ i, E i y := by + intro y hy + by_cases hc : ∃ i, P i y ≠ if b i y then 1 else 0 + · obtain ⟨i, hi⟩ := hc + exact ⟨some i, hi⟩ + · have heq : (fun i => P i y) = fun i => if b i y then 1 else 0 := by + funext i + by_contra hi + exact hc ⟨i, hi⟩ + refine ⟨none, ?_⟩ + change sampledAndPolynomial x (fun i => if b i y then 1 else 0) ≠ _ + simpa only [Q, heq] using hy + calc + ν.probability (fun y => Q y ≠ boolAndValue (fun i => b i y)) ≤ + ν.probability (fun y => ∃ i, E i y) := ν.probability_mono hcover + _ ≤ ∑ i : Option (Fin k), ν.probability (E i) := ν.probability_exists_le E + _ = ν.probability (E none) + ∑ i : Fin k, ν.probability (E (some i)) := by + simp only [Fintype.sum_option] + _ ≤ (7 / 8 : ℝ) ^ s + ∑ i, δ i := + add_le_add hx (sum_le_sum (fun i _ => hδ i)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitGateFailure.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitGateFailure.lean new file mode 100644 index 0000000000000000000000000000000000000000..5dea90d25424457529e0ba09a63bf709e1056665 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitGateFailure.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitRandomGate +import OAI.NumberTheory.TwoPoint.Circuits.CircuitSamplingGrid + +namespace OAI + +/-! The sampled AND polynomial agrees with the Boolean gate whenever the +samplers isolate a false child; all-true inputs are always exact. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def sampledCoordinates {k : ℕ} (x : BooleanCube k) : Finset (Fin k) := + univ.filter (fun i => x i = true) + +def falseCoordinates {k : ℕ} (b : Fin k → Bool) : Finset (Fin k) := + univ.filter (fun i => b i = false) + +noncomputable def sampledAndPolynomial {k s : ℕ} + (x : GateSamplingChoices k k s) (u : Fin k → ℝ) : ℝ := + ∏ a, ∏ i, andGateFactor (sampledCoordinates (x a i)) u + +noncomputable def boolAndValue {k : ℕ} (b : Fin k → Bool) : ℝ := + if ∀ i, b i = true then 1 else 0 + +lemma sampledAndPolynomial_degree {n k s : ℕ} (x : GateSamplingChoices k k s) + (P : Fin k → BooleanCube n → ℝ) (d : ℕ) (hP : ∀ i, WalshDegreeLE (P i) d) : + WalshDegreeLE (fun y => sampledAndPolynomial x (fun i => P i y)) + (d * s * (Nat.log 2 k + 3)) := by + have hinner (a : Fin (Nat.log 2 k + 3)) : + WalshDegreeLE (fun y => ∏ i : Fin s, + andGateFactor (sampledCoordinates (x a i)) (fun j => P j y)) (d * s) := by + have hh := WalshDegreeLE.prod univ + (fun i y => andGateFactor (sampledCoordinates (x a i)) (fun j => P j y)) d + (fun i _ => WalshDegreeLE.andGateFactor _ P d (fun j _ => hP j)) + simpa only [card_univ, Fintype.card_fin] using hh + have hh := WalshDegreeLE.prod univ + (fun a y => ∏ i : Fin s, + andGateFactor (sampledCoordinates (x a i)) (fun j => P j y)) (d * s) + (fun a _ => hinner a) + change WalshDegreeLE (fun y => ∏ a, ∏ i : Fin s, + andGateFactor (sampledCoordinates (x a i)) (fun j => P j y)) _ + simpa only [card_univ, Fintype.card_fin] using hh + +lemma isolatesOne_card {k : ℕ} {S : Finset (Fin k)} {x : BooleanCube k} + (h : isolatesOne S x) : (S.filter (fun i => x i = true)).card = 1 := by + obtain ⟨i, hi, hx⟩ := h + have heq : S.filter (fun j => x j = true) = {i} := by + ext j + simp only [mem_filter, mem_singleton] + constructor + · rintro ⟨hj, htrue⟩ + have hh := hx j hj + rw [htrue] at hh + simpa [singleBitPattern] using hh.symm + · intro hj + subst j + exact ⟨hi, by simpa [singleBitPattern] using hx i hi⟩ + rw [heq, card_singleton] + +lemma sampled_false_card {k : ℕ} (b : Fin k → Bool) (x : BooleanCube k) + (h : isolatesOne (falseCoordinates b) x) : + ((sampledCoordinates x).filter (fun i => b i = false)).card = 1 := by + have heq : (sampledCoordinates x).filter (fun i => b i = false) = + (falseCoordinates b).filter (fun i => x i = true) := by + ext i + simp only [sampledCoordinates, falseCoordinates, mem_filter, mem_univ, true_and] + tauto + rw [heq] + exact isolatesOne_card h + +lemma sampledAndPolynomial_all_true {k s : ℕ} (x : GateSamplingChoices k k s) + (b : Fin k → Bool) (hb : ∀ i, b i = true) : + sampledAndPolynomial x (fun i => if b i then 1 else 0) = 1 := by + unfold sampledAndPolynomial + have hh (a : Fin (Nat.log 2 k + 3)) (i : Fin s) : + andGateFactor (sampledCoordinates (x a i)) (fun j => if b j then 1 else 0) = 1 := + andGateFactor_all_true _ b (fun j _ => hb j) + simp only [hh, prod_const_one] + +lemma sampledAndPolynomial_isolated {k s : ℕ} (x : GateSamplingChoices k k s) + (b : Fin k → Bool) (h : ∃ a i, isolatesOne (falseCoordinates b) (x a i)) : + sampledAndPolynomial x (fun i => if b i then 1 else 0) = 0 := by + obtain ⟨a, i, hi⟩ := h + unfold sampledAndPolynomial + apply prod_eq_zero (mem_univ a) + apply prod_eq_zero (mem_univ i) + exact andGateFactor_one_false _ b (sampled_false_card b (x a i) hi) + +lemma sampledAndPolynomial_failure {k s : ℕ} (x : GateSamplingChoices k k s) + (b : Fin k → Bool) + (h : sampledAndPolynomial x (fun i => if b i then 1 else 0) ≠ boolAndValue b) : + ∀ a i, ¬isolatesOne (falseCoordinates b) (x a i) := by + have hn : ¬∀ i, b i = true := by + intro hb + apply h + rw [sampledAndPolynomial_all_true x b hb] + exact (ite_eq_left hb).symm + intro a i hi + apply h + rw [sampledAndPolynomial_isolated x b ⟨a, i, hi⟩] + exact (ite_eq_right hn).symm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitGateSwitching.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitGateSwitching.lean new file mode 100644 index 0000000000000000000000000000000000000000..b41fff88930d72b75cd5bbd3b7e9af7d1c1f9af4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitGateSwitching.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitDecisionRestriction +import OAI.NumberTheory.TwoPoint.Circuits.CircuitSwitchingLemma + +namespace OAI + +/-! Switching a gate whose inputs already have shallow decision trees. +The number of clauses is irrelevant to the switching estimate. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def decisionTreeDisjunction {n k : ℕ} (T : Fin k → BooleanDecisionTree n) : + List (CubeTerm n) := + (univ : Finset (Fin k)).toList.flatMap (fun i => (T i).toDNF) + +theorem decisionTreeDisjunction_eval {n k : ℕ} (T : Fin k → BooleanDecisionTree n) + (x : BooleanCube n) : + dnfEval (decisionTreeDisjunction T) x = decide (∃ i, (T i).eval x = true) := by + apply Bool.eq_iff_iff.mpr + simp only [dnfEval_eq_true, decisionTreeDisjunction, List.mem_flatMap, + Finset.mem_toList, mem_univ, true_and, decide_eq_true_eq] + constructor + · rintro ⟨C, ⟨i, hC⟩, he⟩ + exact ⟨i, (T i).toDNF_eval x ▸ (dnfEval_eq_true _ _).mpr ⟨C, hC, he⟩⟩ + · rintro ⟨i, hi⟩ + have hh : dnfEval (T i).toDNF x = true := by rwa [(T i).toDNF_eval] + obtain ⟨C, hC, he⟩ := (dnfEval_eq_true _ _).mp hh + exact ⟨C, ⟨i, hC⟩, he⟩ + +theorem decisionTreeDisjunction_width {n k r : ℕ} (T : Fin k → BooleanDecisionTree n) + (hT : ∀ i, (T i).depth ≤ r) : + ∀ C ∈ decisionTreeDisjunction T, C.support.card ≤ r := by + intro C hC + obtain ⟨i, _, hi⟩ := List.mem_flatMap.mp hC + exact ((T i).toDNF_width C hi).trans (hT i) + +theorem disjunction_restriction_switching {n k r : ℕ} (f : Fin k → BooleanCube n → Bool) + (hf : ∀ i, HasSmallDecisionTree (f i) r) + (p : ℝ) (hp : 0 ≤ p) (hp1 : p < 1) + (hq : ((3 * (2 * r + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p)) ≤ 1 / 2) : + (restrictionLaw n p hp hp1.le).probability (fun ρ => + ¬ HasSmallDecisionTree (fun x => decide (∃ i, f i (ρ.apply x) = true)) r) ≤ + 2 * (((3 * (2 * r + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p))) ^ (r + 1) := by + choose T hT he using hf + have hF := decisionTreeDisjunction_width T hT + have hh := dnf_restriction_has_shallow_tree (decisionTreeDisjunction T) hF p hp hp1 hq r + apply (FiniteLaw.probability_mono _ ?_).trans hh + intro ρ hρ hgood + apply hρ + obtain ⟨S, hS, hs⟩ := hgood + refine ⟨S, hS, ?_⟩ + intro x + rw [hs, decisionTreeDisjunction_eval] + simp only [he] + +theorem conjunction_restriction_switching {n k r : ℕ} (f : Fin k → BooleanCube n → Bool) + (hf : ∀ i, HasSmallDecisionTree (f i) r) + (p : ℝ) (hp : 0 ≤ p) (hp1 : p < 1) + (hq : ((3 * (2 * r + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p)) ≤ 1 / 2) : + (restrictionLaw n p hp hp1.le).probability (fun ρ => + ¬ HasSmallDecisionTree (fun x => decide (∀ i, f i (ρ.apply x) = true)) r) ≤ + 2 * (((3 * (2 * r + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p))) ^ (r + 1) := by + have hh := disjunction_restriction_switching (fun i x => Bool.not (f i x)) + (fun i => (hf i).negate) p hp hp1 hq + apply (FiniteLaw.probability_mono _ ?_).trans hh + intro ρ hρ hgood + apply hρ + have heq : (fun x => Bool.not (decide (∃ i, Bool.not (f i (ρ.apply x)) = true))) = + (fun x => decide (∀ i, f i (ρ.apply x) = true)) := by + funext x + by_cases hall : ∀ i, f i (ρ.apply x) = true + · simp [hall] + · obtain ⟨i, hi⟩ := not_forall.mp hall + have hn : ∃ i, Bool.not (f i (ρ.apply x)) = true := by + refine ⟨i, ?_⟩ + cases h : f i (ρ.apply x) <;> simp_all + simp only [hn, decide_true, Bool.not_true, hall, decide_false] + have hneg := hgood.negate + exact Eq.mp (congrArg (fun f => HasSmallDecisionTree f r) heq) hneg + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitIsolation.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitIsolation.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8157ffeb642c5058bf32b46b5ab1970d814988f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitIsolation.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitDyadicSampling +import OAI.NumberTheory.TwoPoint.Circuits.CircuitProbabilisticMethod +import OAI.NumberTheory.TwoPoint.Bounds.IndependentSampling + +namespace OAI + +/-! Independent repetition amplifies the single-hit experiment. These finite +identities are the random-subset step of the circuit polynomial construction. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def isolatesOne {n : ℕ} (S : Finset (Fin n)) (x : BooleanCube n) : Prop := + ∃ i ∈ S, ∀ j ∈ S, x j = singleBitPattern i j + +lemma singleHitScore_eq_indicator {n : ℕ} (S : Finset (Fin n)) (x : BooleanCube n) : + singleHitScore S x = if isolatesOne S x then 1 else 0 := by + by_cases hx : isolatesOne S x + · rw [ite_eq_left hx] + obtain ⟨i, hi, hxi⟩ := hx + unfold singleHitScore + rw [sum_eq_single i] + · exact ite_eq_left hxi + · intro j hj hji + unfold cubePattern + apply ite_eq_right + intro hxj + have hh := (hxi i hi).symm.trans (hxj i hi) + simp [singleBitPattern, Ne.symm hji] at hh + · exact fun h => (h hi).elim + · rw [ite_eq_right hx] + unfold singleHitScore + apply sum_eq_zero + intro i hi + unfold cubePattern + exact ite_eq_right (fun h => hx ⟨i, hi, h⟩) + +theorem bernoulliCubeLaw_isolatesOne (n : ℕ) (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) + (S : Finset (Fin n)) : + (bernoulliCubeLaw n p hp hp1).probability (isolatesOne S) = + (S.card : ℝ) * p * (1 - p) ^ (S.card - 1) := by + unfold FiniteLaw.probability + have heq : (fun x => if isolatesOne S x then (1 : ℝ) else 0) = singleHitScore S := + funext (fun x => (singleHitScore_eq_indicator S x).symm) + rw [heq] + exact bernoulliCubeLaw_singleHitScore n p hp hp1 S + +lemma FiniteLaw.probability_complement {α : Type*} [Fintype α] + (μ : FiniteLaw α) (E : α → Prop) : + μ.probability (fun x => ¬E x) = 1 - μ.probability E := by + unfold FiniteLaw.probability FiniteLaw.average + calc + _ = ∑ x, (μ.weight x - μ.weight x * (if E x then (1 : ℝ) else 0)) := by + apply sum_congr rfl + intro x _ + by_cases hx : E x <;> simp [hx] + _ = _ := by rw [sum_sub_distrib, μ.total] + +theorem FiniteLaw.independent_failure {α : Type*} [Fintype α] + (μ : FiniteLaw α) (E : α → Prop) (s : ℕ) : + (FiniteLaw.independent (fun _ : Fin s => μ)).probability + (fun x => ∀ i, ¬E (x i)) = (1 - μ.probability E) ^ s := by + calc + _ = ∏ _i : Fin s, μ.probability (fun x => ¬E x) := + FiniteLaw.independent_probability_all (fun _ : Fin s => μ) (fun _ x => ¬E x) + _ = _ := by + simp only [μ.probability_complement, prod_const, card_univ, Fintype.card_fin] + +theorem FiniteLaw.independent_failure_le {α : Type*} [Fintype α] + (μ : FiniteLaw α) (E : α → Prop) (s : ℕ) + (hE : (1 / 8 : ℝ) ≤ μ.probability E) : + (FiniteLaw.independent (fun _ : Fin s => μ)).probability + (fun x => ∀ i, ¬E (x i)) ≤ (7 / 8 : ℝ) ^ s := by + rw [μ.independent_failure] + apply pow_le_pow_left₀ + · linarith [μ.probability_le_one E] + · linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitIsolationEvent.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitIsolationEvent.lean new file mode 100644 index 0000000000000000000000000000000000000000..76d551b0765cc0a3a08158d13e36f5c13a22aebc --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitIsolationEvent.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitBooleanOps +import OAI.NumberTheory.TwoPoint.Circuits.CircuitGateApproximation + +namespace OAI + +/-! The single-hit test used by the random polynomial is itself a small +constant-depth circuit on the original child outputs. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace AC0Circuit + +noncomputable def certificateDisjunction {ι : Type*} [Fintype ι] {n : ℕ} + (c : ι → AC0Circuit n) : AC0Circuit n := + (conjunction (fun i => (c i).negate)).negate + +lemma certificateDisjunction_eval {ι : Type*} [Fintype ι] {n : ℕ} + (c : ι → AC0Circuit n) (x : BooleanCube n) : + (certificateDisjunction c).eval x = true ↔ ∃ i, (c i).eval x = true := by + rw [certificateDisjunction, negate_eval] + simp only [ne_eq, conjunction_eval, negate_eval, not_forall, not_not] + +lemma certificateDisjunction_depth {ι : Type*} [Fintype ι] {n d : ℕ} + (c : ι → AC0Circuit n) (hc : ∀ i, (c i).depth ≤ d) : + (certificateDisjunction c).depth ≤ d + 1 := by + simp only [certificateDisjunction, negate_depth] + exact conjunction_depth _ (fun i => by simpa only [negate_depth] using hc i) + +lemma certificateDisjunction_size {ι : Type*} [Fintype ι] {n : ℕ} + (c : ι → AC0Circuit n) : (certificateDisjunction c).size = 1 + ∑ i, (c i).size := by + simp only [certificateDisjunction, negate_size, conjunction_size] + +noncomputable def uniqueFalseTerm {n k : ℕ} (c : Fin k → AC0Circuit n) + (S : Finset (Fin k)) (i : S) : AC0Circuit n := + conjunction (fun j : S => if j = i then (c j).negate else c j) + +lemma uniqueFalseTerm_eval {n k : ℕ} (c : Fin k → AC0Circuit n) + (S : Finset (Fin k)) (i : S) (x : BooleanCube n) : + (uniqueFalseTerm c S i).eval x = true ↔ + (c i).eval x = false ∧ ∀ j : S, j ≠ i → (c j).eval x = true := by + rw [uniqueFalseTerm, conjunction_eval] + constructor + · intro h + refine ⟨?_, fun j hj => ?_⟩ + · have hi := h i + apply Bool.eq_false_iff.mpr + simpa only [ite_true, negate_eval] using hi + · simpa only [ite_eq_right hj] using h j + · rintro ⟨hi, h⟩ j + by_cases hj : j = i + · subst j + rw [ite_eq_left rfl, negate_eval, hi] + decide + · simpa only [ite_eq_right hj] using h j hj + +noncomputable def uniqueFalseCircuit {n k : ℕ} (c : Fin k → AC0Circuit n) + (S : Finset (Fin k)) : AC0Circuit n := + certificateDisjunction (fun i : S => uniqueFalseTerm c S i) + +lemma uniqueFalseCircuit_eval {n k : ℕ} (c : Fin k → AC0Circuit n) + (S : Finset (Fin k)) (x : BooleanCube n) : + (uniqueFalseCircuit c S).eval x = true ↔ + ∃ i : S, (c i).eval x = false ∧ ∀ j : S, j ≠ i → (c j).eval x = true := by + simp only [uniqueFalseCircuit, certificateDisjunction_eval, uniqueFalseTerm_eval] + +lemma uniqueFalseTerm_depth {n k d : ℕ} (c : Fin k → AC0Circuit n) + (hc : ∀ i, (c i).depth ≤ d) (S : Finset (Fin k)) (i : S) : + (uniqueFalseTerm c S i).depth ≤ d + 1 := by + apply conjunction_depth + intro j + split_ifs <;> simpa only [negate_depth] using hc j + +lemma uniqueFalseCircuit_depth {n k d : ℕ} (c : Fin k → AC0Circuit n) + (hc : ∀ i, (c i).depth ≤ d) (S : Finset (Fin k)) : + (uniqueFalseCircuit c S).depth ≤ d + 2 := by + exact certificateDisjunction_depth _ (uniqueFalseTerm_depth c hc S) + +lemma uniqueFalseTerm_size {n k : ℕ} (c : Fin k → AC0Circuit n) + (S : Finset (Fin k)) (i : S) : + (uniqueFalseTerm c S i).size = 1 + ∑ j : S, (c j).size := by + rw [uniqueFalseTerm, conjunction_size] + congr 1 + apply sum_congr rfl + intro j _ + split_ifs <;> simp only [negate_size] + +lemma uniqueFalseCircuit_size {n k : ℕ} (c : Fin k → AC0Circuit n) + (S : Finset (Fin k)) : + (uniqueFalseCircuit c S).size = 1 + S.card * (1 + ∑ j : S, (c j).size) := by + simp only [uniqueFalseCircuit, certificateDisjunction_size, uniqueFalseTerm_size, sum_const, + card_univ, Fintype.card_coe, nsmul_eq_mul, Nat.cast_id] + +lemma uniqueFalseCircuit_size_le {n k : ℕ} (c : Fin k → AC0Circuit n) + (S : Finset (Fin k)) : + (uniqueFalseCircuit c S).size ≤ 1 + k * (1 + ∑ j, (c j).size) := by + rw [uniqueFalseCircuit_size] + have hcard : S.card ≤ k := (card_le_card (subset_univ S)).trans_eq (card_fin k) + have hsum : ∑ j : S, (c j).size ≤ ∑ j, (c j).size := by + calc + _ = ∑ j ∈ S, (c j).size := sum_coe_sort S (fun j => (c j).size) + _ ≤ _ := sum_le_sum_of_subset_of_nonneg (subset_univ S) (fun _ _ _ => Nat.zero_le _) + exact Nat.add_le_add_left (Nat.mul_le_mul hcard (Nat.add_le_add_left hsum 1)) 1 + +end AC0Circuit + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitLogarithmicBudget.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitLogarithmicBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..9314fd56599de6a5487bcc28ff1a68d5482c3b54 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitLogarithmicBudget.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitPolynomialGrowth + +namespace OAI + +/-! Convert a dyadic accuracy index to the natural logarithm used in the +published fixed-depth bounded-independence input. -/ + +namespace TwoPointCorrelations + +lemma dyadic_index_of_ratio (m : ℕ) (hm : 1 ≤ m) (ε : ℝ) + (hε : 0 < ε) (hεhalf : ε ≤ 1 / 2) : + ∃ j : ℕ, m ≤ 2 ^ j ∧ (1 / 2 : ℝ) ^ j ≤ ε ∧ + (j : ℝ) + 1 ≤ 6 * Real.log ((m : ℝ) / ε) := by + let L := Real.log ((m : ℝ) / ε) + have hmreal : (1 : ℝ) ≤ m := by exact_mod_cast hm + have hratio : (2 : ℝ) ≤ (m : ℝ) / ε := by + apply (le_div_iff₀ hε).mpr + linarith + have hlogtwo : (1 / 2 : ℝ) ≤ Real.log 2 := by + have h := Real.one_sub_inv_le_log_of_pos (by norm_num : (0 : ℝ) < 2) + norm_num at h ⊢ + exact h + have hL : 1 / 2 ≤ L := hlogtwo.trans (Real.log_le_log (by norm_num) hratio) + let j := ⌈2 * L⌉₊ + have hjlo : 2 * L ≤ (j : ℝ) := Nat.le_ceil _ + have hjhi : (j : ℝ) < 2 * L + 1 := Nat.ceil_lt_add_one (by linarith) + have hlogbound : L ≤ (j : ℝ) * Real.log 2 := by + nlinarith [show (0 : ℝ) ≤ j from Nat.cast_nonneg j] + have hx : (m : ℝ) / ε ≤ (2 : ℝ) ^ j := by + apply (Real.log_le_log_iff (by positivity) (by positivity)).mp + simpa only [Real.log_pow] using hlogbound + have hmul : (m : ℝ) ≤ (2 : ℝ) ^ j * ε := (div_le_iff₀ hε).mp hx + have hmle : (m : ℝ) ≤ (2 : ℝ) ^ j := by nlinarith [show (0 : ℝ) < 2 ^ j by positivity] + have heps : (1 / 2 : ℝ) ^ j ≤ ε := by + have hh : (1 : ℝ) / (2 : ℝ) ^ j ≤ ε := + (div_le_iff₀ (by positivity)).mpr (by nlinarith) + simpa only [div_pow, one_pow] using hh + exact ⟨j, by exact_mod_cast hmle, heps, by linarith⟩ + +theorem bravermanDegree_logarithmic_budget : + ∃ K C : ℕ, 0 < K ∧ 0 < C ∧ ∀ m : ℕ, 1 ≤ m → + ∀ ε : ℝ, 0 < ε → ε ≤ 1 / 2 → ∀ t : ℕ, + (K : ℝ) * (Real.log ((m : ℝ) / ε)) ^ C ≤ (t : ℝ) → + ∃ j : ℕ, m ≤ 2 ^ j ∧ (1 / 2 : ℝ) ^ j ≤ ε ∧ bravermanDegree j ≤ t := by + obtain ⟨K, C, hK, hC, hbound⟩ := bravermanDegree_polynomial_positive + refine ⟨K * 6 ^ C, C, by positivity, hC, ?_⟩ + intro m hm ε hε hεhalf t ht + obtain ⟨j, hmj, hjε, hjlog⟩ := dyadic_index_of_ratio m hm ε hε hεhalf + refine ⟨j, hmj, hjε, ?_⟩ + have hj : (bravermanDegree j : ℝ) ≤ (K : ℝ) * ((j : ℝ) + 1) ^ C := by + exact_mod_cast hbound j + have hdeg : (bravermanDegree j : ℝ) ≤ (t : ℝ) := by + calc + _ ≤ _ := hj + _ ≤ (K : ℝ) * (6 * Real.log ((m : ℝ) / ε)) ^ C := by gcongr + _ = ((K * 6 ^ C : ℕ) : ℝ) * (Real.log ((m : ℝ) / ε)) ^ C := by + push_cast + rw [mul_pow] + ring + _ ≤ _ := ht + exact_mod_cast hdeg + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitMixedLaw.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitMixedLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..03ee7d5b3e55c18d117c1056dbd1476dca805600 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitMixedLaw.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitGateApproximation + +namespace OAI + +/-! The half-uniform input law in Braverman's proof. Small exceptional +probability for this law bounds both the uniform and supplied probabilities. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def cubeDensityLaw {n : ℕ} (g : BooleanCube n → ℝ) + (hg : ∀ x, 0 ≤ g x) (hmean : cubeAverage g = 1) : FiniteLaw (BooleanCube n) where + weight x := g x / Fintype.card (BooleanCube n) + nonneg x := div_nonneg (hg x) (Nat.cast_nonneg _) + total := by simpa only [← sum_div, cubeAverage] using hmean + +lemma cubeDensityLaw_average {n : ℕ} (g : BooleanCube n → ℝ) + (hg : ∀ x, 0 ≤ g x) (hmean : cubeAverage g = 1) (f : BooleanCube n → ℝ) : + (cubeDensityLaw g hg hmean).average f = cubeAverage (fun x => g x * f x) := by + unfold FiniteLaw.average cubeDensityLaw cubeAverage + rw [sum_div] + apply sum_congr rfl + intro x _ + ring + +lemma half_uniform_density_mean {n : ℕ} (g : BooleanCube n → ℝ) + (hmean : cubeAverage g = 1) : + cubeAverage (fun x => (g x + 1) / 2) = 1 := by + have heq : (fun x => (g x + 1) / 2) = fun x => (1 / 2 : ℝ) * (g x + 1) := by + funext x + ring + rw [heq, cubeAverage_mul_const, cubeAverage_add, hmean, cubeAverage_const] + norm_num + +noncomputable def mixedCubeLaw {n : ℕ} (g : BooleanCube n → ℝ) + (hg : ∀ x, 0 ≤ g x) (hmean : cubeAverage g = 1) : FiniteLaw (BooleanCube n) := + cubeDensityLaw (fun x => (g x + 1) / 2) (fun x => by have hx := hg x; positivity) + (half_uniform_density_mean g hmean) + +lemma mixedCubeLaw_probability {n : ℕ} (g : BooleanCube n → ℝ) + (hg : ∀ x, 0 ≤ g x) (hmean : cubeAverage g = 1) (E : BooleanCube n → Prop) : + (mixedCubeLaw g hg hmean).probability E = + ((cubeDensityLaw g hg hmean).probability E + + cubeAverage (fun x => if E x then (1 : ℝ) else 0)) / 2 := by + unfold mixedCubeLaw FiniteLaw.probability + rw [cubeDensityLaw_average, cubeDensityLaw_average] + have heq : (fun x => (g x + 1) / 2 * (if E x then (1 : ℝ) else 0)) = + fun x => (1 / 2 : ℝ) * + (g x * (if E x then (1 : ℝ) else 0) + (if E x then (1 : ℝ) else 0)) := by + funext x + ring + rw [heq, cubeAverage_mul_const, cubeAverage_add] + ring + +theorem mixedCubeLaw_exception_bounds {n : ℕ} (g : BooleanCube n → ℝ) + (hg : ∀ x, 0 ≤ g x) (hmean : cubeAverage g = 1) (E : BooleanCube n → Prop) + {δ : ℝ} (hE : (mixedCubeLaw g hg hmean).probability E ≤ δ) : + (cubeDensityLaw g hg hmean).probability E ≤ 2 * δ ∧ + cubeAverage (fun x => if E x then (1 : ℝ) else 0) ≤ 2 * δ := by + rw [mixedCubeLaw_probability] at hE + have hμ := (cubeDensityLaw g hg hmean).probability_nonneg E + have hU : 0 ≤ cubeAverage (fun x => if E x then (1 : ℝ) else 0) := by + calc + 0 = cubeAverage (fun _ : BooleanCube n => (0 : ℝ)) := by simp + _ ≤ _ := cubeAverage_mono (fun x => by split_ifs <;> norm_num) + constructor <;> linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitNormBudget.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitNormBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..004f45f24ba97cf72cd3af5f2e9dd761f8205cf1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitNormBudget.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitExceptionBudget + +namespace OAI + +/-! A coarse uniform bound on the exceptional values of the polynomial. +For fixed depth its logarithm is polynomial in the sampling count and log size. -/ + +namespace TwoPointCorrelations.AC0Circuit + +open Finset +open scoped Classical + +theorem sampleNormBound_le {n : ℕ} (s : ℕ) (c : AC0Circuit n) + (m : ℕ) (hm : c.size ≤ m) : + c.sampleNormBound s ≤ (2 * ((m : ℝ) + 1) ^ 2) ^ + ((2 * (s * (Nat.log 2 m + 3)) + 2) ^ c.depth) := by + induction c generalizing m with + | literal i b => + simp only [sampleNormBound, depth, pow_zero, pow_one] + nlinarith [Nat.cast_nonneg (α := ℝ) m] + | @andGate k c ih | @orGate k c ih => + have hm' : 1 + ∑ i, (c i).size ≤ m := hm + have hsize (i : Fin k) : (c i).size ≤ m := by + have hh := single_le_sum (fun j _ => Nat.zero_le (c j).size) (mem_univ i) + omega + have hcount : k ≤ ∑ i, (c i).size := by + calc + k = ∑ _i : Fin k, 1 := by simp + _ ≤ _ := sum_le_sum (fun i _ => (c i).size_pos) + have hk : k ≤ m := by omega + have hkreal : (k : ℝ) ≤ m := by exact_mod_cast hk + let A : ℝ := 2 * ((m : ℝ) + 1) ^ 2 + let R := s * (Nat.log 2 m + 3) + let D := univ.sup (fun i => (c i).depth) + let E := (2 * R + 2) ^ D + let V := A ^ E + have hA : 2 ≤ A := by dsimp [A]; nlinarith [Nat.cast_nonneg (α := ℝ) m] + have hA1 : 1 ≤ A := by linarith + have hV : 1 ≤ V := one_le_pow₀ hA1 + have hE : 1 ≤ E := by dsimp [E]; exact Nat.one_le_pow D (2 * R + 2) (by omega) + have hchildren (i : Fin k) : (c i).sampleNormBound s ≤ V := by + have hdepth := le_sup (f := fun j => (c j).depth) (mem_univ i) + exact (ih i m (hsize i)).trans (pow_le_pow_right₀ hA1 + (Nat.pow_le_pow_right (by omega : 0 < 2 * R + 2) hdepth)) + have hsum : ∑ i, (c i).sampleNormBound s ≤ (m : ℝ) * V := by + calc + _ ≤ ∑ _i : Fin k, V := sum_le_sum (fun i _ => hchildren i) + _ = (k : ℝ) * V := by simp + _ ≤ _ := mul_le_mul_of_nonneg_right hkreal (by linarith) + have hS0 : 0 ≤ ∑ i, (c i).sampleNormBound s := + sum_nonneg (fun i _ => sampleNormBound_nonneg s (c i)) + have hbase : 1 + (k : ℝ) * (2 + ∑ i, (c i).sampleNormBound s) ≤ A * V := by + have hh := mul_le_mul hkreal (add_le_add (le_refl (2 : ℝ)) hsum) + (by linarith : (0 : ℝ) ≤ 2 + ∑ i, (c i).sampleNormBound s) (Nat.cast_nonneg m) + have hpoly := mul_le_mul_of_nonneg_left hV + (show 0 ≤ (m : ℝ) ^ 2 + 4 * m + 2 by positivity) + dsimp [A] + nlinarith + have hnonneg : 0 ≤ 1 + (k : ℝ) * (2 + ∑ i, (c i).sampleNormBound s) := by + positivity + have hR : s * (Nat.log 2 k + 3) ≤ R := + Nat.mul_le_mul_left s (Nat.add_le_add_right (Nat.log_mono_right hk) 3) + have hpow : (1 + (k : ℝ) * (2 + ∑ i, (c i).sampleNormBound s)) ^ + (s * (Nat.log 2 k + 3)) ≤ (A * V) ^ R := + (pow_le_pow_left₀ hnonneg hbase _).trans + (pow_le_pow_right₀ (by nlinarith) hR) + have heq : (A * V) ^ R = A ^ ((E + 1) * R) := by + dsimp only [V] + rw [← pow_succ', ← pow_mul] + have hplus : 1 + A ^ ((E + 1) * R) ≤ A ^ ((E + 1) * R + 1) := by + have hz : 1 ≤ A ^ ((E + 1) * R) := one_le_pow₀ hA1 + rw [pow_succ] + nlinarith + have hexponent : (E + 1) * R + 1 ≤ (2 * R + 2) ^ (D + 1) := by + have hRE : R ≤ R * E := by simpa using Nat.mul_le_mul_left R hE + rw [pow_succ] + change (E + 1) * R + 1 ≤ E * (2 * R + 2) + nlinarith + change 1 + (1 + (k : ℝ) * (2 + ∑ i, (c i).sampleNormBound s)) ^ + (s * (Nat.log 2 k + 3)) ≤ A ^ ((2 * R + 2) ^ (1 + D)) + calc + _ ≤ 1 + (A * V) ^ R := add_le_add (le_refl (1 : ℝ)) hpow + _ = 1 + A ^ ((E + 1) * R) := by rw [heq] + _ ≤ A ^ ((E + 1) * R + 1) := hplus + _ ≤ _ := pow_le_pow_right₀ hA1 (by simpa [Nat.add_comm] using hexponent) + +end TwoPointCorrelations.AC0Circuit + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitOrApproximation.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitOrApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..103b5a5a3c5c255b0512138358301e7632bb4402 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitOrApproximation.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitApproximationDegree + +namespace OAI + +/-! De Morgan duality transfers the sampled AND approximation to OR gates. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def boolOrValue {k : ℕ} (b : Fin k → Bool) : ℝ := + if ∃ i, b i = true then 1 else 0 + +lemma boolAndValue_not {k : ℕ} (b : Fin k → Bool) : + boolAndValue (fun i => !(b i)) = 1 - boolOrValue b := by + have he : (∀ i, Bool.not (b i) = true) ↔ ¬∃ i, b i = true := by simp + simp only [boolAndValue, boolOrValue, he] + split_ifs <;> norm_num + +theorem exists_composed_or_approximation {n : ℕ} + (ν : FiniteLaw (BooleanCube n)) (k s d : ℕ) + (b : Fin k → BooleanCube n → Bool) (P : Fin k → BooleanCube n → ℝ) + (hP : ∀ i, WalshDegreeLE (P i) d) (δ : Fin k → ℝ) + (hδ : ∀ i, ν.probability (fun y => P i y ≠ if b i y then 1 else 0) ≤ δ i) : + ∃ Q : BooleanCube n → ℝ, + WalshDegreeLE Q (d * s * (Nat.log 2 k + 3)) ∧ + ν.probability (fun y => Q y ≠ boolOrValue (fun i => b i y)) ≤ + (7 / 8 : ℝ) ^ s + ∑ i, δ i := by + let R := fun i y => 1 - P i y + have hR (i : Fin k) : WalshDegreeLE (R i) d := + (WalshDegreeLE.const 1 d).sub (hP i) + have hδ' (i : Fin k) : + ν.probability (fun y => R i y ≠ if !(b i y) then 1 else 0) ≤ δ i := by + apply le_trans (ν.probability_mono ?_) (hδ i) + intro y hy heq + apply hy + dsimp only [R] + rw [heq] + cases b i y <;> norm_num + obtain ⟨Q, hQ, he⟩ := exists_composed_and_approximation ν k s d + (fun i y => !(b i y)) R hR δ hδ' + refine ⟨fun y => 1 - Q y, (WalshDegreeLE.const 1 _).sub hQ, ?_⟩ + apply le_trans (ν.probability_mono ?_) he + intro y hy heq + apply hy + change 1 - Q y = _ + rw [heq, boolAndValue_not] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitOrCertificate.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitOrCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4d0844d4907cba5d576ed0fa80559ba455086ef --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitOrCertificate.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitAndCertificate + +namespace OAI + +/-! The OR step uses complementary child polynomials and the same Boolean +error certificates. Both polarities therefore admit the same recursive bounds. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def CircuitCertificate.orGate {n k : ℕ} + (ν : FiniteLaw (BooleanCube n)) (s : ℕ) (c : Fin k → AC0Circuit n) + (H : ∀ i, CircuitCertificate ν s (c i)) : + CircuitCertificate ν s (.orGate c) := by + let P := fun i x => 1 - (H i).polynomial x + let E := fun i => (H i).error + let c' := fun i => (c i).negate + have hcorrect (i : Fin k) (x : BooleanCube n) (hx : (E i).eval x ≠ true) : + P i x = (c' i).indicator x := by + change 1 - (H i).polynomial x = (c i).negate.indicator x + rw [(H i).exact_off_error x hx, AC0Circuit.negate_indicator] + let hs := exists_certified_and_sample ν s c' E P + (fun i => ((c i).size : ℝ) * (7 / 8 : ℝ) ^ s) + (fun i => (H i).error_probability) hcorrect + let sample := Classical.choose hs + have hprob := (Classical.choose_spec hs).1 + have hexact := (Classical.choose_spec hs).2 + refine + { polynomial := fun x => 1 - sampledAndPolynomial sample (fun i => P i x) + error := AC0Circuit.combineGateException sample c' E + degree_bound := ?_ + error_depth := ?_ + error_size := ?_ + error_probability := ?_ + exact_off_error := ?_ + norm_bound := ?_ } + · let d := univ.sup (fun i => (c i).approximationDegree s) + have hP (i : Fin k) : WalshDegreeLE (P i) d := + (WalshDegreeLE.const 1 d).sub ((H i).degree_bound.mono + (le_sup (f := fun j => (c j).approximationDegree s) (mem_univ i))) + exact (WalshDegreeLE.const 1 _).sub (sampledAndPolynomial_degree sample P d hP) + · let D := univ.sup (fun i => (c i).depth) + have hc (i : Fin k) : (c' i).depth ≤ D := by + simpa only [c', AC0Circuit.negate_depth] using + (le_sup (f := fun j => (c j).depth) (mem_univ i)) + have hE (i : Fin k) : (E i).depth ≤ 4 * D + 4 := by + have hh := (H i).error_depth + have hd := le_sup (f := fun j => (c j).depth) (mem_univ i) + change (H i).error.depth ≤ 4 * D + 4 + omega + have hh := AC0Circuit.combineGateException_depth sample c' E hc hE (by omega) + change (AC0Circuit.combineGateException sample c' E).depth ≤ 4 * (1 + D) + 1 + omega + · rw [AC0Circuit.combineGateException_size] + have hs := AC0Circuit.gateSamplingException_size sample c' + simp only [c', AC0Circuit.negate_size] at hs + have he : ∑ i, (E i).size ≤ ∑ i, (c i).exceptionSizeBound s := + sum_le_sum (fun i _ => (H i).error_size) + change 1 + (AC0Circuit.gateSamplingException sample c').size + ∑ i, (E i).size ≤ + 4 + (∑ i, (c i).size) + s * (Nat.log 2 k + 3) * + (1 + k * (1 + ∑ i, (c i).size)) + ∑ i, (c i).exceptionSizeBound s + dsimp only [c'] + omega + · convert hprob using 1 + simp only [AC0Circuit.size, Nat.cast_add, Nat.cast_one, Nat.cast_sum, add_mul, + one_mul, sum_mul] + · intro x hx + have hh := hexact x hx + change 1 - sampledAndPolynomial sample (fun i => P i x) = _ + rw [hh] + have he := AC0Circuit.negate_indicator (.orGate c) x + change (AC0Circuit.andGate c').indicator x = 1 - (AC0Circuit.orGate c).indicator x at he + rw [he] + ring + · intro x + let B := ∑ i, (c i).sampleNormBound s + have hB : 0 ≤ B := sum_nonneg (fun i _ => AC0Circuit.sampleNormBound_nonneg s (c i)) + have hP (i : Fin k) : |P i x| ≤ 1 + B := by + have hi : |(H i).polynomial x| ≤ B := + ((H i).norm_bound x).trans + (single_le_sum (fun j _ => AC0Circuit.sampleNormBound_nonneg s (c j)) (mem_univ i)) + exact (abs_sub _ _).trans (by simpa only [abs_one] using add_le_add (le_refl (1 : ℝ)) hi) + have hb := sampledAndPolynomial_abs_le sample (fun i => P i x) (by positivity : 0 ≤ 1 + B) hP + have hbase : 1 + (k : ℝ) * (1 + (1 + B)) = 1 + (k : ℝ) * (2 + B) := by ring + rw [hbase] at hb + change |1 - sampledAndPolynomial sample (fun i => P i x)| ≤ + 1 + (1 + (k : ℝ) * (2 + B)) ^ (s * (Nat.log 2 k + 3)) + exact (abs_sub _ _).trans (by simpa only [abs_one] using add_le_add (le_refl (1 : ℝ)) hb) + +noncomputable def AC0Circuit.certificate {n : ℕ} (ν : FiniteLaw (BooleanCube n)) + (s : ℕ) (c : AC0Circuit n) : CircuitCertificate ν s c := by + induction c with + | literal i b => exact CircuitCertificate.literal ν s i b + | andGate c ih => exact CircuitCertificate.andGate ν s c ih + | orGate c ih => exact CircuitCertificate.orGate ν s c ih + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitPartialAssignment.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitPartialAssignment.lean new file mode 100644 index 0000000000000000000000000000000000000000..d984142c26fbcc034dd354d71cd45b22f463d49b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitPartialAssignment.lean @@ -0,0 +1,151 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitRestriction + +namespace OAI + +/-! Partial assignments and the consistent terms used in the canonical +decision tree of a DNF. Each term contains at most one literal per variable. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +abbrev PartialAssignment (n : ℕ) := Fin n → Option Bool + +namespace PartialAssignment + +def apply {n : ℕ} (ρ : PartialAssignment n) (x : BooleanCube n) : BooleanCube n := + fun i => (ρ i).getD (x i) + +def Extends {n : ℕ} (ρ τ : PartialAssignment n) : Prop := + ∀ i b, ρ i = some b → τ i = some b + +def assign {n : ℕ} (ρ : PartialAssignment n) (S : Finset (Fin n)) + (x : BooleanCube n) : PartialAssignment n := fun i => if i ∈ S then some (x i) else ρ i + +def free {n : ℕ} (ρ : PartialAssignment n) : Finset (Fin n) := + univ.filter (fun i => ρ i = none) + +@[simp] lemma assign_empty {n : ℕ} (ρ : PartialAssignment n) (x : BooleanCube n) : + ρ.assign ∅ x = ρ := by funext i; simp [assign] + +lemma assign_insert {n : ℕ} (ρ : PartialAssignment n) (S : Finset (Fin n)) + (x : BooleanCube n) (i : Fin n) : + ρ.assign (insert i S) x = assign (Function.update ρ i (some (x i))) S x := by + funext j + by_cases hji : j = i <;> by_cases hj : j ∈ S <;> simp [assign, hji, hj] + +lemma apply_assign_free {n : ℕ} (ρ : PartialAssignment n) (S : Finset (Fin n)) + (hS : S ⊆ ρ.free) (x : BooleanCube n) : + (ρ.assign S x).apply x = ρ.apply x := by + funext i + by_cases hi : i ∈ S + · have hρ : ρ i = none := (mem_filter.mp (hS hi)).2 + simp [assign, apply, hi, hρ] + · simp [assign, apply, hi] + +lemma assign_extends {n : ℕ} (ρ : PartialAssignment n) (S : Finset (Fin n)) + (hS : S ⊆ ρ.free) (x : BooleanCube n) : ρ.Extends (ρ.assign S x) := by + intro i b hb + have hi : i ∉ S := by + intro hi + have hn := (mem_filter.mp (hS hi)).2 + rw [hb] at hn + cases hn + simp [assign, hi, hb] + +lemma extends_trans {n : ℕ} {ρ σ τ : PartialAssignment n} + (hρσ : ρ.Extends σ) (hστ : σ.Extends τ) : ρ.Extends τ := + fun i b hb => hστ i b (hρσ i b hb) + +end PartialAssignment + +structure CubeTerm (n : ℕ) where + support : Finset (Fin n) + value : BooleanCube n + +namespace CubeTerm + +def eval {n : ℕ} (C : CubeTerm n) (x : BooleanCube n) : Bool := + decide (∀ i ∈ C.support, x i = C.value i) + +def Compatible {n : ℕ} (C : CubeTerm n) (ρ : PartialAssignment n) : Prop := + ∀ i ∈ C.support, ρ i = none ∨ ρ i = some (C.value i) + +def Satisfied {n : ℕ} (C : CubeTerm n) (ρ : PartialAssignment n) : Prop := + ∀ i ∈ C.support, ρ i = some (C.value i) + +def live {n : ℕ} (C : CubeTerm n) (ρ : PartialAssignment n) : Finset (Fin n) := + C.support.filter (fun i => ρ i = none) + +lemma live_subset_free {n : ℕ} (C : CubeTerm n) (ρ : PartialAssignment n) : + C.live ρ ⊆ ρ.free := by + intro i hi + exact mem_filter.mpr ⟨mem_univ _, (mem_filter.mp hi).2⟩ + +lemma incompatible_mono {n : ℕ} (C : CubeTerm n) {ρ τ : PartialAssignment n} + (hρ : ¬ C.Compatible ρ) (h : ρ.Extends τ) : ¬ C.Compatible τ := by + intro hτ + apply hρ + intro i hi + cases hri : ρ i with + | none => exact Or.inl rfl + | some b => + have hti := h i b hri + rcases hτ i hi with hn | hv + · rw [hti] at hn + cases hn + · have hb : b = C.value i := Option.some.inj (hti.symm.trans hv) + exact Or.inr (congrArg some hb) + +lemma eval_apply_of_incompatible {n : ℕ} (C : CubeTerm n) + (ρ : PartialAssignment n) (hρ : ¬ C.Compatible ρ) (x : BooleanCube n) : + C.eval (ρ.apply x) = false := by + apply Bool.eq_false_iff.mpr + intro he + apply hρ + have he : ∀ i ∈ C.support, ρ.apply x i = C.value i := of_decide_eq_true he + intro i hi + cases hr : ρ i with + | none => exact Or.inl rfl + | some b => + right + have hb := he i hi + simpa [PartialAssignment.apply, hr] using hb + +lemma satisfied_assign_live_iff {n : ℕ} (C : CubeTerm n) + (ρ : PartialAssignment n) (hρ : C.Compatible ρ) (x : BooleanCube n) : + C.Satisfied (ρ.assign (C.live ρ) x) ↔ C.eval (ρ.apply x) = true := by + simp only [Satisfied, eval, decide_eq_true_eq] + constructor + · intro hs i hi + by_cases hl : i ∈ C.live ρ + · have hn := (mem_filter.mp hl).2 + have hb := hs i hi + simpa [PartialAssignment.assign, PartialAssignment.apply, hl, hn] using hb + · have hn : ρ i ≠ none := fun hn => hl (mem_filter.mpr ⟨hi, hn⟩) + have hv := (hρ i hi).resolve_left hn + simp [PartialAssignment.apply, hv] + · intro hx i hi + by_cases hn : ρ i = none + · have hl : i ∈ C.live ρ := mem_filter.mpr ⟨hi, hn⟩ + have hv := hx i hi + simpa [PartialAssignment.assign, PartialAssignment.apply, hl, hn] using hv + · have hl : i ∉ C.live ρ := fun hl => hn (mem_filter.mp hl).2 + simp [PartialAssignment.assign, hl, (hρ i hi).resolve_left hn] + +lemma satisfied_assign_value {n : ℕ} (C : CubeTerm n) + (ρ : PartialAssignment n) (hρ : C.Compatible ρ) : + C.Satisfied (ρ.assign (C.live ρ) C.value) := by + rw [C.satisfied_assign_live_iff ρ hρ] + apply decide_eq_true + intro i hi + rcases hρ i hi with hn | hv + · simp [PartialAssignment.apply, hn] + · simp [PartialAssignment.apply, hv] + +end CubeTerm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitPolynomialAlgebra.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitPolynomialAlgebra.lean new file mode 100644 index 0000000000000000000000000000000000000000..4608a5196955571f12e8d07c5f13b38c91969b9d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitPolynomialAlgebra.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitPolynomialMean +import Mathlib.Data.Finset.SymmDiff + +namespace OAI + +/-! Algebra of the low-degree functions used in the circuit approximation. +Multiplication adds degrees, including after Boolean multilinearization. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical symmDiff + +variable {n : ℕ} + +lemma walsh_mul (S T : Finset (Fin n)) (x : BooleanCube n) : + walsh S x * walsh T x = walsh (S ∆ T) x := by + have hd : Disjoint (S ∆ T) (S ∩ T) := by + rw [disjoint_left] + intro i hi hi' + simp only [mem_symmDiff, mem_inter] at hi hi' + tauto + have hu : (S ∆ T) ∪ (S ∩ T) = S ∪ T := by + ext i + simp only [mem_union, mem_symmDiff, mem_inter] + tauto + have he : walsh (S ∪ T) x * walsh (S ∩ T) x = walsh S x * walsh T x := + prod_union_inter + have hh : walsh (S ∪ T) x = walsh (S ∆ T) x * walsh (S ∩ T) x := by + simpa only [walsh, hu] using + (prod_union hd : (∏ i ∈ (S ∆ T) ∪ (S ∩ T), booleanSign (x i)) = _) + rw [hh, mul_assoc, walsh_mul_self, mul_one] at he + exact he.symm + +lemma WalshDegreeLE.of_walsh (S : Finset (Fin n)) {t : ℕ} (hS : S.card ≤ t) : + WalshDegreeLE (walsh S) t := by + refine ⟨fun T => if T = S then 1 else 0, ?_⟩ + intro x + simp [hS] + +lemma WalshDegreeLE.const (c : ℝ) (t : ℕ) : + WalshDegreeLE (fun _ : BooleanCube n => c) t := by + refine ⟨fun S => if S = ∅ then c else 0, ?_⟩ + intro x + simp + +lemma WalshDegreeLE.smul {F : BooleanCube n → ℝ} {t : ℕ} + (hF : WalshDegreeLE F t) (c : ℝ) : WalshDegreeLE (fun x => c * F x) t := by + obtain ⟨a, ha⟩ := hF + refine ⟨fun S => c * a S, ?_⟩ + intro x + dsimp only + rw [ha, mul_sum] + apply sum_congr rfl + intro S _ + ring + +lemma WalshDegreeLE.sub {F G : BooleanCube n → ℝ} {t : ℕ} + (hF : WalshDegreeLE F t) (hG : WalshDegreeLE G t) : + WalshDegreeLE (fun x => F x - G x) t := by + obtain ⟨a, ha⟩ := hF + obtain ⟨b, hb⟩ := hG + refine ⟨fun S => a S - b S, ?_⟩ + intro x + dsimp only + rw [ha, hb, ← sum_sub_distrib] + apply sum_congr rfl + intro S _ + ring + +lemma WalshDegreeLE.sum {ι : Type*} (I : Finset ι) (F : ι → BooleanCube n → ℝ) + {t : ℕ} (hF : ∀ i ∈ I, WalshDegreeLE (F i) t) : + WalshDegreeLE (fun x => ∑ i ∈ I, F i x) t := by + choose a ha using fun i : I => hF i i.property + refine ⟨fun S => ∑ i : I, a i S, ?_⟩ + intro x + dsimp only + rw [← sum_coe_sort I] + simp_rw [ha] + rw [sum_comm] + apply sum_congr rfl + intro S _ + exact (sum_mul _ _ _).symm + +lemma WalshDegreeLE.mul {F G : BooleanCube n → ℝ} {p q : ℕ} + (hF : WalshDegreeLE F p) (hG : WalshDegreeLE G q) : + WalshDegreeLE (fun x => F x * G x) (p + q) := by + obtain ⟨a, ha⟩ := hF + obtain ⟨b, hb⟩ := hG + let A := (univ : Finset (Finset (Fin n))).filter (fun S => S.card ≤ p) + let B := (univ : Finset (Finset (Fin n))).filter (fun S => S.card ≤ q) + have heq : (fun x => F x * G x) = fun x => + ∑ S ∈ A, ∑ T ∈ B, (a S * b T) * walsh (S ∆ T) x := by + funext x + rw [ha, hb, sum_mul] + apply sum_congr rfl + intro S _ + rw [mul_sum] + apply sum_congr rfl + intro T _ + rw [← walsh_mul] + ring + rw [heq] + apply WalshDegreeLE.sum A + intro S hS + apply WalshDegreeLE.sum B + intro T hT + apply WalshDegreeLE.smul + apply WalshDegreeLE.of_walsh + calc + (S ∆ T).card ≤ (S ∪ T).card := card_le_card symmDiff_subset_union + _ ≤ S.card + T.card := card_union_le S T + _ ≤ p + q := add_le_add (mem_filter.mp hS).2 (mem_filter.mp hT).2 + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitPolynomialGrowth.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitPolynomialGrowth.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a6c52c02fa9e093b4c9e9a4c0b9bc7218908e2a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitPolynomialGrowth.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitDyadicBudgets + +namespace OAI + +/-! The explicit dyadic independence budget is polynomial in its accuracy +parameter. The closure argument avoids expanding enormous fixed constants. -/ + +namespace TwoPointCorrelations + +def NatPolynomialGrowth (f : ℕ → ℕ) : Prop := + ∃ K C : ℕ, ∀ j, f j ≤ K * (j + 1) ^ C + +namespace NatPolynomialGrowth + +theorem const (a : ℕ) : NatPolynomialGrowth (fun _ => a) := + ⟨a, 0, fun _ => by simp⟩ + +theorem id : NatPolynomialGrowth (fun j => j) := + ⟨1, 1, fun _ => by simp⟩ + +theorem add {f g : ℕ → ℕ} (hf : NatPolynomialGrowth f) (hg : NatPolynomialGrowth g) : + NatPolynomialGrowth (fun j => f j + g j) := by + obtain ⟨K, C, hK⟩ := hf + obtain ⟨L, D, hL⟩ := hg + refine ⟨K + L, C + D, fun j => ?_⟩ + calc + _ ≤ K * (j + 1) ^ C + L * (j + 1) ^ D := Nat.add_le_add (hK j) (hL j) + _ ≤ K * (j + 1) ^ (C + D) + L * (j + 1) ^ (C + D) := by + gcongr <;> omega + _ = _ := by ring + +theorem mul {f g : ℕ → ℕ} (hf : NatPolynomialGrowth f) (hg : NatPolynomialGrowth g) : + NatPolynomialGrowth (fun j => f j * g j) := by + obtain ⟨K, C, hK⟩ := hf + obtain ⟨L, D, hL⟩ := hg + refine ⟨K * L, C + D, fun j => ?_⟩ + calc + _ ≤ (K * (j + 1) ^ C) * (L * (j + 1) ^ D) := Nat.mul_le_mul (hK j) (hL j) + _ = _ := by rw [pow_add]; ring + +theorem pow {f : ℕ → ℕ} (hf : NatPolynomialGrowth f) (k : ℕ) : + NatPolynomialGrowth (fun j => f j ^ k) := by + obtain ⟨K, C, hK⟩ := hf + refine ⟨K ^ k, C * k, fun j => ?_⟩ + calc + _ ≤ (K * (j + 1) ^ C) ^ k := Nat.pow_le_pow_left (hK j) k + _ = _ := by rw [mul_pow, pow_mul] + +end NatPolynomialGrowth + +theorem bravermanDegree_polynomial : NatPolynomialGrowth bravermanDegree := by + have hid := NatPolynomialGrowth.id + have hbase : NatPolynomialGrowth bravermanBase := + ((NatPolynomialGrowth.const 40).mul (hid.add (NatPolynomialGrowth.const 1))).mul + (hid.add (NatPolynomialGrowth.const 3)) + have hnorm : NatPolynomialGrowth bravermanNormExponent := + ((NatPolynomialGrowth.const 2).mul hid |>.add (NatPolynomialGrowth.const 3)).mul + (((NatPolynomialGrowth.const 2).mul hbase |>.add (NatPolynomialGrowth.const 2)).pow 22) + have herror : NatPolynomialGrowth bravermanErrorExponent := + (NatPolynomialGrowth.const 20).mul (hid.add (NatPolynomialGrowth.const 3)) + have hr : NatPolynomialGrowth bravermanSwitches := + ((((NatPolynomialGrowth.const 2).mul hnorm).add herror).add hid).add + (NatPolynomialGrowth.const 10) + have hden : NatPolynomialGrowth (fun j => switchingDenominator (bravermanSwitches j)) := + (NatPolynomialGrowth.const 24).mul + ((((NatPolynomialGrowth.const 2).mul hr).add (NatPolynomialGrowth.const 3)).pow 2) + have hD : NatPolynomialGrowth (fun j => switchingDegree 89 (bravermanSwitches j)) := + (((NatPolynomialGrowth.const 8).mul (hr.add (NatPolynomialGrowth.const 1))).mul + (hden.pow 89)) + exact (NatPolynomialGrowth.const 2).mul ((hbase.pow 22).add hD) + +theorem bravermanDegree_polynomial_positive : + ∃ K C : ℕ, 0 < K ∧ 0 < C ∧ ∀ j, bravermanDegree j ≤ K * (j + 1) ^ C := by + obtain ⟨K, C, h⟩ := bravermanDegree_polynomial + refine ⟨K + 1, C + 1, by omega, by omega, fun j => (h j).trans ?_⟩ + exact Nat.mul_le_mul (Nat.le_succ K) (Nat.pow_le_pow_right (by omega) (Nat.le_succ C)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitPolynomialMean.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitPolynomialMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd55ce1ebb47b75344b4a29ccbccc3b01c041c89 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitPolynomialMean.lean @@ -0,0 +1,124 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitClauseIndependence + +namespace OAI + +/-! The polynomial-expectation step in Braverman's proof (Proposition 6, +author version https://www.cs.toronto.edu/~mbraverm/FoolAC0v7.pdf). +On the Boolean cube, multilinear degree is represented by Walsh support. +Preservation of low-degree expectations gives a sandwich criterion for +bounded-independence comparison. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {n : ℕ} + +def cubeRestrict (S : Finset (Fin n)) (x : BooleanCube n) : S → Bool := fun i => x i + +noncomputable def cubeExtend (S : Finset (Fin n)) (z : S → Bool) : BooleanCube n := + fun i => if hi : i ∈ S then z ⟨i, hi⟩ else false + +lemma cubePattern_extend (S : Finset (Fin n)) (z : S → Bool) (x : BooleanCube n) : + cubePattern S (cubeExtend S z) x = if cubeRestrict S x = z then 1 else 0 := by + have heq : (∀ i ∈ S, x i = cubeExtend S z i) ↔ cubeRestrict S x = z := by + constructor + · intro h + funext i + simpa only [cubeRestrict, cubeExtend, dite_eq_left i.property] using h i i.property + · intro h i hi + have hh := congrFun h ⟨i, hi⟩ + simpa only [cubeRestrict, cubeExtend, dite_eq_left hi] using hh + simp only [cubePattern, heq] + +lemma cube_function_partition (S : Finset (Fin n)) (φ : (S → Bool) → ℝ) + (x : BooleanCube n) : + φ (cubeRestrict S x) = ∑ z : S → Bool, φ z * cubePattern S (cubeExtend S z) x := by + simp only [cubePattern_extend] + simp + +lemma TWiseUniformDensity.restricted_mean {t : ℕ} {g : BooleanCube n → ℝ} + (hg : TWiseUniformDensity g t) (S : Finset (Fin n)) (hS : S.card ≤ t) + (φ : (S → Bool) → ℝ) : + cubeAverage (fun x => g x * φ (cubeRestrict S x)) = + (∑ z : S → Bool, φ z) / (2 : ℝ) ^ S.card := by + have heq : (fun x => g x * φ (cubeRestrict S x)) = + fun x => ∑ z : S → Bool, φ z * (g x * cubePattern S (cubeExtend S z) x) := by + funext x + rw [cube_function_partition S φ x, mul_sum] + apply sum_congr rfl + intro z _ + ring + rw [heq, cubeAverage_sum] + simp_rw [cubeAverage_mul_const, hg S hS] + simp only [div_eq_mul_inv, sum_mul, one_mul] + +lemma uniformDensity_tWise (t : ℕ) : + TWiseUniformDensity (fun _ : BooleanCube n => (1 : ℝ)) t := by + intro S _ z + simpa only [one_mul] using cubeAverage_pattern S z + +lemma TWiseUniformDensity.restricted_expectation {t : ℕ} {g : BooleanCube n → ℝ} + (hg : TWiseUniformDensity g t) (S : Finset (Fin n)) (hS : S.card ≤ t) + (φ : (S → Bool) → ℝ) : + cubeAverage (fun x => g x * φ (cubeRestrict S x)) = + cubeAverage (fun x => φ (cubeRestrict S x)) := by + rw [hg.restricted_mean S hS φ] + simpa only [one_mul] using ((uniformDensity_tWise t).restricted_mean S hS φ).symm + +lemma TWiseUniformDensity.walsh_expectation {t : ℕ} {g : BooleanCube n → ℝ} + (hg : TWiseUniformDensity g t) (S : Finset (Fin n)) (hS : S.card ≤ t) : + cubeAverage (fun x => g x * walsh S x) = cubeAverage (walsh S) := by + have heq (x : BooleanCube n) : + walsh S x = ∏ i : S, booleanSign (cubeRestrict S x i) := by + simp only [walsh, cubeRestrict] + exact (Finset.prod_attach S (fun i => booleanSign (x i))).symm + have hfun : walsh S = fun x => ∏ i : S, booleanSign (cubeRestrict S x i) := funext heq + rw [hfun] + exact hg.restricted_expectation S hS (fun z => ∏ i : S, booleanSign (z i)) + +/-- A concrete finite representation of a real multilinear polynomial of +degree at most t, restricted to the Boolean cube. -/ +def WalshDegreeLE (F : BooleanCube n → ℝ) (t : ℕ) : Prop := + ∃ a : Finset (Fin n) → ℝ, ∀ x, + F x = ∑ S ∈ (univ : Finset (Finset (Fin n))).filter (fun S => S.card ≤ t), + a S * walsh S x + +lemma TWiseUniformDensity.polynomial_expectation {t : ℕ} {g F : BooleanCube n → ℝ} + (hg : TWiseUniformDensity g t) (hF : WalshDegreeLE F t) : + cubeAverage (fun x => g x * F x) = cubeAverage F := by + obtain ⟨a, ha⟩ := hF + have hfun : F = fun x => ∑ S ∈ (univ : Finset (Finset (Fin n))).filter + (fun S => S.card ≤ t), a S * walsh S x := funext ha + rw [hfun] + simp_rw [mul_sum] + rw [cubeAverage_sum, cubeAverage_sum] + apply sum_congr rfl + intro S hS + have hs : S.card ≤ t := (mem_filter.mp hS).2 + have heq : (fun x => g x * (a S * walsh S x)) = + fun x => a S * (g x * walsh S x) := by funext x; ring + rw [heq, cubeAverage_mul_const, cubeAverage_mul_const, hg.walsh_expectation S hs] + +/-- Two low-degree pointwise bounds with small uniform gap also bound every +t-wise independent law. This criterion supplies the finite probability +interface for the analytic polynomial construction. -/ +theorem TWiseUniformDensity.sandwich_error {t : ℕ} {g F P Q : BooleanCube n → ℝ} + (hg : TWiseUniformDensity g t) (hn : ∀ x, 0 ≤ g x) + (hP : WalshDegreeLE P t) (hQ : WalshDegreeLE Q t) + (hPF : ∀ x, P x ≤ F x) (hFQ : ∀ x, F x ≤ Q x) + {ε : ℝ} (hgap : cubeAverage (fun x => Q x - P x) ≤ ε) : + |cubeAverage (fun x => g x * F x) - cubeAverage F| ≤ ε := by + have hp := cubeAverage_mono (fun x => mul_le_mul_of_nonneg_left (hPF x) (hn x)) + have hq := cubeAverage_mono (fun x => mul_le_mul_of_nonneg_left (hFQ x) (hn x)) + rw [hg.polynomial_expectation hP] at hp + rw [hg.polynomial_expectation hQ] at hq + have hp' := cubeAverage_mono hPF + have hq' := cubeAverage_mono hFQ + rw [cubeAverage_sub] at hgap + exact abs_le.mpr ⟨by linarith, by linarith⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitProbabilisticMethod.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitProbabilisticMethod.lean new file mode 100644 index 0000000000000000000000000000000000000000..a49882912cf7cc9883f4959e172c6f09ce22d50e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitProbabilisticMethod.lean @@ -0,0 +1,44 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitBernoulli + +namespace OAI + +/-! The averaging step that chooses one polynomial approximation from a +finite random construction, for an arbitrary input distribution. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma FiniteLaw.exists_average_le {α : Type*} [Fintype α] + (μ : FiniteLaw α) (f : α → ℝ) {a : ℝ} (ha : μ.average f ≤ a) : + ∃ x, f x ≤ a := by + by_contra hn + have hf : ∀ x, a < f x := by simpa only [not_exists, not_le] using hn + have hpos : ∃ x, 0 < μ.weight x := by + have ht : 0 < ∑ x, μ.weight x := by rw [μ.total]; norm_num + simpa only [sum_pos_iff_of_nonneg (fun x _ => μ.nonneg x), mem_univ, true_and] using ht + obtain ⟨x, hx⟩ := hpos + have hlt : (∑ y, μ.weight y * a) < ∑ y, μ.weight y * f y := by + apply sum_lt_sum + · intro y _ + exact mul_le_mul_of_nonneg_left (hf y).le (μ.nonneg y) + · exact ⟨x, mem_univ _, mul_lt_mul_of_pos_left (hf x) hx⟩ + change μ.average (fun _ => a) < μ.average f at hlt + rw [μ.average_const] at hlt + exact (not_lt_of_ge ha) hlt + +/-- If every fixed input has small failure probability over random choices, +one fixed choice has small failure probability for the supplied input law. -/ +theorem exists_choice_of_pointwise_failure {α β : Type*} [Fintype α] [Fintype β] + (μ : FiniteLaw α) (ν : FiniteLaw β) (E : α → β → Prop) {ε : ℝ} + (hE : ∀ x, μ.probability (fun a => E a x) ≤ ε) : + ∃ a, ν.probability (E a) ≤ ε := by + apply μ.exists_average_le + unfold FiniteLaw.probability + rw [μ.average_comm ν] + exact (ν.average_mono hE).trans_eq (ν.average_const ε) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitQueryWalk.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitQueryWalk.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd2961b730b1316a88beb32499df254672d1b3cf --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitQueryWalk.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitAssignmentUpdates + +namespace OAI + +/-! Complete query blocks along a canonical DNF path. A prefix of a path is +enough for the switching encoding; the final Boolean answer is irrelevant. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +structure DNFQueryBlock (n : ℕ) where + term : CubeTerm n + queried : Finset (Fin n) + answer : BooleanCube n + +namespace DNFQueryBlock + +def support {n : ℕ} : List (DNFQueryBlock n) → Finset (Fin n) + | [] => ∅ + | b :: bs => b.queried ∪ support bs + +def length {n : ℕ} : List (DNFQueryBlock n) → ℕ + | [] => 0 + | b :: bs => b.queried.card + length bs + +def image {n : ℕ} : PartialAssignment n → List (DNFQueryBlock n) → PartialAssignment n + | ρ, [] => ρ + | ρ, b :: bs => image (ρ.assign b.queried b.term.value) bs + +end DNFQueryBlock + +inductive CanonicalDNFWalk {n : ℕ} : + List (CubeTerm n) → PartialAssignment n → List (DNFQueryBlock n) → Prop + | nil (F ρ) : CanonicalDNFWalk F ρ [] + | skip {C F ρ bs} (hC : ¬ C.Compatible ρ) (h : CanonicalDNFWalk F ρ bs) : + CanonicalDNFWalk (C :: F) ρ bs + | step {C F ρ bs} (x : BooleanCube n) (hC : C.Compatible ρ) + (hne : (C.live ρ).Nonempty) (h : CanonicalDNFWalk F (ρ.assign (C.live ρ) x) bs) : + CanonicalDNFWalk (C :: F) ρ (⟨C, C.live ρ, x⟩ :: bs) + +namespace CanonicalDNFWalk + +lemma support_subset_free {n : ℕ} {F : List (CubeTerm n)} {ρ : PartialAssignment n} + {bs : List (DNFQueryBlock n)} (h : CanonicalDNFWalk F ρ bs) : + DNFQueryBlock.support bs ⊆ ρ.free := by + induction h with + | nil => simp [DNFQueryBlock.support] + | skip _ _ ih => exact ih + | @step C F ρ bs x _ _ _ ih => + intro i hi + rcases mem_union.mp hi with hi | hi + · exact C.live_subset_free ρ hi + · have hh := ih hi + rw [PartialAssignment.free_assign] at hh + exact (mem_sdiff.mp hh).1 + +lemma head_disjoint_tail {n : ℕ} {C : CubeTerm n} {F : List (CubeTerm n)} + {ρ : PartialAssignment n} {bs : List (DNFQueryBlock n)} (x : BooleanCube n) + (h : CanonicalDNFWalk F (ρ.assign (C.live ρ) x) bs) : + Disjoint (C.live ρ) (DNFQueryBlock.support bs) := by + apply Finset.disjoint_left.mpr + intro i hi htail + have hh := h.support_subset_free htail + rw [PartialAssignment.free_assign] at hh + exact (mem_sdiff.mp hh).2 hi + +lemma length_eq_card_support {n : ℕ} {F : List (CubeTerm n)} + {ρ : PartialAssignment n} {bs : List (DNFQueryBlock n)} + (h : CanonicalDNFWalk F ρ bs) : + DNFQueryBlock.length bs = (DNFQueryBlock.support bs).card := by + induction h with + | nil => simp [DNFQueryBlock.length, DNFQueryBlock.support] + | skip _ _ ih => exact ih + | @step C F ρ bs x _ _ h ih => + simp only [DNFQueryBlock.length, DNFQueryBlock.support] + rw [card_union_of_disjoint (head_disjoint_tail x h), ih] + +lemma length_le_dimension {n : ℕ} {F : List (CubeTerm n)} + {ρ : PartialAssignment n} {bs : List (DNFQueryBlock n)} + (h : CanonicalDNFWalk F ρ bs) : DNFQueryBlock.length bs ≤ n := by + rw [h.length_eq_card_support] + exact (card_le_card (subset_univ _)).trans_eq (by simp) + +end CanonicalDNFWalk + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRandomGate.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRandomGate.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9ddf612d98e27b38d298690444fcc1f394967a8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRandomGate.lean @@ -0,0 +1,103 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitIsolation + +namespace OAI + +/-! Polynomial gate replacement. A sampled subset contributes a linear +factor that is one on an all-true input and zero when the subset contains +exactly one false input. Repetition is a product of these factors. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +variable {n : ℕ} + +lemma WalshDegreeLE.prod {ι : Type*} (I : Finset ι) (F : ι → BooleanCube n → ℝ) + (d : ℕ) (hF : ∀ i ∈ I, WalshDegreeLE (F i) d) : + WalshDegreeLE (fun x => ∏ i ∈ I, F i x) (d * I.card) := by + induction I using Finset.induction_on with + | empty => simpa using WalshDegreeLE.const (n := n) 1 0 + | @insert i I hi ih => + have hFi := hF i (mem_insert_self i I) + have hI := ih (fun j hj => hF j (mem_insert_of_mem hj)) + have hh := hFi.mul hI + have heq : (fun x => ∏ j ∈ insert i I, F j x) = + fun x => F i x * ∏ j ∈ I, F j x := by + funext x + exact prod_insert hi + rw [heq] + convert hh using 1 + simp only [card_insert_of_notMem hi] + ring + +noncomputable def andGateFactor {k : ℕ} (S : Finset (Fin k)) (u : Fin k → ℝ) : ℝ := + 1 - ∑ i ∈ S, (1 - u i) + +noncomputable def andGatePolynomial {k r : ℕ} + (S : Fin r → Finset (Fin k)) (u : Fin k → ℝ) : ℝ := + ∏ j, andGateFactor (S j) u + +lemma WalshDegreeLE.andGateFactor {k : ℕ} (S : Finset (Fin k)) + (P : Fin k → BooleanCube n → ℝ) (d : ℕ) + (hP : ∀ i ∈ S, WalshDegreeLE (P i) d) : + WalshDegreeLE (fun x => TwoPointCorrelations.andGateFactor S (fun i => P i x)) d := by + have hsum := WalshDegreeLE.sum S (fun i x => 1 - P i x) + (fun i hi => (WalshDegreeLE.const (n := n) 1 d).sub (hP i hi)) + exact (WalshDegreeLE.const (n := n) 1 d).sub hsum + +lemma WalshDegreeLE.andGatePolynomial {k r : ℕ} (S : Fin r → Finset (Fin k)) + (P : Fin k → BooleanCube n → ℝ) (d : ℕ) + (hP : ∀ i, WalshDegreeLE (P i) d) : + WalshDegreeLE (fun x => TwoPointCorrelations.andGatePolynomial S (fun i => P i x)) + (d * r) := by + have hh := WalshDegreeLE.prod univ + (fun j x => TwoPointCorrelations.andGateFactor (S j) (fun i => P i x)) d + (fun j _ => WalshDegreeLE.andGateFactor (S j) P d (fun i _ => hP i)) + change WalshDegreeLE (fun x => ∏ j : Fin r, + TwoPointCorrelations.andGateFactor (S j) (fun i => P i x)) (d * r) + simpa only [card_univ, Fintype.card_fin] using hh + +lemma andGateFactor_all_true {k : ℕ} (S : Finset (Fin k)) + (b : Fin k → Bool) (hb : ∀ i ∈ S, b i = true) : + andGateFactor S (fun i => if b i then 1 else 0) = 1 := by + unfold andGateFactor + have hz : (∑ i ∈ S, (1 - (if b i then (1 : ℝ) else 0))) = 0 := by + apply sum_eq_zero + intro i hi + simp [hb i hi] + rw [hz, sub_zero] + +lemma andGateFactor_one_false {k : ℕ} (S : Finset (Fin k)) + (b : Fin k → Bool) (hb : (S.filter (fun i => b i = false)).card = 1) : + andGateFactor S (fun i => if b i then 1 else 0) = 0 := by + unfold andGateFactor + have heq : (∑ i ∈ S, (1 - (if b i then (1 : ℝ) else 0))) = + ((S.filter (fun i => b i = false)).card : ℝ) := by + calc + _ = ∑ i ∈ S, (if b i = false then (1 : ℝ) else 0) := by + apply sum_congr rfl + intro i _ + cases b i <;> norm_num + _ = _ := by simp + rw [heq, hb] + norm_num + +lemma andGatePolynomial_all_true {k r : ℕ} (S : Fin r → Finset (Fin k)) + (b : Fin k → Bool) (hb : ∀ i, b i = true) : + andGatePolynomial S (fun i => if b i then 1 else 0) = 1 := by + unfold andGatePolynomial + have hf : ∀ j, andGateFactor (S j) (fun i => if b i then 1 else 0) = 1 := + fun j => andGateFactor_all_true (S j) b (fun i _ => hb i) + simp only [hf, prod_const_one] + +lemma andGatePolynomial_isolated_false {k r : ℕ} (S : Fin r → Finset (Fin k)) + (b : Fin k → Bool) (hb : ∃ j, ((S j).filter (fun i => b i = false)).card = 1) : + andGatePolynomial S (fun i => if b i then 1 else 0) = 0 := by + obtain ⟨j, hj⟩ := hb + unfold andGatePolynomial + exact prod_eq_zero (mem_univ j) (andGateFactor_one_false (S j) b hj) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRandomRestriction.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRandomRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..608eff538eddb49494530b029252569c0ed871ab --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRandomRestriction.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitRestrictionFourier +import OAI.NumberTheory.TwoPoint.Circuits.CircuitRestrictionSurvival +import OAI.NumberTheory.TwoPoint.Circuits.CircuitDecisionTree + +namespace OAI + +/-! Transfer from low-degree approximation after a random restriction to +the Fourier tail of the original function. All probability spaces are finite. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem restriction_fourier_average {n : ℕ} (f : BooleanCube n → ℝ) + (μ : FiniteLaw (BooleanCube n)) (t : ℕ) : + μ.average (fun mask => cubeAverage (fun y => cubeAverage (fun x => + (f (restrictCube (sampledCoordinates mask) y x) - + walshTruncation (fun z => f (restrictCube (sampledCoordinates mask) y z)) t x) ^ 2))) = + ∑ S : Finset (Fin n), (walshCoefficient f S) ^ 2 * + μ.probability (fun mask => t < (S ∩ sampledCoordinates mask).card) := by + simp_rw [restricted_fourier_tail_mean, sum_filter] + rw [μ.average_sum] + apply sum_congr rfl + intro S _ + have heq : (fun mask : BooleanCube n => + if t < (S ∩ sampledCoordinates mask).card then (walshCoefficient f S) ^ 2 else 0) = + fun mask => (if t < (S ∩ sampledCoordinates mask).card then (1 : ℝ) else 0) * + (walshCoefficient f S) ^ 2 := by + funext mask + split_ifs <;> simp + rw [heq, μ.average_mul_const] + rw [mul_comm] + congr 1 + unfold FiniteLaw.probability + apply congrArg μ.average + funext mask + by_cases h : t < (S ∩ sampledCoordinates mask).card <;> simp [h] + +theorem fourier_tail_le_random_restriction {n : ℕ} (f : BooleanCube n → ℝ) + (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) (t d : ℕ) + (ht : 2 * (t : ℝ) ≤ p * (d + 1)) (hd : 8 ≤ p * (d + 1)) : + cubeAverage (fun x => (f x - walshTruncation f d x) ^ 2) ≤ + 2 * (bernoulliCubeLaw n p hp hp1).average (fun mask => + cubeAverage (fun y => cubeAverage (fun x => + (f (restrictCube (sampledCoordinates mask) y x) - + walshTruncation (fun z => f (restrictCube (sampledCoordinates mask) y z)) t x) ^ 2))) := by + rw [walshTruncation_error, restriction_fourier_average, sum_filter, mul_sum] + apply sum_le_sum + intro S _ + by_cases hS : d < S.card + · rw [ite_eq_left hS] + have hcard : (d : ℝ) + 1 ≤ S.card := by exact_mod_cast hS + have hmul := mul_le_mul_of_nonneg_left hcard hp + have hsurv := bernoulli_support_survival p hp hp1 S t (ht.trans hmul) (hd.trans hmul) + have h := mul_le_mul_of_nonneg_left hsurv (sq_nonneg (walshCoefficient f S)) + nlinarith + · rw [ite_eq_right hS] + exact mul_nonneg (by norm_num) (mul_nonneg (sq_nonneg _) + ((bernoulliCubeLaw n p hp hp1).probability_nonneg _)) + +lemma walshTruncation_error_le_square {n : ℕ} (f : BooleanCube n → ℝ) (t : ℕ) : + cubeAverage (fun x => (f x - walshTruncation f t x) ^ 2) ≤ + cubeAverage (fun x => (f x) ^ 2) := by + rw [walshTruncation_error, walsh_parseval] + exact sum_le_sum_of_subset_of_nonneg (filter_subset _ _) + (fun S _ _ => sq_nonneg (walshCoefficient f S)) + +lemma walshTruncation_error_eq_zero {n t : ℕ} {f : BooleanCube n → ℝ} + (hf : WalshDegreeLE f t) : + cubeAverage (fun x => (f x - walshTruncation f t x) ^ 2) = 0 := by + rw [walshTruncation_error] + apply sum_eq_zero + intro S hS + rw [hf.high_coefficient_zero S (mem_filter.mp hS).2] + simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRecursiveApproximation.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRecursiveApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..119445b797ac280509017c41ba444af38123871b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRecursiveApproximation.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitOrApproximation + +namespace OAI + +/-! The recursive polynomial approximation in Braverman's Lemma 8, with +an explicit degree and an error union bound over the circuit tree. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem AC0Circuit.exists_polynomial_approximation {n : ℕ} + (ν : FiniteLaw (BooleanCube n)) (s : ℕ) (c : AC0Circuit n) : + ∃ P : BooleanCube n → ℝ, WalshDegreeLE P (c.approximationDegree s) ∧ + ν.probability (fun x => P x ≠ c.indicator x) ≤ + (c.size : ℝ) * (7 / 8 : ℝ) ^ s := by + induction c with + | literal i b => + refine ⟨(AC0Circuit.literal i b).indicator, literal_indicator_degree i b, ?_⟩ + simp only [ne_eq, not_true_eq_false, FiniteLaw.probability, FiniteLaw.average, + ite_false, mul_zero, sum_const_zero] + positivity + | @andGate k children ih => + choose P hP he using ih + let d := univ.sup (fun i => (children i).approximationDegree s) + have hdeg i : WalshDegreeLE (P i) d := + (hP i).mono (le_sup (f := fun i => (children i).approximationDegree s) (mem_univ i)) + obtain ⟨Q, hQ, herror⟩ := exists_composed_and_approximation ν k s d + (fun i => (children i).eval) P hdeg + (fun i => ((children i).size : ℝ) * (7 / 8 : ℝ) ^ s) he + refine ⟨Q, hQ, ?_⟩ + have hid (x : BooleanCube n) : (AC0Circuit.andGate children).indicator x = + boolAndValue (fun i => (children i).eval x) := by + simp only [AC0Circuit.indicator, AC0Circuit.eval, boolAndValue, decide_eq_true_eq] + simp only [hid] + convert herror using 1 + simp only [AC0Circuit.size, Nat.cast_add, Nat.cast_one, Nat.cast_sum, add_mul, + one_mul, sum_mul] + | @orGate k children ih => + choose P hP he using ih + let d := univ.sup (fun i => (children i).approximationDegree s) + have hdeg i : WalshDegreeLE (P i) d := + (hP i).mono (le_sup (f := fun i => (children i).approximationDegree s) (mem_univ i)) + obtain ⟨Q, hQ, herror⟩ := exists_composed_or_approximation ν k s d + (fun i => (children i).eval) P hdeg + (fun i => ((children i).size : ℝ) * (7 / 8 : ℝ) ^ s) he + refine ⟨Q, hQ, ?_⟩ + have hid (x : BooleanCube n) : (AC0Circuit.orGate children).indicator x = + boolOrValue (fun i => (children i).eval x) := by + simp only [AC0Circuit.indicator, AC0Circuit.eval, boolOrValue, decide_eq_true_eq] + simp only [hid] + convert herror using 1 + simp only [AC0Circuit.size, Nat.cast_add, Nat.cast_one, Nat.cast_sum, add_mul, + one_mul, sum_mul] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestriction.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..39e8ff3a55be97aadc46c8ac37998c99906c29f8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestriction.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitFourierTruncation + +namespace OAI + +/-! Restrictions retain the coordinates in `L` and fix every other bit. +Walsh characters factor into their live and fixed coordinates. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def restrictCube {n : ℕ} (L : Finset (Fin n)) + (y x : BooleanCube n) : BooleanCube n := fun i => if i ∈ L then x i else y i + +lemma walsh_restrictCube {n : ℕ} (L S : Finset (Fin n)) (y x : BooleanCube n) : + walsh S (restrictCube L y x) = walsh (S \ L) y * walsh (S ∩ L) x := by + have hu : S \ L ∪ S ∩ L = S := sdiff_union_inter S L + calc + _ = walsh (S \ L) (restrictCube L y x) * + walsh (S ∩ L) (restrictCube L y x) := by + simp only [walsh, ← prod_union (disjoint_sdiff_inter S L), hu] + _ = _ := by + congr 1 + · apply prod_congr rfl + intro i hi + simp only [restrictCube, ite_eq_right (mem_sdiff.mp hi).2] + · apply prod_congr rfl + intro i hi + simp only [restrictCube, ite_eq_left (mem_inter.mp hi).2] + +lemma WalshDegreeLE.restrict {n t : ℕ} {F : BooleanCube n → ℝ} + (hF : WalshDegreeLE F t) (L : Finset (Fin n)) (y : BooleanCube n) : + WalshDegreeLE (fun x => F (restrictCube L y x)) t := by + obtain ⟨a, ha⟩ := hF + have heq : (fun x => F (restrictCube L y x)) = fun x => + ∑ S ∈ (univ : Finset (Finset (Fin n))).filter (fun S => S.card ≤ t), + (a S * walsh (S \ L) y) * walsh (S ∩ L) x := by + funext x + rw [ha] + apply sum_congr rfl + intro S _ + rw [walsh_restrictCube] + ring + rw [heq] + apply WalshDegreeLE.sum + intro S hS + apply WalshDegreeLE.smul + apply WalshDegreeLE.of_walsh + exact (card_le_card inter_subset_left).trans (mem_filter.mp hS).2 + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionComposition.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionComposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fd7a31f8c3c96d0dd1ae392e09a194569a35f3b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionComposition.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitRestrictionDistribution + +namespace OAI + +/-! Applying two independent restrictions multiplies their live-coordinate +parameters. This is the distribution identity used for depth reduction. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def composeRestrictionBit (r s : Option Bool) : Option Bool := + match r with | none => s | some b => some b + +def composeRestriction {n : ℕ} (ρ τ : PartialAssignment n) : PartialAssignment n := + fun i => composeRestrictionBit (ρ i) (τ i) + +lemma composeRestriction_apply {n : ℕ} (ρ τ : PartialAssignment n) (x : BooleanCube n) : + (composeRestriction ρ τ).apply x = ρ.apply (τ.apply x) := by + funext i + cases hρ : ρ i <;> simp [composeRestriction, composeRestrictionBit, PartialAssignment.apply, hρ] + +lemma restriction_compose_atom (p q : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) + (hq : 0 ≤ q) (hq1 : q ≤ 1) (z : Option Bool) : + ((restrictionBitLaw p hp hp1).product (restrictionBitLaw q hq hq1)).probability + (fun b => composeRestrictionBit b.1 b.2 = z) = + (restrictionBitLaw (p * q) (mul_nonneg hp hq) (by nlinarith)).weight z := by + cases z with + | none => + simp [FiniteLaw.probability, FiniteLaw.average, FiniteLaw.product, + restrictionBitLaw, Fintype.sum_prod_type, Fintype.sum_option, composeRestrictionBit] + | some b => + cases b <;> + simp [FiniteLaw.probability, FiniteLaw.average, FiniteLaw.product, + restrictionBitLaw, Fintype.sum_prod_type, Fintype.sum_option, composeRestrictionBit] <;> + ring + +theorem restrictionLaw_compose {n : ℕ} (p q : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) + (hq : 0 ≤ q) (hq1 : q ≤ 1) (f : PartialAssignment n → ℝ) : + (restrictionLaw n p hp hp1).average (fun ρ => + (restrictionLaw n q hq hq1).average (fun τ => f (composeRestriction ρ τ))) = + (restrictionLaw n (p * q) (mul_nonneg hp hq) (by nlinarith)).average f := by + have hm := FiniteLaw.independent_average_map + (fun _ : Fin n => (restrictionBitLaw p hp hp1).product (restrictionBitLaw q hq hq1)) + (fun _ : Fin n => restrictionBitLaw (p * q) (mul_nonneg hp hq) (by nlinarith)) + (fun _ b => composeRestrictionBit b.1 b.2) + (fun _ z => restriction_compose_atom p q hp hp1 hq hq1 z) f + have hpair := FiniteLaw.independent_average_pair + (fun _ : Fin n => restrictionBitLaw p hp hp1) + (fun _ : Fin n => restrictionBitLaw q hq hq1) + (fun ρ τ => f (composeRestriction ρ τ)) + exact hpair.symm.trans hm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionDecay.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..162e15ba60c28b87dcc41dc63b87fdd941dfec4c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionDecay.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitRandomRestriction + +namespace OAI + +/-! The spectral consequence of simplifying a Boolean function under random +restrictions: only restrictions whose decision trees remain deep contribute. -/ + +namespace TwoPointCorrelations + +open scoped Classical + +lemma restricted_error_le_degree_failure {n t : ℕ} (f : BooleanCube n → ℝ) + (hf : ∀ x, f x = 0 ∨ f x = 1) (L : Finset (Fin n)) (y : BooleanCube n) : + cubeAverage (fun x => (f (restrictCube L y x) - + walshTruncation (fun z => f (restrictCube L y z)) t x) ^ 2) ≤ + if WalshDegreeLE (fun x => f (restrictCube L y x)) t then (0 : ℝ) else 1 := by + split_ifs with h + · rw [walshTruncation_error_eq_zero h] + · apply (walshTruncation_error_le_square _ _).trans + calc + cubeAverage (fun x => (f (restrictCube L y x)) ^ 2) ≤ + cubeAverage (fun _ : BooleanCube n => (1 : ℝ)) := by + apply cubeAverage_mono + intro x + rcases hf (restrictCube L y x) with hx | hx <;> simp [hx] + _ = 1 := cubeAverage_const 1 + +theorem fourier_tail_le_degree_failure {n : ℕ} (f : BooleanCube n → ℝ) + (hf : ∀ x, f x = 0 ∨ f x = 1) + (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) (t d : ℕ) + (ht : 2 * (t : ℝ) ≤ p * (d + 1)) (hd : 8 ≤ p * (d + 1)) : + cubeAverage (fun x => (f x - walshTruncation f d x) ^ 2) ≤ + 2 * (bernoulliCubeLaw n p hp hp1).average (fun mask => cubeAverage (fun y => + if WalshDegreeLE (fun x => f (restrictCube (sampledCoordinates mask) y x)) t + then (0 : ℝ) else 1)) := by + apply (fourier_tail_le_random_restriction f p hp hp1 t d ht hd).trans + apply mul_le_mul_of_nonneg_left _ (by norm_num) + apply FiniteLaw.average_mono + intro mask + apply cubeAverage_mono + intro y + exact restricted_error_le_degree_failure f hf _ y + +lemma degree_failure_le_decision_tree_failure {n t : ℕ} (f : BooleanCube n → ℝ) : + (if WalshDegreeLE f t then (0 : ℝ) else 1) ≤ + if ∃ c : BooleanDecisionTree n, c.depth ≤ t ∧ c.indicator = f then 0 else 1 := by + by_cases h : ∃ c : BooleanDecisionTree n, c.depth ≤ t ∧ c.indicator = f + · obtain ⟨c, hc, rfl⟩ := h + have hd := c.indicator_degree.mono hc + simp only [hd, ite_true] + split_ifs <;> norm_num + · simp only [h, ite_false] + split_ifs <;> norm_num + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionDistribution.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionDistribution.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e0b013fb8a688dcb2fb3523065eba1b2b0eb8f4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionDistribution.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitRestrictionLaw +import OAI.NumberTheory.TwoPoint.Circuits.CircuitGateFailure + +namespace OAI + +/-! The three-valued restriction law is exactly the experiment that first +chooses live bits and then independent uniform values for the fixed bits. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma FiniteLaw.independent_average_pair {n : ℕ} {α β : Type*} + [Fintype α] [Fintype β] (μ : Fin n → FiniteLaw α) (ν : Fin n → FiniteLaw β) + (f : (Fin n → α) → (Fin n → β) → ℝ) : + (independent (fun i => (μ i).product (ν i))).average + (fun z => f (fun i => (z i).1) (fun i => (z i).2)) = + (independent μ).average (fun x => (independent ν).average (f x)) := by + let e : (Fin n → α × β) ≃ ((Fin n → α) × (Fin n → β)) := + { toFun := fun z => (fun i => (z i).1, fun i => (z i).2) + invFun := fun z i => (z.1 i, z.2 i) + left_inv := fun _ => rfl + right_inv := fun _ => rfl } + calc + _ = ∑ z : (Fin n → α) × (Fin n → β), + (independent (fun i => (μ i).product (ν i))).weight (fun i => (z.1 i, z.2 i)) * + f z.1 z.2 := by + exact (e.symm.sum_comp (fun z => + (independent (fun i => (μ i).product (ν i))).weight z * + f (fun i => (z i).1) (fun i => (z i).2))).symm + _ = _ := by + simp only [average, independent, product, prod_mul_distrib, Fintype.sum_prod_type, + mul_sum, mul_assoc] + +lemma bernoulli_half_average {n : ℕ} (f : BooleanCube n → ℝ) : + (bernoulliCubeLaw n (1 / 2) (by norm_num) (by norm_num)).average f = cubeAverage f := by + have hw (x : BooleanCube n) : + (bernoulliCubeLaw n (1 / 2) (by norm_num) (by norm_num)).weight x = + (1 / 2 : ℝ) ^ n := by + norm_num [bernoulliCubeLaw, FiniteLaw.independent, booleanLaw, one_div] + simp only [one_div, inv_pow] + simp only [FiniteLaw.average, hw, ← mul_sum] + simp [cubeAverage, BooleanCube, div_eq_mul_inv, mul_comm] + +def partialAssignmentOfMask {n : ℕ} (mask y : BooleanCube n) : PartialAssignment n := + fun i => if mask i then none else some (y i) + +lemma partialAssignmentOfMask_apply {n : ℕ} (mask y x : BooleanCube n) : + (partialAssignmentOfMask mask y).apply x = restrictCube (sampledCoordinates mask) y x := by + funext i + cases hi : mask i <;> simp [partialAssignmentOfMask, PartialAssignment.apply, + restrictCube, sampledCoordinates, hi] + +lemma restriction_pair_atom (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) (z : Option Bool) : + ((booleanLaw p hp hp1).product (booleanLaw (1 / 2) (by norm_num) (by norm_num))).probability + (fun b => (if b.1 then none else some b.2) = z) = + (restrictionBitLaw p hp hp1).weight z := by + cases z with + | none => simp [FiniteLaw.probability, FiniteLaw.average, FiniteLaw.product, + booleanLaw, restrictionBitLaw, Fintype.sum_prod_type]; ring + | some b => cases b <;> + simp [FiniteLaw.probability, FiniteLaw.average, FiniteLaw.product, + booleanLaw, restrictionBitLaw, Fintype.sum_prod_type] <;> ring + +theorem restrictionLaw_average {n : ℕ} (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) + (f : PartialAssignment n → ℝ) : + (restrictionLaw n p hp hp1).average f = + (bernoulliCubeLaw n p hp hp1).average (fun mask => + cubeAverage (fun y => f (partialAssignmentOfMask mask y))) := by + have hm := FiniteLaw.independent_average_map + (fun _ : Fin n => (booleanLaw p hp hp1).product + (booleanLaw (1 / 2) (by norm_num) (by norm_num))) + (fun _ : Fin n => restrictionBitLaw p hp hp1) + (fun _ b => if b.1 then none else some b.2) + (fun _ z => restriction_pair_atom p hp hp1 z) f + unfold restrictionLaw + rw [← hm] + change (FiniteLaw.independent (fun _ : Fin n => (booleanLaw p hp hp1).product + (booleanLaw (1 / 2) (by norm_num) (by norm_num)))).average + (fun z => f (partialAssignmentOfMask (fun i => (z i).1) (fun i => (z i).2))) = _ + refine (FiniteLaw.independent_average_pair (fun _ : Fin n => booleanLaw p hp hp1) + (fun _ : Fin n => booleanLaw (1 / 2) (by norm_num) (by norm_num)) + (fun mask y => f (partialAssignmentOfMask mask y))).trans ?_ + apply congrArg (bernoulliCubeLaw n p hp hp1).average + funext mask + exact bernoulli_half_average _ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionFourier.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionFourier.lean new file mode 100644 index 0000000000000000000000000000000000000000..0419b47530cad66a738c5db377fd40cb939dbe1a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionFourier.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitRestriction + +namespace OAI + +/-! Orthogonality after fixing coordinates. Averaging over the fixed bits +removes all cross terms with different original Walsh supports. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma restricted_walshCoefficient {n : ℕ} (f : BooleanCube n → ℝ) + (L T : Finset (Fin n)) (y : BooleanCube n) : + walshCoefficient (fun x => f (restrictCube L y x)) T = + ∑ S ∈ (univ : Finset (Finset (Fin n))).filter (fun S => S ∩ L = T), + walshCoefficient f S * walsh (S \ L) y := by + have hf : (fun x => f (restrictCube L y x)) = fun x => + ∑ S : Finset (Fin n), + (walshCoefficient f S * walsh (S \ L) y) * walsh (S ∩ L) x := by + funext x + rw [← walsh_inversion f (restrictCube L y x)] + apply sum_congr rfl + intro S _ + rw [walsh_restrictCube] + ring + rw [hf] + change cubeAverage (fun x => (∑ S : Finset (Fin n), + (walshCoefficient f S * walsh (S \ L) y) * walsh (S ∩ L) x) * walsh T x) = _ + simp only [sum_mul] + rw [cubeAverage_sum, sum_filter] + apply sum_congr rfl + intro S _ + simp only [mul_assoc, cubeAverage_mul_const, cubeAverage_walsh_mul] + split_ifs <;> simp + +lemma restriction_support_injective {n : ℕ} (L T S U : Finset (Fin n)) + (hS : S ∩ L = T) (hU : U ∩ L = T) (h : S \ L = U \ L) : S = U := by + calc + S = S \ L ∪ S ∩ L := (sdiff_union_inter S L).symm + _ = U \ L ∪ U ∩ L := by rw [h, hS, hU] + _ = U := sdiff_union_inter U L + +theorem restricted_walshCoefficient_mean_sq {n : ℕ} (f : BooleanCube n → ℝ) + (L T : Finset (Fin n)) : + cubeAverage (fun y => (walshCoefficient (fun x => f (restrictCube L y x)) T) ^ 2) = + ∑ S ∈ (univ : Finset (Finset (Fin n))).filter (fun S => S ∩ L = T), + (walshCoefficient f S) ^ 2 := by + let I := (univ : Finset (Finset (Fin n))).filter (fun S => S ∩ L = T) + have heq : (fun y => (walshCoefficient (fun x => f (restrictCube L y x)) T) ^ 2) = + fun y => ∑ S ∈ I, ∑ U ∈ I, + (walshCoefficient f S * walshCoefficient f U) * + (walsh (S \ L) y * walsh (U \ L) y) := by + funext y + rw [restricted_walshCoefficient, pow_two, sum_mul] + apply sum_congr rfl + intro S _ + rw [mul_sum] + apply sum_congr rfl + intro U _ + ring + rw [heq, cubeAverage_sum] + apply sum_congr rfl + intro S hS + rw [cubeAverage_sum] + simp_rw [cubeAverage_mul_const, cubeAverage_walsh_mul] + rw [sum_eq_single S] + · simp [pow_two] + · intro U hU hUS + have hd : S \ L ≠ U \ L := by + intro hd + apply hUS + exact (restriction_support_injective L T S U + (mem_filter.mp hS).2 (mem_filter.mp hU).2 hd).symm + simp [hd] + · exact fun h => (h hS).elim + +theorem restricted_fourier_tail_mean {n : ℕ} (f : BooleanCube n → ℝ) + (L : Finset (Fin n)) (t : ℕ) : + cubeAverage (fun y => cubeAverage (fun x => + (f (restrictCube L y x) - walshTruncation (fun z => f (restrictCube L y z)) t x) ^ 2)) = + ∑ S ∈ (univ : Finset (Finset (Fin n))).filter (fun S => t < (S ∩ L).card), + (walshCoefficient f S) ^ 2 := by + simp_rw [walshTruncation_error] + rw [cubeAverage_sum] + simp_rw [restricted_walshCoefficient_mean_sq, sum_filter] + have hsum (T : Finset (Fin n)) : + (if t < T.card then ∑ S : Finset (Fin n), + if S ∩ L = T then (walshCoefficient f S) ^ 2 else 0 else 0) = + ∑ S : Finset (Fin n), if t < T.card then + (if S ∩ L = T then (walshCoefficient f S) ^ 2 else 0) else 0 := by + by_cases h : t < T.card <;> simp [h] + simp_rw [hsum] + rw [sum_comm] + apply sum_congr rfl + intro S _ + rw [sum_eq_single (S ∩ L)] + · simp + · intro T _ hT + by_cases ht : t < T.card <;> simp [ht, Ne.symm hT] + · intro h + exact (h (mem_univ _)).elim + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionLaw.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..19d32fc74668b2b4d12b4f364cbe8e6b04b6fdf9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionLaw.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitPartialAssignment +import OAI.NumberTheory.TwoPoint.Circuits.CircuitBernoulli + +namespace OAI + +/-! The three-valued product law for independent random restrictions. +Fixing `s` previously free coordinates changes weight by an exact factor. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def restrictionBitLaw (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) : + FiniteLaw (Option Bool) where + weight b := match b with | none => p | some _ => (1 - p) / 2 + nonneg b := by cases b <;> dsimp <;> positivity + total := by simp [Fintype.sum_option]; ring + +noncomputable def restrictionLaw (n : ℕ) (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) : + FiniteLaw (PartialAssignment n) := + FiniteLaw.independent (fun _ : Fin n => restrictionBitLaw p hp hp1) + +theorem restrictionLaw_assign_weight {n : ℕ} (p : ℝ) (hp : 0 ≤ p) (hp1 : p < 1) + (ρ : PartialAssignment n) (S : Finset (Fin n)) (hS : S ⊆ ρ.free) + (x : BooleanCube n) : + (restrictionLaw n p hp hp1.le).weight ρ = + (2 * p / (1 - p)) ^ S.card * + (restrictionLaw n p hp hp1.le).weight (ρ.assign S x) := by + have hn : 1 - p ≠ 0 := by linarith + have hpoint (i : Fin n) : + (restrictionBitLaw p hp hp1.le).weight (ρ i) = + (if i ∈ S then 2 * p / (1 - p) else 1) * + (restrictionBitLaw p hp hp1.le).weight (ρ.assign S x i) := by + by_cases hi : i ∈ S + · have hρ := (mem_filter.mp (hS hi)).2 + simp only [restrictionBitLaw, PartialAssignment.assign, hi, hρ, ite_true] + field_simp + · simp [PartialAssignment.assign, hi] + change (∏ i, (restrictionBitLaw p hp hp1.le).weight (ρ i)) = _ + simp_rw [hpoint] + rw [prod_mul_distrib, Fintype.prod_ite_mem, prod_const] + rfl + +theorem FiniteLaw.probability_le_of_encoding {α β : Type*} + [Fintype α] [Fintype β] (μ : FiniteLaw α) (E : α → Prop) + (encode : α → α × β) (r : ℝ) (hr : 0 ≤ r) + (hinj : ∀ x, E x → ∀ y, E y → encode x = encode y → x = y) + (hweight : ∀ x, E x → μ.weight x ≤ r * μ.weight (encode x).1) : + μ.probability E ≤ Fintype.card β * r := by + calc + μ.probability E = ∑ x ∈ (univ : Finset α).filter E, μ.weight x := by + simp [FiniteLaw.probability, FiniteLaw.average, sum_filter, mul_ite] + _ ≤ ∑ y : α × β, r * μ.weight y.1 := by + apply sum_le_sum_of_injOn encode + · intro x hx y hy h + exact hinj x (mem_filter.mp hx).2 y (mem_filter.mp hy).2 h + · exact fun _ _ => mem_univ _ + · exact fun x hx => hweight x (mem_filter.mp hx).2 + · exact fun y _ _ => mul_nonneg hr (μ.nonneg y.1) + _ = Fintype.card β * r := by + simp only [Fintype.sum_prod_type, sum_const, card_univ, nsmul_eq_mul] + rw [← mul_sum, ← mul_sum, μ.total] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionProbability.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..ebb0903d130a4265d2b6ebbe4665dadb69d224b6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionProbability.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitBernoulli +import OAI.NumberTheory.TwoPoint.Bounds.PrimeRowSecondMoment + +namespace OAI + +/-! A finite second-moment lower-tail bound for the live coordinates of a +random restriction. It is used to transfer high-degree Fourier mass. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma FiniteLaw.probability_mul_le_average {α : Type*} [Fintype α] + (μ : FiniteLaw α) (E : α → Prop) (f : α → ℝ) (a : ℝ) + (hf : ∀ x, 0 ≤ f x) (hE : ∀ x, E x → a ≤ f x) : + a * μ.probability E ≤ μ.average f := by + calc + _ = μ.average (fun x => if E x then a else 0) := by + unfold FiniteLaw.probability FiniteLaw.average + rw [mul_sum] + apply sum_congr rfl + intro x _ + by_cases hx : E x <;> simp [hx] + ring + _ ≤ _ := μ.average_mono (fun x => by by_cases hx : E x <;> simp [hx, hf x, hE x]) + +lemma independent_boolean_variance {ι : Type*} [Fintype ι] [DecidableEq ι] + (q : ι → ℝ) (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) : + (FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i))).average + (fun b => (booleanCount b - ∑ i, q i) ^ 2) ≤ ∑ i, q i := by + let μ := FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i)) + let V := ∑ i, q i + have hm : μ.average booleanCount = V := independent_boolean_count_average q hq0 hq1 + have hs : μ.average (fun b => (booleanCount b) ^ 2) ≤ V ^ 2 + V := + independent_boolean_count_square q hq0 hq1 + have he (b : ι → Bool) : (booleanCount b - V) ^ 2 = + (booleanCount b) ^ 2 + booleanCount b * (-2 * V) + V ^ 2 := by ring + change μ.average (fun b => (booleanCount b - V) ^ 2) ≤ V + simp_rw [he] + rw [μ.average_add, μ.average_add, μ.average_mul_const, μ.average_const, hm] + nlinarith + +theorem independent_boolean_lower_tail {ι : Type*} [Fintype ι] [DecidableEq ι] + (q : ι → ℝ) (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) + (a : ℝ) (ha : 2 * a ≤ ∑ i, q i) (hlarge : 8 ≤ ∑ i, q i) : + (FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i))).probability + (fun b => booleanCount b ≤ a) ≤ 1 / 2 := by + let μ := FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i)) + let V := ∑ i, q i + have hV : 0 < V := by dsimp [V]; linarith + have hp : ∀ b : ι → Bool, booleanCount b ≤ a → + 2 * V ≤ (booleanCount b - V) ^ 2 := by + intro b hb + have h1 : 0 ≤ V / 2 - booleanCount b := by dsimp [V]; linarith + have h2 : 0 ≤ 3 * V / 2 - booleanCount b := by dsimp [V]; linarith + have hh := mul_nonneg h1 h2 + have hv := mul_nonneg hV.le (show 0 ≤ V - 8 by dsimp [V]; linarith) + nlinarith + have hm := μ.probability_mul_le_average (fun b => booleanCount b ≤ a) + (fun b => (booleanCount b - V) ^ 2) (2 * V) (fun _ => sq_nonneg _) hp + have hv := independent_boolean_variance q hq0 hq1 + change μ.average (fun b => (booleanCount b - V) ^ 2) ≤ V at hv + apply (mul_le_mul_iff_right₀ (show 0 < 2 * V by positivity)).mp + calc + 2 * V * μ.probability (fun b => booleanCount b ≤ a) ≤ V := hm.trans hv + _ = 2 * V * (1 / 2) := by ring + +theorem independent_boolean_survival {ι : Type*} [Fintype ι] [DecidableEq ι] + (q : ι → ℝ) (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i ≤ 1) + (a : ℝ) (ha : 2 * a ≤ ∑ i, q i) (hlarge : 8 ≤ ∑ i, q i) : + 1 / 2 ≤ (FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i))).probability + (fun b => a < booleanCount b) := by + let μ := FiniteLaw.independent (fun i => booleanLaw (q i) (hq0 i) (hq1 i)) + have h := independent_boolean_lower_tail q hq0 hq1 a ha hlarge + have hc : μ.probability (fun b => a < booleanCount b) = + 1 - μ.probability (fun b => booleanCount b ≤ a) := by + simpa only [not_le] using μ.probability_complement (fun b => booleanCount b ≤ a) + rw [hc] + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionSurvival.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionSurvival.lean new file mode 100644 index 0000000000000000000000000000000000000000..d41f6992ea00c76972e87110865acdd8b47d86e5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitRestrictionSurvival.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitRestrictionProbability +import OAI.NumberTheory.TwoPoint.Circuits.CircuitGateFailure + +namespace OAI + +/-! A Fourier support with sufficiently many expected live coordinates +retains more than `t` coordinates with probability at least one half. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma booleanCount_restrict {n : ℕ} (S : Finset (Fin n)) (x : BooleanCube n) : + booleanCount (fun i : S => x i) = ((S ∩ sampledCoordinates x).card : ℝ) := by + unfold booleanCount + rw [sum_coe_sort S (fun i => if x i then (1 : ℝ) else 0)] + have hset : S ∩ sampledCoordinates x = S.filter (fun i => x i = true) := by + ext i + simp [sampledCoordinates] + rw [hset] + exact sum_boole (fun i => x i = true) S + +theorem bernoulli_support_survival {n : ℕ} (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) + (S : Finset (Fin n)) (t : ℕ) + (ht : 2 * (t : ℝ) ≤ p * S.card) (hlarge : 8 ≤ p * S.card) : + 1 / 2 ≤ (bernoulliCubeLaw n p hp hp1).probability + (fun x => t < (S ∩ sampledCoordinates x).card) := by + have h := independent_boolean_survival (fun _ : S => p) (fun _ => hp) (fun _ => hp1) + (t : ℝ) (by simpa [mul_comm] using ht) (by simpa [mul_comm] using hlarge) + have heq : (bernoulliCubeLaw n p hp hp1).probability + (fun x => t < (S ∩ sampledCoordinates x).card) = + (FiniteLaw.independent (fun _ : S => booleanLaw p hp hp1)).probability + (fun x => (t : ℝ) < booleanCount x) := by + unfold FiniteLaw.probability + refine Eq.trans ?_ (FiniteLaw.independent_average_restrict + (fun _ : Fin n => booleanLaw p hp hp1) S + (fun x => if (t : ℝ) < booleanCount x then (1 : ℝ) else 0)) + apply congrArg (bernoulliCubeLaw n p hp hp1).average + funext x + simp only [booleanCount_restrict, Nat.cast_lt] + by_cases hx : t < (S ∩ sampledCoordinates x).card <;> simp [hx] + rw [heq] + exact h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSampleNorm.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSampleNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d41d6202ed26de230a848565db16e3f80d3f561 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSampleNorm.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitGateFailure + +namespace OAI + +/-! Pointwise norm bounds for the sampled polynomial. These control the +exceptional values when the Fourier approximation is used as a cutoff. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma andGateFactor_abs_le {k : ℕ} (S : Finset (Fin k)) (u : Fin k → ℝ) + {B : ℝ} (hB : 0 ≤ B) (hu : ∀ i, |u i| ≤ B) : + |andGateFactor S u| ≤ 1 + (k : ℝ) * (1 + B) := by + have hcard : (S.card : ℝ) ≤ k := by + exact_mod_cast (card_le_card (subset_univ S)).trans_eq (card_fin k) + calc + _ ≤ |(1 : ℝ)| + |∑ i ∈ S, (1 - u i)| := abs_sub _ _ + _ ≤ 1 + ∑ i ∈ S, |1 - u i| := by + simpa only [abs_one] using add_le_add (le_refl (1 : ℝ)) + (abs_sum_le_sum_abs (fun i => 1 - u i) S) + _ ≤ 1 + ∑ _i ∈ S, (1 + B) := by + apply add_le_add (le_refl (1 : ℝ)) + apply sum_le_sum + intro i _ + exact (abs_sub _ _).trans + (by simpa only [abs_one] using (add_le_add (le_refl (1 : ℝ)) (hu i))) + _ = 1 + (S.card : ℝ) * (1 + B) := by simp only [sum_const, nsmul_eq_mul] + _ ≤ _ := add_le_add (le_refl (1 : ℝ)) + (mul_le_mul_of_nonneg_right hcard (by positivity)) + +lemma sampledAndPolynomial_abs_le {k s : ℕ} (sample : GateSamplingChoices k k s) + (u : Fin k → ℝ) {B : ℝ} (hB : 0 ≤ B) (hu : ∀ i, |u i| ≤ B) : + |sampledAndPolynomial sample u| ≤ + (1 + (k : ℝ) * (1 + B)) ^ (s * (Nat.log 2 k + 3)) := by + calc + _ = ∏ a : Fin (Nat.log 2 k + 3), ∏ j : Fin s, + |andGateFactor (sampledCoordinates (sample a j)) u| := by + simp only [sampledAndPolynomial, abs_prod] + _ ≤ ∏ _a : Fin (Nat.log 2 k + 3), ∏ _j : Fin s, + (1 + (k : ℝ) * (1 + B)) := by + apply prod_le_prod₀ + · intro a _ + exact prod_nonneg (fun _ _ => abs_nonneg _) + · intro a _ + exact prod_le_prod₀ (fun _ _ => abs_nonneg _) + (fun j _ => andGateFactor_abs_le _ u hB hu) + _ = _ := by simp only [prod_const, card_univ, Fintype.card_fin, ← pow_mul] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSamplingException.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSamplingException.lean new file mode 100644 index 0000000000000000000000000000000000000000..a72f7d31b149be28f586d5ec0508e9c99373154f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSamplingException.lean @@ -0,0 +1,159 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitIsolationEvent + +namespace OAI + +/-! The exceptional event is expressed by the single-hit circuits, so it +can itself be approximated by Fourier truncation in the next stage. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma isolatesOne_false_iff {k : ℕ} (b mask : BooleanCube k) : + isolatesOne (falseCoordinates b) mask ↔ + ∃ i : sampledCoordinates mask, b i = false ∧ + ∀ j : sampledCoordinates mask, j ≠ i → b j = true := by + constructor + · rintro ⟨i, hi, hm⟩ + have hbi : b i = false := (mem_filter.mp hi).2 + have hmi : mask i = true := by simpa [singleBitPattern] using hm i hi + let v : sampledCoordinates mask := ⟨i, by simp [sampledCoordinates, hmi]⟩ + refine ⟨v, hbi, ?_⟩ + intro j hji + have hval : j.val ≠ i := fun h => hji (Subtype.ext h) + have hmj : mask j = true := (mem_filter.mp j.property).2 + cases hb : b j + · have hj : j.val ∈ falseCoordinates b := by simp [falseCoordinates, hb] + have ht := hm j hj + simp [singleBitPattern, hval, hmj] at ht + · rfl + · rintro ⟨i, hbi, hj⟩ + refine ⟨i, by simp [falseCoordinates, hbi], ?_⟩ + intro j hjfalse + have hbj : b j = false := (mem_filter.mp hjfalse).2 + by_cases hji : j = i.val + · subst j + have hmi : mask i = true := (mem_filter.mp i.property).2 + simpa [singleBitPattern] using hmi + · have hmj : mask j = false := by + cases hmask : mask j + · rfl + · let v : sampledCoordinates mask := ⟨j, by simp [sampledCoordinates, hmask]⟩ + have hne : v ≠ i := fun h => hji (congrArg Subtype.val h) + have htrue := hj v hne + rw [show b v = false from hbj] at htrue + contradiction + simp [singleBitPattern, hji, hmj] + +namespace AC0Circuit + +noncomputable def gateSamplingException {n k s : ℕ} + (sample : GateSamplingChoices k k s) (c : Fin k → AC0Circuit n) : AC0Circuit n := + conjunction (fun flag : Bool => if flag then + (certificateDisjunction (fun j : Fin (Nat.log 2 k + 3) × Fin s => + uniqueFalseCircuit c (sampledCoordinates (sample j.1 j.2)))).negate + else (andGate c).negate) + +lemma gateSamplingException_eval {n k s : ℕ} + (sample : GateSamplingChoices k k s) (c : Fin k → AC0Circuit n) + (x : BooleanCube n) : + (gateSamplingException sample c).eval x = true ↔ + (¬∀ i, (c i).eval x = true) ∧ + ∀ a j, ¬isolatesOne (falseCoordinates (fun i => (c i).eval x)) (sample a j) := by + simp only [gateSamplingException, conjunction_eval, Bool.forall_bool, Bool.false_eq_true, + ite_false, ite_true, negate_eval, ne_eq, certificateDisjunction_eval, uniqueFalseCircuit_eval, + eval, decide_eq_true_eq, not_exists, Prod.forall, isolatesOne_false_iff] + +lemma gateSamplingException_depth {n k s d : ℕ} + (sample : GateSamplingChoices k k s) (c : Fin k → AC0Circuit n) + (hc : ∀ i, (c i).depth ≤ d) : + (gateSamplingException sample c).depth ≤ d + 4 := by + apply conjunction_depth + intro flag + cases flag + · simp only [Bool.false_eq_true, ite_false, negate_depth, depth] + have h := Finset.sup_le (fun i (_ : i ∈ univ) => hc i) + omega + · simp only [ite_true, negate_depth] + apply certificateDisjunction_depth + intro j + exact uniqueFalseCircuit_depth c hc _ + +lemma gateSamplingException_size {n k s : ℕ} + (sample : GateSamplingChoices k k s) (c : Fin k → AC0Circuit n) : + (gateSamplingException sample c).size ≤ + 3 + (∑ i, (c i).size) + s * (Nat.log 2 k + 3) * + (1 + k * (1 + ∑ i, (c i).size)) := by + rw [gateSamplingException, conjunction_size] + simp only [Fintype.sum_bool, Bool.false_eq_true, ite_false, ite_true, negate_size, + certificateDisjunction_size, size] + have hsum : (∑ j : Fin (Nat.log 2 k + 3) × Fin s, + (uniqueFalseCircuit c (sampledCoordinates (sample j.1 j.2))).size) ≤ + s * (Nat.log 2 k + 3) * (1 + k * (1 + ∑ i, (c i).size)) := by + calc + _ ≤ ∑ _j : Fin (Nat.log 2 k + 3) × Fin s, + (1 + k * (1 + ∑ i, (c i).size)) := + sum_le_sum (fun j _ => uniqueFalseCircuit_size_le c _) + _ = _ := by simp only [sum_const, card_univ, Fintype.card_prod, + Fintype.card_fin, nsmul_eq_mul, Nat.cast_id]; ring + omega + +end AC0Circuit + +lemma sampledAndPolynomial_error_detected {n k s : ℕ} + (sample : GateSamplingChoices k k s) (c : Fin k → AC0Circuit n) + (x : BooleanCube n) + (h : sampledAndPolynomial sample (fun i => (c i).indicator x) ≠ + (AC0Circuit.andGate c).indicator x) : + (AC0Circuit.gateSamplingException sample c).eval x = true := by + rw [AC0Circuit.gateSamplingException_eval] + have hb : sampledAndPolynomial sample (fun i => if (c i).eval x then 1 else 0) ≠ + boolAndValue (fun i => (c i).eval x) := by + simpa only [AC0Circuit.indicator, AC0Circuit.eval, decide_eq_true_eq, boolAndValue] using h + refine ⟨?_, sampledAndPolynomial_failure sample _ hb⟩ + intro hall + apply hb + rw [sampledAndPolynomial_all_true sample _ hall] + exact (ite_eq_left hall).symm + +lemma gateSamplingException_pointwise_probability {n k : ℕ} (s : ℕ) + (c : Fin k → AC0Circuit n) (x : BooleanCube n) : + (gateSamplingLaw k k s).probability + (fun sample => (AC0Circuit.gateSamplingException sample c).eval x = true) ≤ + (7 / 8 : ℝ) ^ s := by + by_cases hall : ∀ i, (c i).eval x = true + · have hz : (gateSamplingLaw k k s).probability + (fun sample => (AC0Circuit.gateSamplingException sample c).eval x = true) = 0 := by + have he (sample : GateSamplingChoices k k s) : + ¬(AC0Circuit.gateSamplingException sample c).eval x = true := by + intro h + exact ((AC0Circuit.gateSamplingException_eval sample c x).mp h).1 hall + unfold FiniteLaw.probability + simp only [ite_eq_right (he _)] + exact FiniteLaw.average_const (gateSamplingLaw k k s) 0 + rw [hz] + positivity + · have hnonempty : (falseCoordinates (fun i => (c i).eval x)).Nonempty := by + push Not at hall + obtain ⟨i, hi⟩ := hall + refine ⟨i, ?_⟩ + cases hb : (c i).eval x <;> simp_all [falseCoordinates] + have hcard : (falseCoordinates (fun i => (c i).eval x)).card ≤ k := by + exact (card_le_card (filter_subset _ _)).trans_eq (card_fin k) + apply le_trans ((gateSamplingLaw k k s).probability_mono ?_) + (gateSamplingLaw_failure k k s _ hnonempty hcard) + intro sample hsample + exact (AC0Circuit.gateSamplingException_eval sample c x).mp hsample |>.2 + +theorem exists_gateSamplingException_small {n k : ℕ} + (ν : FiniteLaw (BooleanCube n)) (s : ℕ) (c : Fin k → AC0Circuit n) : + ∃ sample : GateSamplingChoices k k s, + ν.probability (fun x => (AC0Circuit.gateSamplingException sample c).eval x = true) ≤ + (7 / 8 : ℝ) ^ s := by + exact exists_choice_of_pointwise_failure (gateSamplingLaw k k s) ν _ + (gateSamplingException_pointwise_probability s c) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSamplingGrid.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSamplingGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e5188e9554b85de824d38e7afe45b1da74983d0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSamplingGrid.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitIsolation +import OAI.NumberTheory.TwoPoint.Bounds.IndependentSampling + +namespace OAI + +/-! A logarithmic grid of repeated Bernoulli samplers isolates a member of +every nonempty marked set, with failure at most `(7/8)^s`. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def dyadicCubeLaw (n a : ℕ) : FiniteLaw (BooleanCube n) := + bernoulliCubeLaw n (1 / (2 : ℝ) ^ a) (by positivity) + (by + have hpow : (1 : ℝ) ≤ (2 : ℝ) ^ a := one_le_pow₀ (by norm_num) + simpa only [div_one] using + one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 1) hpow) + +abbrev GateSamplingChoices (n k s : ℕ) := Fin (Nat.log 2 k + 3) → Fin s → BooleanCube n + +noncomputable def gateSamplingLaw (n k s : ℕ) : FiniteLaw (GateSamplingChoices n k s) := + FiniteLaw.independent (fun a : Fin (Nat.log 2 k + 3) => + FiniteLaw.independent (fun _ : Fin s => dyadicCubeLaw n a.val)) + +theorem gateSamplingLaw_failure (n k s : ℕ) (S : Finset (Fin n)) + (hS : S.Nonempty) (hSk : S.card ≤ k) : + (gateSamplingLaw n k s).probability + (fun x => ∀ a i, ¬isolatesOne S (x a i)) ≤ (7 / 8 : ℝ) ^ s := by + obtain ⟨a, ha, hhit⟩ := exists_dyadic_single_hit k S.card hS.card_pos hSk + let a₀ : Fin (Nat.log 2 k + 3) := ⟨a, by omega⟩ + have hsingle : (1 / 8 : ℝ) ≤ (dyadicCubeLaw n a).probability (isolatesOne S) := by + simpa only [dyadicCubeLaw, bernoulliCubeLaw_isolatesOne] using hhit + calc + _ = ∏ b : Fin (Nat.log 2 k + 3), + (FiniteLaw.independent (fun _ : Fin s => dyadicCubeLaw n b.val)).probability + (fun x => ∀ i, ¬isolatesOne S (x i)) := + FiniteLaw.independent_probability_all _ _ + (∏ b : Fin (Nat.log 2 k + 3), + (FiniteLaw.independent (fun _ : Fin s => dyadicCubeLaw n b.val)).probability + (fun x => ∀ i, ¬isolatesOne S (x i))) ≤ + ∏ b : Fin (Nat.log 2 k + 3), if b = a₀ then (7 / 8 : ℝ) ^ s else 1 := by + apply prod_le_prod₀ + · intro b _ + exact FiniteLaw.probability_nonneg _ _ + · intro b _ + by_cases hb : b = a₀ + · subst b + rw [ite_eq_left rfl] + exact (dyadicCubeLaw n a).independent_failure_le (isolatesOne S) s hsingle + · rw [ite_eq_right hb] + exact FiniteLaw.probability_le_one _ _ + _ = (7 / 8 : ℝ) ^ s := by simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSemiExact.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSemiExact.lean new file mode 100644 index 0000000000000000000000000000000000000000..13b808c59609bfaa4ecdfacdcde93758cb858506 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSemiExact.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitPolynomialAlgebra + +namespace OAI + +/-! The finite algebraic steps of Braverman's Lemmas 11–12. A polynomial +that vanishes off a Boolean event gives a pointwise minorant after applying +`p ↦ 1 - (1-p)^2`; the uniform squared error is exactly the minorant gap. +Only the approximation construction, not this expectation argument, needs +the circuit-depth estimates. -/ + +namespace TwoPointCorrelations + +variable {n : ℕ} + +noncomputable def semiExactMinorant (P : BooleanCube n → ℝ) (x : BooleanCube n) : ℝ := + 1 - (1 - P x) ^ 2 + +lemma semiExactMinorant_le {F P : BooleanCube n → ℝ} + (hF : ∀ x, F x = 0 ∨ F x = 1) (hzero : ∀ x, F x = 0 → P x = 0) : + ∀ x, semiExactMinorant P x ≤ F x := by + intro x + rcases hF x with hx | hx + · simp [semiExactMinorant, hzero x hx, hx] + · rw [hx] + unfold semiExactMinorant + nlinarith [sq_nonneg (1 - P x)] + +lemma semiExactMinorant_gap {F P : BooleanCube n → ℝ} + (hF : ∀ x, F x = 0 ∨ F x = 1) (hzero : ∀ x, F x = 0 → P x = 0) : + ∀ x, F x - semiExactMinorant P x = (F x - P x) ^ 2 := by + intro x + rcases hF x with hx | hx + · simp [semiExactMinorant, hzero x hx, hx] + · simp only [semiExactMinorant, hx] + ring + +lemma WalshDegreeLE.minorant {P : BooleanCube n → ℝ} {d : ℕ} + (hP : WalshDegreeLE P d) : WalshDegreeLE (semiExactMinorant P) (d + d) := by + have hp := (WalshDegreeLE.const (n := n) 1 d).sub hP + have hs := hp.mul hp + have hq := (WalshDegreeLE.const (n := n) 1 (d + d)).sub hs + change WalshDegreeLE (fun x => 1 - (1 - P x) ^ 2) (d + d) + simpa only [pow_two] using hq + +/-- A small exceptional set and a semi-exact low-degree approximation give +the required one-sided comparison of the original Boolean expectation. -/ +theorem TWiseUniformDensity.semiExact_lower {t : ℕ} + {g F F₀ P : BooleanCube n → ℝ} + (hg : TWiseUniformDensity g t) (hn : ∀ x, 0 ≤ g x) + (hF₀ : ∀ x, F₀ x = 0 ∨ F₀ x = 1) + (hzero : ∀ x, F₀ x = 0 → P x = 0) + (hdeg : WalshDegreeLE (semiExactMinorant P) t) + {δu δg ε : ℝ} + (hu : cubeAverage (fun x => |F x - F₀ x|) ≤ δu) + (hmu : cubeAverage (fun x => g x * |F x - F₀ x|) ≤ δg) + (herr : cubeAverage (fun x => (F₀ x - P x) ^ 2) ≤ ε) : + cubeAverage F - (δu + δg + ε) ≤ cubeAverage (fun x => g x * F x) := by + have hu' : cubeAverage F ≤ cubeAverage F₀ + δu := by + have hb : ∀ x, F x ≤ F₀ x + |F x - F₀ x| := by + intro x + linarith [le_abs_self (F x - F₀ x)] + have h := cubeAverage_mono hb + rw [cubeAverage_add] at h + linarith + have hgap : cubeAverage F₀ - cubeAverage (semiExactMinorant P) ≤ ε := by + rw [← cubeAverage_sub] + simpa only [semiExactMinorant_gap hF₀ hzero] using herr + have hlow : cubeAverage (semiExactMinorant P) ≤ + cubeAverage (fun x => g x * F₀ x) := by + have h := cubeAverage_mono (fun x => mul_le_mul_of_nonneg_left + (semiExactMinorant_le hF₀ hzero x) (hn x)) + rw [hg.polynomial_expectation hdeg] at h + exact h + have hmu' : cubeAverage (fun x => g x * F₀ x) ≤ + cubeAverage (fun x => g x * F x) + δg := by + have hb : ∀ x, g x * F₀ x ≤ g x * F x + g x * |F x - F₀ x| := by + intro x + have h : F₀ x ≤ F x + |F x - F₀ x| := by + have ha := le_abs_self (F₀ x - F x) + rw [abs_sub_comm] at ha + linarith + have h' := mul_le_mul_of_nonneg_left h (hn x) + nlinarith only [h'] + have h := cubeAverage_mono hb + rw [cubeAverage_add] at h + linarith + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSwitchingLemma.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSwitchingLemma.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e9eaf33afde5637afd888023daec81e67219214 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSwitchingLemma.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitSwitchingMass +import OAI.NumberTheory.TwoPoint.Circuits.CircuitTreeWalk +import OAI.NumberTheory.TwoPoint.Circuits.CircuitGateApproximation +import Mathlib.Analysis.SpecificLimits.Basic + +namespace OAI + +/-! A switching estimate sufficient for the fixed-depth application. The +position/separator encoding gives a quadratic dependence on term width; +this still yields polylogarithmic degree for every fixed circuit depth. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma finite_geometric_tail (n s : ℕ) (q : ℝ) (hq : 0 ≤ q) (hqhalf : q ≤ 1 / 2) : + (∑ i : Fin (n + 1), if s ≤ i.val then q ^ i.val else 0) ≤ 2 * q ^ s := by + let I := (univ : Finset (Fin (n + 1))).filter (fun i => s ≤ i.val) + have hs : (∑ i : Fin (n + 1), if s ≤ i.val then q ^ i.val else 0) = + ∑ i ∈ I, q ^ i.val := (sum_filter _ _).symm + rw [hs] + calc + _ ≤ ∑ j ∈ range (n + 1), q ^ s * (1 / 2 : ℝ) ^ j := by + apply sum_le_sum_of_injOn (fun i : Fin (n + 1) => i.val - s) + · intro i hi j hj hij + apply Fin.ext + have his := (mem_filter.mp hi).2 + have hjs := (mem_filter.mp hj).2 + change i.val - s = j.val - s at hij + omega + · intro _ hj + obtain ⟨i, _, rfl⟩ := mem_image.mp hj + exact mem_range.mpr (Nat.lt_of_le_of_lt (Nat.sub_le _ _) i.isLt) + · intro i hi + have his := (mem_filter.mp hi).2 + calc + q ^ i.val = q ^ s * q ^ (i.val - s) := by rw [← pow_add, Nat.add_sub_of_le his] + _ ≤ _ := mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hq hqhalf _) (pow_nonneg hq _) + · intro j _ _ + positivity + _ = q ^ s * ∑ j ∈ range (n + 1), (1 / 2 : ℝ) ^ j := by rw [mul_sum] + _ ≤ q ^ s * 2 := mul_le_mul_of_nonneg_left (sum_geometric_two_le _) (pow_nonneg hq _) + _ = _ := mul_comm _ _ + +theorem canonicalDNFTree_switching {n w : ℕ} (F : List (CubeTerm n)) + (hF : ∀ C ∈ F, C.support.card ≤ w) + (p : ℝ) (hp : 0 ≤ p) (hp1 : p < 1) + (hq : ((3 * (2 * w + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p)) ≤ 1 / 2) + (s : ℕ) : + (restrictionLaw n p hp hp1.le).probability + (fun ρ => s ≤ (canonicalDNFTree F ρ).depth) ≤ + 2 * (((3 * (2 * w + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p))) ^ s := by + let μ := restrictionLaw n p hp hp1.le + let q := ((3 * (2 * w + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p)) + let E := fun i : Fin (n + 1) => fun ρ : PartialAssignment n => + s ≤ i.val ∧ ∃ bs, CanonicalDNFWalk F ρ bs ∧ DNFQueryBlock.length bs = i.val + have hq0 : 0 ≤ q := by dsimp [q]; positivity + have hcover : μ.probability (fun ρ => s ≤ (canonicalDNFTree F ρ).depth) ≤ + μ.probability (fun ρ => ∃ i : Fin (n + 1), E i ρ) := by + apply μ.probability_mono + intro ρ hρ + obtain ⟨bs, hb, hdepth⟩ := canonicalDNFTree_depth_walk F ρ + let i : Fin (n + 1) := ⟨DNFQueryBlock.length bs, Nat.lt_succ_of_le hb.length_le_dimension⟩ + exact ⟨i, hρ.trans hdepth, bs, hb, rfl⟩ + have heach (i : Fin (n + 1)) : μ.probability (E i) ≤ + if s ≤ i.val then q ^ i.val else 0 := by + by_cases his : s ≤ i.val + · rw [ite_eq_left his] + apply (μ.probability_mono (fun ρ hρ => hρ.2)).trans + have hb := canonicalWalk_probability F hF p hp hp1 (h := i.val) + simpa only [q, mul_pow] using hb + · rw [ite_eq_right his] + have he : μ.probability (E i) = 0 := by + unfold FiniteLaw.probability + calc + _ = μ.average (fun _ => 0) := by + apply congrArg μ.average + funext ρ + simp [E, his] + _ = 0 := μ.average_const 0 + exact he.le + exact hcover.trans ((μ.probability_exists_le E).trans + ((sum_le_sum (fun i _ => heach i)).trans (finite_geometric_tail n s q hq0 hq))) + +theorem dnf_restriction_has_shallow_tree {n w : ℕ} (F : List (CubeTerm n)) + (hF : ∀ C ∈ F, C.support.card ≤ w) + (p : ℝ) (hp : 0 ≤ p) (hp1 : p < 1) + (hq : ((3 * (2 * w + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p)) ≤ 1 / 2) + (t : ℕ) : + (restrictionLaw n p hp hp1.le).probability + (fun ρ => ¬ ∃ T : BooleanDecisionTree n, T.depth ≤ t ∧ + ∀ x, T.eval x = dnfEval F (ρ.apply x)) ≤ + 2 * (((3 * (2 * w + 3) ^ 2 : ℕ) : ℝ) * (2 * p / (1 - p))) ^ (t + 1) := by + apply (FiniteLaw.probability_mono _ ?_).trans + (canonicalDNFTree_switching F hF p hp hp1 hq (t + 1)) + intro ρ hρ + have hn : ¬ (canonicalDNFTree F ρ).depth ≤ t := by + intro ht + exact hρ ⟨canonicalDNFTree F ρ, ht, canonicalDNFTree_eval F ρ⟩ + omega + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSwitchingMass.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSwitchingMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..1546bfa3ce0b743fe79f7782258208986d2fa8ad --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitSwitchingMass.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitWalkCode +import OAI.NumberTheory.TwoPoint.Circuits.CircuitFiniteCodes + +namespace OAI + +/-! The weighted injection bounds the probability of canonical query walks +of any specified length. The bound depends on term width and query count, +and is independent of the number of terms. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem canonicalWalk_probability {n w h : ℕ} (F : List (CubeTerm n)) + (hF : ∀ C ∈ F, C.support.card ≤ w) + (p : ℝ) (hp : 0 ≤ p) (hp1 : p < 1) : + (restrictionLaw n p hp hp1.le).probability + (fun ρ => ∃ bs, CanonicalDNFWalk F ρ bs ∧ DNFQueryBlock.length bs = h) ≤ + ((3 * (2 * w + 3) ^ 2 : ℕ) : ℝ) ^ h * (2 * p / (1 - p)) ^ h := by + let E := fun ρ : PartialAssignment n => + ∃ bs, CanonicalDNFWalk F ρ bs ∧ DNFQueryBlock.length bs = h + let pick (ρ : PartialAssignment n) (he : E ρ) := Classical.choose he + have hpick (ρ : PartialAssignment n) (he : E ρ) : + CanonicalDNFWalk F ρ (pick ρ he) ∧ DNFQueryBlock.length (pick ρ he) = h := + Classical.choose_spec he + let code (ρ : PartialAssignment n) (he : E ρ) : BoundedRestrictionCode w (2 * h) := + packRestrictionCode w (2 * h) (DNFQueryBlock.codes (pick ρ he)) + (by rw [← (hpick ρ he).2]; exact (hpick ρ he).1.codes_length_le) + ((hpick ρ he).1.code_positions_le hF) + let empty : BoundedRestrictionCode w (2 * h) := + ⟨⟨0, Nat.succ_pos _⟩, Fin.elim0⟩ + let encode (ρ : PartialAssignment n) : PartialAssignment n × BoundedRestrictionCode w (2 * h) := + if he : E ρ then (DNFQueryBlock.image ρ (pick ρ he), code ρ he) else (ρ, empty) + have hinj : ∀ ρ, E ρ → ∀ τ, E τ → encode ρ = encode τ → ρ = τ := by + intro ρ hρ τ hτ heq + have heq' : (DNFQueryBlock.image ρ (pick ρ hρ), code ρ hρ) = + (DNFQueryBlock.image τ (pick τ hτ), code τ hτ) := by + simpa only [encode, dite_eq_left hρ, dite_eq_left hτ] using heq + have hc := congrArg (fun z : PartialAssignment n × BoundedRestrictionCode w (2 * h) => + readRestrictionCode z.2) heq' + simp only [code, read_packRestrictionCode] at hc + exact (hpick ρ hρ).1.image_code_injective (hpick τ hτ).1 (congrArg Prod.fst heq') hc + have hr : 0 ≤ (2 * p / (1 - p)) ^ h := by positivity + have hw : ∀ ρ, E ρ → (restrictionLaw n p hp hp1.le).weight ρ ≤ + (2 * p / (1 - p)) ^ h * (restrictionLaw n p hp hp1.le).weight (encode ρ).1 := by + intro ρ he + have heq := (hpick ρ he).1.image_weight p hp hp1 + rw [(hpick ρ he).2] at heq + simpa only [encode, dite_eq_left he] using heq.le + have hprob := (restrictionLaw n p hp hp1.le).probability_le_of_encoding E encode + ((2 * p / (1 - p)) ^ h) hr hinj hw + apply hprob.trans + apply mul_le_mul_of_nonneg_right _ hr + exact_mod_cast boundedRestrictionCode_card_queries w h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitTreeWalk.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitTreeWalk.lean new file mode 100644 index 0000000000000000000000000000000000000000..194980d5881262509e0dfefa67ec57fb4d7680d0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitTreeWalk.lean @@ -0,0 +1,109 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitCanonicalTree +import OAI.NumberTheory.TwoPoint.Circuits.CircuitQueryWalk + +namespace OAI + +/-! A longest branch of the concrete canonical tree supplies a query walk +with at least that many queried variables. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace BooleanDecisionTree + +lemma queryVariables_depth_state {n : ℕ} (is : List (Fin n)) + (k : PartialAssignment n → BooleanDecisionTree n) (ρ : PartialAssignment n) : + ∃ τ : PartialAssignment n, + (queryVariables is k ρ).depth = is.length + (k τ).depth ∧ + (∀ j ∉ is.toFinset, τ j = ρ j) ∧ + (∀ j ∈ is.toFinset, ∃ b, τ j = some b) := by + induction is generalizing ρ with + | nil => exact ⟨ρ, by simp [queryVariables], fun _ _ => rfl, by simp⟩ + | cons i is ih => + obtain ⟨b, hb⟩ : ∃ b : Bool, + max (queryVariables is k (Function.update ρ i (some false))).depth + (queryVariables is k (Function.update ρ i (some true))).depth = + (queryVariables is k (Function.update ρ i (some b))).depth := by + by_cases h : (queryVariables is k (Function.update ρ i (some false))).depth ≤ + (queryVariables is k (Function.update ρ i (some true))).depth + · exact ⟨true, max_eq_right h⟩ + · exact ⟨false, max_eq_left (Nat.le_of_lt (Nat.lt_of_not_ge h))⟩ + obtain ⟨τ, ht, hout, hin⟩ := ih (Function.update ρ i (some b)) + refine ⟨τ, ?_, ?_, ?_⟩ + · simp only [queryVariables, depth, hb, ht, List.length_cons] + omega + · intro j hj + have hj' : j ∉ is.toFinset := fun h => hj (by simp [h]) + have hji : j ≠ i := fun h => hj (by simp [h]) + rw [hout j hj'] + simp [hji] + · intro j hj + by_cases hj' : j ∈ is.toFinset + · exact hin j hj' + · have hji : j = i := by simpa [hj'] using hj + subst j + exact ⟨b, by simpa using hout i hj'⟩ + +lemma queryVariables_depth_witness {n : ℕ} (is : List (Fin n)) + (k : PartialAssignment n → BooleanDecisionTree n) (ρ : PartialAssignment n) : + ∃ x : BooleanCube n, (queryVariables is k ρ).depth = + is.length + (k (ρ.assign is.toFinset x)).depth := by + obtain ⟨τ, ht, hout, hin⟩ := queryVariables_depth_state is k ρ + let x : BooleanCube n := fun i => (τ i).getD false + have he : τ = ρ.assign is.toFinset x := by + funext i + by_cases hi : i ∈ is.toFinset + · obtain ⟨b, hb⟩ := hin i hi + simp [PartialAssignment.assign, hi, x, hb] + · simp [PartialAssignment.assign, hi, hout i hi] + exact ⟨x, by simpa only [he] using ht⟩ + +end BooleanDecisionTree + +lemma CubeTerm.satisfied_of_live_empty {n : ℕ} (C : CubeTerm n) + (ρ : PartialAssignment n) (hC : C.Compatible ρ) (h : C.live ρ = ∅) : + C.Satisfied ρ := by + intro i hi + rcases hC i hi with hn | hv + · have hm : i ∈ C.live ρ := mem_filter.mpr ⟨hi, hn⟩ + rw [h] at hm + exact False.elim (notMem_empty i hm) + · exact hv + +theorem canonicalDNFTree_depth_walk {n : ℕ} (F : List (CubeTerm n)) + (ρ : PartialAssignment n) : ∃ bs : List (DNFQueryBlock n), + CanonicalDNFWalk F ρ bs ∧ (canonicalDNFTree F ρ).depth ≤ DNFQueryBlock.length bs := by + induction F generalizing ρ with + | nil => exact ⟨[], .nil _ _, le_refl _⟩ + | cons C F ih => + by_cases hC : C.Compatible ρ + · by_cases he : C.live ρ = ∅ + · refine ⟨[], .nil _ _, ?_⟩ + have hs := C.satisfied_of_live_empty ρ hC he + simp [canonicalDNFTree, hC, he, BooleanDecisionTree.queryVariables, hs, + BooleanDecisionTree.depth, DNFQueryBlock.length] + · have hne := Finset.nonempty_iff_ne_empty.mpr he + let k := fun τ => if C.Satisfied τ then BooleanDecisionTree.leaf true + else canonicalDNFTree F τ + obtain ⟨x, hx⟩ := BooleanDecisionTree.queryVariables_depth_witness + ((C.live ρ).sort (· ≤ ·)) k ρ + simp only [Finset.sort_toFinset, Finset.length_sort] at hx + have hdepth : (canonicalDNFTree (C :: F) ρ).depth = + (C.live ρ).card + (k (ρ.assign (C.live ρ) x)).depth := by + simpa only [canonicalDNFTree, hC, ite_true] using hx + by_cases hs : C.Satisfied (ρ.assign (C.live ρ) x) + · refine ⟨[⟨C, C.live ρ, x⟩], .step x hC hne (.nil _ _), ?_⟩ + simp [hdepth, k, hs, BooleanDecisionTree.depth, DNFQueryBlock.length] + · obtain ⟨bs, hbs, hb⟩ := ih (ρ.assign (C.live ρ) x) + refine ⟨⟨C, C.live ρ, x⟩ :: bs, .step x hC hne hbs, ?_⟩ + simpa only [hdepth, k, hs, ite_false, DNFQueryBlock.length] using + Nat.add_le_add_left hb (C.live ρ).card + · obtain ⟨bs, hbs, hb⟩ := ih ρ + refine ⟨bs, .skip hC hbs, ?_⟩ + simpa only [canonicalDNFTree, hC, ite_false] using hb + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitWalkCode.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitWalkCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..56aa47a641811ce3a7ac6edf4aa12c3e5372a346 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitWalkCode.lean @@ -0,0 +1,130 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitBlockCode +import OAI.NumberTheory.TwoPoint.Circuits.CircuitWalkImage + +namespace OAI + +/-! Injectivity of the switching encoding. Earlier incompatible terms stay +incompatible, while the first queried term becomes compatible in the image. +The first block and its responses can therefore be decoded and removed. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace DNFQueryBlock + +lemma codes_cons {n : ℕ} (b : DNFQueryBlock n) (bs : List (DNFQueryBlock n)) : + codes (b :: bs) = b.literalCode.map some ++ none :: codes bs := by + simp [codes, code, List.append_assoc] + +lemma codes_eq_nil_iff {n : ℕ} (bs : List (DNFQueryBlock n)) : codes bs = [] ↔ bs = [] := by + cases bs with + | nil => simp [codes] + | cons b bs => simp [codes_cons] + +end DNFQueryBlock + +namespace CanonicalDNFWalk + +lemma codes_length_le {n : ℕ} {F : List (CubeTerm n)} {ρ : PartialAssignment n} + {bs : List (DNFQueryBlock n)} (h : CanonicalDNFWalk F ρ bs) : + (DNFQueryBlock.codes bs).length ≤ 2 * DNFQueryBlock.length bs := by + induction h with + | nil => simp [DNFQueryBlock.codes, DNFQueryBlock.length] + | skip _ _ ih => exact ih + | @step C F ρ bs x _ hne _ ih => + have hc : 1 ≤ (C.live ρ).card := card_pos.mpr hne + simp only [DNFQueryBlock.codes_cons, List.length_append, List.length_map, + List.length_cons, DNFQueryBlock.literalCode, Finset.length_sort, + DNFQueryBlock.length] + omega + +lemma code_positions_le {n w : ℕ} {F : List (CubeTerm n)} {ρ : PartialAssignment n} + {bs : List (DNFQueryBlock n)} (h : CanonicalDNFWalk F ρ bs) + (hF : ∀ C ∈ F, C.support.card ≤ w) : + ∀ z ∈ DNFQueryBlock.codes bs, ∀ a b, z = some (a, b) → a ≤ w := by + induction h with + | nil => simp [DNFQueryBlock.codes] + | @skip C F ρ bs _ _ ih => + exact ih (fun D hD => hF D (List.mem_cons_of_mem C hD)) + | @step C F ρ bs x _ _ _ ih => + intro z hz a b hza + rw [DNFQueryBlock.codes_cons] at hz + rcases List.mem_append.mp hz with hz | hz + · obtain ⟨q, hq, hqz⟩ := List.mem_map.mp hz + obtain ⟨i, hi, hiq⟩ := List.mem_map.mp hq + have hp : (C.slot i, x i) = (a, b) := Option.some.inj + ((congrArg some hiq).trans (hqz.trans hza)) + have hslot : C.slot i = a := congrArg Prod.fst hp + rw [← hslot] + exact (C.slot_le i).trans (hF C (by simp)) + · rcases List.mem_cons.mp hz with hz | hz + · rw [hz] at hza + cases hza + · exact ih (fun D hD => hF D (List.mem_cons_of_mem C hD)) z hz a b hza + +theorem image_code_injective {n : ℕ} {F : List (CubeTerm n)} + {ρ τ : PartialAssignment n} {bs cs : List (DNFQueryBlock n)} + (hρ : CanonicalDNFWalk F ρ bs) (hτ : CanonicalDNFWalk F τ cs) + (hi : DNFQueryBlock.image ρ bs = DNFQueryBlock.image τ cs) + (hc : DNFQueryBlock.codes bs = DNFQueryBlock.codes cs) : ρ = τ := by + induction F generalizing ρ τ bs cs with + | nil => + cases hρ + cases hτ + exact hi + | cons C F ih => + by_cases hb : bs = [] + · subst bs + have hc' : cs = [] := (DNFQueryBlock.codes_eq_nil_iff cs).mp hc.symm + subst cs + exact hi + by_cases hd : cs = [] + · subst cs + have hb' : bs = [] := (DNFQueryBlock.codes_eq_nil_iff bs).mp hc + exact False.elim (hb hb') + cases hρ with + | nil => exact False.elim (hb rfl) + | skip hC hρ => + cases hτ with + | nil => exact False.elim (hd rfl) + | skip hD hτ => exact ih hρ hτ hi hc + | step y hD hne hτ => + have hbad := C.incompatible_mono hC hρ.image_extends + apply False.elim + apply hbad + rw [hi] + exact step_image_compatible y hD hτ + | @step _ _ _ bs x hC hne hρ => + cases hτ with + | nil => exact False.elim (hd rfl) + | skip hD hτ => + have hbad := C.incompatible_mono hD hτ.image_extends + apply False.elim + apply hbad + rw [← hi] + exact step_image_compatible x hC hρ + | @step _ _ _ cs y hD hne' hτ => + rw [DNFQueryBlock.codes_cons, DNFQueryBlock.codes_cons] at hc + obtain ⟨hlit, hrest⟩ := separated_option_lists_injective _ _ _ _ hc + obtain ⟨hS, hxy⟩ := DNFQueryBlock.literalCode_injective C (C.live ρ) (C.live τ) + (filter_subset _ _) (filter_subset _ _) x y hlit + have hr := congrArg (fun σ : PartialAssignment n => σ.assign (C.live ρ) x) hi + rw [step_image_restore x hρ] at hr + have hright : + (DNFQueryBlock.image τ (⟨C, C.live τ, y⟩ :: cs)).assign (C.live ρ) x = + DNFQueryBlock.image (τ.assign (C.live τ) y) cs := by + rw [PartialAssignment.assign_congr_on _ _ x y hxy, hS] + exact step_image_restore y hτ + rw [hright] at hr + have hnext := ih hρ hτ hr hrest + apply PartialAssignment.assign_injective_of_free ρ τ (C.live ρ) + (C.live_subset_free ρ) (by rw [hS]; exact C.live_subset_free τ) x y + simpa only [hS] using hnext + +end CanonicalDNFWalk + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitWalkImage.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitWalkImage.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbec761825e3ba942a6d5daf932d91d98a76d04c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitWalkImage.lean @@ -0,0 +1,128 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitQueryWalk +import OAI.NumberTheory.TwoPoint.Circuits.CircuitRestrictionLaw + +namespace OAI + +/-! The switching encoding changes each queried block to the values that +satisfy its term. Query blocks are disjoint, so their responses can later be +restored without disturbing the remaining encoding. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +namespace DNFQueryBlock + +lemma image_eq_outside {n : ℕ} (ρ : PartialAssignment n) (bs : List (DNFQueryBlock n)) + (i : Fin n) (hi : i ∉ support bs) : image ρ bs i = ρ i := by + induction bs generalizing ρ with + | nil => rfl + | cons b bs ih => + have hb : i ∉ b.queried := fun hb => hi (mem_union_left _ hb) + have ht : i ∉ support bs := fun ht => hi (mem_union_right _ ht) + rw [image, ih _ ht] + simp [PartialAssignment.assign, hb] + +lemma image_extends {n : ℕ} (ρ : PartialAssignment n) (bs : List (DNFQueryBlock n)) + (h : support bs ⊆ ρ.free) : ρ.Extends (image ρ bs) := by + intro i b hb + have hi : i ∉ support bs := by + intro hi + have hn := (mem_filter.mp (h hi)).2 + rw [hb] at hn + cases hn + rw [image_eq_outside ρ bs i hi, hb] + +lemma image_free {n : ℕ} (ρ : PartialAssignment n) (bs : List (DNFQueryBlock n)) : + (image ρ bs).free = ρ.free \ support bs := by + induction bs generalizing ρ with + | nil => simp [image, support] + | cons b bs ih => + rw [image, ih, PartialAssignment.free_assign, support] + ext i + simp only [mem_sdiff, mem_union] + tauto + +lemma image_assign_comm {n : ℕ} (ρ : PartialAssignment n) (bs : List (DNFQueryBlock n)) + (S : Finset (Fin n)) (hS : Disjoint S (support bs)) (x : BooleanCube n) : + image (ρ.assign S x) bs = (image ρ bs).assign S x := by + induction bs generalizing ρ with + | nil => rfl + | cons b bs ih => + have hh := disjoint_union_right.mp hS + rw [image, PartialAssignment.assign_comm ρ S b.queried hh.1, ih _ hh.2] + rfl + +lemma image_eq_assign {n : ℕ} (ρ : PartialAssignment n) (bs : List (DNFQueryBlock n)) : + image ρ bs = ρ.assign (support bs) (fun i => (image ρ bs i).getD false) := by + funext i + by_cases hi : i ∈ support bs + · have hn : image ρ bs i ≠ none := by + intro hn + have hf : i ∈ (image ρ bs).free := mem_filter.mpr ⟨mem_univ _, hn⟩ + rw [image_free] at hf + exact (mem_sdiff.mp hf).2 hi + cases hb : image ρ bs i with + | none => exact False.elim (hn hb) + | some b => simp [PartialAssignment.assign, hi, hb] + · simp [PartialAssignment.assign, hi, image_eq_outside ρ bs i hi] + +lemma image_compatible {n : ℕ} (C : CubeTerm n) (ρ : PartialAssignment n) + (bs : List (DNFQueryBlock n)) (hS : Disjoint C.support (support bs)) + (hC : C.Compatible ρ) : C.Compatible (image ρ bs) := by + intro i hi + have hn : i ∉ support bs := fun hs => Finset.disjoint_left.mp hS hi hs + rw [image_eq_outside ρ bs i hn] + exact hC i hi + +end DNFQueryBlock + +namespace CanonicalDNFWalk + +lemma image_extends {n : ℕ} {F : List (CubeTerm n)} {ρ : PartialAssignment n} + {bs : List (DNFQueryBlock n)} (h : CanonicalDNFWalk F ρ bs) : + ρ.Extends (DNFQueryBlock.image ρ bs) := + DNFQueryBlock.image_extends ρ bs h.support_subset_free + +lemma step_image_compatible {n : ℕ} {C : CubeTerm n} {F : List (CubeTerm n)} + {ρ : PartialAssignment n} {bs : List (DNFQueryBlock n)} + (x : BooleanCube n) (hC : C.Compatible ρ) + (h : CanonicalDNFWalk F (ρ.assign (C.live ρ) x) bs) : + C.Compatible (DNFQueryBlock.image ρ (⟨C, C.live ρ, x⟩ :: bs)) := by + have hd : Disjoint C.support (DNFQueryBlock.support bs) := by + apply Finset.disjoint_left.mpr + intro i hi ht + exact Finset.disjoint_left.mp (C.live_update_disjoint ρ x) hi + (h.support_subset_free ht) + apply DNFQueryBlock.image_compatible C _ bs hd + intro i hi + exact Or.inr (C.satisfied_assign_value ρ hC i hi) + +lemma step_image_restore {n : ℕ} {C : CubeTerm n} {F : List (CubeTerm n)} + {ρ : PartialAssignment n} {bs : List (DNFQueryBlock n)} + (x : BooleanCube n) (h : CanonicalDNFWalk F (ρ.assign (C.live ρ) x) bs) : + (DNFQueryBlock.image ρ (⟨C, C.live ρ, x⟩ :: bs)).assign (C.live ρ) x = + DNFQueryBlock.image (ρ.assign (C.live ρ) x) bs := by + change (DNFQueryBlock.image (ρ.assign (C.live ρ) C.value) bs).assign (C.live ρ) x = _ + rw [← DNFQueryBlock.image_assign_comm _ bs _ (head_disjoint_tail x h)] + congr 1 + funext i + by_cases hi : i ∈ C.live ρ <;> simp [PartialAssignment.assign, hi] + +theorem image_weight {n : ℕ} {F : List (CubeTerm n)} {ρ : PartialAssignment n} + {bs : List (DNFQueryBlock n)} (h : CanonicalDNFWalk F ρ bs) + (p : ℝ) (hp : 0 ≤ p) (hp1 : p < 1) : + (restrictionLaw n p hp hp1.le).weight ρ = + (2 * p / (1 - p)) ^ DNFQueryBlock.length bs * + (restrictionLaw n p hp hp1.le).weight (DNFQueryBlock.image ρ bs) := by + have hw := restrictionLaw_assign_weight p hp hp1 ρ (DNFQueryBlock.support bs) + h.support_subset_free (fun i => (DNFQueryBlock.image ρ bs i).getD false) + rw [← DNFQueryBlock.image_eq_assign, ← h.length_eq_card_support] at hw + exact hw + +end CanonicalDNFWalk + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitWalshExpansion.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitWalshExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..7188c886ed90fb41bc5ce3fc85c35f29da2636c9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/CircuitWalshExpansion.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.TwoPoint.Circuits.CircuitPolynomialAlgebra + +namespace OAI + +/-! Finite Walsh inversion and squared-error identities. These supply the +Fourier truncations used in the circuit approximation argument. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma walsh_kernel {n : ℕ} (x y : BooleanCube n) : + (∑ S : Finset (Fin n), walsh S x * walsh S y) = + if x = y then (2 : ℝ) ^ n else 0 := by + have heq : (∑ S : Finset (Fin n), walsh S x * walsh S y) = + ∏ i : Fin n, (1 + booleanSign (x i) * booleanSign (y i)) := by + simp only [walsh, ← prod_mul_distrib] + simpa using (prod_one_add (f := fun i : Fin n => + booleanSign (x i) * booleanSign (y i)) univ).symm + rw [heq] + by_cases hxy : x = y + · subst y + norm_num + · rw [ite_eq_right hxy] + obtain ⟨i, hi⟩ : ∃ i, x i ≠ y i := by + simpa only [funext_iff, not_forall] using hxy + apply prod_eq_zero (mem_univ i) + cases hx : x i <;> cases hy : y i <;> simp_all [booleanSign] + +theorem walsh_inversion {n : ℕ} (f : BooleanCube n → ℝ) (x : BooleanCube n) : + (∑ S : Finset (Fin n), walshCoefficient f S * walsh S x) = f x := by + have heq : (∑ S : Finset (Fin n), walshCoefficient f S * walsh S x) = + cubeAverage (fun y => f y * ∑ S : Finset (Fin n), walsh S y * walsh S x) := by + simp only [mul_sum, cubeAverage_sum] + apply sum_congr rfl + intro S _ + unfold walshCoefficient + have hp : (fun y => f y * (walsh S y * walsh S x)) = + fun y => walsh S x * (f y * walsh S y) := by funext y; ring + rw [hp, cubeAverage_mul_const, mul_comm] + rw [heq] + simp only [walsh_kernel, cubeAverage, mul_ite, mul_zero] + simp [Fintype.card_bool, eq_comm] + +theorem walsh_parseval {n : ℕ} (f : BooleanCube n → ℝ) : + cubeAverage (fun x => (f x) ^ 2) = + ∑ S : Finset (Fin n), (walshCoefficient f S) ^ 2 := by + have heq : (fun x => (f x) ^ 2) = fun x => + ∑ S : Finset (Fin n), walshCoefficient f S * (f x * walsh S x) := by + funext x + calc + _ = f x * (∑ S : Finset (Fin n), walshCoefficient f S * walsh S x) := by + rw [walsh_inversion] + ring + _ = _ := by + rw [mul_sum] + apply sum_congr rfl + intro S _ + ring + rw [heq, cubeAverage_sum] + apply sum_congr rfl + intro S _ + rw [cubeAverage_mul_const] + change walshCoefficient f S * walshCoefficient f S = _ + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Circuits/FourierCorrection.lean b/lean/OAI/NumberTheory/TwoPoint/Circuits/FourierCorrection.lean new file mode 100644 index 0000000000000000000000000000000000000000..990202660b6575c701ec03027220ac05fa043037 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Circuits/FourierCorrection.lean @@ -0,0 +1,362 @@ +import Mathlib.Algebra.BigOperators.Field +import Mathlib.Data.Fintype.Pi +import Mathlib.Tactic + +namespace OAI + +/-! +# Correcting an almost independent Boolean density + +This is the finite Fourier correction used in the proof of the manuscript's +finite-residue comparison (`q:finite-law`, `q:fourier-correction-tv`). The +construction removes the chosen nonconstant Walsh coefficients and adds the +constant `a` before normalization, retaining pointwise nonnegativity. +-/ + +namespace TwoPointCorrelations + +open Finset + +abbrev BooleanCube (n : ℕ) := Fin n → Bool + +/-- Uniform average on the finite Boolean cube. -/ +noncomputable def cubeAverage {n : ℕ} (f : BooleanCube n → ℝ) : ℝ := + (∑ x, f x) / Fintype.card (BooleanCube n) + +lemma cubeAverage_add {n : ℕ} (f g : BooleanCube n → ℝ) : + cubeAverage (fun x => f x + g x) = cubeAverage f + cubeAverage g := by + simp [cubeAverage, Finset.sum_add_distrib, add_div] + +lemma cubeAverage_sub {n : ℕ} (f g : BooleanCube n → ℝ) : + cubeAverage (fun x => f x - g x) = cubeAverage f - cubeAverage g := by + simp [cubeAverage, Finset.sum_sub_distrib, sub_div] + +lemma cubeAverage_mul_const {n : ℕ} (f : BooleanCube n → ℝ) (c : ℝ) : + cubeAverage (fun x => c * f x) = c * cubeAverage f := by + simp only [cubeAverage, ← Finset.mul_sum, mul_div_assoc] + +@[simp] lemma cubeAverage_const {n : ℕ} (c : ℝ) : + cubeAverage (fun _ : BooleanCube n => c) = c := by + simp [cubeAverage, Finset.sum_const] + +lemma cubeAverage_sum {n : ℕ} {ι : Type*} (s : Finset ι) + (f : ι → BooleanCube n → ℝ) : + cubeAverage (fun x => ∑ i ∈ s, f i x) = ∑ i ∈ s, cubeAverage (f i) := by + simp only [cubeAverage, Finset.sum_div] + rw [Finset.sum_comm] + +lemma cubeAverage_mono {n : ℕ} {f g : BooleanCube n → ℝ} + (h : ∀ x, f x ≤ g x) : cubeAverage f ≤ cubeAverage g := by + exact div_le_div_of_nonneg_right (Finset.sum_le_sum (fun x _ => h x)) (by positivity) + +/-- The sign representation of a Boolean coordinate. -/ +def booleanSign (b : Bool) : ℝ := if b then -1 else 1 + +@[simp] lemma booleanSign_not (b : Bool) : booleanSign (!b) = -booleanSign b := by + cases b <;> norm_num [booleanSign] + +@[simp] lemma booleanSign_sq (b : Bool) : booleanSign b * booleanSign b = 1 := by + cases b <;> norm_num [booleanSign] + +@[simp] lemma abs_booleanSign (b : Bool) : |booleanSign b| = 1 := by + cases b <;> norm_num [booleanSign] + +/-- The Walsh character indexed by a coordinate set. -/ +def walsh {n : ℕ} (S : Finset (Fin n)) (x : BooleanCube n) : ℝ := + ∏ i ∈ S, booleanSign (x i) + +@[simp] lemma walsh_empty {n : ℕ} (x : BooleanCube n) : walsh ∅ x = 1 := by + simp [walsh] + +@[simp] lemma abs_walsh {n : ℕ} (S : Finset (Fin n)) (x : BooleanCube n) : + |walsh S x| = 1 := by + simp [walsh, Finset.abs_prod] + +@[simp] lemma walsh_mul_self {n : ℕ} (S : Finset (Fin n)) (x : BooleanCube n) : + walsh S x * walsh S x = 1 := by + unfold walsh + rw [← Finset.prod_mul_distrib] + simp + +/-- The measure-preserving involution that reverses one coordinate. -/ +def flipBit {n : ℕ} (i : Fin n) : BooleanCube n ≃ BooleanCube n where + toFun x := Function.update x i (!x i) + invFun x := Function.update x i (!x i) + left_inv x := by + funext j + by_cases hj : j = i + · subst j; simp + · simp [Function.update_of_ne hj] + right_inv x := by + funext j + by_cases hj : j = i + · subst j; simp + · simp [Function.update_of_ne hj] + +lemma walsh_flipBit {n : ℕ} (S : Finset (Fin n)) (i : Fin n) (x : BooleanCube n) : + walsh S (flipBit i x) = if i ∈ S then -walsh S x else walsh S x := by + by_cases hi : i ∈ S + · rw [ite_eq_left hi] + have hrest : (∏ j ∈ S.erase i, booleanSign ((flipBit i x) j)) = + ∏ j ∈ S.erase i, booleanSign (x j) := by + apply Finset.prod_congr rfl + intro j hj + simp [flipBit, Function.update_of_ne (mem_erase.mp hj).1] + unfold walsh + rw [← Finset.prod_erase_mul _ _ hi, hrest, + ← Finset.prod_erase_mul _ (fun j => booleanSign (x j)) hi] + simp [flipBit] + · rw [ite_eq_right hi] + apply Finset.prod_congr rfl + intro j hj + have hji : j ≠ i := by intro h; subst j; exact hi hj + simp [flipBit, Function.update_of_ne hji] + +lemma cubeAverage_eq_zero_of_flip {n : ℕ} (f : BooleanCube n → ℝ) (i : Fin n) + (hf : ∀ x, f (flipBit i x) = -f x) : cubeAverage f = 0 := by + have hsum : (∑ x, f (flipBit i x)) = ∑ x, f x := + (flipBit i).sum_comp f + simp_rw [hf] at hsum + rw [Finset.sum_neg_distrib] at hsum + have hz : (∑ x, f x) = 0 := by linarith + simp [cubeAverage, hz] + +lemma cubeAverage_walsh {n : ℕ} {S : Finset (Fin n)} (hS : S.Nonempty) : + cubeAverage (walsh S) = 0 := by + obtain ⟨i, hi⟩ := hS + apply cubeAverage_eq_zero_of_flip _ i + intro x + simp [walsh_flipBit, hi] + +lemma cubeAverage_walsh_mul {n : ℕ} (S T : Finset (Fin n)) : + cubeAverage (fun x => walsh S x * walsh T x) = if S = T then 1 else 0 := by + classical + by_cases hST : S = T + · subst T; simp + · rw [ite_eq_right hST] + have hex : ∃ i, ¬ (i ∈ S ↔ i ∈ T) := by + simpa only [Finset.ext_iff, not_forall] using hST + obtain ⟨i, hi⟩ := hex + apply cubeAverage_eq_zero_of_flip _ i + intro x + by_cases hSi : i ∈ S + · have hTi : i ∉ T := fun h => hi ⟨fun _ => h, fun _ => hSi⟩ + simp [walsh_flipBit, hSi, hTi] + · have hTi : i ∈ T := by + by_contra hnot + apply hi + simp [hSi, hnot] + simp [walsh_flipBit, hSi, hTi] + +/-- Nonempty coordinate sets through order `t`. -/ +def lowWalshSets (n t : ℕ) : Finset (Finset (Fin n)) := + univ.filter (fun S => S.Nonempty ∧ S.card ≤ t) + +noncomputable def walshCoefficient {n : ℕ} (f : BooleanCube n → ℝ) + (S : Finset (Fin n)) : ℝ := cubeAverage (fun x => f x * walsh S x) + +noncomputable def lowWalshCorrection {n : ℕ} (f : BooleanCube n → ℝ) + (t : ℕ) (x : BooleanCube n) : ℝ := + ∑ S ∈ lowWalshSets n t, walshCoefficient f S * walsh S x + +noncomputable def lowWalshMass {n : ℕ} (f : BooleanCube n → ℝ) (t : ℕ) : ℝ := + ∑ S ∈ lowWalshSets n t, |walshCoefficient f S| + +lemma cubeAverage_lowWalshCorrection {n : ℕ} (f : BooleanCube n → ℝ) (t : ℕ) : + cubeAverage (lowWalshCorrection f t) = 0 := by + change cubeAverage (fun x => ∑ S ∈ lowWalshSets n t, walshCoefficient f S * walsh S x) = 0 + rw [cubeAverage_sum] + apply Finset.sum_eq_zero + intro S hS + rw [cubeAverage_mul_const, cubeAverage_walsh (mem_filter.mp hS).2.1, mul_zero] + +lemma lowWalshCorrection_abs_le {n : ℕ} (f : BooleanCube n → ℝ) + (t : ℕ) (x : BooleanCube n) : |lowWalshCorrection f t x| ≤ lowWalshMass f t := by + unfold lowWalshCorrection lowWalshMass + apply (Finset.abs_sum_le_sum_abs _ _).trans + apply Finset.sum_le_sum + intro S hS + simp + +lemma lowWalshCorrection_coefficient {n : ℕ} (f : BooleanCube n → ℝ) + (t : ℕ) (S : Finset (Fin n)) (hS : S ∈ lowWalshSets n t) : + cubeAverage (fun x => lowWalshCorrection f t x * walsh S x) = walshCoefficient f S := by + simp only [lowWalshCorrection, Finset.sum_mul] + rw [cubeAverage_sum] + simp_rw [mul_assoc, cubeAverage_mul_const, cubeAverage_walsh_mul] + simp [hS] + +/-- Add a constant after removing low Walsh modes, then renormalize. -/ +noncomputable def correctedCubeDensity {n : ℕ} (f : BooleanCube n → ℝ) + (t : ℕ) (a : ℝ) (x : BooleanCube n) : ℝ := + (f x - lowWalshCorrection f t x + a) / (1 + a) + +lemma correctedCubeDensity_nonneg {n : ℕ} (f : BooleanCube n → ℝ) (t : ℕ) (a : ℝ) + (hf : ∀ x, 0 ≤ f x) (ha : 0 ≤ a) (hmass : lowWalshMass f t ≤ a) : + ∀ x, 0 ≤ correctedCubeDensity f t a x := by + intro x + apply div_nonneg _ (by linarith) + have hH := (le_abs_self (lowWalshCorrection f t x)).trans + ((lowWalshCorrection_abs_le f t x).trans hmass) + linarith [hf x] + +lemma cubeAverage_correctedCubeDensity {n : ℕ} (f : BooleanCube n → ℝ) + (t : ℕ) (a : ℝ) (hf : cubeAverage f = 1) (ha : 0 ≤ a) : + cubeAverage (correctedCubeDensity f t a) = 1 := by + have hden : 1 + a ≠ 0 := by linarith + unfold correctedCubeDensity + simp only [div_eq_mul_inv] + simp_rw [mul_comm _ (1 + a)⁻¹] + rw [cubeAverage_mul_const, cubeAverage_add, cubeAverage_sub, + hf, cubeAverage_lowWalshCorrection, cubeAverage_const] + field_simp + ring + +lemma correctedCubeDensity_coefficient {n : ℕ} (f : BooleanCube n → ℝ) + (t : ℕ) (a : ℝ) (S : Finset (Fin n)) (hS : S ∈ lowWalshSets n t) : + walshCoefficient (correctedCubeDensity f t a) S = 0 := by + unfold walshCoefficient correctedCubeDensity + have heq : (fun x => (f x - lowWalshCorrection f t x + a) / (1 + a) * walsh S x) = + fun x => (1 + a)⁻¹ * + ((f x * walsh S x - lowWalshCorrection f t x * walsh S x) + a * walsh S x) := by + funext x + ring + rw [heq, cubeAverage_mul_const, cubeAverage_add, cubeAverage_sub, + lowWalshCorrection_coefficient f t S hS, cubeAverage_mul_const, + cubeAverage_walsh (mem_filter.mp hS).2.1] + change (1 + a)⁻¹ * (walshCoefficient f S - walshCoefficient f S + a * 0) = 0 + ring + +/-- Total variation from the initial density is at most `3a/2`. -/ +theorem correctedCubeDensity_totalVariation_le {n : ℕ} (f : BooleanCube n → ℝ) + (t : ℕ) (a : ℝ) (hf : ∀ x, 0 ≤ f x) (hmean : cubeAverage f = 1) + (ha : 0 ≤ a) (hmass : lowWalshMass f t ≤ a) : + cubeAverage (fun x => |correctedCubeDensity f t a x - f x|) / 2 ≤ 3 * a / 2 := by + have hden : 0 < 1 + a := by linarith + have hpoint (x : BooleanCube n) : + |correctedCubeDensity f t a x - f x| ≤ a * (2 + f x) := by + have hdiff : correctedCubeDensity f t a x - f x = + (-lowWalshCorrection f t x + a * (1 - f x)) / (1 + a) := by + unfold correctedCubeDensity + field_simp + ring + rw [hdiff, abs_div, abs_of_pos hden] + apply (div_le_self (abs_nonneg _) (by linarith : 1 ≤ 1 + a)).trans + have hH := (lowWalshCorrection_abs_le f t x).trans hmass + have hF : |1 - f x| ≤ 1 + f x := by + rw [abs_le] + constructor <;> linarith [hf x] + calc + |-lowWalshCorrection f t x + a * (1 - f x)| ≤ + |lowWalshCorrection f t x| + a * |1 - f x| := by + simpa [abs_mul, abs_of_nonneg ha] using + abs_add_le (-lowWalshCorrection f t x) (a * (1 - f x)) + _ ≤ a + a * (1 + f x) := add_le_add hH (mul_le_mul_of_nonneg_left hF ha) + _ = a * (2 + f x) := by ring + have hav := cubeAverage_mono hpoint + rw [cubeAverage_mul_const, cubeAverage_add, cubeAverage_const, hmean] at hav + linarith + +/-- Indicator of a prescribed pattern on a set of coordinates. -/ +noncomputable def cubePattern {n : ℕ} (S : Finset (Fin n)) + (z x : BooleanCube n) : ℝ := if ∀ i ∈ S, x i = z i then 1 else 0 + +/-- Finite Walsh inversion of a cylinder indicator. -/ +lemma cubePattern_walsh_expansion {n : ℕ} (S : Finset (Fin n)) + (z x : BooleanCube n) : + (2 : ℝ) ^ S.card * cubePattern S z x = + ∑ T ∈ S.powerset, walsh T z * walsh T x := by + have hcoord (i : Fin n) : 1 + booleanSign (z i) * booleanSign (x i) = + if x i = z i then (2 : ℝ) else 0 := by + cases hx : x i <;> cases hz : z i <;> norm_num [booleanSign, hx, hz] + have hprod : (∏ i ∈ S, (1 + booleanSign (z i) * booleanSign (x i))) = + (2 : ℝ) ^ S.card * cubePattern S z x := by + by_cases h : ∀ i ∈ S, x i = z i + · calc + (∏ i ∈ S, (1 + booleanSign (z i) * booleanSign (x i))) = + ∏ _i ∈ S, (2 : ℝ) := by + apply Finset.prod_congr rfl + intro i hi + rw [hcoord, ite_eq_left (h i hi)] + _ = (2 : ℝ) ^ S.card * cubePattern S z x := by + rw [cubePattern, ite_eq_left h] + simp + · have hex : ∃ i ∈ S, x i ≠ z i := by + push Not at h + exact h + obtain ⟨i, hi, hneq⟩ := hex + have hz : (∏ i ∈ S, (1 + booleanSign (z i) * booleanSign (x i))) = 0 := by + apply Finset.prod_eq_zero hi + rw [hcoord, ite_eq_right hneq] + simp [hz, cubePattern, h] + rw [← hprod, Finset.prod_one_add] + apply Finset.sum_congr rfl + intro T hT + rw [Finset.prod_mul_distrib] + rfl + +/-- Vanishing of all nonconstant Walsh coefficients on a coordinate set makes +that marginal exactly uniform. -/ +lemma cubeAverage_pattern_of_walsh {n : ℕ} (g : BooleanCube n → ℝ) + (S : Finset (Fin n)) (z : BooleanCube n) (hmean : cubeAverage g = 1) + (hcoeff : ∀ T ⊆ S, T.Nonempty → walshCoefficient g T = 0) : + cubeAverage (fun x => g x * cubePattern S z x) = 1 / (2 : ℝ) ^ S.card := by + have hsum : (∑ T ∈ S.powerset, walsh T z * walshCoefficient g T) = 1 := by + rw [Finset.sum_eq_single ∅] + · simpa [walshCoefficient] using hmean + · intro T hT hne + rw [hcoeff T (mem_powerset.mp hT) (Finset.nonempty_iff_ne_empty.mpr hne), mul_zero] + · simp + have hscale : (2 : ℝ) ^ S.card * cubeAverage (fun x => g x * cubePattern S z x) = 1 := by + calc + (2 : ℝ) ^ S.card * cubeAverage (fun x => g x * cubePattern S z x) = + cubeAverage (fun x => (2 : ℝ) ^ S.card * (g x * cubePattern S z x)) := + (cubeAverage_mul_const _ _).symm + _ = cubeAverage (fun x => ∑ T ∈ S.powerset, + walsh T z * (g x * walsh T x)) := by + congr 1 + funext x + rw [mul_left_comm, cubePattern_walsh_expansion, Finset.mul_sum] + apply Finset.sum_congr rfl + intro T hT + ring + _ = ∑ T ∈ S.powerset, walsh T z * walshCoefficient g T := by + rw [cubeAverage_sum] + apply Finset.sum_congr rfl + intro T hT + exact cubeAverage_mul_const _ _ + _ = 1 := hsum + apply (eq_div_iff (pow_ne_zero _ (by norm_num : (2 : ℝ) ≠ 0))).mpr + nlinarith only [hscale] + +/-- Every assignment to at most `t` selected coordinates has its uniform mass. -/ +def TWiseUniformDensity {n : ℕ} (g : BooleanCube n → ℝ) (t : ℕ) : Prop := + ∀ (S : Finset (Fin n)), S.card ≤ t → ∀ z : BooleanCube n, + cubeAverage (fun x => g x * cubePattern S z x) = 1 / (2 : ℝ) ^ S.card + +lemma correctedCubeDensity_tWiseUniform {n : ℕ} (f : BooleanCube n → ℝ) + (t : ℕ) (a : ℝ) (hmean : cubeAverage f = 1) (ha : 0 ≤ a) : + TWiseUniformDensity (correctedCubeDensity f t a) t := by + intro S hS z + apply cubeAverage_pattern_of_walsh _ S z (cubeAverage_correctedCubeDensity f t a hmean ha) + intro T hTS hT + apply correctedCubeDensity_coefficient + exact Finset.mem_filter.mpr ⟨Finset.mem_univ T, + hT, (Finset.card_le_card hTS).trans hS⟩ + +/-- The complete finite correction used before applying Braverman's theorem. -/ +theorem fourierCorrection {n : ℕ} (f : BooleanCube n → ℝ) (t : ℕ) (a : ℝ) + (hf : ∀ x, 0 ≤ f x) (hmean : cubeAverage f = 1) + (ha : 0 ≤ a) (hmass : lowWalshMass f t ≤ a) : + (∀ x, 0 ≤ correctedCubeDensity f t a x) ∧ + cubeAverage (correctedCubeDensity f t a) = 1 ∧ + TWiseUniformDensity (correctedCubeDensity f t a) t ∧ + cubeAverage (fun x => |correctedCubeDensity f t a x - f x|) / 2 ≤ 3 * a / 2 := + ⟨correctedCubeDensity_nonneg f t a hf ha hmass, + cubeAverage_correctedCubeDensity f t a hmean ha, + correctedCubeDensity_tWiseUniform f t a hmean ha, + correctedCubeDensity_totalVariation_le f t a hf hmean ha hmass⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/ConditionalMain.lean b/lean/OAI/NumberTheory/TwoPoint/ConditionalMain.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e68c1ef2bcee5a6774a916d2b453e1a4279d12c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/ConditionalMain.lean @@ -0,0 +1,45 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ConditionalLiouville +import OAI.NumberTheory.TwoPoint.Bounds.ConditionalElliott + +namespace OAI + +/-! Paper 009-01, all three main results, with their published inputs explicit. -/ + +namespace OrdinaryTwoPointCorrelationsConditional + +open TwoPointCorrelations +open Filter + +theorem liouville_log_saving (hP : ModFiveThetaInput) + (hBr : BravermanDepth22Input) (hM : PrimeReciprocalInput) + (hMRT : MRTLiouvilleShortInput) : + ∃ c : ℝ, 0 < c ∧ ∀ a₁ a₂ b₁ b₂ : ℕ, + 0 < a₁ → 0 < a₂ → a₁ * b₂ ≠ a₂ * b₁ → + ∃ C : ℝ, 0 < C ∧ ∀ X : ℝ, 3 ≤ X → + ‖affineSum liouville liouville a₁ a₂ b₁ b₂ ⌊X⌋₊‖ ≤ + C * X / Real.rpow (Real.log X) c := + conditional_liouvilleLogSaving hP hBr hM hMRT + +theorem binary_corrected_elliott (hP : ModFiveThetaInput) + (hBr : BravermanDepth22Input) (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) : + ∀ f₁ f₂ : ℕ → ℂ, Multiplicative f₁ → Multiplicative f₂ → + OneBounded f₁ → OneBounded f₂ → + (UniformlyNonpretentious f₁ ∨ UniformlyNonpretentious f₂) → + ∀ h₁ h₂ : ℕ, h₁ ≠ h₂ → + Tendsto (fun N : ℕ => correlationSum f₁ f₂ h₁ h₂ N / (N : ℂ)) atTop (nhds 0) := + conditional_binaryCorrectedElliott hP hBr hM hMRT + +theorem affine_corrected_elliott (hP : ModFiveThetaInput) + (hBr : BravermanDepth22Input) (hM : PrimeReciprocalInput) + (hMRT : MRTShortExponentialInput) : + ∀ f₁ f₂ : ℕ → ℂ, Multiplicative f₁ → Multiplicative f₂ → + OneBounded f₁ → OneBounded f₂ → + (UniformlyNonpretentious f₁ ∨ UniformlyNonpretentious f₂) → + ∀ a₁ a₂ b₁ b₂ : ℕ, 0 < a₁ → 0 < a₂ → a₁ * b₂ ≠ a₂ * b₁ → + Tendsto (fun N : ℕ => affineSum f₁ f₂ a₁ a₂ b₁ b₂ N / (N : ℂ)) atTop (nhds 0) := + conditional_affineCorrectedElliott hP hBr hM hMRT + +end OrdinaryTwoPointCorrelationsConditional + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcBandAvoidance.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcBandAvoidance.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf3336fabddedf61589e958b5c887b90aa457043 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcBandAvoidance.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTBandSeparation +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcGlobalMean +import OAI.NumberTheory.TwoPoint.Halasz.HalaszGeneralMean + +namespace OAI + +/-! The chosen bands avoid every small correction or gcd divisor, and +passing to the completely multiplicative part preserves the exact distance. -/ +namespace TwoPointCorrelations + +open Finset + +lemma major_arc_actual_prime_lower {P Q : ℝ} {J j p : ℕ} + (hP : 2 ≤ P) (hPQ : P ≤ Q) (hLP : 1 < Real.log P) + (hj : j ∈ Icc 1 J) + (hp : p ∈ mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) : P < (p:ℝ) := by + have hlo := mrt_band_lower_monotone P Q 1 j (by decide) (mem_Icc.mp hj).1 hP hPQ hLP + rw [mrtBandLower_one P Q (by linarith)] at hlo + have hb := mrtPrimeBand_bounds (Real.exp_pos _).le (Real.exp_pos _).le hp + exact hlo.trans_lt hb.1 + +lemma major_arc_actual_bands_avoid {P Q : ℝ} {J d : ℕ} + (hP : 2 ≤ P) (hPQ : P ≤ Q) (hLP : 1 < Real.log P) + (hd : 0 < d) (hdP : (d:ℝ) ≤ P) : + mrtPrimeAvoids ((Icc 1 J).biUnion + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j))) d := by + apply mrtPrimeAvoids_of_lt _ hd + intro p hp + obtain ⟨j,hj,hp⟩ := mem_biUnion.mp hp + exact_mod_cast hdP.trans_lt (major_arc_actual_prime_lower hP hPQ hLP hj hp) + +lemma major_arc_actual_bands_disjoint {P Q : ℝ} {J : ℕ} + (hP : 2 ≤ P) (hPQ : P ≤ Q) (hLP : 1 < Real.log P) : + Set.PairwiseDisjoint (Icc 1 J : Set ℕ) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) := by + intro i hi j hj hij + have hdis := mrt_actual_bands_pairwise_disjoint P Q J hP hPQ hLP + exact hdis (x := ⟨i,hi⟩) (y := ⟨j,hj⟩) (by trivial) (by trivial) + (fun h => hij (congrArg Subtype.val h)) + +lemma major_arc_first_prime_range {P Q W : ℝ} {H R₀ p : ℕ} + (hP : 2 ≤ P) (hPQ : P ≤ Q) (hPW : 2*W ≤ P) (hPR : (2*R₀:ℕ) ≤ P) + (hQH : Q ≤ (H:ℝ)/W) + (hp : p ∈ mrtPrimeBand (mrtBandLower P Q 1) (mrtBandUpper Q 1)) : + p ≠ 2 ∧ 2*R₀ ≤ p ∧ 2*W ≤ (p:ℝ) ∧ (p:ℝ) ≤ (H:ℝ)/W := by + have hP0 : 0 < P := by linarith + have hQ0 : 0 < Q := hP0.trans_le hPQ + have hp' : p ∈ mrtPrimeBand P Q := by + simpa only [mrtBandLower_one P Q hP0,mrtBandUpper_one Q hQ0] using hp + have hb := mrtPrimeBand_bounds hP0.le hQ0.le hp' + refine ⟨?_,?_,hPW.trans hb.1.le,hb.2.trans hQH⟩ + · intro he + norm_num [he] at hb + linarith [hb.1] + · exact_mod_cast hPR.trans hb.1.le + +lemma major_arc_complete_distance {F : ℕ → ℂ} {X H : ℕ} {M : ℝ} + (hd : MRTDistanceLowerBound F X H M) : + MRTDistanceLowerBound (mrtCompletePart F) X H M := by + intro q hq hqmax χ t ht + rw [halasz_complete_distance] + exact hd q hq hqmax χ t ht + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcCharacters.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcCharacters.lean new file mode 100644 index 0000000000000000000000000000000000000000..813f1c936b937f14e4eed0f527e1a1e2e8bf5ad0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcCharacters.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.TwoPoint.Bounds.CharacterTwists +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTTypicalCoarse +import Mathlib.NumberTheory.DirichletCharacter.Orthogonality + +namespace OAI + +/-! Multiplicative Fourier resolution of the reduced, unit progression in +MRT section 4. The original residue need not be a unit: this lemma is applied +after taking out its common divisor with the modulus. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma major_arc_unit_indicator (q : ℕ) [NeZero q] (b : ZMod q) + (hb : IsUnit b) (n : ZMod q) : + (if n = b then (1 : ℂ) else 0) = (q.totient : ℂ)⁻¹ * + ∑ χ : DirichletCharacter ℂ q, χ b⁻¹ * χ n := by + rw [DirichletCharacter.sum_char_inv_mul_char_eq ℂ hb n] + have hφ : (q.totient : ℂ) ≠ 0 := by + exact_mod_cast (Nat.totient_pos.mpr (NeZero.pos q)).ne' + by_cases h : n = b + · simp [h, hφ] + · simp [h, Ne.symm h] + +lemma major_arc_unit_progression (S : Finset ℕ) (v : ℕ → ℂ) + (q : ℕ) [NeZero q] (b : ZMod q) (hb : IsUnit b) : + (∑ n ∈ S, if (n : ZMod q) = b then v n else 0) = + (q.totient : ℂ)⁻¹ * ∑ χ : DirichletCharacter ℂ q, + χ b⁻¹ * ∑ n ∈ S, v n * χ (n : ZMod q) := by + have hi (n : ℕ) : (if (n : ZMod q) = b then v n else 0) = + (q.totient : ℂ)⁻¹ * ∑ χ : DirichletCharacter ℂ q, + χ b⁻¹ * (v n * χ (n : ZMod q)) := by + have h := congrArg (fun z : ℂ => z * v n) + (major_arc_unit_indicator q b hb (n : ZMod q)) + simp only [ite_mul, one_mul, zero_mul] at h + rw [h, mul_assoc, sum_mul] + congr 1 + apply sum_congr rfl + intro χ _ + ring + simp_rw [hi] + rw [← mul_sum, sum_comm] + congr 1 + apply sum_congr rfl + intro χ _ + rw [mul_sum] + +lemma major_arc_unit_progression_norm (S : Finset ℕ) (v : ℕ → ℂ) + (q : ℕ) [NeZero q] (b : ZMod q) (hb : IsUnit b) : + ‖∑ n ∈ S, if (n : ZMod q) = b then v n else 0‖ ≤ + (q.totient : ℝ)⁻¹ * ∑ χ : DirichletCharacter ℂ q, + ‖∑ n ∈ S, v n * χ (n : ZMod q)‖ := by + rw [major_arc_unit_progression S v q b hb, norm_mul, norm_inv, + Complex.norm_natCast] + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr (Nat.cast_nonneg _)) + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro χ _ + rw [norm_mul] + exact mul_le_of_le_one_left (norm_nonneg _) (χ.norm_le_one _) + +lemma major_arc_typical_twist {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (F : ℕ → ℂ) {q : ℕ} + (χ : DirichletCharacter ℂ q) : + mrtTypicalCoefficient J P (twistByCharacter F χ) = + twistByCharacter (mrtTypicalCoefficient J P F) χ := by + funext n + simp only [mrtTypicalCoefficient, twistByCharacter] + split_ifs <;> simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcCorrectedMean.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcCorrectedMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..323bb28b0c3ce8c7092d94823087ba9bbe85aad2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcCorrectedMean.lean @@ -0,0 +1,126 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcPerturbedGlobal +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcBandAvoidance +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTCorrectionParameters +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTCorrectionArcScale + +namespace OAI + +/-! Apply the character estimate to the completely multiplicative part +inside each small correction divisor. The original coefficient and original +pretentious distance return in the conclusion. -/ +namespace TwoPointCorrelations + +open Finset + +theorem major_arc_corrected_typical_mean + (hprime : HalaszPrimeSparseInput) (hhigh : HalaszHighPrimeInput) : + ∃ C : ℝ, 0 < C ∧ ∃ N₀ : ℕ, ∀ X V H K H₀ : ℕ, + 2 ≤ X → 1 ≤ Real.log (X:ℝ) → H ≤ V → N₀ ≤ K → 1 ≤ K → + Real.sqrt (X:ℝ) ≤ K → + ∀ P Q : ℝ, 2 ≤ P → P ≤ Q → 2 ≤ Real.log P → 1 ≤ Real.log Q → + 8192*(Real.log (Real.log Q)+1) ≤ (1/100:ℝ)*Real.log P → + 2 ≤ mrtBaseResolution P Q (1/100) → 2*Q ≤ K → + ∀ J : ℕ, 1 ≤ J → + (∀ n : ℕ, K ≤ n → n ≤ 2*X → + 200*Real.log (Real.log n)+1 ≤ Real.log (mrtBandLower P Q J) ∧ + ∀ j ∈ Icc 1 J, mrtBandUpper Q j ≤ Real.exp (Real.sqrt (Real.log n))) → + ∀ W : ℝ, 2 ≤ W → W ≤ K → W^9 ≤ mrtBaseResolution P Q (1/100) → W^5 ≤ P → + W^250 ≤ (H:ℝ) → + (∀ d : ℕ, 0 < d → d ≤ mrtCorrectionCutoff W → + V/d+1 ≤ 2*X ∧ (2*(K:ℝ)+1)/(V/d+1:ℕ) ≤ (W^4)⁻¹) → + ∀ q : ℕ, 0 < q → (q:ℝ) ≤ W → (q:ℝ) ≤ mrtModulusCutoff X H₀ → + (∀ d : ℕ, 0 < d → d ≤ mrtCorrectionCutoff W → q ≤ V/d+1 ∧ + ∀ k : ℕ, 1 ≤ k → k ≤ H/d+1 → ((H/d+1:ℕ):ℝ)/W^2 ≤ k → + ∀ b ∈ q.divisors, 4 ≤ k/b+1 ∧ k/b+1 ≤ K ∧ + W ≤ (k/b+1:ℕ) ∧ Q/(k/b+1:ℕ) ≤ W^7) → + ∀ F : ℕ → ℂ, F 1=1 → Multiplicative F → OneBounded F → + ∀ M : ℝ, 0 ≤ M → MRTDistanceLowerBound F X H₀ M → ∀ r : ℤ, ∀ β : ℝ, + |β| *(H:ℝ) ≤ 1 → + shortExponentialIntegral (mrtTypicalCoefficient (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) V H ((r:ℝ)/q+β) ≤ + mrtCorrectionBound*(V:ℝ)*H* + (4*(1+4*Real.pi)*(4*C*(Real.sqrt W*(1+Real.log W))*(Real.exp (-2*M/5)+ + Real.sqrt (Real.log (Real.log X)/(Real.log X)^(1/80:ℝ))+W⁻¹)+3/W)+ + 5*W^(-5/4:ℝ)) := by + obtain ⟨C,hC,N₀,hmajor⟩ := major_arc_typical_perturbed_global hprime hhigh + refine ⟨C,hC,N₀,?_⟩ + intro X V H K H₀ hX hLX hHV hKN hK hKX P Q hP hPQ hLP hLQ hbudget hres hQK + J hJ hbands W hW hWK hWR hWP hH houter q hq hqW hqmax hwindow + F hF1 hFm hFb M hM hd r β hβ + have hCB : 0 < mrtCorrectionBound := Real.exp_pos _ + have hW1 : 1 ≤ W := by linarith + have hW0 : 0 < W := by linarith + obtain ⟨hD,hDH,hDover,hDtail⟩ := mrt_correction_cutoff_scale hW hH + have hWP2 : W^2 ≤ P := (pow_le_pow_right₀ hW1 (by norm_num : (2:ℕ)≤5)).trans hWP + let R := Real.exp (-2*M/5)+Real.sqrt + (Real.log (Real.log X)/(Real.log X)^(1/80:ℝ))+W⁻¹ + let ε := (1+4*Real.pi)*(4*C*(Real.sqrt W*(1+Real.log W))*R+3/W) + have hlog : 0 ≤ 1+Real.log W := by linarith [Real.log_nonneg hW1] + have hR : 0 ≤ R := by dsimp [R]; positivity + have hε : 0 ≤ ε := by dsimp [ε]; positivity + have hp : ∀ j ∈ Icc 1 J, ∀ p ∈ mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j), + mrtCorrectionCutoff W < p := by + intro j hj p hp + have hlow := major_arc_actual_prime_lower hP hPQ (by linarith) hj hp + exact_mod_cast (mrt_correction_cutoff_bounds hW).2.2.trans_lt (hWP.trans_lt hlow) + have hav : ∀ b ∈ q.divisors, mrtPrimeAvoids ((Icc 1 J).biUnion + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j))) b := by + intro b hb + have hb0 : 0 < b := Nat.pos_of_dvd_of_pos (Nat.mem_divisors.mp hb).1 hq + have hbq : b ≤ q := Nat.le_of_dvd hq (Nat.mem_divisors.mp hb).1 + apply major_arc_actual_bands_avoid hP hPQ (by linarith) hb0 + exact (show (b:ℝ) ≤ q by exact_mod_cast hbq).trans (hqW.trans + ((le_self_pow₀ hW1 (by decide : (5:ℕ)≠0)).trans hWP)) + have hm := mrt_correction_typical_quotient_mean (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) + (fun _ _ _ hp => mrtPrimeBand_prime hp) F hFm hFb hF1 V H (mrtCorrectionCutoff W) + hD hDH hHV hp ((r:ℝ)/q+β) ε hε ?_ + · have ht : (mrtCorrectionCutoff W:ℝ)/H+ + 2*(mrtCorrectionCutoff W:ℝ)^(-(1/4:ℝ)) ≤ 5*W^(-5/4:ℝ) := by linarith + calc + _ ≤ mrtCorrectionBound*(V:ℝ)*H*(4*ε+ + (mrtCorrectionCutoff W:ℝ)/H+2*(mrtCorrectionCutoff W:ℝ)^(-(1/4:ℝ))) := hm + _ ≤ mrtCorrectionBound*(V:ℝ)*H*(4*ε+5*W^(-5/4:ℝ)) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + linarith only [ht] + _ = _ := by dsimp [ε,R]; ring + intro d hdD + obtain ⟨hdI,hdD⟩ := mem_filter.mp hdD + have hd0 : 0 < d := (mem_Icc.mp hdI).1 + have hdW : (d:ℝ) ≤ W^5 := + (show (d:ℝ) ≤ mrtCorrectionCutoff W by exact_mod_cast hdD).trans + (mrt_correction_cutoff_bounds hW).2.2 + have hdH : d ≤ H := hdD.trans hDH + have hHp : W^5 ≤ ((H/d+1:ℕ):ℝ) := by + have hb := mrt_correction_quotient_power hW1 hH hd0 hdW + (show (H:ℝ)/W^2 ≤ H from div_le_self (Nat.cast_nonneg H) (one_le_pow₀ hW1)) + exact (pow_le_pow_right₀ hW1 (by norm_num : (5:ℕ)≤243)).trans hb + have hβd : |(d:ℝ)*β| *((H/d+1:ℕ):ℝ) ≤ 2 := by + have hlen := mrt_quotient_length_le_two hd0 hdH + have hdr : (0:ℝ) < d := by exact_mod_cast hd0 + rw [abs_mul,abs_of_pos hdr] + calc + _ = |β| *((d:ℝ)*(H/d+1:ℕ)) := by ring + _ ≤ |β| *(2*(H:ℝ)) := by + apply mul_le_mul_of_nonneg_left _ (abs_nonneg β) + calc + (d:ℝ)*(H/d+1:ℕ) ≤ (d:ℝ)*(2*((H:ℝ)/d)) := + mul_le_mul_of_nonneg_left hlen hdr.le + _ = _ := by field_simp + _ ≤ _ := by nlinarith + have hFcomp1 : mrtCompletePart F 1=1 := fromPrimePowers_one _ + have hi := hmajor X (V/d+1) (H/d+1) K H₀ hX hLX (houter d hd0 hdD).1 + hKN hK hKX P Q hP hPQ hLP hLQ hbudget hres hQK J hJ hbands W hW1 hWK hWR hWP2 + hHp (houter d hd0 hdD).2 q hq (hwindow d hd0 hdD).1 hqW hqmax hav + (hwindow d hd0 hdD).2 (mrtCompletePart F) hFcomp1 + (fun a b ha hb => mrtCompletePart_mul F ha hb) (mrtCompletePart_oneBounded F hFb) + M hM (major_arc_complete_distance hd) (d*(r:ℤ)) ((d:ℝ)*β) hβd + have hphase : (d:ℝ)*((r:ℝ)/q+β) = ((d*(r:ℤ):ℤ):ℝ)/q+(d:ℝ)*β := by + push_cast + ring + rw [hphase] + simpa only [ε,R,mul_assoc,mul_left_comm,mul_comm] using hi + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcCorrectedRate.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcCorrectedRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c4d1919286683c847ce6977d1276d3befd6c695 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcCorrectedRate.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcGlobalRate +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTCorrectionSummability + +namespace OAI + +/-! The correction and character factors fit the exact error exponents +of corrected MRT Theorem 1.7 at the common parameter. -/ +namespace TwoPointCorrelations + +open Filter + +lemma major_arc_inverse_parameter_error {W : ℝ} (hW : 1 ≤ W) : + W⁻¹ ≤ majorArcWorkingError W ∧ W^(-5/4:ℝ) ≤ majorArcWorkingError W := by + have hW0 : 0 < W := by linarith + have hi : W⁻¹ ≤ majorArcWorkingError W := by + calc + _ = W^(-1:ℝ) := (Real.rpow_neg_one W).symm + _ ≤ W^(-1/5:ℝ) := Real.rpow_le_rpow_of_exponent_le hW (by norm_num) + _ ≤ _ := le_mul_of_one_le_left (Real.rpow_nonneg hW0.le _) + (by linarith [Real.log_nonneg hW]) + refine ⟨hi,?_⟩ + exact (Real.rpow_le_rpow_of_exponent_le hW (show (-5/4:ℝ) ≤ -1 by norm_num)).trans + (by simpa only [Real.rpow_neg_one] using hi) + +theorem major_arc_corrected_published_rate (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ H M : ℝ, 1 ≤ Real.log H → + 1 ≤ Real.log (Real.log H) → 0 ≤ M → + let W := majorArcParameter L H M + mrtCorrectionBound*(4*(1+4*Real.pi)*(4*C*(Real.sqrt W*(1+Real.log W))* + (Real.exp (-2*M/5)+Real.sqrt (Real.log L/L^(1/80:ℝ))+W⁻¹)+3/W)+ + 5*W^(-5/4:ℝ)) ≤ + (2500*mrtCorrectionBound*(C+1)*(1+4*Real.pi))* + (Real.exp (-M/20)+Real.log (Real.log H)/Real.log H+L^(-1/700:ℝ)) := by + filter_upwards [major_arc_weighted_energy_rate,major_arc_parameter_rate, + eventually_ge_atTop (1:ℝ)] with L henergy hparameter hL + intro H M hH hHH hM + dsimp only + let W := majorArcParameter L H M + let E := Real.exp (-M/20)+Real.log (Real.log H)/Real.log H+L^(-1/700:ℝ) + obtain ⟨hW,hWH,hWL,hWM⟩ := major_arc_parameter_bounds hL hH hM + have hE : 0 ≤ E := by dsimp [E]; positivity + have hk : majorArcWorkingError W ≤ 21*E := by + have hh := hparameter H M hH hHH hM + have he := Real.exp_pos (-M/20) + have hl : 0 ≤ L^(-1/700:ℝ) := Real.rpow_nonneg (by linarith) _ + have hshort : 0 ≤ Real.log (Real.log H)/Real.log H := by positivity + rw [mul_div_assoc] at hh + dsimp only [E,W] + linarith + have he : Real.sqrt W*(1+Real.log W)* + (Real.exp (-2*M/5)+Real.sqrt (Real.log L/L^(1/80:ℝ))+W⁻¹) ≤ 122*E := by + have hh := henergy W M hW hWL hM hWM + have hexp := Real.exp_pos (-M/20) + have hl : 0 ≤ L^(-1/700:ℝ) := Real.rpow_nonneg (by linarith) _ + have hshort : 0 ≤ Real.log (Real.log H)/Real.log H := by positivity + dsimp only [E] at * + linarith + obtain ⟨hinv,hpow⟩ := major_arc_inverse_parameter_error hW + have hi : 1/W ≤ 21*E := by simpa only [one_div] using hinv.trans hk + have hp : W^(-5/4:ℝ) ≤ 21*E := hpow.trans hk + have hb : 0 < mrtCorrectionBound := Real.exp_pos _ + have ht : 0 < 1+4*Real.pi := by positivity + calc + _ ≤ mrtCorrectionBound*(4*(1+4*Real.pi)*(4*C*(122*E)+3*(21*E))+5*(21*E)) := by + apply mul_le_mul_of_nonneg_left _ hb.le + have hm := mul_le_mul_of_nonneg_left he (show 0 ≤ 4*C by positivity) + have hm' : 4*C*(Real.sqrt W*(1+Real.log W))* + (Real.exp (-2*M/5)+Real.sqrt (Real.log L/L^(1/80:ℝ))+W⁻¹) ≤ 4*C*(122*E) := by + simpa only [mul_assoc] using hm + have hmain := mul_le_mul_of_nonneg_left + (add_le_add hm' (mul_le_mul_of_nonneg_left hi (by norm_num : (0:ℝ)≤3))) + (show 0 ≤ 4*(1+4*Real.pi) by positivity) + have htail := mul_le_mul_of_nonneg_left hp (by norm_num : (0:ℝ)≤5) + have hs := add_le_add hmain htail + convert hs using 1 + ring + _ ≤ _ := by + have hc : (4*(1+4*Real.pi)*(4*C*122+3*21)+5*21) ≤ + 2500*(C+1)*(1+4*Real.pi) := by nlinarith [Real.pi_pos] + have hm := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hc hE) hb.le + convert hm using 1 <;> ring + +lemma major_arc_rate_volume {A C B x y : ℝ} (hx : 0 ≤ x) (hy : 0 ≤ y) + (h : C*A ≤ B) : C*x*y*A ≤ B*x*y := by + calc + _ = (C*A)*x*y := by ring + _ ≤ _ := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right h hx) hy + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcCorrectionGeometry.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcCorrectionGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..3e0cf3f3f07f0b24442b17e04d06ff5e07ac3bbc --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcCorrectionGeometry.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTNestedQuotients +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTWorkingOuterScale + +namespace OAI + +/-! Numerical conditions for the actual nested correction and character +windows, including the initial-block boundary and both floor errors. -/ +namespace TwoPointCorrelations + +open Finset + +lemma major_arc_correction_outer {X V K : ℕ} {W : ℝ} + (hXV : X ≤ V) (hVX : V+1 ≤ 2*X) + (hboundary : ∀ d : ℕ, 0 < d → d ≤ mrtCorrectionCutoff W → + (2*(K:ℝ)+1)/(X/d+1:ℕ) ≤ (W^4)⁻¹) : + ∀ d : ℕ, 0 < d → d ≤ mrtCorrectionCutoff W → + V/d+1 ≤ 2*X ∧ (2*(K:ℝ)+1)/(V/d+1:ℕ) ≤ (W^4)⁻¹ := by + intro d hd hdD + refine ⟨(Nat.add_le_add_right (Nat.div_le_self V d) 1).trans hVX,?_⟩ + apply le_trans _ (hboundary d hd hdD) + apply div_le_div_of_nonneg_left (by positivity) (by positivity) + exact_mod_cast Nat.add_le_add_right (Nat.div_le_div_right hXV) 1 + +lemma major_arc_correction_window_data {H h K V q : ℕ} {W Q : ℝ} + (hW : 2 ≤ W) (hH : W^252 ≤ (H:ℝ)) + (hh : (H:ℝ)/W^2 ≤ h) (hhH : h ≤ H) (hhV : h ≤ V) + (hHK : H+2 ≤ K) (hQ : Q ≤ (H:ℝ)/W^3) (hq : 0 < q) (hqW : (q:ℝ) ≤ W) : + W^250 ≤ (h:ℝ) ∧ + ∀ d : ℕ, 0 < d → d ≤ mrtCorrectionCutoff W → + q ≤ V/d+1 ∧ ∀ k : ℕ, 1 ≤ k → k ≤ h/d+1 → + ((h/d+1:ℕ):ℝ)/W^2 ≤ k → ∀ b ∈ q.divisors, + 4 ≤ k/b+1 ∧ k/b+1 ≤ K ∧ W ≤ (k/b+1:ℕ) ∧ Q/(k/b+1:ℕ) ≤ W^7 := by + have hW1 : 1 ≤ W := by linarith + have hW0 : 0 < W := by linarith + have hH0 : 0 ≤ (H:ℝ) := Nat.cast_nonneg H + have hbase : W^250 ≤ (H:ℝ) := + (pow_le_pow_right₀ hW1 (by norm_num : (250:ℕ)≤252)).trans hH + have hlarge : W^250 ≤ (h:ℝ) := by + apply le_trans _ hh + apply (le_div_iff₀ (pow_pos hW0 2)).mpr + simpa only [←pow_add] using hH + refine ⟨hlarge,?_⟩ + intro d hd hdD + have hdW : (d:ℝ) ≤ W^5 := + (show (d:ℝ) ≤ mrtCorrectionCutoff W by exact_mod_cast hdD).trans + (mrt_correction_cutoff_bounds hW).2.2 + have hqV : q ≤ V/d+1 := by + have hlen := mrt_correction_quotient_power hW1 hbase hd hdW hh + have hsmall : (q:ℝ) ≤ W^243 := hqW.trans (le_self_pow₀ hW1 (by decide)) + have hqhd : q ≤ h/d+1 := by exact_mod_cast hsmall.trans hlen + exact hqhd.trans (Nat.add_le_add_right (Nat.div_le_div_right hhV) 1) + refine ⟨hqV,?_⟩ + intro k _ hkh hkl b hb + have hb0 : 0 < b := Nat.pos_of_dvd_of_pos (Nat.mem_divisors.mp hb).1 hq + have hbW : (b:ℝ) ≤ W := + (show (b:ℝ) ≤ q by exact_mod_cast Nat.le_of_dvd hq (Nat.mem_divisors.mp hb).1).trans hqW + have hlen := mrt_nested_prefix_large hW1 hbase hd hb0 hdW hbW hh hkl + have hWlen : W ≤ (k/b+1:ℕ) := (le_self_pow₀ hW1 (by decide : (240:ℕ)≠0)).trans hlen + have hfour : 4 ≤ (k/b+1:ℕ) := by + have hfourpow : (4:ℝ) ≤ W^240 := by + have hs : (4:ℝ) ≤ W^2 := by nlinarith + exact hs.trans (pow_le_pow_right₀ hW1 (by norm_num : (2:ℕ)≤240)) + exact_mod_cast hfourpow.trans hlen + exact ⟨hfour,(mrt_nested_prefix_upper hhH hkh).trans hHK,hWlen, + mrt_nested_prefix_prime_ratio hW0 hH0 hQ hd hb0 hdW hbW hh hkl⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcDivisorBounds.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcDivisorBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..0034b079c65ea1923d0ac3f80cb816c1eb3c8fed --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcDivisorBounds.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcGCD +import Mathlib.NumberTheory.Harmonic.Bounds + +namespace OAI + +/-! The divided-scale volume pays for the gcd sum. The main term costs +only sqrt(q)(1+log q), while endpoint rounding has an explicit q factor. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma major_arc_divisor_reciprocal (q : ℕ) (hq : 0 < q) : + (∑ d ∈ q.divisors, (d:ℝ)⁻¹) ≤ 1+Real.log q := by + have hs : q.divisors ⊆ Icc 1 q := by + intro d hd + have hdq := (Nat.mem_divisors.mp hd).1 + exact mem_Icc.mpr ⟨Nat.pos_of_dvd_of_pos hdq hq,Nat.le_of_dvd hq hdq⟩ + calc + _ ≤ ∑ d ∈ Icc 1 q, (d:ℝ)⁻¹ := sum_le_sum_of_subset_of_nonneg hs (by intros; positivity) + _ = (harmonic q:ℝ) := by + rw [harmonic_eq_sum_Icc] + push_cast + rfl + _ ≤ _ := harmonic_le_one_add_log q + +lemma major_arc_divisor_weighted (q : ℕ) (hq : 0 < q) (A B : ℝ) + (hA : 0 ≤ A) (hB : 0 ≤ B) : + (∑ d ∈ q.divisors, Real.sqrt ((q/d:ℕ):ℝ)*(A/(d:ℝ)+B)) ≤ + Real.sqrt (q:ℝ)*((1+Real.log q)*A+(q:ℝ)*B) := by + calc + _ ≤ ∑ d ∈ q.divisors, Real.sqrt (q:ℝ)*(A/(d:ℝ)+B) := by + apply sum_le_sum + intro d _ + apply mul_le_mul_of_nonneg_right _ (by positivity) + apply Real.sqrt_le_sqrt + exact_mod_cast Nat.div_le_self q d + _ = Real.sqrt (q:ℝ)*(A*(∑ d ∈ q.divisors,(d:ℝ)⁻¹)+(q.divisors.card:ℝ)*B) := by + rw [mul_sum] + simp only [div_eq_mul_inv,sum_add_distrib,←mul_sum,sum_const,nsmul_eq_mul] + _ ≤ _ := by + apply mul_le_mul_of_nonneg_left _ (Real.sqrt_nonneg _) + apply add_le_add + · simpa only [mul_comm] using mul_le_mul_of_nonneg_left + (major_arc_divisor_reciprocal q hq) hA + · exact mul_le_mul_of_nonneg_right (by exact_mod_cast Nat.card_divisors_le_self q) hB + +lemma major_arc_log_overhead {W : ℝ} (hW : 1 ≤ W) : + 1+Real.log W ≤ 101*W^(1/100:ℝ) := by + have hp : 1 ≤ W^(1/100:ℝ) := Real.one_le_rpow hW (by norm_num) + have hl := Real.log_le_rpow_div (show 0 ≤ W by linarith) (show (0:ℝ) < 1/100 by norm_num) + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcDivisors.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcDivisors.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f254a58f5319b04dc516bdd65ae562c8baaf126 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcDivisors.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcGCD +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcRational +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTCharacterFourier + +namespace OAI + +/-! Resolving a rational phase on each gcd stratum. The coefficients are +finite unit-group Fourier coefficients, so their total mass is controlled +by the square root of the reduced modulus. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma major_arc_rational_val (q : ℕ) [NeZero q] (r : ℤ) (n : ℕ) : + additiveCharacter ((r:ℝ)/q) (n:ZMod q).val = additiveCharacter ((r:ℝ)/q) n := by + rw [major_arc_rational_character,major_arc_rational_character] + simp + +lemma major_arc_character_inversion_nat (q : ℕ) [NeZero q] (r : ℤ) (n : ℕ) : + (∑ χ : DirichletCharacter ℂ q, mrtAdditiveCharacterCoefficient q r χ*naturalCharacter χ n) = + if IsUnit (n:ZMod q) then additiveCharacter ((r:ℝ)/q) n else 0 := by + rw [show (∑ χ : DirichletCharacter ℂ q, + mrtAdditiveCharacterCoefficient q r χ*naturalCharacter χ n) = + ∑ χ : DirichletCharacter ℂ q, mrtAdditiveCharacterCoefficient q r χ*χ (n:ZMod q) by rfl] + rw [mrt_additive_character_inversion,major_arc_rational_val] + +lemma major_arc_divisor_quotient_pos {q : ℕ} (hq : 0 < q) + (d : {d : ℕ // d ∈ q.divisors}) : 0 < q/d.val := by + have hdq := (Nat.mem_divisors.mp d.property).1 + exact Nat.div_pos (Nat.le_of_dvd hq hdq) (Nat.pos_of_dvd_of_pos hdq hq) + +noncomputable def majorArcDivisorTerm {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (F : ℕ → ℂ) (q : ℕ) (hq : 0 < q) (r : ℤ) + (d : {d : ℕ // d ∈ q.divisors}) (n : ℕ) : ℂ := by + letI : NeZero (q/d.val) := ⟨(major_arc_divisor_quotient_pos hq d).ne'⟩ + exact F d.val * ∑ χ : DirichletCharacter ℂ (q/d.val), + mrtAdditiveCharacterCoefficient (q/d.val) r χ * + dilationSequence d.val (mrtTypicalCoefficient J P (twistByCharacter F χ)) n + +lemma major_arc_divisor_term {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (hP : ∀ j ∈ J, ∀ p ∈ P j, p.Prime) + (F : ℕ → ℂ) (hF : ∀ a b, 0 < a → 0 < b → F (a*b)=F a*F b) + (q : ℕ) (hq : 0 < q) (r : ℤ) (d : {d : ℕ // d ∈ q.divisors}) + (havoid : mrtPrimeAvoids (J.biUnion P) d.val) (n : ℕ) (hn : 0 < n) : + majorArcDivisorTerm J P F q hq r d n = + if n.gcd q=d.val then + mrtTypicalCoefficient J P F n*additiveCharacter ((r:ℝ)/q) n else 0 := by + let : NeZero (q/d.val) := ⟨(major_arc_divisor_quotient_pos hq d).ne'⟩ + have hdq := (Nat.mem_divisors.mp d.property).1 + have hd : 0 < d.val := Nat.pos_of_dvd_of_pos hdq hq + have he : majorArcDivisorTerm J P F q hq r d n = + mrtTypicalCoefficient J P F n * + ∑ χ : DirichletCharacter ℂ (q/d.val), + mrtAdditiveCharacterCoefficient (q/d.val) r χ*dilate d.val (naturalCharacter χ) n := by + unfold majorArcDivisorTerm + rw [mul_sum,mul_sum] + apply sum_congr rfl + intro χ _ + have hh := major_arc_typical_dilation J P hP F hF hd havoid χ hn + calc + _ = mrtAdditiveCharacterCoefficient (q/d.val) r χ * + (F d.val*dilationSequence d.val (mrtTypicalCoefficient J P (twistByCharacter F χ)) n) := by ring + _ = _ := by rw [←hh]; ring + rw [he] + by_cases hdn : d.val∣n + · simp only [dilate,hdn,ite_true] + rw [major_arc_character_inversion_nat] + by_cases hu : IsUnit ((n/d.val:ℕ):ZMod (q/d.val)) + · have hg := (major_arc_reduced_unit_iff q d.val n hq hdq hdn).mp hu + rw [ite_eq_left hu,ite_eq_left hg] + have hp := major_arc_gcd_phase q n hq r + rw [hg] at hp + rw [hp] + · have hg : n.gcd q≠d.val := fun h => hu + ((major_arc_reduced_unit_iff q d.val n hq hdq hdn).mpr h) + rw [ite_eq_right hu,ite_eq_right hg,mul_zero] + · simp only [dilate,hdn,ite_false,mul_zero,sum_const_zero] + have hg : n.gcd q≠d.val := by + intro hg + exact hdn (hg ▸ Nat.gcd_dvd_left n q) + rw [ite_eq_right hg] + +theorem major_arc_divisor_expansion {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (hP : ∀ j ∈ J, ∀ p ∈ P j, p.Prime) + (F : ℕ → ℂ) (hF : ∀ a b, 0 < a → 0 < b → F (a*b)=F a*F b) + (q : ℕ) (hq : 0 < q) (r : ℤ) + (havoid : ∀ d ∈ q.divisors, mrtPrimeAvoids (J.biUnion P) d) + (n : ℕ) (hn : 0 < n) : + mrtTypicalCoefficient J P F n*additiveCharacter ((r:ℝ)/q) n = + ∑ d : {d : ℕ // d ∈ q.divisors}, majorArcDivisorTerm J P F q hq r d n := by + simp_rw [major_arc_divisor_term J P hP F hF q hq r _ (havoid _ (Subtype.property _)) n hn] + let dg : {d : ℕ // d ∈ q.divisors} := ⟨n.gcd q,Nat.mem_divisors.mpr ⟨Nat.gcd_dvd_right n q,hq.ne'⟩⟩ + rw [sum_eq_single dg] + · simp [dg] + · intro d _ hd + have hg : n.gcd q≠d.val := by + intro hg + apply hd + exact Subtype.ext hg.symm + rw [ite_eq_right hg] + · simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcEnergyRoot.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcEnergyRoot.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d3b31add50b5b12e83636d9ca8eeca17189162a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcEnergyRoot.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTypicalShortEnergySharp +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcPublishedRate + +namespace OAI + +/-! Taking the square root of the literal typical short energy. The +first-band resolution losses are paid before character summation. -/ +namespace TwoPointCorrelations + +lemma major_arc_three_term_root {B s t r : ℝ} + (hB : 0 ≤ B) (hs : 0 ≤ s) (ht : 0 ≤ t) (hr : 0 ≤ r) : + Real.sqrt (B*(s^2+t^2+r^2)) ≤ (B+1)*(s+t+r) := by + apply (Real.sqrt_le_iff).mpr + refine ⟨by positivity,?_⟩ + have hcoef : B ≤ (B+1)^2 := by nlinarith [sq_nonneg B] + have hsum : s^2+t^2+r^2 ≤ (s+t+r)^2 := by + nlinarith [mul_nonneg hs ht,mul_nonneg hs hr,mul_nonneg ht hr] + calc + _ ≤ (B+1)^2*(s^2+t^2+r^2) := mul_le_mul_of_nonneg_right hcoef (by positivity) + _ ≤ (B+1)^2*(s+t+r)^2 := mul_le_mul_of_nonneg_left hsum (by positivity) + _ = _ := by ring + +noncomputable def majorArcEnergyConstant (C : ℝ) : ℝ := + (139968/(2*Real.pi))*(12*(C+33792*Real.exp 1+2+2048*Real.exp 2)+2048*Real.exp 1)+1 + +lemma major_arc_energy_constant_pos {C : ℝ} (hC : 0 ≤ C) : + 0 < majorArcEnergyConstant C := by + unfold majorArcEnergyConstant + positivity + +lemma major_arc_short_energy_root {C W R P H Q M δ : ℝ} + (hC : 0 ≤ C) (hW : 1 ≤ W) (hR : W^9 ≤ R) (hP : W^2 ≤ P) + (hH : W ≤ H) (hQ : Q/H ≤ W^7) (hδ : 0 ≤ δ) : + Real.sqrt ((139968/(2*Real.pi))*(12*(C*(Real.exp (-4*M/5)+δ)+ + 33792*Real.exp 1*R⁻¹+2*P⁻¹+1024*Real.exp 2*R⁻¹*(1+Q/H))+ + 2048*Real.exp 1/H^2)) ≤ + majorArcEnergyConstant C*(Real.exp (-2*M/5)+Real.sqrt δ+W⁻¹) := by + have hW0 : 0 < W := by linarith + have hR0 : 0 < R := (pow_pos hW0 9).trans_le hR + have hP0 : 0 < P := (pow_pos hW0 2).trans_le hP + have hH0 : 0 < H := hW0.trans_le hH + have hW5 : 1 ≤ W^7 := one_le_pow₀ hW + have hRR : R⁻¹ ≤ (W^2)⁻¹ := by + apply inv_anti₀ (pow_pos hW0 2) + exact (pow_le_pow_right₀ hW (by omega : 2 ≤ 9)).trans hR + have hPP : P⁻¹ ≤ (W^2)⁻¹ := inv_anti₀ (pow_pos hW0 2) hP + have hHH : 1/H^2 ≤ (W^2)⁻¹ := by + simpa only [one_div] using inv_anti₀ (pow_pos hW0 2) (pow_le_pow_left₀ hW0.le hH 2) + have hRQ : R⁻¹*(1+Q/H) ≤ 2*(W^2)⁻¹ := by + have hi : R⁻¹ ≤ (W^9)⁻¹ := inv_anti₀ (pow_pos hW0 9) hR + calc + _ ≤ R⁻¹*(2*W^7) := mul_le_mul_of_nonneg_left (by linarith) (inv_nonneg.mpr hR0.le) + _ ≤ (W^9)⁻¹*(2*W^7) := mul_le_mul_of_nonneg_right hi (by positivity) + _ = _ := by field_simp + let B := (139968/(2*Real.pi))*(12*(C+33792*Real.exp 1+2+2048*Real.exp 2)+2048*Real.exp 1) + let S := Real.exp (-4*M/5)+δ+(W^2)⁻¹ + have hterm : Real.exp (-4*M/5)+δ ≤ S := by + dsimp only [S] + exact le_add_of_nonneg_right (inv_nonneg.mpr (sq_nonneg W)) + have hinv : (W^2)⁻¹ ≤ S := by + dsimp only [S] + exact le_add_of_nonneg_left (add_nonneg (Real.exp_pos _).le hδ) + have hbounds : + C*(Real.exp (-4*M/5)+δ)+33792*Real.exp 1*R⁻¹+2*P⁻¹+ + 1024*Real.exp 2*R⁻¹*(1+Q/H) ≤ + (C+33792*Real.exp 1+2+2048*Real.exp 2)*S := by + have ha := mul_le_mul_of_nonneg_left hterm hC + have hb := mul_le_mul_of_nonneg_left (hRR.trans hinv) (show 0 ≤ 33792*Real.exp 1 by positivity) + have hc := mul_le_mul_of_nonneg_left (hPP.trans hinv) (show (0:ℝ) ≤ 2 by norm_num) + have hd := mul_le_mul_of_nonneg_left (hRQ.trans (mul_le_mul_of_nonneg_left hinv (by norm_num : (0:ℝ)≤2))) + (show 0 ≤ 1024*Real.exp 2 by positivity) + nlinarith only [ha,hb,hc,hd] + have he : (139968/(2*Real.pi))*(12*(C*(Real.exp (-4*M/5)+δ)+ + 33792*Real.exp 1*R⁻¹+2*P⁻¹+1024*Real.exp 2*R⁻¹*(1+Q/H))+ + 2048*Real.exp 1/H^2) ≤ B*S := by + have ht := mul_le_mul_of_nonneg_left (hHH.trans hinv) (show 0 ≤ 2048*Real.exp 1 by positivity) + have hi : 12*(C*(Real.exp (-4*M/5)+δ)+33792*Real.exp 1*R⁻¹+2*P⁻¹+ + 1024*Real.exp 2*R⁻¹*(1+Q/H))+2048*Real.exp 1/H^2 ≤ + (12*(C+33792*Real.exp 1+2+2048*Real.exp 2)+2048*Real.exp 1)*S := by + calc + _ = 12*(C*(Real.exp (-4*M/5)+δ)+33792*Real.exp 1*R⁻¹+2*P⁻¹+ + 1024*Real.exp 2*R⁻¹*(1+Q/H))+2048*Real.exp 1*(1/H^2) := by ring + _ ≤ 12*((C+33792*Real.exp 1+2+2048*Real.exp 2)*S)+2048*Real.exp 1*S := + add_le_add (mul_le_mul_of_nonneg_left hbounds (by norm_num)) ht + _ = _ := by ring + simpa only [B,mul_assoc] using mul_le_mul_of_nonneg_left hi (show 0 ≤ 139968/(2*Real.pi) by positivity) + have hs : S=(Real.exp (-2*M/5))^2+(Real.sqrt δ)^2+(W⁻¹)^2 := by + dsimp [S] + rw [Real.sq_sqrt hδ,inv_pow] + have hx : (Real.exp (-2*M/5))^2=Real.exp (-4*M/5) := by + rw [← Real.exp_nat_mul] + congr 1 + ring + rw [hx] + calc + _ ≤ Real.sqrt (B*S) := Real.sqrt_le_sqrt he + _ ≤ (B+1)*(Real.exp (-2*M/5)+Real.sqrt δ+W⁻¹) := by + rw [hs] + exact major_arc_three_term_root (by dsimp [B]; positivity) + (Real.exp_pos _).le (Real.sqrt_nonneg _) (inv_nonneg.mpr hW0.le) + _ = _ := rfl + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcGCD.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcGCD.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6472d2982e07a54945f547ccad8eea9df6d80a9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcGCD.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcResidues + +namespace OAI + +/-! Gcd strata of a rational additive phase. The unit character expansion +on the quotient is supported on exactly one divisor of the modulus. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma major_arc_reduced_unit_iff (q d n : ℕ) (hq : 0 < q) + (hdq : d∣q) (hdn : d∣n) : + IsUnit ((n/d:ℕ) : ZMod (q/d)) ↔ n.gcd q=d := by + have hd : 0 < d := Nat.pos_of_dvd_of_pos hdq hq + have hquot : 0 < q/d := Nat.div_pos (Nat.le_of_dvd hq hdq) hd + let : NeZero (q/d) := ⟨hquot.ne'⟩ + rw [ZMod.isUnit_iff_coprime] + constructor + · intro hc + have he : n.gcd q=d*((n/d).gcd (q/d)) := by + conv_lhs => rw [←Nat.mul_div_cancel' hdn,←Nat.mul_div_cancel' hdq] + exact Nat.gcd_mul_left d (n/d) (q/d) + simpa only [hc.gcd_eq_one,mul_one] using he + · intro he + have hc := Nat.coprime_div_gcd_div_gcd (Nat.gcd_pos_of_pos_right n hq) + rwa [he] at hc + +lemma major_arc_gcd_phase (q n : ℕ) (hq : 0 < q) (r : ℤ) : + additiveCharacter ((r:ℝ)/((q/n.gcd q:ℕ):ℝ)) (n/n.gcd q) = + additiveCharacter ((r:ℝ)/q) n := by + have hd : 0 < n.gcd q := Nat.gcd_pos_of_pos_right n hq + have hd0 : (n.gcd q:ℝ)≠0 := by exact_mod_cast hd.ne' + have hq0 : (q:ℝ)≠0 := by exact_mod_cast hq.ne' + have hncast : ((n/n.gcd q:ℕ):ℝ)=(n:ℝ)/(n.gcd q:ℝ) := + Nat.cast_div (Nat.gcd_dvd_left n q) hd0 + have hqcast : ((q/n.gcd q:ℕ):ℝ)=(q:ℝ)/(n.gcd q:ℝ) := + Nat.cast_div (Nat.gcd_dvd_right n q) hd0 + unfold additiveCharacter + rw [hncast,hqcast] + congr 2 + field_simp + +/-- The reduced unit projector partitions every positive argument, including +arguments in nonunit residue classes and reduced modulus one. -/ +lemma major_arc_gcd_partition (q n : ℕ) (hq : 0 < q) (_hn : 0 < n) + (r : ℤ) : + (∑ d ∈ q.divisors, if d∣n then + if IsUnit ((n/d:ℕ):ZMod (q/d)) then + additiveCharacter ((r:ℝ)/((q/d:ℕ):ℝ)) (n/d) else 0 else 0) = + additiveCharacter ((r:ℝ)/q) n := by + rw [sum_eq_single (n.gcd q)] + · rw [ite_eq_left (Nat.gcd_dvd_left n q), + ite_eq_left ((major_arc_reduced_unit_iff q (n.gcd q) n hq + (Nat.gcd_dvd_right n q) (Nat.gcd_dvd_left n q)).mpr rfl)] + exact major_arc_gcd_phase q n hq r + · intro d hd hne + by_cases hdn : d∣n + · rw [ite_eq_left hdn,ite_eq_right] + intro hu + exact hne ((major_arc_reduced_unit_iff q d n hq (Nat.mem_divisors.mp hd).1 hdn).mp hu).symm + · rw [ite_eq_right hdn] + · intro hnot + exact (hnot (Nat.mem_divisors.mpr ⟨Nat.gcd_dvd_right n q,hq.ne'⟩)).elim + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcGlobalMean.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcGlobalMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..22170d6a8ddb331beeb5f75ac5f7db912f94cd46 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcGlobalMean.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTypicalGlobalRange +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcPerturbedSharp +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTCorrectionQuotient + +namespace OAI + +/-! Global typical means for each character in the exact gcd decomposition. +The quotient volume is retained before the divisor sum is taken. -/ +namespace TwoPointCorrelations + +open Finset + +lemma major_arc_character_volume {C R I : ℝ} {V H K q d : ℕ} + (hC : 0 ≤ C) (hR : 0 ≤ R) (hd : 0 < d) (hdq : d ≤ q) + (hdV : d ≤ V) (hdH : d ≤ H) + (hmean : I ≤ C*(V/d+1:ℕ)*(H/d+1:ℕ)*R+ + (2*(K:ℝ)+1)*(H/d+1:ℕ)) : + (d:ℝ)*I ≤ (4*C*V*H*R+2*(q:ℝ)*(2*(K:ℝ)+1)*H)/(d:ℝ) := by + have hdr : (0:ℝ) < d := by exact_mod_cast hd + have hx := mrt_quotient_length_le_two hd hdV + have hh := mrt_quotient_length_le_two hd hdH + have hmain : C*(V/d+1:ℕ)*(H/d+1:ℕ)*R ≤ + C*(2*((V:ℝ)/d))*(2*((H:ℝ)/d))*R := by gcongr + have herr : (2*(K:ℝ)+1)*(H/d+1:ℕ) ≤ + (2*(K:ℝ)+1)*(2*((H:ℝ)/d)) := by gcongr + have hq : (d:ℝ) ≤ q := by exact_mod_cast hdq + calc + _ ≤ (d:ℝ)*(C*(2*((V:ℝ)/d))*(2*((H:ℝ)/d))*R+ + (2*(K:ℝ)+1)*(2*((H:ℝ)/d))) := + mul_le_mul_of_nonneg_left (hmean.trans (add_le_add hmain herr)) hdr.le + _ = (4*C*V*H*R+2*(d:ℝ)*(2*(K:ℝ)+1)*H)/(d:ℝ) := by field_simp; ring + _ ≤ _ := by gcongr + +theorem major_arc_typical_rational_global + (hprime : HalaszPrimeSparseInput) (hhigh : HalaszHighPrimeInput) : + ∃ C : ℝ, 0 < C ∧ ∃ N₀ : ℕ, ∀ X V H K H₀ : ℕ, + 2 ≤ X → 1 ≤ Real.log (X:ℝ) → V ≤ 2*X → N₀ ≤ K → 1 ≤ K → + Real.sqrt (X:ℝ) ≤ K → + ∀ P Q : ℝ, 2 ≤ P → P ≤ Q → 2 ≤ Real.log P → 1 ≤ Real.log Q → + 8192*(Real.log (Real.log Q)+1) ≤ (1/100:ℝ)*Real.log P → + 2 ≤ mrtBaseResolution P Q (1/100) → 2*Q ≤ K → + ∀ J : ℕ, 1 ≤ J → + (∀ n : ℕ, K ≤ n → n ≤ 2*X → + 200*Real.log (Real.log n)+1 ≤ Real.log (mrtBandLower P Q J) ∧ + ∀ j ∈ Icc 1 J, mrtBandUpper Q j ≤ Real.exp (Real.sqrt (Real.log n))) → + ∀ W : ℝ, 1 ≤ W → W ≤ K → W^9 ≤ mrtBaseResolution P Q (1/100) → W^2 ≤ P → + ∀ q : ℕ, 0 < q → q ≤ V → q ≤ H → (q:ℝ) ≤ mrtModulusCutoff X H₀ → + (∀ d ∈ q.divisors, mrtPrimeAvoids ((Icc 1 J).biUnion + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j))) d) → + (∀ d ∈ q.divisors, 4 ≤ H/d+1 ∧ H/d+1 ≤ K ∧ + W ≤ (H/d+1:ℕ) ∧ Q/(H/d+1:ℕ) ≤ W^7) → + ∀ F : ℕ → ℂ, F 1=1 → (∀ a b, 0 < a → 0 < b → F (a*b)=F a*F b) → OneBounded F → + ∀ M : ℝ, 0 ≤ M → MRTDistanceLowerBound F X H₀ M → ∀ r : ℤ, + shortExponentialIntegral (mrtTypicalCoefficient (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) V H ((r:ℝ)/q) ≤ + Real.sqrt (q:ℝ)*((1+Real.log q)* + (4*C*V*H*(Real.exp (-2*M/5)+ + Real.sqrt (Real.log (Real.log X)/(Real.log X)^(1/80:ℝ))+W⁻¹)+ + 2*(q:ℝ)*(2*(K:ℝ)+1)*H)+(q:ℝ)*V) := by + obtain ⟨C,hC,N₀,hglobal⟩ := halasz_typical_global_range hprime hhigh + refine ⟨C,hC,N₀,?_⟩ + intro X V H K H₀ hX hLX hV hKN hK hKX P Q hP hPQ hLP hLQ hbudget hres hQK + J hJ hbands W hW hWK hWR hWP q hq hqV hqH hqmax havoid hwindow F hF1 hFc hFb M hM hd r + let R := Real.exp (-2*M/5)+ + Real.sqrt (Real.log (Real.log X)/(Real.log X)^(1/80:ℝ))+W⁻¹ + have hR : 0 ≤ R := by dsimp [R]; positivity + apply major_arc_typical_rational_sharp _ _ + (fun j _ p hp => mrtPrimeBand_prime hp) F hFc hFb q hq r V H + (4*C*V*H*R+2*(q:ℝ)*(2*(K:ℝ)+1)*H) (by positivity) havoid + intro d χ + have hd0 : 0 < d.val := Nat.pos_of_dvd_of_pos (Nat.mem_divisors.mp d.property).1 hq + have hdq : d.val ≤ q := Nat.le_of_dvd hq (Nat.mem_divisors.mp d.property).1 + have hwin := hwindow d.val d.property + have hY : V/d.val+1 ≤ 2*X+1 := (Nat.add_le_add_right (Nat.div_le_self V d.val) 1).trans + (Nat.add_le_add_right hV 1) + have hχ1 : twistByCharacter F χ 1=1 := by simp [twistByCharacter,hF1] + have hm := hglobal X (V/d.val+1) (H/d.val+1) K 1 hX hLX hY hKN hK hKX + hwin.1 hwin.2.1 P Q hP hPQ hLP hLQ hbudget hres hQK J hJ hbands + W hW hWK hWR hWP hwin.2.2.1 hwin.2.2.2 + (twistByCharacter F χ) hχ1 (major_arc_twist_complete F hFc χ) (hFb.twistByCharacter χ) M hM + (fun t ht => major_arc_divisor_distance hd q hq hqmax d χ t ht) + apply major_arc_character_volume hC.le hR hd0 hdq (hdq.trans hqV) (hdq.trans hqH) + simpa only [R,Nat.cast_one] using hm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcGlobalRate.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcGlobalRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..7026af957a27d3a7d226988fbab8b92c69798d1a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcGlobalRate.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcPublishedRate + +namespace OAI + +/-! Absorb the initial dyadic block and quotient rounding after the +square-root character estimate, retaining the published energy rate. -/ +namespace TwoPointCorrelations + +lemma major_arc_boundary_rate {W q V H K : ℝ} + (hW : 1 ≤ W) (hq : 1 ≤ q) (hqW : q ≤ W) + (hK : (2*K+1)/V ≤ (W^4)⁻¹) (hH : W^3 ≤ H) : + 2*Real.sqrt q*(1+Real.log q)*q*((2*K+1)/V)+Real.sqrt q*q/H ≤ 3/W := by + have hW0 : 0 < W := by linarith + have hq0 : 0 < q := by linarith + have hH0 : 0 < H := (pow_pos hW0 3).trans_le hH + have hroot : Real.sqrt q ≤ W := + (Real.sqrt_le_self_iff.mpr (Or.inr hq)).trans hqW + have hlog : 1+Real.log q ≤ W := by + linarith [Real.log_le_sub_one_of_pos hq0] + have hlog0 : 0 ≤ 1+Real.log q := by linarith [Real.log_nonneg hq] + have hfirst : 2*Real.sqrt q*(1+Real.log q)*q*((2*K+1)/V) ≤ 2/W := by + calc + _ ≤ 2*Real.sqrt q*(1+Real.log q)*q*(W^4)⁻¹ := + mul_le_mul_of_nonneg_left hK (by positivity) + _ ≤ 2*W*W*W*(W^4)⁻¹ := by gcongr + _ = _ := by field_simp + have hsecond : Real.sqrt q*q/H ≤ 1/W := by + apply (div_le_iff₀ hH0).mpr + calc + _ ≤ W*W := mul_le_mul hroot hqW hq0.le hW0.le + _ ≤ (1/W)*H := by + rw [div_mul_eq_mul_div,one_mul] + apply (le_div_iff₀ hW0).mpr + simpa only [pow_succ,pow_two,pow_zero,one_mul] using hH + calc + _ ≤ 2/W+1/W := add_le_add hfirst hsecond + _ = _ := by ring + +lemma major_arc_global_normalized {I C R W q V H K : ℝ} + (hC : 0 ≤ C) (hR : 0 ≤ R) (hW : 1 ≤ W) (hq : 1 ≤ q) (hqW : q ≤ W) + (hV : 0 < V) (hK : (2*K+1)/V ≤ (W^4)⁻¹) (hH : W^3 ≤ H) + (hi : I ≤ Real.sqrt q*((1+Real.log q)* + (4*C*V*H*R+2*q*(2*K+1)*H)+q*V)) : + I ≤ V*H*(4*C*(Real.sqrt W*(1+Real.log W))*R+3/W) := by + have hW0 : 0 < W := by linarith + have hH0 : 0 < H := (pow_pos hW0 3).trans_le hH + have hq0 : 0 < q := by linarith + have hweight : Real.sqrt q*(1+Real.log q) ≤ Real.sqrt W*(1+Real.log W) := by + apply mul_le_mul (Real.sqrt_le_sqrt hqW) + (by linarith [Real.log_le_log hq0 hqW]) + (by linarith [Real.log_nonneg hq]) (Real.sqrt_nonneg W) + have hmain := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hweight (show 0 ≤ 4*C by positivity)) hR + have herr := major_arc_boundary_rate hW hq hqW hK hH + calc + I ≤ Real.sqrt q*((1+Real.log q)*(4*C*V*H*R+2*q*(2*K+1)*H)+q*V) := hi + _ = V*H*(4*C*(Real.sqrt q*(1+Real.log q))*R+ + (2*Real.sqrt q*(1+Real.log q)*q*((2*K+1)/V)+Real.sqrt q*q/H)) := by + field_simp + ring + _ ≤ _ := mul_le_mul_of_nonneg_left (add_le_add hmain herr) (mul_nonneg hV.le hH0.le) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPerturbation.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPerturbation.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ced736e78560a91fc9733affefc6ee78e0b66d4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPerturbation.lean @@ -0,0 +1,109 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShortSumSampling +import Mathlib.Algebra.BigOperators.Module +import Mathlib.Analysis.SpecialFunctions.Trigonometric.Bounds + +namespace OAI + +/-! A finite partial-summation form of the major-arc frequency perturbation. +The error uses the actual shorter windows before averaging the origin; +no frequency supremum is moved inside an integral. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma major_arc_abel_bound (a w : ℕ → ℂ) (N : ℕ) (L : ℝ) + (hw : ∀ n, ‖w n‖ ≤ 1) + (hstep : ∀ n, ‖w (n + 1) - w n‖ ≤ L) : + ‖∑ n ∈ range N, a n * w n‖ ≤ ‖∑ n ∈ range N, a n‖ + + L * ∑ n ∈ range (N - 1), ‖∑ j ∈ range (n + 1), a j‖ := by + have he := sum_range_by_parts' a w N + simp only [smul_eq_mul] at he + rw [he] + apply (norm_sub_le _ _).trans + apply add_le_add + · rw [norm_mul] + exact mul_le_of_le_one_right (norm_nonneg _) (hw _) + · calc + _ ≤ ∑ n ∈ range (N - 1), + ‖(∑ j ∈ range (n + 1), a j) * (w (n + 1) - w n)‖ := norm_sum_le _ _ + _ ≤ ∑ n ∈ range (N - 1), L * ‖∑ j ∈ range (n + 1), a j‖ := by + apply sum_le_sum + intro n _ + rw [norm_mul, mul_comm L] + exact mul_le_mul_of_nonneg_left (hstep n) (norm_nonneg _) + _ = _ := (mul_sum _ _ _).symm + +lemma major_arc_character_step (β : ℝ) (n : ℕ) : + ‖additiveCharacter β (n + 1) - additiveCharacter β n‖ ≤ + 2 * Real.pi * |β| := by + have he : additiveCharacter β (n + 1) - additiveCharacter β n = + additiveCharacter β n * (additiveCharacter β 1 - 1) := by + rw [additiveCharacter_nat_add] + ring + rw [he, norm_mul, norm_additiveCharacter, one_mul] + have h := Real.norm_exp_I_mul_ofReal_sub_one_le (x := 2 * Real.pi * β) + have harg : additiveCharacter β 1 = Complex.exp (Complex.I * (2 * Real.pi * β : ℝ)) := by + unfold additiveCharacter + congr 1 + push_cast + ring + rw [harg] + convert h using 1 + rw [Real.norm_eq_abs, abs_mul, abs_mul, abs_of_pos Real.pi_pos] + norm_num + +lemma major_arc_frequency_perturbation (a : ℕ → ℂ) (H v : ℕ) (α β : ℝ) : + ‖shortExponentialSum a H (α + β) v‖ ≤ + ‖shortExponentialSum a H α v‖ + 2 * Real.pi * |β| * + ∑ h ∈ range (H - 1), ‖shortExponentialSum a (h + 1) α v‖ := by + have hb := major_arc_abel_bound + (fun n => a (v + n + 1) * additiveCharacter α (v + n + 1)) + (fun n => additiveCharacter β (v + n + 1)) H (2 * Real.pi * |β|) + (fun n => (norm_additiveCharacter β _).le) + (fun n => by + simpa only [Nat.add_assoc] using major_arc_character_step β (v + n + 1)) + simp only [shortExponentialSum_at_nat, sum_Icc_shift] + convert hb using 1 + apply congrArg norm + apply sum_congr rfl + intro n _ + rw [additiveCharacter_add] + ring + +theorem major_arc_integral_perturbation (a : ℕ → ℂ) (X H : ℕ) (α β : ℝ) : + shortExponentialIntegral a X H (α + β) ≤ + shortExponentialIntegral a X H α + 2 * Real.pi * |β| * + ∑ h ∈ range (H - 1), shortExponentialIntegral a X (h + 1) α := by + simp only [shortExponentialIntegral_eq_sum] + calc + _ ≤ ∑ v ∈ range X, (‖shortExponentialSum a H α v‖ + 2 * Real.pi * |β| * + ∑ h ∈ range (H - 1), ‖shortExponentialSum a (h + 1) α v‖) := + sum_le_sum (fun v _ => major_arc_frequency_perturbation a H v α β) + _ = _ := by rw [sum_add_distrib, ← mul_sum, sum_comm] + +lemma major_arc_integral_perturbation_uniform (a : ℕ → ℂ) (X H : ℕ) + (hH : 0 < H) (α β K : ℝ) (hK : 0 ≤ K) + (hprefix : ∀ h : ℕ, 1 ≤ h → h ≤ H → shortExponentialIntegral a X h α ≤ K) : + shortExponentialIntegral a X H (α + β) ≤ + (1 + 2 * Real.pi * |β| * H) * K := by + apply (major_arc_integral_perturbation a X H α β).trans + have hs : (∑ h ∈ range (H - 1), shortExponentialIntegral a X (h + 1) α) ≤ + (H : ℝ) * K := by + calc + _ ≤ ∑ _h ∈ range (H - 1), K := by + apply sum_le_sum + intro h hh + exact hprefix (h + 1) (by omega) (by have := mem_range.mp hh; omega) + _ = ((H - 1 : ℕ) : ℝ) * K := by simp + _ ≤ (H : ℝ) * K := mul_le_mul_of_nonneg_right + (by exact_mod_cast Nat.sub_le H 1) hK + calc + _ ≤ K + 2 * Real.pi * |β| * ((H : ℝ) * K) := + add_le_add (hprefix H hH le_rfl) (mul_le_mul_of_nonneg_left hs (by positivity)) + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPerturbedGlobal.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPerturbedGlobal.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb28599c4bfe3f2fe781b8d1d82618ab0348ce99 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPerturbedGlobal.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcGlobalMean +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcGlobalRate +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcPrefixCutoff + +namespace OAI + +/-! Major-arc perturbation for the literal typical coefficient. Very short +prefixes use boundedness; every longer prefix uses the proved character mean. -/ +namespace TwoPointCorrelations + +open Finset + +theorem major_arc_typical_perturbed_global + (hprime : HalaszPrimeSparseInput) (hhigh : HalaszHighPrimeInput) : + ∃ C : ℝ, 0 < C ∧ ∃ N₀ : ℕ, ∀ X V H K H₀ : ℕ, + 2 ≤ X → 1 ≤ Real.log (X:ℝ) → V ≤ 2*X → N₀ ≤ K → 1 ≤ K → + Real.sqrt (X:ℝ) ≤ K → + ∀ P Q : ℝ, 2 ≤ P → P ≤ Q → 2 ≤ Real.log P → 1 ≤ Real.log Q → + 8192*(Real.log (Real.log Q)+1) ≤ (1/100:ℝ)*Real.log P → + 2 ≤ mrtBaseResolution P Q (1/100) → 2*Q ≤ K → + ∀ J : ℕ, 1 ≤ J → + (∀ n : ℕ, K ≤ n → n ≤ 2*X → + 200*Real.log (Real.log n)+1 ≤ Real.log (mrtBandLower P Q J) ∧ + ∀ j ∈ Icc 1 J, mrtBandUpper Q j ≤ Real.exp (Real.sqrt (Real.log n))) → + ∀ W : ℝ, 1 ≤ W → W ≤ K → W^9 ≤ mrtBaseResolution P Q (1/100) → W^2 ≤ P → + W^5 ≤ (H:ℝ) → (2*(K:ℝ)+1)/(V:ℝ) ≤ (W^4)⁻¹ → + ∀ q : ℕ, 0 < q → q ≤ V → (q:ℝ) ≤ W → (q:ℝ) ≤ mrtModulusCutoff X H₀ → + (∀ d ∈ q.divisors, mrtPrimeAvoids ((Icc 1 J).biUnion + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j))) d) → + (∀ h : ℕ, 1 ≤ h → h ≤ H → (H:ℝ)/W^2 ≤ h → + ∀ d ∈ q.divisors, 4 ≤ h/d+1 ∧ h/d+1 ≤ K ∧ + W ≤ (h/d+1:ℕ) ∧ Q/(h/d+1:ℕ) ≤ W^7) → + ∀ F : ℕ → ℂ, F 1=1 → (∀ a b, 0 < a → 0 < b → F (a*b)=F a*F b) → OneBounded F → + ∀ M : ℝ, 0 ≤ M → MRTDistanceLowerBound F X H₀ M → ∀ r : ℤ, ∀ β : ℝ, + |β| *(H:ℝ) ≤ 2 → + shortExponentialIntegral (mrtTypicalCoefficient (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) V H ((r:ℝ)/q+β) ≤ + (1+4*Real.pi)*(V:ℝ)*H* + (4*C*(Real.sqrt W*(1+Real.log W))*(Real.exp (-2*M/5)+ + Real.sqrt (Real.log (Real.log X)/(Real.log X)^(1/80:ℝ))+W⁻¹)+3/W) := by + obtain ⟨C,hC,N₀,hrational⟩ := major_arc_typical_rational_global hprime hhigh + refine ⟨C,hC,N₀,?_⟩ + intro X V H K H₀ hX hLX hV hKN hK hKX P Q hP hPQ hLP hLQ hbudget hres hQK + J hJ hbands W hW hWK hWR hWP hH hboundary q hq hqV hqW hqmax havoid hwindow + F hF1 hFc hFb M hM hd r β hβ + let R := Real.exp (-2*M/5)+ + Real.sqrt (Real.log (Real.log X)/(Real.log X)^(1/80:ℝ))+W⁻¹ + let ε := 4*C*(Real.sqrt W*(1+Real.log W))*R+3/W + have hW0 : 0 < W := by linarith + have hH0 : (0:ℝ) < H := (pow_pos hW0 5).trans_le hH + have hV0 : (0:ℝ) < V := by exact_mod_cast hq.trans_le hqV + have hq1 : (1:ℝ) ≤ q := by exact_mod_cast hq + have hR : 0 ≤ R := by dsimp [R]; positivity + have hlog : 0 ≤ 1+Real.log W := by linarith [Real.log_nonneg hW] + have hmain : 0 ≤ 4*C*(Real.sqrt W*(1+Real.log W))*R := by positivity + have hε : 0 ≤ ε := by dsimp [ε]; positivity + have hsmall : (V:ℝ)*((H:ℝ)/W^2) ≤ (V:ℝ)*H*ε := by + have hsq : W ≤ W^2 := le_self_pow₀ hW (by decide) + have hi : (W^2)⁻¹ ≤ W⁻¹ := inv_le_inv₀ (pow_pos hW0 2) hW0 |>.mpr hsq + have he : W⁻¹ ≤ ε := by dsimp [ε]; rw [div_eq_mul_inv]; nlinarith [inv_pos.mpr hW0] + have hh := mul_le_mul_of_nonneg_left (hi.trans he) (Nat.cast_nonneg H) + simpa only [div_eq_mul_inv,mul_assoc] using mul_le_mul_of_nonneg_left hh hV0.le + have hp := major_arc_perturbation_cutoff_two _ + (mrtTypicalCoefficient_oneBounded (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F hFb) + V H (by exact_mod_cast hH0) ((r:ℝ)/q) β ((H:ℝ)/W^2) ((V:ℝ)*H*ε) + (by positivity) hsmall hβ ?_ + · convert hp using 1 + dsimp [ε,R] + ring + intro h hh hhH hu + have hp3 : W^3 ≤ (h:ℝ) := by + apply le_trans _ hu + apply (le_div_iff₀ (pow_pos hW0 2)).mpr + simpa only [←pow_add] using hH + have hqh : q ≤ h := by + have ht : (q:ℝ) ≤ h := hqW.trans ((le_self_pow₀ hW (by decide : 3≠0)).trans hp3) + exact_mod_cast ht + have hr := hrational X V h K H₀ hX hLX hV hKN hK hKX P Q hP hPQ hLP hLQ + hbudget hres hQK J hJ hbands W hW hWK hWR hWP q hq hqV hqh hqmax havoid + (hwindow h hh hhH hu) F hF1 hFc hFb M hM hd r + have hn := major_arc_global_normalized hC.le hR hW hq1 hqW hV0 hboundary hp3 hr + have hhreal : (h:ℝ) ≤ H := by exact_mod_cast hhH + calc + _ ≤ (V:ℝ)*h*ε := hn + _ ≤ _ := by gcongr + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPerturbedSharp.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPerturbedSharp.lean new file mode 100644 index 0000000000000000000000000000000000000000..152d346928b6767d473a6f8ee70dac72c3be1d12 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPerturbedSharp.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcRationalSharp +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcReduction + +namespace OAI + +/-! Preserve the square-root modulus loss through partial summation. +The estimates for shorter intervals remain explicit. -/ +namespace TwoPointCorrelations + +open Finset + +theorem major_arc_typical_perturbed_sharp {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (hP : ∀ j ∈ J, ∀ p ∈ P j, p.Prime) + (F : ℕ → ℂ) (hFm : ∀ a b, 0 < a → 0 < b → F (a*b)=F a*F b) (hF : OneBounded F) + (q : ℕ) (hq : 0 < q) (r : ℤ) (X H : ℕ) (hH : 0 < H) + (A : ℝ) (hA : 0 ≤ A) (β : ℝ) + (havoid : ∀ d ∈ q.divisors, mrtPrimeAvoids (J.biUnion P) d) + (hshort : ∀ h : ℕ, 1 ≤ h → h ≤ H → + ∀ d : {d : ℕ // d ∈ q.divisors}, ∀ χ : DirichletCharacter ℂ (q/d.val), + (d.val:ℝ)*shortExponentialIntegral (mrtTypicalCoefficient J P (twistByCharacter F χ)) + (X/d.val+1) (h/d.val+1) 0 ≤ A/(d.val:ℝ)) : + shortExponentialIntegral (mrtTypicalCoefficient J P F) X H ((r:ℝ)/q+β) ≤ + (1+2*Real.pi*|β| *H)*Real.sqrt (q:ℝ)*((1+Real.log q)*A+(q:ℝ)*X) := by + have hq1 : (1:ℝ) ≤ q := by exact_mod_cast hq + have hK : 0 ≤ Real.sqrt (q:ℝ)*((1+Real.log q)*A+(q:ℝ)*X) := by + have hl := Real.log_nonneg hq1 + positivity + have hh := major_arc_integral_perturbation_uniform (mrtTypicalCoefficient J P F) + X H hH ((r:ℝ)/q) β _ hK (fun h hh hhH => + major_arc_typical_rational_sharp J P hP F hFm hF q hq r X h A hA havoid (hshort h hh hhH)) + simpa only [mul_assoc] using hh + +lemma major_arc_twist_complete {q : ℕ} (F : ℕ → ℂ) + (hF : ∀ a b, 0 < a → 0 < b → F (a*b)=F a*F b) + (χ : DirichletCharacter ℂ q) : + ∀ a b, 0 < a → 0 < b → twistByCharacter F χ (a*b)=twistByCharacter F χ a*twistByCharacter F χ b := by + intro a b ha hb + simp only [twistByCharacter,hF a b ha hb,Nat.cast_mul,map_mul] + ring + +lemma major_arc_divisor_distance {F : ℕ → ℂ} {X H : ℕ} {M : ℝ} + (hd : MRTDistanceLowerBound F X H M) (q : ℕ) (hq : 0 < q) + (hqmax : (q:ℝ) ≤ mrtModulusCutoff X H) + (d : {d : ℕ // d ∈ q.divisors}) (χ : DirichletCharacter ℂ (q/d.val)) + (t : ℝ) (ht : |t| ≤ X) : + M ≤ squaredDistance (twistByCharacter F χ) (mrtArchimedeanTwist t) X := by + apply hd.major_arc_character (q/d.val) (major_arc_divisor_quotient_pos hq d) _ χ t ht + exact (show ((q/d.val:ℕ):ℝ) ≤ q by exact_mod_cast Nat.div_le_self q d.val).trans hqmax + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPrefixCutoff.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPrefixCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2129b089cd5fb57dff1ff06844cb5924a00337c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPrefixCutoff.lean @@ -0,0 +1,45 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcPerturbedSharp +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcTrivial + +namespace OAI + +/-! Very short prefixes use boundedness; character estimates are only +needed above the cutoff where all divided windows remain long. -/ +namespace TwoPointCorrelations + +lemma major_arc_prefix_cutoff (B : ℕ → ℂ) (hB : OneBounded B) + (X H : ℕ) (α U K : ℝ) (hsmall : (X:ℝ)*U ≤ K) + (hlong : ∀ h : ℕ, 1 ≤ h → h ≤ H → U ≤ (h:ℝ) → + shortExponentialIntegral B X h α ≤ K) : + ∀ h : ℕ, 1 ≤ h → h ≤ H → shortExponentialIntegral B X h α ≤ K := by + intro h hh hhH + by_cases hu : U ≤ (h:ℝ) + · exact hlong h hh hhH hu + · exact (minor_arc_short_integral_trivial B hB X h α).trans + ((mul_le_mul_of_nonneg_left (le_of_not_ge hu) (Nat.cast_nonneg X)).trans hsmall) + +theorem major_arc_perturbation_cutoff (B : ℕ → ℂ) (hB : OneBounded B) + (X H : ℕ) (hH : 0 < H) (α β U K : ℝ) (hK : 0 ≤ K) + (hsmall : (X:ℝ)*U ≤ K) (hphase : |β| *(H:ℝ) ≤ 1) + (hlong : ∀ h : ℕ, 1 ≤ h → h ≤ H → U ≤ (h:ℝ) → + shortExponentialIntegral B X h α ≤ K) : + shortExponentialIntegral B X H (α+β) ≤ (1+2*Real.pi)*K := by + apply (major_arc_integral_perturbation_uniform B X H hH α β K hK + (major_arc_prefix_cutoff B hB X H α U K hsmall hlong)).trans + apply mul_le_mul_of_nonneg_right _ hK + nlinarith [Real.pi_pos] + +theorem major_arc_perturbation_cutoff_two (B : ℕ → ℂ) (hB : OneBounded B) + (X H : ℕ) (hH : 0 < H) (α β U K : ℝ) (hK : 0 ≤ K) + (hsmall : (X:ℝ)*U ≤ K) (hphase : |β| *(H:ℝ) ≤ 2) + (hlong : ∀ h : ℕ, 1 ≤ h → h ≤ H → U ≤ (h:ℝ) → + shortExponentialIntegral B X h α ≤ K) : + shortExponentialIntegral B X H (α+β) ≤ (1+4*Real.pi)*K := by + apply (major_arc_integral_perturbation_uniform B X H hH α β K hK + (major_arc_prefix_cutoff B hB X H α U K hsmall hlong)).trans + apply mul_le_mul_of_nonneg_right _ hK + nlinarith [Real.pi_pos] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPublishedRate.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPublishedRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b157ac4dc1b3756e83abaf8f88673267dfb110a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcPublishedRate.lean @@ -0,0 +1,196 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcDivisorBounds +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTArcRate + +namespace OAI + +/-! The common major/minor-arc parameter and its quantitative rates. +The fifth-root working length retains the published logarithmic error. -/ +namespace TwoPointCorrelations + +open Filter + +noncomputable def majorArcParameter (L H M : ℝ) : ℝ := + min ((Real.log H)^5) (min (L^(1/125:ℝ)) (Real.exp (M/3))) + +lemma major_arc_parameter_bounds {L H M : ℝ} (hL : 1 ≤ L) + (hH : 1 ≤ Real.log H) (hM : 0 ≤ M) : + 1 ≤ majorArcParameter L H M ∧ + majorArcParameter L H M ≤ (Real.log H)^5 ∧ + majorArcParameter L H M ≤ L^(1/125:ℝ) ∧ + majorArcParameter L H M ≤ Real.exp (M/3) := by + exact ⟨le_min (one_le_pow₀ hH) (le_min + (Real.one_le_rpow hL (by norm_num)) (Real.one_le_exp (by positivity))), + min_le_left _ _, (min_le_right _ _).trans (min_le_left _ _), + (min_le_right _ _).trans (min_le_right _ _)⟩ + +noncomputable def majorArcWorkingError (W : ℝ) : ℝ := + (1+Real.log W)*W^(-1/5:ℝ) + +lemma major_arc_working_short {H : ℝ} (hH : 1 ≤ Real.log H) + (hHH : 1 ≤ Real.log (Real.log H)) : + majorArcWorkingError ((Real.log H)^5) ≤ 6*Real.log (Real.log H)/Real.log H := by + have hL : 0 < Real.log H := by linarith + have hp : ((Real.log H)^5)^(-1/5:ℝ) = (Real.log H)⁻¹ := by + rw [← Real.rpow_natCast,← Real.rpow_mul hL.le] + norm_num [Real.rpow_neg_one] + unfold majorArcWorkingError + rw [hp,Real.log_pow] + rw [mul_inv_le_iff₀ hL] + field_simp + norm_num + linarith + +lemma major_arc_working_exponential {M : ℝ} (hM : 0 ≤ M) : + majorArcWorkingError (Real.exp (M/3)) ≤ 21*Real.exp (-M/20) := by + have hh := Real.add_one_le_exp (M/60) + have hcoef : 1+M/3 ≤ 21*Real.exp (M/60) := by + have he : 1 ≤ Real.exp (M/60) := Real.one_le_exp (by positivity) + linarith + unfold majorArcWorkingError + rw [Real.log_exp,Real.rpow_def_of_pos (Real.exp_pos _),Real.log_exp] + calc + _ ≤ (21*Real.exp (M/60))*Real.exp (M/3*(-1/5)) := + mul_le_mul_of_nonneg_right hcoef (Real.exp_pos _).le + _ = _ := by + rw [mul_assoc,← Real.exp_add] + congr 2 + ring + +lemma major_arc_working_outer : + ∀ᶠ L : ℝ in atTop, + majorArcWorkingError (L^(1/125:ℝ)) ≤ L^(-1/700:ℝ) := by + have hh := (isLittleO_log_rpow_atTop (show (0:ℝ)<3/17500 by norm_num)).bound + (show (0:ℝ)<1/2 by norm_num) + have hg := (tendsto_rpow_atTop (show (0:ℝ)<3/17500 by norm_num)).eventually + (eventually_ge_atTop (2:ℝ)) + filter_upwards [hh,hg,eventually_ge_atTop (1:ℝ)] with L hh hg hL + have hL0 : 0 < L := by linarith + rw [Real.norm_eq_abs,abs_of_nonneg (Real.log_nonneg hL),Real.norm_eq_abs, + abs_of_nonneg (Real.rpow_nonneg hL0.le _)] at hh + have hp : (L^(1/125:ℝ))^(-1/5:ℝ)=L^(-1/625:ℝ) := by + rw [← Real.rpow_mul hL0.le] + norm_num + unfold majorArcWorkingError + rw [Real.log_rpow hL0,hp] + calc + _ ≤ L^(3/17500:ℝ)*L^(-1/625:ℝ) := by + apply mul_le_mul_of_nonneg_right _ (Real.rpow_nonneg hL0.le _) + nlinarith [Real.log_nonneg hL] + _ = _ := by rw [← Real.rpow_add hL0]; norm_num + +lemma major_arc_working_min {a b : ℝ} (ha : 1 ≤ a) (hb : 1 ≤ b) : + majorArcWorkingError (min a b) ≤ majorArcWorkingError a+majorArcWorkingError b := by + have hfa : 0 ≤ majorArcWorkingError a := + mul_nonneg (by linarith [Real.log_nonneg ha]) (Real.rpow_nonneg (by linarith) _) + have hfb : 0 ≤ majorArcWorkingError b := + mul_nonneg (by linarith [Real.log_nonneg hb]) (Real.rpow_nonneg (by linarith) _) + rcases le_total a b with hab | hba + · rw [min_eq_left hab] + exact le_add_of_nonneg_right hfb + · rw [min_eq_right hba] + exact le_add_of_nonneg_left hfa + +lemma major_arc_parameter_rate : + ∀ᶠ L : ℝ in atTop, ∀ H M : ℝ, 1 ≤ Real.log H → + 1 ≤ Real.log (Real.log H) → 0 ≤ M → + majorArcWorkingError (majorArcParameter L H M) ≤ + 6*Real.log (Real.log H)/Real.log H + L^(-1/700:ℝ)+21*Real.exp (-M/20) := by + filter_upwards [major_arc_working_outer,eventually_ge_atTop (1:ℝ)] with L houter hL + intro H M hH hHH hM + have ha : 1 ≤ (Real.log H)^5 := one_le_pow₀ hH + have hb : 1 ≤ L^(1/125:ℝ) := Real.one_le_rpow hL (by norm_num) + have hc : 1 ≤ Real.exp (M/3) := Real.one_le_exp (by positivity) + have hi := major_arc_working_min hb hc + have hj := major_arc_working_min ha (le_min hb hc) + change majorArcWorkingError (majorArcParameter L H M) ≤ _ at hj + linarith [major_arc_working_short hH hHH,major_arc_working_exponential hM] + +theorem major_arc_sharp_energy_rate : + ∀ᶠ L : ℝ in atTop, ∀ W : ℝ, 1 ≤ W → W ≤ L^(1/125:ℝ) → + Real.sqrt W*(1+Real.log W)*Real.sqrt (Real.log L/L^(1/80:ℝ)) ≤ + 101*L^(-1/700:ℝ) := by + have hs := (isLittleO_log_rpow_atTop (show (0:ℝ)<1/1000 by norm_num)).bound + (show (0:ℝ)<1 by norm_num) + filter_upwards [hs,eventually_ge_atTop (1:ℝ)] with L hs hL + have hL0 : 0 < L := by linarith + rw [Real.norm_eq_abs,abs_of_nonneg (Real.log_nonneg hL),Real.norm_eq_abs, + abs_of_nonneg (Real.rpow_nonneg hL0.le _),one_mul] at hs + intro W hW hWL + have hW0 : 0 < W := by linarith + have hmod : Real.sqrt W*W^(1/100:ℝ) ≤ L^(51/12500:ℝ) := by + rw [mrt_sqrt_modulus_power hW0] + calc + _ ≤ (L^(1/125:ℝ))^(51/100:ℝ) := Real.rpow_le_rpow hW0.le hWL (by norm_num) + _ = _ := by rw [← Real.rpow_mul hL0.le]; norm_num + have hratio : Real.log L/L^(1/80:ℝ) ≤ L^(-23/2000:ℝ) := by + calc + _ ≤ L^(1/1000:ℝ)/L^(1/80:ℝ) := div_le_div_of_nonneg_right hs (by positivity) + _ = _ := by rw [← Real.rpow_sub hL0]; norm_num + have hroot : Real.sqrt (Real.log L/L^(1/80:ℝ)) ≤ L^(-23/4000:ℝ) := by + calc + _ ≤ Real.sqrt (L^(-23/2000:ℝ)) := Real.sqrt_le_sqrt hratio + _ = _ := by rw [Real.sqrt_eq_rpow,← Real.rpow_mul hL0.le]; norm_num + calc + _ ≤ Real.sqrt W*(101*W^(1/100:ℝ))*Real.sqrt (Real.log L/L^(1/80:ℝ)) := by + gcongr + exact major_arc_log_overhead hW + _ = 101*((Real.sqrt W*W^(1/100:ℝ))*Real.sqrt (Real.log L/L^(1/80:ℝ))) := by ring + _ ≤ 101*(L^(51/12500:ℝ)*L^(-23/4000:ℝ)) := by + gcongr + _ = 101*L^(-167/100000:ℝ) := by rw [← Real.rpow_add hL0]; norm_num + _ ≤ _ := mul_le_mul_of_nonneg_left (Real.rpow_le_rpow_of_exponent_le hL (by norm_num)) (by norm_num) + +lemma major_arc_sharp_distance_rate {W M : ℝ} (hW : 1 ≤ W) (hM : 0 ≤ M) + (hWM : W ≤ Real.exp (M/3)) : + Real.sqrt W*(1+Real.log W)*Real.exp (-2*M/5) ≤ 101*Real.exp (-M/20) := by + have hW0 : 0 < W := by linarith + calc + _ ≤ Real.sqrt W*(101*W^(1/100:ℝ))*Real.exp (-2*M/5) := by + gcongr + exact major_arc_log_overhead hW + _ = 101*(W^(51/100:ℝ)*Real.exp (-2*M/5)) := by + rw [← mrt_sqrt_modulus_power hW0] + ring + _ ≤ 101*((Real.exp (M/3))^(51/100:ℝ)*Real.exp (-2*M/5)) := by + gcongr + _ = 101*Real.exp (-23*M/100) := by + rw [Real.rpow_def_of_pos (Real.exp_pos _),Real.log_exp,← Real.exp_add] + congr 2 + ring + _ ≤ _ := mul_le_mul_of_nonneg_left + (Real.exp_le_exp.mpr (by nlinarith only [hM])) (by norm_num) + + +lemma major_arc_inverse_working_rate {W : ℝ} (hW : 1 ≤ W) : + Real.sqrt W*(1+Real.log W)*W⁻¹ ≤ majorArcWorkingError W := by + have hW0 : 0 < W := by linarith + calc + _ = (1+Real.log W)*W^(-1/2:ℝ) := by + rw [Real.sqrt_eq_rpow,← Real.rpow_neg_one W] + calc + _ = (1+Real.log W)*(W^(1/2:ℝ)*W^(-1:ℝ)) := by ring + _ = _ := by rw [← Real.rpow_add hW0]; norm_num + _ ≤ _ := mul_le_mul_of_nonneg_left + (Real.rpow_le_rpow_of_exponent_le hW (by norm_num)) + (by linarith [Real.log_nonneg hW]) + +theorem major_arc_weighted_energy_rate : + ∀ᶠ L : ℝ in atTop, ∀ W M : ℝ, 1 ≤ W → W ≤ L^(1/125:ℝ) → + 0 ≤ M → W ≤ Real.exp (M/3) → + Real.sqrt W*(1+Real.log W)* + (Real.exp (-2*M/5)+Real.sqrt (Real.log L/L^(1/80:ℝ))+W⁻¹) ≤ + 101*Real.exp (-M/20)+101*L^(-1/700:ℝ)+majorArcWorkingError W := by + filter_upwards [major_arc_sharp_energy_rate] with L henergy + intro W M hW hWL hM hWM + have hm := major_arc_sharp_distance_rate hW hM hWM + have he := henergy W hW hWL + have hi := major_arc_inverse_working_rate hW + calc + _ = Real.sqrt W*(1+Real.log W)*Real.exp (-2*M/5)+ + Real.sqrt W*(1+Real.log W)*Real.sqrt (Real.log L/L^(1/80:ℝ))+ + Real.sqrt W*(1+Real.log W)*W⁻¹ := by ring + _ ≤ _ := add_le_add (add_le_add hm he) hi + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcRational.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcRational.lean new file mode 100644 index 0000000000000000000000000000000000000000..401aca03c8c1910ef7bd686fe42131e2558413c2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcRational.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcResidues +import OAI.NumberTheory.TwoPoint.Bounds.ProgressionFourier + +namespace OAI + +/-! Resolving a rational additive phase into its residue classes before +the multiplicative character expansion. Only a factor equal to the modulus +is lost; no Gauss-sum estimate is needed for the application. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma major_arc_rational_character (q : ℕ) [NeZero q] (r : ℤ) (n : ℕ) : + additiveCharacter ((r : ℝ) / q) n = + ZMod.stdAddChar ((r : ZMod q) * (n : ZMod q)) := by + rw [← Int.cast_natCast n, ← Int.cast_mul, ZMod.stdAddChar_coe] + unfold additiveCharacter + congr 1 + push_cast + ring + +lemma major_arc_residue_partition (S : Finset ℕ) (a : ℕ → ℂ) + (q : ℕ) [NeZero q] (r : ℤ) : + (∑ n ∈ S, a n * additiveCharacter ((r : ℝ) / q) n) = + ∑ b : ZMod q, ZMod.stdAddChar ((r : ZMod q) * b) * + ∑ n ∈ S, if n % q = b.val then a n else 0 := by + simp_rw [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro n _ + rw [sum_eq_single (n : ZMod q)] + · simp [ZMod.val_natCast, major_arc_rational_character, mul_comm] + · intro b _ hbn + have hne : n % q ≠ b.val := by + intro he + apply hbn + apply ZMod.val_injective + simpa only [ZMod.val_natCast] using he.symm + simp [hne] + · simp + +lemma major_arc_rational_sum_norm (S : Finset ℕ) (a : ℕ → ℂ) + (q : ℕ) [NeZero q] (r : ℤ) : + ‖∑ n ∈ S, a n * additiveCharacter ((r : ℝ) / q) n‖ ≤ + ∑ b : ZMod q, ‖∑ n ∈ S, if n % q = b.val then a n else 0‖ := by + rw [major_arc_residue_partition] + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro b _ + simp only [norm_mul, ZMod.stdAddChar_apply, Circle.norm_coe, one_mul, le_refl] + +/-- A common bound for the reduced, twisted intervals controls the +rational frequency with the exact modulus loss. -/ +theorem major_arc_typical_rational_bound {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (hP : ∀ j ∈ J, ∀ p ∈ P j, p.Prime) + (F : ℕ → ℂ) + (hF : ∀ a b, 0 < a → 0 < b → F (a * b) = F a * F b) + (hFb : OneBounded F) (q X H : ℕ) [NeZero q] (r : ℤ) (K : ℝ) + (havoid : ∀ b : ZMod q, mrtPrimeAvoids (J.biUnion P) (b.val.gcd q)) + (hK : ∀ (b : ZMod q) (χ : DirichletCharacter ℂ (q / b.val.gcd q)), + (b.val.gcd q : ℝ) * shortExponentialIntegral + (mrtTypicalCoefficient J P (twistByCharacter F χ)) + (X / b.val.gcd q + 1) (H / b.val.gcd q + 1) 0 + X ≤ K) : + shortExponentialIntegral (mrtTypicalCoefficient J P F) X H ((r : ℝ) / q) ≤ + (q : ℝ) * K := by + rw [shortExponentialIntegral_eq_sum] + calc + _ ≤ ∑ v ∈ range X, ∑ b : ZMod q, + ‖∑ n ∈ Icc (v + 1) (v + H), + if n % q = b.val then mrtTypicalCoefficient J P F n else 0‖ := by + apply sum_le_sum + intro v _ + rw [shortExponentialSum_at_nat] + exact major_arc_rational_sum_norm _ _ q r + _ = ∑ b : ZMod q, ∑ v ∈ range X, + ‖∑ n ∈ Icc (v + 1) (v + H), + if n % q = b.val then mrtTypicalCoefficient J P F n else 0‖ := sum_comm + _ ≤ ∑ _b : ZMod q, K := by + apply sum_le_sum + intro b _ + have hres := major_arc_typical_residue_average J P hP F hF hFb q b.val X H + (NeZero.pos q) (havoid b) + rw [Nat.mod_eq_of_lt b.val_lt] at hres + apply hres.trans + have hd := Nat.gcd_pos_of_pos_right b.val (NeZero.pos q) + have hq' : 0 < q / b.val.gcd q := Nat.div_pos + (Nat.le_of_dvd (NeZero.pos q) (Nat.gcd_dvd_right b.val q)) hd + let : NeZero (q / b.val.gcd q) := ⟨hq'.ne'⟩ + have hφ := (Nat.totient_pos.mpr hq') + have hc : Fintype.card (DirichletCharacter ℂ (q / b.val.gcd q)) = + (q / b.val.gcd q).totient := by + rw [← Nat.card_eq_fintype_card, + DirichletCharacter.card_eq_totient_of_hasEnoughRootsOfUnity] + calc + _ ≤ ((q / b.val.gcd q).totient : ℝ)⁻¹ * + ∑ _χ : DirichletCharacter ℂ (q / b.val.gcd q), K := + mul_le_mul_of_nonneg_left (sum_le_sum (fun χ _ => hK b χ)) (by positivity) + _ = K := by simp [hc, ne_of_gt hφ] + _ = _ := by simp [ZMod.card] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcRationalSharp.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcRationalSharp.lean new file mode 100644 index 0000000000000000000000000000000000000000..b911cb19ce77c12027ab25d25bba3e6f2312a35b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcRationalSharp.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcDivisors +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcDivisorBounds + +namespace OAI + +/-! Rational short sums with the square-root character loss. The +reciprocal gcd volume is retained before summing the strata. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def majorArcDivisorWindow {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (F : ℕ → ℂ) (q : ℕ) (hq : 0 < q) (r : ℤ) + (d : {d : ℕ // d ∈ q.divisors}) (v H : ℕ) : ℂ := by + letI : NeZero (q/d.val) := ⟨(major_arc_divisor_quotient_pos hq d).ne'⟩ + exact F d.val * ∑ χ : DirichletCharacter ℂ (q/d.val), + mrtAdditiveCharacterCoefficient (q/d.val) r χ * + shortExponentialSum (dilationSequence d.val (mrtTypicalCoefficient J P (twistByCharacter F χ))) H 0 v + +lemma major_arc_divisor_window {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (F : ℕ → ℂ) (q : ℕ) (hq : 0 < q) (r : ℤ) + (d : {d : ℕ // d ∈ q.divisors}) (v H : ℕ) : + (∑ n ∈ Icc (v+1) (v+H), majorArcDivisorTerm J P F q hq r d n) = + majorArcDivisorWindow J P F q hq r d v H := by + let : NeZero (q/d.val) := ⟨(major_arc_divisor_quotient_pos hq d).ne'⟩ + unfold majorArcDivisorTerm majorArcDivisorWindow + rw [←mul_sum,sum_comm] + congr 1 + apply sum_congr rfl + intro χ _ + rw [shortExponentialSum_at_nat] + simp [additiveCharacter,mul_sum] + +lemma major_arc_divisor_window_average {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (F : ℕ → ℂ) (hF : OneBounded F) + (q : ℕ) (hq : 0 < q) (r : ℤ) (d : {d : ℕ // d ∈ q.divisors}) (X H : ℕ) + (A : ℝ) (hA : 0 ≤ A) + (hshort : ∀ χ : DirichletCharacter ℂ (q/d.val), + (d.val:ℝ)*shortExponentialIntegral (mrtTypicalCoefficient J P (twistByCharacter F χ)) + (X/d.val+1) (H/d.val+1) 0 ≤ A/(d.val:ℝ)) : + (∑ v ∈ range X, ‖majorArcDivisorWindow J P F q hq r d v H‖) ≤ + Real.sqrt ((q/d.val:ℕ):ℝ)*(A/(d.val:ℝ)+X) := by + let : NeZero (q/d.val) := ⟨(major_arc_divisor_quotient_pos hq d).ne'⟩ + have hd : 0 < d.val := Nat.pos_of_dvd_of_pos (Nat.mem_divisors.mp d.property).1 hq + have hb : ∀ v : ℕ, ‖majorArcDivisorWindow J P F q hq r d v H‖ ≤ + ∑ χ : DirichletCharacter ℂ (q/d.val), ‖mrtAdditiveCharacterCoefficient (q/d.val) r χ‖* + ‖shortExponentialSum (dilationSequence d.val + (mrtTypicalCoefficient J P (twistByCharacter F χ))) H 0 v‖ := by + intro v + unfold majorArcDivisorWindow + rw [norm_mul] + apply (mul_le_of_le_one_left (norm_nonneg _) (hF d.val hd)).trans + exact (norm_sum_le _ _).trans_eq (sum_congr rfl (fun χ _ => norm_mul _ _)) + calc + _ ≤ ∑ v ∈ range X, ∑ χ : DirichletCharacter ℂ (q/d.val), + ‖mrtAdditiveCharacterCoefficient (q/d.val) r χ‖* + ‖shortExponentialSum (dilationSequence d.val + (mrtTypicalCoefficient J P (twistByCharacter F χ))) H 0 v‖ := sum_le_sum (fun v _ => hb v) + _ = ∑ χ : DirichletCharacter ℂ (q/d.val), ‖mrtAdditiveCharacterCoefficient (q/d.val) r χ‖* + (∑ v ∈ range X, ‖shortExponentialSum (dilationSequence d.val + (mrtTypicalCoefficient J P (twistByCharacter F χ))) H 0 v‖) := by + rw [sum_comm] + simp only [mul_sum] + _ ≤ ∑ χ : DirichletCharacter ℂ (q/d.val), + ‖mrtAdditiveCharacterCoefficient (q/d.val) r χ‖*(A/(d.val:ℝ)+X) := by + apply sum_le_sum + intro χ _ + apply mul_le_mul_of_nonneg_left _ (norm_nonneg _) + exact (major_arc_dilation_average _ + (mrtTypicalCoefficient_oneBounded J P _ (hF.twistByCharacter χ)) d.val X H hd).trans + (add_le_add (hshort χ) le_rfl) + _ = (∑ χ : DirichletCharacter ℂ (q/d.val), + ‖mrtAdditiveCharacterCoefficient (q/d.val) r χ‖)*(A/(d.val:ℝ)+X) := (sum_mul _ _ _).symm + _ ≤ _ := mul_le_mul_of_nonneg_right (mrt_additive_character_l1 (q/d.val) r) (by positivity) + +theorem major_arc_typical_rational_sharp {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (hP : ∀ j ∈ J, ∀ p ∈ P j, p.Prime) + (F : ℕ → ℂ) (hFm : ∀ a b, 0 < a → 0 < b → F (a*b)=F a*F b) (hF : OneBounded F) + (q : ℕ) (hq : 0 < q) (r : ℤ) (X H : ℕ) (A : ℝ) (hA : 0 ≤ A) + (havoid : ∀ d ∈ q.divisors, mrtPrimeAvoids (J.biUnion P) d) + (hshort : ∀ d : {d : ℕ // d ∈ q.divisors}, ∀ χ : DirichletCharacter ℂ (q/d.val), + (d.val:ℝ)*shortExponentialIntegral (mrtTypicalCoefficient J P (twistByCharacter F χ)) + (X/d.val+1) (H/d.val+1) 0 ≤ A/(d.val:ℝ)) : + shortExponentialIntegral (mrtTypicalCoefficient J P F) X H ((r:ℝ)/q) ≤ + Real.sqrt (q:ℝ)*((1+Real.log q)*A+(q:ℝ)*X) := by + let : NeZero q := ⟨hq.ne'⟩ + have hw (v : ℕ) : shortExponentialSum (mrtTypicalCoefficient J P F) H ((r:ℝ)/q) v = + ∑ d : {d : ℕ // d ∈ q.divisors}, majorArcDivisorWindow J P F q hq r d v H := by + rw [shortExponentialSum_at_nat] + have he (n : ℕ) (hn : n ∈ Icc (v+1) (v+H)) := + major_arc_divisor_expansion J P hP F hFm q hq r havoid n + (show 0 < n by have := (mem_Icc.mp hn).1; omega) + calc + _ = ∑ n∈Icc (v+1) (v+H), ∑ d : {d : ℕ // d∈q.divisors}, + majorArcDivisorTerm J P F q hq r d n := sum_congr rfl he + _ = ∑ d : {d : ℕ // d∈q.divisors}, ∑ n∈Icc (v+1) (v+H), + majorArcDivisorTerm J P F q hq r d n := sum_comm + _ = _ := sum_congr rfl (fun d _ => major_arc_divisor_window J P F q hq r d v H) + rw [shortExponentialIntegral_eq_sum] + calc + _ ≤ ∑ v ∈ range X, ∑ d : {d : ℕ // d ∈ q.divisors}, ‖majorArcDivisorWindow J P F q hq r d v H‖ := by + apply sum_le_sum + intro v _ + rw [hw] + exact norm_sum_le _ _ + _ = ∑ d : {d : ℕ // d ∈ q.divisors}, ∑ v ∈ range X, ‖majorArcDivisorWindow J P F q hq r d v H‖ := sum_comm + _ ≤ ∑ d : {d : ℕ // d ∈ q.divisors}, Real.sqrt ((q/d.val:ℕ):ℝ)*(A/(d.val:ℝ)+X) := + sum_le_sum (fun d _ => major_arc_divisor_window_average J P F hF q hq r d X H A hA (hshort d)) + _ = ∑ d ∈ q.divisors, Real.sqrt ((q/d:ℕ):ℝ)*(A/(d:ℝ)+X) := by + exact Finset.sum_coe_sort q.divisors (fun d : ℕ => Real.sqrt ((q/d:ℕ):ℝ)*(A/(d:ℝ)+(X:ℝ))) + _ ≤ _ := major_arc_divisor_weighted q hq A X hA (Nat.cast_nonneg X) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcReduction.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..cfc78cf8a3145dc59c8effe5374ea7dc258aef38 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcReduction.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcRational +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcPerturbation + +namespace OAI + +/-! The full major-arc reduction to the short means supplied by MRT's +Dirichlet-polynomial argument. All residues, divided scales, shorter lengths, +and rounding errors remain explicit. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma major_arc_character_distance (F : ℕ → ℂ) {q : ℕ} + (χ : DirichletCharacter ℂ q) (t : ℝ) (N : ℕ) : + squaredDistance (twistByCharacter F χ) (mrtArchimedeanTwist t) N = + squaredDistance F (characterTwist (conjugateCharacter χ) t) N := by + unfold squaredDistance + apply sum_congr rfl + intro p _ + simp only [twistByCharacter, mrtArchimedeanTwist, characterTwist, + conjugateCharacter_apply, map_mul, Complex.conj_conj, mul_assoc] + +lemma MRTDistanceLowerBound.major_arc_character {F : ℕ → ℂ} {X H : ℕ} {M : ℝ} + (hd : MRTDistanceLowerBound F X H M) (q : ℕ) (hq : 0 < q) + (hqmax : (q : ℝ) ≤ mrtModulusCutoff X H) + (χ : DirichletCharacter ℂ q) (t : ℝ) (ht : |t| ≤ (X : ℝ)) : + M ≤ squaredDistance (twistByCharacter F χ) (mrtArchimedeanTwist t) X := by + rw [major_arc_character_distance] + exact hd q hq hqmax (conjugateCharacter χ) t ht + +theorem major_arc_reduction {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (hP : ∀ j ∈ J, ∀ p ∈ P j, p.Prime) + (F : ℕ → ℂ) + (hF : ∀ a b, 0 < a → 0 < b → F (a * b) = F a * F b) + (hFb : OneBounded F) (q X H : ℕ) [NeZero q] (hH : 0 < H) + (r : ℤ) (β W K : ℝ) (hK : 0 ≤ K) + (hβ : |β| ≤ W / ((H : ℝ) * q)) + (havoid : ∀ b : ZMod q, mrtPrimeAvoids (J.biUnion P) (b.val.gcd q)) + (hshort : ∀ (h : ℕ), 1 ≤ h → h ≤ H → + ∀ (b : ZMod q) (χ : DirichletCharacter ℂ (q / b.val.gcd q)), + (b.val.gcd q : ℝ) * shortExponentialIntegral + (mrtTypicalCoefficient J P (twistByCharacter F χ)) + (X / b.val.gcd q + 1) (h / b.val.gcd q + 1) 0 + X ≤ K) : + shortExponentialIntegral (mrtTypicalCoefficient J P F) X H + ((r : ℝ) / q + β) ≤ ((q : ℝ) + 2 * Real.pi * W) * K := by + have hprefix (h : ℕ) (hh : 1 ≤ h) (hhH : h ≤ H) : + shortExponentialIntegral (mrtTypicalCoefficient J P F) X h ((r : ℝ) / q) ≤ + (q : ℝ) * K := + major_arc_typical_rational_bound J P hP F hF hFb q X h r K havoid (hshort h hh hhH) + have hHr : (0 : ℝ) < H := by exact_mod_cast hH + have hqr : (0 : ℝ) < q := by exact_mod_cast NeZero.pos q + have hb : |β| * ((H : ℝ) * q) ≤ W := + (le_div_iff₀ (mul_pos hHr hqr)).mp hβ + calc + _ ≤ (1 + 2 * Real.pi * |β| * H) * ((q : ℝ) * K) := + major_arc_integral_perturbation_uniform _ X H hH _ β _ + (mul_nonneg hqr.le hK) hprefix + _ = (q : ℝ) * K + (2 * Real.pi * K) * (|β| * ((H : ℝ) * q)) := by ring + _ ≤ (q : ℝ) * K + (2 * Real.pi * K) * W := + add_le_add le_rfl (mul_le_mul_of_nonneg_left hb (by positivity)) + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcResidues.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcResidues.lean new file mode 100644 index 0000000000000000000000000000000000000000..b0b32c571394603432caaaed96ba612a36e64d76 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcResidues.lean @@ -0,0 +1,171 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcCharacters +import OAI.NumberTheory.TwoPoint.Bounds.ResidueExpansion +import OAI.NumberTheory.TwoPoint.Bounds.DilatedWindows + +namespace OAI + +/-! Gcd reduction of a typical-set progression, including nonunit classes. +The removed gcd avoids the prime bands, so the typical mask is unchanged. +The resulting windows are literal character twists at the divided scale. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical ComplexConjugate + +lemma major_arc_typical_dilation {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (hP : ∀ j ∈ J, ∀ p ∈ P j, p.Prime) + (F : ℕ → ℂ) + (hF : ∀ a b, 0 < a → 0 < b → F (a * b) = F a * F b) + {d : ℕ} (hd : 0 < d) (havoid : mrtPrimeAvoids (J.biUnion P) d) + {q : ℕ} (χ : DirichletCharacter ℂ q) {n : ℕ} (hn : 0 < n) : + mrtTypicalCoefficient J P F n * dilate d (naturalCharacter χ) n = + F d * dilationSequence d (mrtTypicalCoefficient J P (twistByCharacter F χ)) n := by + by_cases hdn : d ∣ n + · have hm : 0 < n / d := Nat.div_pos (Nat.le_of_dvd hn hdn) hd + have he : n = d * (n / d) := (Nat.mul_div_cancel' hdn).symm + have ht := mrtTypical_mul_of_avoids J P hP havoid (n / d) + simp only [dilate, dilationSequence, ite_eq_left hdn, naturalCharacter] + unfold mrtTypicalCoefficient twistByCharacter + rw [he] at ⊢ + rw [Nat.mul_div_cancel_left _ hd, ht, hF d (n / d) hd hm] + split_ifs <;> simp [mul_assoc] + · simp [dilate, dilationSequence, hdn] + +/-- The original residue `b` is unrestricted; the reduced character modulus +is `q / gcd b q`, and this also covers reduced modulus one. -/ +lemma major_arc_typical_residue_identity {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (hP : ∀ j ∈ J, ∀ p ∈ P j, p.Prime) + (F : ℕ → ℂ) + (hF : ∀ a b, 0 < a → 0 < b → F (a * b) = F a * F b) + (q b : ℕ) (hq : 0 < q) + (havoid : mrtPrimeAvoids (J.biUnion P) (b.gcd q)) + {n : ℕ} (hn : 0 < n) : + (if n % q = b % q then mrtTypicalCoefficient J P F n else 0) = + F (b.gcd q) * ((q / b.gcd q).totient : ℂ)⁻¹ * + ∑ χ : DirichletCharacter ℂ (q / b.gcd q), + conj (naturalCharacter χ (b / b.gcd q)) * + dilationSequence (b.gcd q) + (mrtTypicalCoefficient J P (twistByCharacter F χ)) n := by + have h := congrArg (fun z : ℂ => mrtTypicalCoefficient J P F n * z) + (residue_indicator_eq_character_dilations q b n hq) + simp only [mul_ite, mul_one, mul_zero] at h + rw [h, ← mul_assoc] + simp only [mul_sum] + apply sum_congr rfl + intro χ _ + have hd := Nat.gcd_pos_of_pos_right b hq + have hh := major_arc_typical_dilation J P hP F hF hd havoid χ hn + calc + _ = ((q / b.gcd q).totient : ℂ)⁻¹ * + conj (naturalCharacter χ (b / b.gcd q)) * + (mrtTypicalCoefficient J P F n * dilate (b.gcd q) (naturalCharacter χ) n) := by ring + _ = _ := by rw [hh]; ring + +lemma major_arc_typical_residue_window {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (hP : ∀ j ∈ J, ∀ p ∈ P j, p.Prime) + (F : ℕ → ℂ) + (hF : ∀ a b, 0 < a → 0 < b → F (a * b) = F a * F b) + (q b v H : ℕ) (hq : 0 < q) + (havoid : mrtPrimeAvoids (J.biUnion P) (b.gcd q)) : + (∑ n ∈ Icc (v + 1) (v + H), + if n % q = b % q then mrtTypicalCoefficient J P F n else 0) = + F (b.gcd q) * ((q / b.gcd q).totient : ℂ)⁻¹ * + ∑ χ : DirichletCharacter ℂ (q / b.gcd q), + conj (naturalCharacter χ (b / b.gcd q)) * + shortExponentialSum + (dilationSequence (b.gcd q) + (mrtTypicalCoefficient J P (twistByCharacter F χ))) H 0 v := by + have he0 (n : ℕ) : additiveCharacter 0 n = 1 := by simp [additiveCharacter] + simp_rw [shortExponentialSum_at_nat, he0, mul_one] + have hi (n : ℕ) (hn : n ∈ Icc (v + 1) (v + H)) := + major_arc_typical_residue_identity J P hP F hF q b hq havoid + (show 0 < n by have := (mem_Icc.mp hn).1; omega) + rw [sum_congr rfl hi, ← mul_sum, sum_comm] + congr 1 + apply sum_congr rfl + intro χ _ + rw [mul_sum] + +lemma major_arc_typical_residue_window_norm {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (hP : ∀ j ∈ J, ∀ p ∈ P j, p.Prime) + (F : ℕ → ℂ) + (hF : ∀ a b, 0 < a → 0 < b → F (a * b) = F a * F b) + (hFb : OneBounded F) (q b v H : ℕ) (hq : 0 < q) + (havoid : mrtPrimeAvoids (J.biUnion P) (b.gcd q)) : + ‖∑ n ∈ Icc (v + 1) (v + H), + if n % q = b % q then mrtTypicalCoefficient J P F n else 0‖ ≤ + ((q / b.gcd q).totient : ℝ)⁻¹ * + ∑ χ : DirichletCharacter ℂ (q / b.gcd q), + ‖shortExponentialSum + (dilationSequence (b.gcd q) + (mrtTypicalCoefficient J P (twistByCharacter F χ))) H 0 v‖ := by + rw [major_arc_typical_residue_window J P hP F hF q b v H hq havoid, + mul_assoc, norm_mul, norm_mul, norm_inv, Complex.norm_natCast] + apply (mul_le_mul_of_nonneg_right + (hFb _ (Nat.gcd_pos_of_pos_right b hq)) (by positivity)).trans + rw [one_mul] + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro χ _ + rw [norm_mul, Complex.norm_conj] + exact mul_le_of_le_one_left (norm_nonneg _) (χ.norm_le_one _) + +lemma major_arc_dilation_average (F : ℕ → ℂ) (hF : OneBounded F) + (d X H : ℕ) (hd : 0 < d) : + (∑ v ∈ range X, ‖shortExponentialSum (dilationSequence d F) H 0 v‖) ≤ + (d : ℝ) * shortExponentialIntegral F (X / d + 1) (H / d + 1) 0 + X := by + calc + _ ≤ ∑ v ∈ range X, (‖shortWindowSum F (H / d + 1) 0 (v / d)‖ + 1) := by + apply sum_le_sum + intro v _ + simpa using norm_shortExponentialSum_dilation_le F hF d H v hd 0 + _ = (∑ v ∈ range X, ‖shortWindowSum F (H / d + 1) 0 (v / d)‖) + X := by + rw [sum_add_distrib] + simp + _ ≤ (d : ℝ) * (∑ m ∈ range (X / d + 1), + ‖shortWindowSum F (H / d + 1) 0 m‖) + X := + add_le_add (quotient_sample_sum_le _ (fun _ => norm_nonneg _) d X hd) le_rfl + _ = _ := by + rw [shortExponentialIntegral_eq_sum] + simp_rw [norm_shortExponentialSum_eq_window] + +/-- Averaging all original origins costs the gcd exactly once. The only +rounding error is one endpoint per origin. -/ +theorem major_arc_typical_residue_average {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (hP : ∀ j ∈ J, ∀ p ∈ P j, p.Prime) + (F : ℕ → ℂ) + (hF : ∀ a b, 0 < a → 0 < b → F (a * b) = F a * F b) + (hFb : OneBounded F) (q b X H : ℕ) (hq : 0 < q) + (havoid : mrtPrimeAvoids (J.biUnion P) (b.gcd q)) : + (∑ v ∈ range X, ‖∑ n ∈ Icc (v + 1) (v + H), + if n % q = b % q then mrtTypicalCoefficient J P F n else 0‖) ≤ + ((q / b.gcd q).totient : ℝ)⁻¹ * + ∑ χ : DirichletCharacter ℂ (q / b.gcd q), + ((b.gcd q : ℝ) * shortExponentialIntegral + (mrtTypicalCoefficient J P (twistByCharacter F χ)) + (X / b.gcd q + 1) (H / b.gcd q + 1) 0 + X) := by + calc + _ ≤ ∑ v ∈ range X, ((q / b.gcd q).totient : ℝ)⁻¹ * + ∑ χ : DirichletCharacter ℂ (q / b.gcd q), + ‖shortExponentialSum (dilationSequence (b.gcd q) + (mrtTypicalCoefficient J P (twistByCharacter F χ))) H 0 v‖ := + sum_le_sum (fun v _ => + major_arc_typical_residue_window_norm J P hP F hF hFb q b v H hq havoid) + _ = ((q / b.gcd q).totient : ℝ)⁻¹ * + ∑ χ : DirichletCharacter ℂ (q / b.gcd q), + ∑ v ∈ range X, ‖shortExponentialSum (dilationSequence (b.gcd q) + (mrtTypicalCoefficient J P (twistByCharacter F χ))) H 0 v‖ := by + rw [← mul_sum, sum_comm] + _ ≤ _ := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply sum_le_sum + intro χ _ + exact major_arc_dilation_average _ + (mrtTypicalCoefficient_oneBounded J P _ (hFb.twistByCharacter χ)) + _ X H (Nat.gcd_pos_of_pos_right b hq) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcWorkingBand.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcWorkingBand.lean new file mode 100644 index 0000000000000000000000000000000000000000..d39a6a514cefc4000f25f992cafe369c4ce7fbb1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcWorkingBand.lean @@ -0,0 +1,124 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcWorkingLength +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTWorkingBand + +namespace OAI + +/-! Prime-band costs for the fifth-root working length. Both density +and the minor-arc fourth root have the same elementary rate. -/ +namespace TwoPointCorrelations + +open Filter + +lemma major_arc_working_log_lower {H : ℕ} {W : ℝ} + (hW : 1 ≤ W) (hH : 1 ≤ Real.log (H:ℝ)) + (hWH : W ≤ Real.log (H:ℝ)^5) + (hcap : W^(1/5:ℝ)/4 ≤ Real.log (mrtWorkingCap (W^(2/5:ℝ)):ℝ)) : + W^(1/5:ℝ)/4 ≤ Real.log (majorArcWorkingLength H W:ℝ) := by + have hW0 : 0 < W := by linarith + have hroot : W^(1/5:ℝ) ≤ Real.log (H:ℝ) := by + calc + _ ≤ (Real.log (H:ℝ)^5)^(1/5:ℝ) := Real.rpow_le_rpow hW0.le hWH (by norm_num) + _ = _ := by + rw [← Real.rpow_natCast,← Real.rpow_mul (by linarith : 0 ≤ Real.log (H:ℝ))] + norm_num + unfold majorArcWorkingLength mrtWorkingLength + split_ifs + · nlinarith [Real.rpow_nonneg hW0.le (1/5:ℝ)] + · exact hcap + +lemma major_arc_working_upper_log {H : ℕ} {W : ℝ} (hW : 2 ≤ W) + (hpower : W^6 ≤ (majorArcWorkingLength H W:ℝ)) : + 2 ≤ (majorArcWorkingLength H W:ℝ)/W^3 ∧ + Real.log (majorArcWorkingLength H W:ℝ)/2 ≤ + Real.log ((majorArcWorkingLength H W:ℝ)/W^3) := by + have hW0 : 0 < W := by linarith + have hW1 : 1 ≤ W := by linarith + have hthird : 2 ≤ W^3 := hW.trans (le_self_pow₀ hW1 (by decide)) + have hdiv : W^3 ≤ (majorArcWorkingLength H W:ℝ)/W^3 := by + apply (le_div_iff₀ (pow_pos hW0 3)).mpr + simpa only [← pow_add] using hpower + have hpos : (0:ℝ) < majorArcWorkingLength H W := (pow_pos hW0 6).trans_le hpower + have hl := Real.log_le_log (pow_pos hW0 6) hpower + rw [Real.log_pow] at hl + norm_num only [Nat.cast_ofNat] at hl + refine ⟨hthird.trans hdiv,?_⟩ + rw [Real.log_div hpos.ne' (pow_ne_zero 3 hW0.ne'),Real.log_pow] + norm_num only [Nat.cast_ofNat] + linarith + +lemma major_arc_working_band_density (A : ℕ) {H : ℕ} {W : ℝ} + (hW : 2 ≤ W) (hH : 1 ≤ Real.log (H:ℝ)) + (hWH : W ≤ Real.log (H:ℝ)^5) + (hpower : W^6 ≤ (majorArcWorkingLength H W:ℝ)) + (hcap : W^(1/5:ℝ)/4 ≤ Real.log (mrtWorkingCap (W^(2/5:ℝ)):ℝ)) : + Real.log (W^A)/Real.log ((majorArcWorkingLength H W:ℝ)/W^3) ≤ + 8*(A:ℝ)*majorArcWorkingError W := by + have hW0 : 0 < W := by linarith + have hl := major_arc_working_log_lower (by linarith : 1 ≤ W) hH hWH hcap + have hQ := (major_arc_working_upper_log hW hpower).2 + have hlow : W^(1/5:ℝ)/8 ≤ Real.log ((majorArcWorkingLength H W:ℝ)/W^3) := by linarith + have hlog : 0 ≤ Real.log W := Real.log_nonneg (by linarith) + rw [Real.log_pow] + calc + _ ≤ ((A:ℝ)*Real.log W)/(W^(1/5:ℝ)/8) := + div_le_div_of_nonneg_left (by positivity) (by positivity) hlow + _ = 8*(A:ℝ)*(Real.log W*W^(-1/5:ℝ)) := by + rw [show (-1/5:ℝ)=-(1/5:ℝ) by ring,Real.rpow_neg hW0.le] + ring + _ ≤ _ := by + unfold majorArcWorkingError + gcongr + linarith + +lemma major_arc_minor_working_rate {W h : ℝ} (hW : 1 ≤ W) + (hh : 1 ≤ Real.log h) (hupper : Real.log h ≤ W^(1/5:ℝ)) : + Real.log (Real.log h)*(Real.log h/W)^(1/4:ℝ) ≤ majorArcWorkingError W := by + have hW0 : 0 < W := by linarith + have hlog0 : 0 < Real.log h := by linarith + have hlog := Real.log_le_log hlog0 hupper + rw [Real.log_rpow hW0] at hlog + have hp : (Real.log h/W)^(1/4:ℝ) ≤ W^(-1/5:ℝ) := by + calc + _ ≤ (W^(1/5:ℝ)/W)^(1/4:ℝ) := Real.rpow_le_rpow + (div_nonneg hlog0.le hW0.le) (div_le_div_of_nonneg_right hupper hW0.le) (by norm_num) + _ = _ := by + rw [div_eq_mul_inv,← Real.rpow_neg_one W,← Real.rpow_add hW0,← Real.rpow_mul hW0.le] + norm_num + unfold majorArcWorkingError + apply mul_le_mul _ hp (Real.rpow_nonneg (div_nonneg hlog0.le hW0.le) _) (by linarith [Real.log_nonneg hW]) + nlinarith [Real.log_nonneg hW] + +lemma major_arc_working_band_budget (A : ℕ) (hA : 500000 ≤ A) + {H : ℕ} {W Q : ℝ} (hW : 10 ≤ Real.log W) (hW0 : 0 < W) + (hQ : 1 < Q) (hQH : Q ≤ majorArcWorkingLength H W) : + 8192 * (Real.log (Real.log Q) + 1) ≤ (1 / 100 : ℝ) * Real.log (W ^ A) := by + have hh : (1 : ℝ) < majorArcWorkingLength H W := hQ.trans_le hQH + have hlog := Real.log_le_log (Real.log_pos hQ) + (Real.log_le_log (by linarith : 0 < Q) hQH) + have hb := hlog.trans (major_arc_working_length_loglog hW0 hh) + have hAr : (500000 : ℝ) ≤ A := by exact_mod_cast hA + have hm := mul_le_mul_of_nonneg_right hAr (show 0 ≤ Real.log W by linarith) + rw [Real.log_pow] + nlinarith + +lemma major_arc_working_band_resolution (A : ℕ) (hA : 500000 ≤ A) + {H : ℕ} {W Q : ℝ} (hW : 1 ≤ W) (hQ : 1 < Q) + (hQH : Q ≤ majorArcWorkingLength H W) : + W ^ (100 : ℕ) ≤ mrtBaseResolution (W ^ A) Q (1 / 100) := by + have hW0 : 0 < W := by linarith + have hh : (1 : ℝ) < majorArcWorkingLength H W := hQ.trans_le hQH + have hlog := Real.log_le_log (Real.log_pos hQ) + (Real.log_le_log (by linarith : 0 < Q) hQH) + have hb := hlog.trans (major_arc_working_length_loglog hW0 hh) + have hAr : (500000 : ℝ) ≤ A := by exact_mod_cast hA + have hm := mul_le_mul_of_nonneg_right hAr (Real.log_nonneg hW) + rw [show W ^ (100 : ℕ) = Real.exp ((100 : ℝ) * Real.log W) by + rw [← Real.rpow_natCast, Real.rpow_def_of_pos hW0] + congr 1 + ring, mrtBaseResolution, Real.log_pow] + apply Real.exp_le_exp.mpr + nlinarith [Real.log_nonneg hW] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcWorkingLength.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcWorkingLength.lean new file mode 100644 index 0000000000000000000000000000000000000000..9f40f38f86abfdceae28822ad26f1ad70a9069b9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcWorkingLength.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTWorkingLength +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcPublishedRate + +namespace OAI + +/-! A fifth-root logarithmic cap, obtained from the general square-root +cap by substitution. Its size suits the common Diophantine parameter. -/ +namespace TwoPointCorrelations + +open Filter + +noncomputable def majorArcWorkingLength (H : ℕ) (W : ℝ) : ℕ := + mrtWorkingLength H (W^(2/5:ℝ)) + +lemma major_arc_working_root {W : ℝ} (hW : 0 ≤ W) : + Real.sqrt (W^(2/5:ℝ))=W^(1/5:ℝ) := by + rw [Real.sqrt_eq_rpow,← Real.rpow_mul hW] + norm_num + +lemma major_arc_working_length_le (H : ℕ) (W : ℝ) : + majorArcWorkingLength H W ≤ H := mrt_working_length_upper + +lemma major_arc_working_length_loglog {H : ℕ} {W : ℝ} + (hW : 0 < W) (hH : (1:ℝ) < majorArcWorkingLength H W) : + Real.log (Real.log (majorArcWorkingLength H W:ℝ)) ≤ (1/5:ℝ)*Real.log W := by + have hh := mrt_working_length_loglog (Real.rpow_pos_of_pos hW (2/5)) hH + rw [Real.log_rpow hW] at hh + dsimp only [majorArcWorkingLength] + linarith + +lemma major_arc_working_length_exp_upper (H : ℕ) {W : ℝ} (hW : 0 ≤ W) : + (majorArcWorkingLength H W:ℝ) ≤ Real.exp (W^(1/5:ℝ)) := by + simpa only [majorArcWorkingLength,major_arc_working_root hW] using + mrt_working_length_exp_upper H (W^(2/5:ℝ)) + +theorem major_arc_working_length_power (a : ℕ) : + ∀ᶠ W : ℝ in atTop, ∀ H : ℕ, 0 < H → 1 ≤ Real.log (H:ℝ) → + W ≤ Real.log (H:ℝ)^5 → W^a ≤ (majorArcWorkingLength H W:ℝ) := by + have ht : Tendsto (fun W:ℝ => W^(2/5:ℝ)) atTop atTop := + tendsto_rpow_atTop (by norm_num) + filter_upwards [ht.eventually (mrt_working_cap_power (5*a)), + mrt_working_original_power a,eventually_ge_atTop (1:ℝ)] with W hcap horiginal hW + intro H hH hlog hWH + have hW0 : 0 < W := by linarith + have hc : W^a ≤ (mrtWorkingCap (W^(2/5:ℝ)):ℝ) := by + apply le_trans _ hcap + rw [← Real.rpow_mul_natCast hW0.le (2/5:ℝ) (5*a)] + rw [show (2/5:ℝ)*(5*a:ℕ)=(2:ℝ)*a by push_cast; ring] + rw [Real.rpow_mul_natCast hW0.le,Real.rpow_two] + exact pow_le_pow_left₀ hW0.le (by nlinarith) a + unfold majorArcWorkingLength mrtWorkingLength + split_ifs + · exact horiginal H (by exact_mod_cast hH) hlog hWH + · exact hc + +theorem major_arc_working_length_remainder : + ∀ᶠ W : ℝ in atTop, ∀ H : ℕ, + majorArcWorkingLength H W=H ∨ + (majorArcWorkingLength H W:ℝ)/H ≤ W^(-1/4:ℝ) := by + have ht := (isLittleO_log_rpow_atTop (show (0:ℝ)<1/5 by norm_num)).bound + (show (0:ℝ)<2 by norm_num) + filter_upwards [ht,eventually_gt_atTop (0:ℝ)] with W ht hW + simp only [Real.norm_eq_abs] at ht + rw [abs_of_nonneg (Real.rpow_nonneg hW.le _)] at ht + have hlog : Real.log W ≤ 2*W^(1/5:ℝ) := (le_abs_self _).trans ht + intro H + unfold majorArcWorkingLength mrtWorkingLength + rw [major_arc_working_root hW.le] + split_ifs with h + · exact Or.inl rfl + · right + have hH : Real.exp (W^(1/5:ℝ)) ≤ (H:ℝ) := le_of_not_ge h + have hH0 : (0:ℝ) < H := (Real.exp_pos _).trans_le hH + calc + _ ≤ Real.exp (W^(1/5:ℝ)/2)/(H:ℝ) := by + apply div_le_div_of_nonneg_right _ hH0.le + simpa only [major_arc_working_root hW.le] using mrt_working_cap_upper (W^(2/5:ℝ)) + _ ≤ Real.exp (W^(1/5:ℝ)/2)/Real.exp (W^(1/5:ℝ)) := + div_le_div_of_nonneg_left (Real.exp_pos _).le (Real.exp_pos _) hH + _ = Real.exp (-W^(1/5:ℝ)/2) := by rw [← Real.exp_sub]; congr 1; ring + _ ≤ _ := by + rw [Real.rpow_def_of_pos hW (-1/4:ℝ)] + apply Real.exp_le_exp.mpr + nlinarith + +theorem major_arc_working_cap_log : + ∀ᶠ W : ℝ in atTop, W^(1/5:ℝ)/4 ≤ + Real.log (mrtWorkingCap (W^(2/5:ℝ)):ℝ) := by + have ht : Tendsto (fun W:ℝ => W^(2/5:ℝ)) atTop atTop := tendsto_rpow_atTop (by norm_num) + filter_upwards [ht.eventually mrt_working_cap_log,eventually_ge_atTop (0:ℝ)] with W hcap hW + simpa only [major_arc_working_root hW] using hcap + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcWorkingMean.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcWorkingMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ed59c984da69b889eec2abe3270549326e9d243 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MajorArcWorkingMean.lean @@ -0,0 +1,162 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcCorrectedMean +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcCorrectedRate +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcCorrectionGeometry +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTWorkingParameters +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTShortSubdivisionSharp + +namespace OAI + +/-! The major arcs at the actual common parameter and working length. +The only band hypothesis is the geometry of the common final index, +which is supplied independently by `mrt_working_parameters`. -/ +namespace TwoPointCorrelations + +open Finset Filter + +theorem major_arc_actual_working_mean + (hprime : HalaszPrimeSparseInput) (hhigh : HalaszHighPrimeInput) : + ∃ C : ℝ, 0 < C ∧ ∃ W₀ : ℝ, ∃ X₀ : ℕ, + ∀ X H : ℕ, X₀ ≤ X → 10 ≤ H → H ≤ X → + 1 ≤ Real.log (H:ℝ) → 1 ≤ Real.log (Real.log (H:ℝ)) → + ∀ M : ℝ, 0 ≤ M → + let W := majorArcParameter (Real.log X) H M + let h := majorArcWorkingLength H W + let P := W^(500000:ℕ) + let Q := (h:ℝ)/W^3 + W₀ ≤ W → ∀ Y : ℕ, X ≤ Y → Y+h ≤ 2*X → ∀ J : ℕ, 1 ≤ J → + (∀ n : ℕ, ⌈Real.sqrt (X:ℝ)⌉₊ ≤ n → n ≤ 2*X → + 200*Real.log (Real.log n)+1 ≤ Real.log (mrtBandLower P Q J) ∧ + ∀ j ∈ Icc 1 J, mrtBandUpper Q j ≤ Real.exp (Real.sqrt (Real.log n))) → + ∀ F : ℕ → ℂ, F 1=1 → Multiplicative F → OneBounded F → + MRTDistanceLowerBound F X H M → ∀ r : ℤ, ∀ q : ℕ, + 0 < q → (q:ℝ) ≤ W → ∀ β : ℝ, |β| ≤ W/((h:ℝ)*q) → + shortExponentialIntegral (mrtTypicalCoefficient (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) Y h ((r:ℝ)/q+β) ≤ + C*(Y:ℝ)*h*(Real.exp (-M/20)+mrtShortError X H) := by + obtain ⟨C,hC,N₀,hcorrect⟩ := major_arc_corrected_typical_mean hprime hhigh + obtain ⟨W₁,X₁,hparams⟩ := mrt_working_parameters + obtain ⟨W₂,hpower⟩ := eventually_atTop.mp (major_arc_working_length_power 252) + let D := 2500*mrtCorrectionBound*(C+1)*(1+4*Real.pi) + have hCB : 0 < mrtCorrectionBound := Real.exp_pos _ + have hD : 0 < D := by dsimp [D]; positivity + have hlog : Tendsto (fun X:ℕ => Real.log X) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + have hlarge := (hlog.eventually (major_arc_corrected_published_rate C hC.le)).and + (hlog.eventually major_arc_parameter_rate) + obtain ⟨X₂,hX₂⟩ := eventually_atTop.mp + (hlarge.and (mrt_working_length_add_two_below_sqrt.and + (mrt_working_quotient_boundary.and + ((hlog.eventually (eventually_ge_atTop (1:ℝ))).and + (eventually_ge_atTop (max X₁ (max 2 (N₀^2)))))))) + refine ⟨2*D+21,by positivity,max 2 (max W₁ W₂),X₂,?_⟩ + intro X H hXX₂ hH hHX hLH hLL M hM + dsimp only + intro hW₀ Y hXY hY J hJ hbands F hF1 hFm hFb hd r q hq hqW β hβ + let W := majorArcParameter (Real.log X) H M + let h := majorArcWorkingLength H W + let K := ⌈Real.sqrt (X:ℝ)⌉₊ + let P := W^(500000:ℕ) + let Q := (h:ℝ)/W^3 + change Y+h ≤ 2*X at hY + obtain ⟨hfinal,houter⟩ := hX₂ X hXX₂ + obtain ⟨hcap,hboundary,hLX,hxmin⟩ := houter + have hX : 2 ≤ X := (le_max_left _ _).trans ((le_max_right _ _).trans hxmin) + have hXX : X₁ ≤ X := (le_max_left _ _).trans hxmin + have hN : N₀^2 ≤ X := (le_max_right _ _).trans ((le_max_right _ _).trans hxmin) + have hW : 2 ≤ W := (le_max_left _ _).trans hW₀ + have hWW₁ : W₁ ≤ W := (le_max_left _ _).trans ((le_max_right _ _).trans hW₀) + have hWW₂ : W₂ ≤ W := (le_max_right _ _).trans ((le_max_right _ _).trans hW₀) + have hW1 : 1 ≤ W := by linarith + have hW0 : 0 < W := by linarith + obtain ⟨_,hWH,hWX,_⟩ := major_arc_parameter_bounds hLX hLH hM + have hpow : W^252 ≤ (h:ℝ) := hpower W hWW₂ H (by omega) hLH hWH + have hpow250 : W^250 ≤ (h:ℝ) := + (pow_le_pow_right₀ hW1 (by norm_num : (250:ℕ)≤252)).trans hpow + have hh : 0 < h := by + have hp : (0:ℝ) < h := (pow_pos hW0 252).trans_le hpow + exact_mod_cast hp + have hhX : h ≤ X := (major_arc_working_length_le H W).trans hHX + have hcapK : h+2 ≤ K := hcap W hW1 hWX H + have hKX : K ≤ X := by + apply Nat.ceil_le.mpr + exact Real.sqrt_le_self_iff.mpr (Or.inr (by exact_mod_cast (show 1≤X by omega))) + have hK : 1 ≤ K := by omega + have hNK : N₀ ≤ K := by + have hn : (N₀:ℝ)^2 ≤ X := by exact_mod_cast hN + have hs : (N₀:ℝ) ≤ Real.sqrt (X:ℝ) := by + nlinarith only [hn,Real.sq_sqrt (Nat.cast_nonneg X),Real.sqrt_nonneg (X:ℝ),(show (0:ℝ)≤N₀ from Nat.cast_nonneg N₀)] + exact_mod_cast hs.trans (Nat.le_ceil (Real.sqrt (X:ℝ))) + obtain ⟨hprimepars,_,_⟩ := hparams W hWW₁ H (by omega) hLH hWH X hXX hWX + obtain ⟨hP,hPQ,hLP,hLQ,hbudget,hres100,hres⟩ := hprimepars + have hQK : 2*Q ≤ K := by + have hp := (hparams W hWW₁ H (by omega) hLH hWH X hXX hWX).2.1.2 + exact hp + have hWK : W ≤ K := + ((le_self_pow₀ hW1 (by decide : (252:ℕ)≠0)).trans hpow).trans + (by exact_mod_cast (show h≤K by omega)) + have hWR : W^9 ≤ mrtBaseResolution P Q (1/100) := + (pow_le_pow_right₀ hW1 (by norm_num : (9:ℕ)≤100)).trans hres100 + have hWP : W^5 ≤ P := pow_le_pow_right₀ hW1 (by norm_num : (5:ℕ)≤500000) + let s := mrtArcSubdivisionLength h W + obtain ⟨hs, hsh, hslo, _⟩ := mrt_arc_subdivision_bounds hW hpow250 + let V := Y+h-s + have hVH : s ≤ V := by dsimp [V]; omega + have hwin := major_arc_correction_window_data hW hpow hslo hsh hVH hcapK + (le_refl Q) hq hqW + have houter' := major_arc_correction_outer (show X≤V by dsimp [V]; omega) + (show V+1≤2*X by dsimp [V]; omega) + (fun d hdp hdD => by + have hdpow : (d:ℝ) ≤ W^5 := + (show (d:ℝ) ≤ mrtCorrectionCutoff W by exact_mod_cast hdD).trans + (mrt_correction_cutoff_bounds hW).2.2 + simpa only [K,Nat.cast_add,Nat.cast_mul,Nat.cast_ofNat,Nat.cast_one] using + hboundary W hW1 hWX d hdp hdpow) + have hqmax : (q:ℝ) ≤ mrtModulusCutoff X H := + hqW.trans (le_min hWX hWH) + have hqinv : 1/(q:ℝ) ≤ 1 := by + simpa using one_div_le_one_div_of_le (by norm_num : (0:ℝ)<1) + (show (1:ℝ)≤q by exact_mod_cast hq) + have hphase : |β| *(s:ℝ) ≤ 1 := + (mrt_arc_subdivision_phase hW hpow250 hq hβ).trans hqinv + have hm := hcorrect X V s K H hX hLX hVH hNK hK (Nat.le_ceil _) + P Q hP hPQ hLP hLQ hbudget hres hQK J hJ hbands W hW hWK hWR hWP + hwin.1 houter' q hq hqW hqmax hwin.2 F hF1 hFm hFb M hM hd r β hphase + let E := Real.exp (-M/20)+mrtShortError X H + have hE : 0 ≤ E := by + unfold E mrtShortError + positivity + have hrate := hfinal.1 H M hLH hLL hM + have hm' : shortExponentialIntegral (mrtTypicalCoefficient (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) + V s ((r:ℝ)/q+β) ≤ (D*E)*(V:ℝ)*s := by + apply hm.trans + have hrate' : mrtCorrectionBound*(4*(1+4*Real.pi)* + (4*C*(Real.sqrt W*(1+Real.log W))*(Real.exp (-2*M/5)+ + Real.sqrt (Real.log (Real.log X)/(Real.log X)^(1/80:ℝ))+W⁻¹)+3/W)+ + 5*W^(-5/4:ℝ)) ≤ D*E := by + simpa only [W,D,E,mrtShortError,add_assoc] using hrate + exact major_arc_rate_volume (Nat.cast_nonneg V) (Nat.cast_nonneg s) hrate' + have hsfull := mrt_arc_subdivision_integral_sharp _ + (mrtTypicalCoefficient_oneBounded _ _ F hFb) Y h (hhX.trans hXY) hW hpow250 + (mul_nonneg hD.le hE) ((r:ℝ)/q+β) hm' + have htail : W^(-1/4:ℝ) ≤ 21*E := by + have hk := hfinal.2 H M hLH hLL hM + have hsmall : W^(-1/4:ℝ) ≤ majorArcWorkingError W := by + apply (Real.rpow_le_rpow_of_exponent_le hW1 (show (-1/4:ℝ)≤-1/5 by norm_num)).trans + exact le_mul_of_one_le_left (Real.rpow_nonneg hW0.le _) + (by linarith [Real.log_nonneg hW1]) + have hshort : 0 ≤ Real.log (Real.log (H:ℝ))/Real.log H := by positivity + have hlogerr : 0 ≤ (Real.log X)^(-1/700:ℝ) := Real.rpow_nonneg (by linarith) _ + have hexp := Real.exp_pos (-M/20) + rw [mul_div_assoc] at hk + dsimp [E,mrtShortError] + linarith only [hk,hsmall,hshort,hlogerr,hexp] + calc + _ ≤ (Y:ℝ)*h*(2*(D*E)+W^(-1/4:ℝ)) := by simpa only [neg_div] using hsfull + _ ≤ (Y:ℝ)*h*(2*(D*E)+21*E) := + mul_le_mul_of_nonneg_left (add_le_add le_rfl htail) (by positivity) + _ = _ := by dsimp only [E]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcAlternative.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcAlternative.lean new file mode 100644 index 0000000000000000000000000000000000000000..7419ee77f42f91585951d4fc85b0b4cccfecb339 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcAlternative.lean @@ -0,0 +1,33 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcApproximation +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcTheorem + +namespace OAI + +/-! The rational approximation used for the major/minor arc alternative, +with its actual short-window denominator cutoff. -/ + +namespace TwoPointCorrelations + +lemma minor_arc_short_rational_approximation (α : ℝ) (H : ℕ) (W : ℝ) + (hW : 0 < W) (hWH : W ≤ H) : + ∃ (r : ℤ) (q : ℕ), 0 < q ∧ (q : ℝ) ≤ (H : ℝ) / W ∧ + IsCoprime (q : ℤ) r ∧ + |α - (r : ℝ) / q| ≤ W / ((H : ℝ) * q) ∧ + |α - (r : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2 := by + let Q : ℕ := ⌊(H : ℝ) / W⌋₊ + have hQ : 0 < Q := Nat.floor_pos.mpr ((le_div_iff₀ hW).mpr (by simpa using hWH)) + obtain ⟨r, q, hq, hqQ, hcop, happ, hsquare⟩ := minor_arc_rational_approximation α Q hQ + have hcut : (q : ℝ) ≤ (H : ℝ) / W := + (by exact_mod_cast hqQ : (q : ℝ) ≤ Q).trans (Nat.floor_le (by positivity)) + have hH : (0 : ℝ) < H := hW.trans_le hWH + have hq0 : (0 : ℝ) < q := by exact_mod_cast hq + have hQ0 : (0 : ℝ) < (Q : ℝ) + 1 := by positivity + have hQlarge : (H : ℝ) ≤ ((Q : ℝ) + 1) * W := + (div_le_iff₀ hW).mp (Nat.lt_floor_add_one ((H : ℝ) / W)).le + refine ⟨r, q, hq, hcut, hcop, happ.trans ?_, hsquare⟩ + apply (div_le_div_iff₀ (mul_pos hQ0 hq0) (mul_pos hH hq0)).mpr + nlinarith [mul_le_mul_of_nonneg_right hQlarge hq0.le] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcApproximation.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd410411570fecf5ccacf811f6e24657ad64da0d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcApproximation.lean @@ -0,0 +1,28 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcBilinearSieve +import Mathlib.NumberTheory.DiophantineApproximation.Basic + +namespace OAI + +/-! A reduced rational approximation for the major/minor arc split. -/ + +namespace TwoPointCorrelations + +lemma minor_arc_rational_approximation (α : ℝ) (Q : ℕ) (hQ : 0 < Q) : + ∃ (r : ℤ) (q : ℕ), 0 < q ∧ q ≤ Q ∧ IsCoprime (q : ℤ) r ∧ + |α - (r : ℝ) / q| ≤ 1 / (((Q : ℝ) + 1) * q) ∧ + |α - (r : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2 := by + obtain ⟨a, ha, hden⟩ := Real.exists_rat_abs_sub_le_and_den_le α hQ + have hq0 : (0 : ℝ) < a.den := by exact_mod_cast a.pos + have happrox : |α - (a.num : ℝ) / a.den| ≤ 1 / (((Q : ℝ) + 1) * a.den) := by + simpa only [Rat.cast_def] using ha + refine ⟨a.num, a.den, a.pos, hden, ?_, happrox, ?_⟩ + · apply Int.isCoprime_iff_nat_coprime.mpr + simpa only [Int.natAbs_natCast] using a.reduced.symm + · apply happrox.trans + apply one_div_le_one_div_of_le (sq_pos_of_pos hq0) + have hden' : (a.den : ℝ) ≤ Q := by exact_mod_cast hden + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcBilinearSieve.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcBilinearSieve.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ae35df295ecd1707b098fbcd8d3349df5b0f4f6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcBilinearSieve.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcBilinearWindow +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcSieveSaving + +namespace OAI + +/-! The prime sieve saving for the actual finite bilinear short-window sum. -/ + +namespace TwoPointCorrelations + +open Finset Filter + +theorem minor_arc_bilinear_sieve : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ R : ℝ in atTop, + ∀ (P : Finset ℕ) (N X M H d : ℕ), 0 < d → + (∀ p ∈ P, p.Prime ∧ p ≠ 2 ∧ R ≤ (p : ℝ) ∧ p ≤ N) → (N : ℝ) ≤ 2 * R → + ∀ (a c : ℕ → ℂ), (∀ m ∈ range M, ‖a m‖ ≤ 1) → (∀ p ∈ P, ‖c p‖ ≤ 1) → + ∀ W : ℝ, 1 ≤ W → W ≤ R → R ≤ (H : ℝ) / W → + ∀ (r : ℤ) (q : ℕ), 2 ≤ q → W ≤ (q : ℝ) → (q : ℝ) ≤ (H : ℝ) / W → + ∀ α : ℝ, IsCoprime (q : ℤ) r → + |α - (r : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2 → + (∑ k ∈ range X, ‖minorArcBilinearWindow P M H d a c α k‖) ^ 4 ≤ + C * (M : ℝ) ^ 3 * (X * (3 * H + 1) ^ 3 : ℕ) * H * R ^ 3 * + (1 + Real.log (2 * (H : ℝ))) / (W * Real.log R ^ 4) := by + obtain ⟨C, hC, hk⟩ := minor_arc_sieve_saving + refine ⟨2 * C, by positivity, ?_⟩ + filter_upwards [hk, eventually_ge_atTop (1 : ℝ)] with R hk hR + intro P N X M H d hd hP hN a c ha hc W hW hWR hRH r q hq hWq hqH α hcop happ + have hW0 : 0 < W := by linarith + have hR0 : 0 < R := by linarith + have hHR : R ≤ (H : ℝ) := by + exact (le_mul_of_one_le_right hR0.le hW).trans ((le_div_iff₀ hW0).mp hRH) + have hH0 : 0 ≤ (H : ℝ) := Nat.cast_nonneg H + have hdouble : ∀ p ∈ P, 0 < p ∧ ∀ s ∈ P, s ≤ 2 * p := by + intro p hp + have hpR := (hP p hp).2.2.1 + constructor + · have hp1 : (1 : ℝ) ≤ p := hR.trans hpR + exact_mod_cast (lt_of_lt_of_le (by norm_num : (0 : ℝ) < 1) hp1) + · intro s hs + have hsN : (s : ℝ) ≤ N := by exact_mod_cast (hP s hs).2.2.2 + have hsp : (s : ℝ) ≤ 2 * (p : ℝ) := by linarith + exact_mod_cast hsp + have hV : ∀ p ∈ P, (H : ℝ) / (d * p : ℕ) + 1 ≤ 2 * (H : ℝ) / R := by + intro p hp + have hpR := (hP p hp).2.2.1 + have hd1 : 1 ≤ d := hd + have hdp : R ≤ ((d * p : ℕ) : ℝ) := by + have hpdp : p ≤ d * p := by nlinarith + exact hpR.trans (by exact_mod_cast hpdp) + have hdiv : (H : ℝ) / (d * p : ℕ) ≤ (H : ℝ) / R := + div_le_div_of_nonneg_left hH0 hR0 hdp + have hone : 1 ≤ (H : ℝ) / R := (le_div_iff₀ hR0).mpr (by simpa using hHR) + calc + _ ≤ (H : ℝ) / R + (H : ℝ) / R := add_le_add hdiv hone + _ = _ := by ring + have hbilinear := minor_arc_bilinear_fourth P X M H d hd hdouble a c ha hc α + (2 * (H : ℝ) / R) hV + have hHdiv : (H : ℝ) / W ≤ (2 * (H : ℝ)) / W := by gcongr; linarith + have hkernel := hk P N (fun p hp => ⟨(hP p hp).1, (hP p hp).2.1, (hP p hp).2.2.2⟩) + hN (2 * (H : ℝ)) W (2 * (H : ℝ) / R) hW hWR r q hq hWq + (hqH.trans hHdiv) (hRH.trans hHdiv) (by positivity) (le_refl _) α hcop happ + have hfactor : 0 ≤ (M : ℝ) ^ 3 * (X * (3 * H + 1) ^ 3 : ℕ) := by positivity + apply hbilinear.trans + convert mul_le_mul_of_nonneg_left hkernel hfactor using 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcBilinearWindow.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcBilinearWindow.lean new file mode 100644 index 0000000000000000000000000000000000000000..fbeb3a7f02363014c6efec1b4c4209464c4ae90e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcBilinearWindow.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcHolder + +namespace OAI + +/-! A literal finite bilinear short-window bound, before substituting the +Ramaré cofactor coefficient or the sieve kernel estimate. -/ + +namespace TwoPointCorrelations + +open Finset + +noncomputable def minorArcBilinearWindow (P : Finset ℕ) (M H d : ℕ) + (a c : ℕ → ℂ) (α : ℝ) (k : ℕ) : ℂ := + ∑ m ∈ range M, a m * ∑ p ∈ P, + minorArcWindowTerm M (d * p) k H (c p) (α * p) m + +lemma minor_arc_window_scalar (M A k H : ℕ) (z w : ℂ) (β : ℝ) (m : ℕ) : + w * minorArcWindowTerm M A k H z β m = + minorArcWindowTerm M A k H (z * w) β m := by + unfold minorArcWindowTerm + split_ifs <;> ring + +lemma minor_arc_bilinear_dual (P : Finset ℕ) (X M H d : ℕ) + (a c θ : ℕ → ℂ) (α : ℝ) : + (∑ k ∈ range X, θ k * minorArcBilinearWindow P M H d a c α k) = + ∑ m ∈ range M, a m * ∑ p ∈ P, ∑ k ∈ range X, + minorArcWindowTerm M (d * p) k H (c p * θ k) (α * p) m := by + unfold minorArcBilinearWindow + simp only [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro m _ + rw [sum_comm] + apply sum_congr rfl + intro p _ + apply sum_congr rfl + intro k _ + rw [← minor_arc_window_scalar] + ring + +/-- The full finite minor-arc inequality obtained by polarization, +Hölder, geometric summation and the four-origin support estimate. -/ +theorem minor_arc_bilinear_fourth (P : Finset ℕ) (X M H d : ℕ) (hd : 0 < d) + (hP : ∀ p ∈ P, 0 < p ∧ ∀ q ∈ P, q ≤ 2 * p) + (a c : ℕ → ℂ) (ha : ∀ m ∈ range M, ‖a m‖ ≤ 1) (hc : ∀ p ∈ P, ‖c p‖ ≤ 1) + (α V : ℝ) (hV : ∀ p ∈ P, (H : ℝ) / (d * p : ℕ) + 1 ≤ V) : + (∑ k ∈ range X, ‖minorArcBilinearWindow P M H d a c α k‖) ^ 4 ≤ + (M : ℝ) ^ 3 * (X * (3 * H + 1) ^ 3 : ℕ) * + ∑ p₁ ∈ P, ∑ p₂ ∈ P, ∑ p₃ ∈ P, ∑ p₄ ∈ P, + minorArcGeometricBound V (α * ((p₁ : ℝ) + p₂ - p₃ - p₄)) := by + obtain ⟨θ, hθ, hdual⟩ := minor_arc_norm_sum_duality (range X) + (minorArcBilinearWindow P M H d a c α) + rw [hdual, minor_arc_bilinear_dual] + have hholder := minor_arc_weighted_fourth (range M) a + (fun m => ∑ p ∈ P, ∑ k ∈ range X, + minorArcWindowTerm M (d * p) k H (c p * θ k) (α * p) m) ha + simp only [card_range] at hholder + apply hholder.trans + have hfour := minor_arc_window_fourth P X M H d hd hP c θ hc + (fun k => (hθ k).le) α V hV + have hh := mul_le_mul_of_nonneg_left hfour (by positivity : 0 ≤ (M : ℝ) ^ 3) + simpa only [mul_assoc] using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcCircleKernel.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcCircleKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..10d2c513ff72d9fc4e32e779eb039b7cd372f481 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcCircleKernel.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcGeometric +import Mathlib.Analysis.Normed.Group.AddCircle +import Mathlib.Analysis.SpecialFunctions.Trigonometric.Bounds + +namespace OAI + +/-! Convert the exact geometric denominator to distance from the nearest +integer. This is the kernel used in the rational-spacing estimate. -/ + +namespace TwoPointCorrelations + +open Complex + +lemma minor_arc_phase_gap (α : ℝ) : + 4 * ‖(α : UnitAddCircle)‖ ≤ ‖additiveCharacter α 1 - 1‖ := by + let δ := α - (round α : ℝ) + have hδ : |δ| ≤ 1 / 2 := by + simpa only [UnitAddCircle.norm_eq, abs_one] using + (AddCircle.norm_le_half_period (1 : ℝ) (by norm_num) (x := (α : UnitAddCircle))) + have hsin := Real.mul_abs_le_abs_sin (x := Real.pi * δ) (by + rw [abs_mul, abs_of_pos Real.pi_pos] + nlinarith [Real.pi_pos]) + have hs : |Real.sin (Real.pi * δ)| = |Real.sin (Real.pi * α)| := by + rw [show Real.pi * δ = Real.pi * α - (round α : ℝ) * Real.pi by dsimp [δ]; ring, + Real.sin_sub_int_mul_pi, abs_mul, abs_zpow] + norm_num + have hn : ‖additiveCharacter α 1 - 1‖ = 2 * |Real.sin (Real.pi * α)| := by + have he : additiveCharacter α 1 = Complex.exp (Complex.I * ((2 * Real.pi * α : ℝ) : ℂ)) := by + simp only [additiveCharacter, Nat.cast_one, mul_one] + rw [mul_comm] + rw [he, Complex.norm_exp_I_mul_ofReal_sub_one, + show 2 * Real.pi * α / 2 = Real.pi * α by ring, + Real.norm_eq_abs, abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 2)] + rw [hn, ← hs, UnitAddCircle.norm_eq] + have hδπ : |Real.pi * δ| = Real.pi * |δ| := by rw [abs_mul, abs_of_pos Real.pi_pos] + rw [hδπ] at hsin + have he : (2 / Real.pi) * (Real.pi * |δ|) = 2 * |δ| := by field_simp + rw [he] at hsin + change 4 * |δ| ≤ 2 * |Real.sin (Real.pi * δ)| + linarith + +lemma minor_arc_geometric_circle {α L : ℝ} (hα : 0 < ‖(α : UnitAddCircle)‖) : + minorArcGeometricBound L α ≤ min L (1 / (2 * ‖(α : UnitAddCircle)‖)) := by + have hgap := minor_arc_phase_gap α + have hn : 0 < ‖additiveCharacter α 1 - 1‖ := by linarith + have hz : additiveCharacter α 1 ≠ 1 := by + intro he + simp only [he, sub_self, norm_zero] at hn + linarith + unfold minorArcGeometricBound + rw [ite_eq_right hz] + apply min_le_min_left + apply (div_le_div_iff₀ hn (by positivity : 0 < 2 * ‖(α : UnitAddCircle)‖)).mpr + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcCofactorCutoff.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcCofactorCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..243f68f7a95e9d8295707f344d0a30f936c53457 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcCofactorCutoff.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcBilinearSieve +import Mathlib.Data.Nat.Cast.Order.Field + +namespace OAI + +/-! The finite cofactor cutoff needed by the literal short-window sum. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma minor_arc_cofactor_cutoff (X H R p k : ℕ) (hR : 0 < R) + (hRp : R ≤ p) (hk : k < X) : + (k + H) / p < (X + H) / R + 1 := by + have h₁ : (k + H) / p ≤ (k + H) / R := Nat.div_le_div_left hRp hR + have h₂ : (k + H) / R ≤ (X + H) / R := Nat.div_le_div_right (by omega) + omega + +lemma minor_arc_cofactor_cutoff_bound (X H R : ℕ) (hR : 0 < R) + (hRX : R ≤ X) (hHX : H ≤ X) : + (((X + H) / R + 1 : ℕ) : ℝ) ≤ 3 * (X : ℝ) / R := by + have hR0 : (0 : ℝ) < R := by exact_mod_cast hR + have hHX' : (H : ℝ) ≤ X := by exact_mod_cast hHX + have hRX' : (R : ℝ) ≤ X := by exact_mod_cast hRX + have hdiv : (((X + H) / R : ℕ) : ℝ) ≤ ((X : ℝ) + H) / R := by + simpa only [Nat.cast_add] using (Nat.cast_div_le (m := X + H) (n := R) (α := ℝ)) + push_cast + calc + _ ≤ ((X : ℝ) + H) / R + 1 := add_le_add hdiv le_rfl + _ ≤ 3 * (X : ℝ) / R := by + apply (le_div_iff₀ hR0).mpr + rw [add_mul, div_mul_cancel₀ _ hR0.ne', one_mul] + linarith + +lemma minor_arc_origin_factor_bound (X H : ℕ) (hH : 1 ≤ H) : + (X * (3 * H + 1) ^ 3 : ℕ) ≤ 64 * (X : ℝ) * (H : ℝ) ^ 3 := by + have hH' : (1 : ℝ) ≤ H := by exact_mod_cast hH + have hbase : 3 * (H : ℝ) + 1 ≤ 4 * H := by linarith + have hc := pow_le_pow_left₀ (by positivity : 0 ≤ 3 * (H : ℝ) + 1) hbase 3 + push_cast + calc + _ ≤ (X : ℝ) * (4 * H) ^ 3 := mul_le_mul_of_nonneg_left hc (Nat.cast_nonneg X) + _ = _ := by ring + +lemma minor_arc_cofactor_total_bound (X H R : ℕ) (hR : 0 < R) + (hRX : R ≤ X) (hHX : H ≤ X) (hH : 1 ≤ H) : + ((((X + H) / R + 1 : ℕ) : ℝ) ^ 3 * + (X * (3 * H + 1) ^ 3 : ℕ) * H * (R : ℝ) ^ 3) ≤ + 1728 * (X : ℝ) ^ 4 * (H : ℝ) ^ 4 := by + have hR0 : (R : ℝ) ≠ 0 := by exact_mod_cast hR.ne' + have hM := minor_arc_cofactor_cutoff_bound X H R hR hRX hHX + have hO := minor_arc_origin_factor_bound X H hH + calc + ((((X + H) / R + 1 : ℕ) : ℝ) ^ 3 * + (X * (3 * H + 1) ^ 3 : ℕ) * H * (R : ℝ) ^ 3) ≤ + (3 * (X : ℝ) / R) ^ 3 * (64 * (X : ℝ) * (H : ℝ) ^ 3) * H * (R : ℝ) ^ 3 := by + gcongr + _ = _ := by field_simp [hR0]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcDyadicIntegral.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcDyadicIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6aa8747e1ec660a48b29f077e218f2360c9b0c7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcDyadicIntegral.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcLogSaving + +namespace OAI + +/-! Summing the minor-arc estimate over the actual dyadic prime blocks. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem minor_arc_bilinear_log_saving : + ∃ C : ℝ, 0 < C ∧ ∃ R₀ : ℕ, + ∀ (P J : Finset ℕ) (X H N : ℕ), 1 ≤ H → H ≤ X → + 1 ≤ Real.log (H : ℝ) → J ⊆ Icc 1 N → + (∀ p ∈ P, Nat.log 2 p ∈ J) → (∀ p ∈ P, p.Prime ∧ p ≠ 2) → + (∀ j ∈ J, R₀ ≤ 2 ^ j ∧ 2 ^ j ≤ X) → + (∀ j ∈ J, (Real.log (H : ℝ)) ^ 5 ≤ (2 : ℝ) ^ j ∧ + (2 : ℝ) ^ j ≤ (H : ℝ) / (Real.log (H : ℝ)) ^ 5) → + ∀ (a c : ℕ → ℂ), (∀ m, ‖a m‖ ≤ 1) → (∀ p ∈ P, ‖c p‖ ≤ 1) → + ∀ (r : ℤ) (q : ℕ), 2 ≤ q → + (Real.log (H : ℝ)) ^ 5 ≤ (q : ℝ) → + (q : ℝ) ≤ (H : ℝ) / (Real.log (H : ℝ)) ^ 5 → + ∀ α : ℝ, IsCoprime (q : ℤ) r → + |α - (r : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2 → + (∑ k ∈ range X, ‖minorArcBilinearWindow P (X + H + 1) H 1 a c α k‖) ≤ + C * (X : ℝ) * H * (1 + Real.log (N : ℝ)) / Real.log (H : ℝ) := by + obtain ⟨D, hD, hbound⟩ := minor_arc_dyadic_log_saving + obtain ⟨R₀, hR₀⟩ := eventually_atTop.mp hbound + have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) + refine ⟨D / Real.log 2, div_pos hD hlog2, R₀, ?_⟩ + intro P J X H N hH hHX hlogH hJN hPJ hP hR hgeom a c ha hc r q hq hWq hqH α hcop happ + let M : ℕ → ℕ := fun j => (X + H) / 2 ^ j + 1 + have hcut : ∀ k ∈ range X, ∀ p ∈ P, (k + H) / (1 * p) < X + H + 1 := by + intro k hk p _ + have hkX := mem_range.mp hk + have hd := Nat.div_le_self (k + H) (1 * p) + omega + have hcuts : ∀ j ∈ J, ∀ k ∈ range X, ∀ p ∈ minorArcDyadicPrimes P j, + (k + H) / (1 * p) < M j := by + intro j hj k hk p hp + simp only [one_mul] + exact minor_arc_cofactor_cutoff X H (2 ^ j) p k (by positivity) + (minor_arc_dyadic_primes_bounds P j p hp (hP p (mem_filter.mp hp).1).1.pos).1 + (mem_range.mp hk) + let K : ℝ := D * (X : ℝ) * H / Real.log (H : ℝ) + have hK : 0 ≤ K := by dsimp [K]; positivity + have hblock : ∀ j ∈ J, + (∑ k ∈ range X, ‖minorArcBilinearWindow (minorArcDyadicPrimes P j) (M j) H 1 a c α k‖) ≤ + K / Real.log ((2 : ℝ) ^ j) := by + intro j hj + have hprime : ∀ p ∈ minorArcDyadicPrimes P j, + p.Prime ∧ p ≠ 2 ∧ 2 ^ j ≤ p ∧ p ≤ 2 * 2 ^ j := by + intro p hp + have hpP := (mem_filter.mp hp).1 + exact ⟨(hP p hpP).1, (hP p hpP).2, + minor_arc_dyadic_primes_bounds P j p hp (hP p hpP).1.pos⟩ + have hh := hR₀ (2 ^ j) (hR j hj).1 (minorArcDyadicPrimes P j) X H + hH hHX (hR j hj).2 hlogH hprime a c ha + (fun p hp => hc p (mem_filter.mp hp).1) + (by simpa only [Nat.cast_pow, Nat.cast_ofNat] using (hgeom j hj).1) + (by simpa only [Nat.cast_pow, Nat.cast_ofNat] using (hgeom j hj).2) + r q hq hWq hqH α hcop happ + dsimp [M, K] + convert hh using 1 + push_cast + ring + calc + _ ≤ ∑ j ∈ J, ∑ k ∈ range X, + ‖minorArcBilinearWindow (minorArcDyadicPrimes P j) (M j) H 1 a c α k‖ := + minor_arc_bilinear_dyadic_sum_le J P hPJ X (X + H + 1) H 1 M hcut hcuts a c α + _ ≤ K * (1 + Real.log (N : ℝ)) / Real.log 2 := + minor_arc_weighted_dyadic_log_sum J N hJN K hK _ hblock + _ = _ := by dsimp [K]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcDyadicSieve.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcDyadicSieve.lean new file mode 100644 index 0000000000000000000000000000000000000000..6728537a4708c78590b4900e61c164601d6c770b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcDyadicSieve.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcCofactorCutoff + +namespace OAI + +/-! Cancellation of the dyadic cofactor scale in the fourth moment. -/ + +namespace TwoPointCorrelations + +open Finset Filter + +theorem minor_arc_dyadic_bilinear_sieve : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ R : ℕ in atTop, + ∀ (P : Finset ℕ) (X H : ℕ), 1 ≤ H → H ≤ X → R ≤ X → + (∀ p ∈ P, p.Prime ∧ p ≠ 2 ∧ R ≤ p ∧ p ≤ 2 * R) → + ∀ (a c : ℕ → ℂ), (∀ m, ‖a m‖ ≤ 1) → (∀ p ∈ P, ‖c p‖ ≤ 1) → + ∀ W : ℝ, 1 ≤ W → W ≤ (R : ℝ) → (R : ℝ) ≤ (H : ℝ) / W → + ∀ (r : ℤ) (q : ℕ), 2 ≤ q → W ≤ (q : ℝ) → (q : ℝ) ≤ (H : ℝ) / W → + ∀ α : ℝ, IsCoprime (q : ℤ) r → + |α - (r : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2 → + (∑ k ∈ range X, ‖minorArcBilinearWindow P ((X + H) / R + 1) H 1 a c α k‖) ^ 4 ≤ + C * (X : ℝ) ^ 4 * (H : ℝ) ^ 4 * (1 + Real.log (2 * (H : ℝ))) / + (W * Real.log (R : ℝ) ^ 4) := by + obtain ⟨C, hC, hbound⟩ := minor_arc_bilinear_sieve + refine ⟨1728 * C, by positivity, ?_⟩ + have hb : ∀ᶠ R : ℕ in atTop, _ := + tendsto_natCast_atTop_atTop.eventually hbound + filter_upwards [hb, eventually_ge_atTop 2] with R hbound hR + intro P X H hH hHX hRX hP a c ha hc W hW hWR hRH r q hq hWq hqH α hcop happ + have hR0 : 0 < R := by omega + have hp : ∀ p ∈ P, p.Prime ∧ p ≠ 2 ∧ (R : ℝ) ≤ p ∧ p ≤ 2 * R := by + intro p hp + exact ⟨(hP p hp).1, (hP p hp).2.1, by exact_mod_cast (hP p hp).2.2.1, + (hP p hp).2.2.2⟩ + have hbil := hbound P (2 * R) X ((X + H) / R + 1) H 1 (by norm_num) hp + (by simp) a c (fun m _ => ha m) hc W hW hWR hRH + r q hq hWq hqH α hcop happ + have hlog : 0 ≤ 1 + Real.log (2 * (H : ℝ)) := by + have hH' : (1 : ℝ) ≤ H := by exact_mod_cast hH + have hh : 1 ≤ 2 * (H : ℝ) := by linarith + linarith [Real.log_nonneg hh] + have hK : 0 ≤ (1 + Real.log (2 * (H : ℝ))) / (W * Real.log (R : ℝ) ^ 4) := + div_nonneg hlog (mul_nonneg (by linarith) (by positivity)) + have hcore := mul_le_mul_of_nonneg_left + (minor_arc_cofactor_total_bound X H R hR0 hRX hHX hH) hC.le + have hfinal := mul_le_mul_of_nonneg_right hcore hK + apply hbil.trans + convert hfinal using 1 <;> ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcDyadicSummation.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcDyadicSummation.lean new file mode 100644 index 0000000000000000000000000000000000000000..518f75c3a4b08d7a8d783325b509cc530a59a367 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcDyadicSummation.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcParameters +import Mathlib.NumberTheory.Harmonic.Bounds +import Mathlib.Data.Nat.Log + +namespace OAI + +/-! Summing the reciprocal logarithmic saving over dyadic prime blocks. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma minor_arc_dyadic_prime_bounds {p j : ℕ} (hp : 0 < p) (hj : Nat.log 2 p = j) : + 2 ^ j ≤ p ∧ p ≤ 2 * 2 ^ j := by + have hl := Nat.pow_log_le_self 2 hp.ne' + have hu := Nat.lt_pow_succ_log_self (by norm_num : 1 < 2) p + rw [hj] at hl hu + rw [pow_succ] at hu + exact ⟨hl, by omega⟩ + +lemma minor_arc_dyadic_index_pos {p : ℕ} (hp : 2 ≤ p) : 1 ≤ Nat.log 2 p := by + apply Nat.le_log_of_pow_le (by norm_num : 1 < 2) + simpa using hp + +lemma minor_arc_dyadic_log_sum (J : Finset ℕ) (N : ℕ) + (hJ : J ⊆ Icc 1 N) : + (∑ j ∈ J, 1 / Real.log ((2 : ℝ) ^ j)) ≤ + (1 + Real.log (N : ℝ)) / Real.log 2 := by + have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hfull : (∑ j ∈ Icc 1 N, 1 / Real.log ((2 : ℝ) ^ j)) = + (harmonic N : ℝ) / Real.log 2 := by + simp only [Real.log_pow] + rw [harmonic_eq_sum_Icc, Rat.cast_sum] + simp only [Rat.cast_inv, Rat.cast_natCast, sum_div] + apply sum_congr rfl + intro j _ + simp only [mul_inv_rev, div_eq_mul_inv] + ring + calc + _ ≤ ∑ j ∈ Icc 1 N, 1 / Real.log ((2 : ℝ) ^ j) := by + apply sum_le_sum_of_subset_of_nonneg hJ + intro j hj _ + rw [Real.log_pow] + positivity + _ = (harmonic N : ℝ) / Real.log 2 := hfull + _ ≤ _ := div_le_div_of_nonneg_right (harmonic_le_one_add_log N) hlog2.le + +lemma minor_arc_weighted_dyadic_log_sum (J : Finset ℕ) (N : ℕ) + (hJ : J ⊆ Icc 1 N) (K : ℝ) (hK : 0 ≤ K) (S : ℕ → ℝ) + (hS : ∀ j ∈ J, S j ≤ K / Real.log ((2 : ℝ) ^ j)) : + (∑ j ∈ J, S j) ≤ K * (1 + Real.log (N : ℝ)) / Real.log 2 := by + calc + _ ≤ ∑ j ∈ J, K / Real.log ((2 : ℝ) ^ j) := sum_le_sum hS + _ = K * ∑ j ∈ J, 1 / Real.log ((2 : ℝ) ^ j) := by + rw [mul_sum] + apply sum_congr rfl + intro j _ + ring + _ ≤ K * ((1 + Real.log (N : ℝ)) / Real.log 2) := + mul_le_mul_of_nonneg_left (minor_arc_dyadic_log_sum J N hJ) hK + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcDyadicWindows.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcDyadicWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..82e9347837d1fdf7c5eb31f0c262597f6c3af08a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcDyadicWindows.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcRamareWindow +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcDyadicSummation + +namespace OAI + +/-! Splitting only the prime index into dyadic blocks. The cofactor +coefficient, including its full-prime-set denominator, stays fixed. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def minorArcDyadicPrimes (P : Finset ℕ) (j : ℕ) : Finset ℕ := + P.filter (fun p => Nat.log 2 p = j) + +lemma minor_arc_dyadic_primes_bounds (P : Finset ℕ) (j p : ℕ) + (hp : p ∈ minorArcDyadicPrimes P j) (hp0 : 0 < p) : + 2 ^ j ≤ p ∧ p ≤ 2 * 2 ^ j := + minor_arc_dyadic_prime_bounds hp0 (mem_filter.mp hp).2 + +lemma minor_arc_bilinear_dyadic_partition (J P : Finset ℕ) + (hJ : ∀ p ∈ P, Nat.log 2 p ∈ J) (M H d k : ℕ) + (a c : ℕ → ℂ) (α : ℝ) : + minorArcBilinearWindow P M H d a c α k = + ∑ j ∈ J, minorArcBilinearWindow (minorArcDyadicPrimes P j) M H d a c α k := by + unfold minorArcBilinearWindow + have hp (m : ℕ) : (∑ j ∈ J, ∑ p ∈ minorArcDyadicPrimes P j, + minorArcWindowTerm M (d * p) k H (c p) (α * p) m) = + ∑ p ∈ P, minorArcWindowTerm M (d * p) k H (c p) (α * p) m := + sum_fiberwise_of_maps_to hJ _ + rw [sum_comm (s := J) (t := range M)] + apply sum_congr rfl + intro m _ + rw [← mul_sum, hp] + +lemma minor_arc_bilinear_dyadic_cutoffs (J P : Finset ℕ) + (hJ : ∀ p ∈ P, Nat.log 2 p ∈ J) (M H d k : ℕ) (N : ℕ → ℕ) + (hM : ∀ p ∈ P, (k + H) / (d * p) < M) + (hN : ∀ j ∈ J, ∀ p ∈ minorArcDyadicPrimes P j, (k + H) / (d * p) < N j) + (a c : ℕ → ℂ) (α : ℝ) : + minorArcBilinearWindow P M H d a c α k = + ∑ j ∈ J, minorArcBilinearWindow (minorArcDyadicPrimes P j) (N j) H d a c α k := by + rw [minor_arc_bilinear_dyadic_partition J P hJ] + apply sum_congr rfl + intro j hj + exact minor_arc_bilinear_cutoff_eq (minorArcDyadicPrimes P j) M (N j) H d k + (fun p hp => hM p (mem_filter.mp hp).1) (hN j hj) a c α + +lemma minor_arc_bilinear_dyadic_sum_le (J P : Finset ℕ) + (hJ : ∀ p ∈ P, Nat.log 2 p ∈ J) (X M H d : ℕ) (N : ℕ → ℕ) + (hM : ∀ k ∈ range X, ∀ p ∈ P, (k + H) / (d * p) < M) + (hN : ∀ j ∈ J, ∀ k ∈ range X, ∀ p ∈ minorArcDyadicPrimes P j, + (k + H) / (d * p) < N j) + (a c : ℕ → ℂ) (α : ℝ) : + (∑ k ∈ range X, ‖minorArcBilinearWindow P M H d a c α k‖) ≤ + ∑ j ∈ J, ∑ k ∈ range X, + ‖minorArcBilinearWindow (minorArcDyadicPrimes P j) (N j) H d a c α k‖ := by + calc + _ ≤ ∑ k ∈ range X, ∑ j ∈ J, + ‖minorArcBilinearWindow (minorArcDyadicPrimes P j) (N j) H d a c α k‖ := by + apply sum_le_sum + intro k hk + rw [minor_arc_bilinear_dyadic_cutoffs J P hJ M H d k N + (hM k hk) (fun j hj => hN j hj k hk)] + exact norm_sum_le _ _ + _ = _ := sum_comm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcEnergyKernel.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcEnergyKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2cf417e2c72e706a648db3e30ca574bccef0ed3 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcEnergyKernel.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcShiftedFiber +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcKernelSymmetry +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcPrimeFourth + +namespace OAI + +/-! Regrouping the prime fourth moment by its integer additive difference. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma minor_arc_fiber_sum {α β : Type*} (S : Finset α) (T : Finset β) + (f : α → β) (w : β → ℝ) (B : ℝ) + (hmap : ∀ a ∈ S, f a ∈ T) (hw : ∀ b ∈ T, 0 ≤ w b) + (hcard : ∀ b ∈ T, ((S.filter (fun a => f a = b)).card : ℝ) ≤ B) : + (∑ a ∈ S, w (f a)) ≤ B * (∑ b ∈ T, w b) := by + rw [← sum_fiberwise_of_maps_to hmap (fun a => w (f a)), mul_sum] + apply sum_le_sum + intro b hb + calc + _ = ((S.filter (fun a => f a = b)).card : ℝ) * w b := by + rw [sum_congr rfl (fun a ha => congrArg w (mem_filter.mp ha).2)] + simp only [sum_const, nsmul_eq_mul] + _ ≤ _ := mul_le_mul_of_nonneg_right (hcard b hb) (hw b hb) + +theorem minor_arc_prime_fourth_energy (P : Finset ℕ) (c : ℕ → ℂ) + (hc : ∀ p ∈ P, ‖c p‖ ≤ 1) (α : ℝ) (a b N : ℕ) + (hP : ∀ p ∈ P, p ≤ N) : + (∑ m ∈ Ico a b, ‖∑ p ∈ P, c p * additiveCharacter (α * p) m‖ ^ 4) ≤ + (Finset.addEnergy P P : ℝ) * + ∑ n ∈ Icc (-(2 * (N : ℤ))) (2 * (N : ℤ)), + minorArcGeometricBound ((b - a : ℕ) : ℝ) (α * (n : ℝ)) := by + let S := (P ×ˢ P) ×ˢ (P ×ˢ P) + let f : (ℕ × ℕ) × (ℕ × ℕ) → ℤ := fun v => + ((v.1.1 : ℤ) + v.1.2) - ((v.2.1 : ℤ) + v.2.2) + have hmap : ∀ v ∈ S, f v ∈ Icc (-(2 * (N : ℤ))) (2 * (N : ℤ)) := by + rintro ⟨⟨p, q⟩, ⟨r, s⟩⟩ hv + obtain ⟨hpq, hrs⟩ := mem_product.mp hv + obtain ⟨hp, hq⟩ := mem_product.mp hpq + obtain ⟨hr, hs⟩ := mem_product.mp hrs + have := hP p hp + have := hP q hq + have := hP r hr + have := hP s hs + apply mem_Icc.mpr + dsimp [f] + omega + have he := minor_arc_fiber_sum S (Icc (-(2 * (N : ℤ))) (2 * (N : ℤ))) f + (fun n => minorArcGeometricBound ((b - a : ℕ) : ℝ) (α * (n : ℝ))) + (Finset.addEnergy P P : ℝ) hmap + (fun n _ => minor_arc_geometric_nonneg (Nat.cast_nonneg _) _) + (fun n _ => by + have hh := (Nat.cast_le (α := ℝ)).mpr (minor_arc_prime_shifted_fiber P n) + simpa only [S, f] using hh) + apply (minor_arc_prime_fourth P c hc α a b).trans + convert he using 1 + dsimp [S, f] + simp only [sum_product] + apply sum_congr rfl + intro p hp + apply sum_congr rfl + intro q hq + apply sum_congr rfl + intro r hr + apply sum_congr rfl + intro s hs + congr 1 + push_cast + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcFirstBand.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcFirstBand.lean new file mode 100644 index 0000000000000000000000000000000000000000..40fa5cf1c8abf32789a4baabb95cdab3f15c688d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcFirstBand.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcTheorem +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTBandParameters +import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics + +namespace OAI + +/-! First-band parameters. A larger fixed lower-endpoint power absorbs +the explicit factorial constants; it changes only the absolute constant. -/ + +namespace TwoPointCorrelations + +open Filter + +noncomputable def minorArcFirstLower (A : ℕ) (H : ℝ) : ℝ := (Real.log H) ^ (5 * A) + +noncomputable def minorArcFirstUpper (H : ℝ) : ℝ := H / (Real.log H) ^ 15 + +lemma minor_arc_first_lower_log (A : ℕ) (H : ℝ) : + Real.log (minorArcFirstLower A H) = 5 * (A : ℝ) * Real.log (Real.log H) := by + simp only [minorArcFirstLower, Real.log_pow, Nat.cast_mul, Nat.cast_ofNat] + +lemma minor_arc_first_band_budget (A : ℕ) (hA : 500000 ≤ A) (H : ℝ) + (hloglog : 1 ≤ Real.log (Real.log H)) (hQ : 1 < minorArcFirstUpper H) + (hQH : minorArcFirstUpper H ≤ H) : + 8192 * (Real.log (Real.log (minorArcFirstUpper H)) + 1) ≤ + (1 / 100 : ℝ) * Real.log (minorArcFirstLower A H) := by + have hmono := Real.log_le_log (Real.log_pos hQ) + (Real.log_le_log (by linarith : 0 < minorArcFirstUpper H) hQH) + have hA' : (500000 : ℝ) ≤ A := by exact_mod_cast hA + have hm := mul_le_mul_of_nonneg_right hA' (by linarith : 0 ≤ Real.log (Real.log H)) + rw [minor_arc_first_lower_log] + nlinarith + +lemma minor_arc_first_band_density (A : ℕ) (H : ℝ) + (hL : 0 < Real.log H) (hLL : 0 ≤ Real.log (Real.log H)) + (hQ : Real.log H / 2 ≤ Real.log (minorArcFirstUpper H)) : + Real.log (minorArcFirstLower A H) / Real.log (minorArcFirstUpper H) ≤ + 10 * (A : ℝ) * Real.log (Real.log H) / Real.log H := by + rw [minor_arc_first_lower_log] + calc + _ ≤ (5 * (A : ℝ) * Real.log (Real.log H)) / (Real.log H / 2) := + div_le_div_of_nonneg_left (by positivity) (by positivity) hQ + _ = _ := by ring + +theorem minor_arc_first_band_scale (A R₀ : ℕ) (hA : 2 ≤ A) : + ∀ᶠ H : ℝ in atTop, 4 ≤ H ∧ 2 ≤ Real.log H ∧ 1 ≤ Real.log (Real.log H) ∧ + 4 ≤ minorArcFirstLower A H ∧ 2 * (R₀ : ℝ) ≤ minorArcFirstLower A H ∧ + 2 * (Real.log H) ^ 5 ≤ minorArcFirstLower A H ∧ + minorArcFirstLower A H ≤ minorArcFirstUpper H ∧ + minorArcFirstUpper H ≤ H / (Real.log H) ^ 5 ∧ + (Real.log H) / 2 ≤ Real.log (minorArcFirstUpper H) ∧ + 1 ≤ Real.log (minorArcFirstUpper H) := by + let E : ℕ := max (5 * A + 15) 30 + have hsmall := (Real.isLittleO_pow_log_id_atTop (n := E)).bound (by norm_num : (0 : ℝ) < 1) + have hlarge := Real.tendsto_log_atTop.eventually + (eventually_ge_atTop (max (4 : ℝ) (2 * R₀))) + have hloglog := (Real.tendsto_log_atTop.comp Real.tendsto_log_atTop).eventually + (eventually_ge_atTop (1 : ℝ)) + filter_upwards [hsmall, hlarge, hloglog, eventually_ge_atTop (4 : ℝ)] with H hs hl hll hH + have hL4 : 4 ≤ Real.log H := (le_max_left _ _).trans hl + have hLR : 2 * (R₀ : ℝ) ≤ Real.log H := (le_max_right _ _).trans hl + have hL1 : 1 ≤ Real.log H := by linarith + have hL0 : 0 < Real.log H := by linarith + have hH0 : 0 < H := by linarith + dsimp only [id] at hs + rw [Real.norm_eq_abs, abs_of_nonneg (pow_nonneg hL0.le E), Real.norm_eq_abs, + abs_of_pos hH0, one_mul] at hs + have hsA : Real.log H ^ (5 * A + 15) ≤ H := + (pow_le_pow_right₀ hL1 (le_max_left _ _)).trans hs + have hs30 : Real.log H ^ 30 ≤ H := + (pow_le_pow_right₀ hL1 (le_max_right _ _)).trans hs + have hP0 : 0 < minorArcFirstLower A H := by unfold minorArcFirstLower; positivity + have hPL : Real.log H ≤ minorArcFirstLower A H := + le_self_pow₀ hL1 (by omega : 5 * A ≠ 0) + have hPQ : minorArcFirstLower A H ≤ minorArcFirstUpper H := by + apply (le_div_iff₀ (pow_pos hL0 15)).mpr + simpa only [minorArcFirstLower, ← pow_add] using hsA + have hW2 : 2 ≤ Real.log H ^ 5 := + (by linarith : 2 ≤ Real.log H).trans (le_self_pow₀ hL1 (by norm_num : (5 : ℕ) ≠ 0)) + have hWP : 2 * Real.log H ^ 5 ≤ minorArcFirstLower A H := by + have hpow := pow_le_pow_right₀ (by linarith : 1 ≤ Real.log H ^ 5) hA + have hbase : 2 * Real.log H ^ 5 ≤ (Real.log H ^ 5) ^ 2 := by nlinarith + exact hbase.trans (by simpa only [pow_mul, minorArcFirstLower] using hpow) + have hQU : minorArcFirstUpper H ≤ H / Real.log H ^ 5 := + div_le_div_of_nonneg_left hH0.le (pow_pos hL0 5) + (pow_le_pow_right₀ hL1 (by norm_num : 5 ≤ 15)) + have h30 := Real.log_le_log (pow_pos hL0 30) hs30 + rw [Real.log_pow] at h30 + norm_num at h30 + have hlogQ : Real.log (minorArcFirstUpper H) = Real.log H - 15 * Real.log (Real.log H) := by + rw [minorArcFirstUpper, Real.log_div hH0.ne' (pow_ne_zero 15 hL0.ne'), Real.log_pow] + norm_num + have hhalf : Real.log H / 2 ≤ Real.log (minorArcFirstUpper H) := by rw [hlogQ]; linarith + exact ⟨hH, by linarith, hll, hL4.trans hPL, hLR.trans hPL, hWP, hPQ, hQU, + hhalf, by linarith⟩ + +theorem minor_arc_first_band_density_eventually (A : ℕ) (hA : 2 ≤ A) : + ∀ᶠ H : ℝ in atTop, + Real.log (minorArcFirstLower A H) / Real.log (minorArcFirstUpper H) ≤ + 10 * (A : ℝ) * Real.log (Real.log H) / Real.log H := by + filter_upwards [minor_arc_first_band_scale A 0 hA] with H hH + obtain ⟨_, hL, hLL, _, _, _, _, _, hhalf, _⟩ := hH + exact minor_arc_first_band_density A H (by linarith) (by linarith) hhalf + +theorem minor_arc_first_band_budget_eventually (A : ℕ) (hA : 500000 ≤ A) : + ∀ᶠ H : ℝ in atTop, + 8192 * (Real.log (Real.log (minorArcFirstUpper H)) + 1) ≤ + (1 / 100 : ℝ) * Real.log (minorArcFirstLower A H) := by + filter_upwards [minor_arc_first_band_scale A 0 (by omega)] with H hs + obtain ⟨hH, hL, hLL, hP, _hPR, _hPW, hPQ, hQU, _hhalf, _hQ⟩ := hs + apply minor_arc_first_band_budget A hA H hLL (by linarith) + exact hQU.trans (div_le_self (by linarith) (one_le_pow₀ (by linarith : 1 ≤ Real.log H))) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcFourthExpansion.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcFourthExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..43fb7f542683c5b68fa0b419d547d4cde8ca8566 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcFourthExpansion.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcGeometric + +namespace OAI + +/-! Exact finite fourth-moment expansion, before any sieve or rational +approximation is used. -/ + +namespace TwoPointCorrelations + +open Finset Complex +open scoped ComplexConjugate + +lemma minor_arc_fourth_power (z : ℂ) : + ‖z‖ ^ 4 = (z * z * conj z * conj z).re := by + rw [show ‖z‖ ^ 4 = (‖z‖ ^ 2) ^ 2 by ring, Complex.sq_norm] + simp only [Complex.normSq_apply, Complex.mul_re, Complex.mul_im, + Complex.conj_re, Complex.conj_im] + ring + +lemma minor_arc_fourth_sum {ι : Type*} (P : Finset ι) (f : ι → ℂ) : + ‖∑ p ∈ P, f p‖ ^ 4 = + ∑ p₁ ∈ P, ∑ p₂ ∈ P, ∑ p₃ ∈ P, ∑ p₄ ∈ P, + (f p₁ * f p₂ * conj (f p₃) * conj (f p₄)).re := by + have h₂ : (∑ p ∈ P, f p) * (∑ p ∈ P, f p) = + ∑ p₁ ∈ P, ∑ p₂ ∈ P, f p₁ * f p₂ := sum_mul_sum _ _ _ _ + have h₃ : (∑ p ∈ P, f p) * (∑ p ∈ P, f p) * conj (∑ p ∈ P, f p) = + ∑ p₁ ∈ P, ∑ p₂ ∈ P, ∑ p₃ ∈ P, f p₁ * f p₂ * conj (f p₃) := by + rw [h₂, map_sum] + simp only [sum_mul] + simp only [mul_sum] + rw [minor_arc_fourth_power, h₃, map_sum] + simp only [sum_mul] + simp only [mul_sum, Complex.re_sum] + +lemma minor_arc_fourth_moment_expansion {ι : Type*} (P : Finset ι) + (S : Finset ℕ) (f : ι → ℕ → ℂ) : + (∑ m ∈ S, ‖∑ p ∈ P, f p m‖ ^ 4) = + ∑ p₁ ∈ P, ∑ p₂ ∈ P, ∑ p₃ ∈ P, ∑ p₄ ∈ P, + (∑ m ∈ S, f p₁ m * f p₂ m * conj (f p₃ m) * conj (f p₄ m)).re := by + simp_rw [minor_arc_fourth_sum] + rw [sum_comm] + apply sum_congr rfl + intro p₁ _ + rw [sum_comm] + apply sum_congr rfl + intro p₂ _ + rw [sum_comm] + apply sum_congr rfl + intro p₃ _ + rw [sum_comm] + apply sum_congr rfl + intro p₄ _ + rw [Complex.re_sum] + +lemma minor_arc_fourth_moment_bound {ι : Type*} (P : Finset ι) + (S : Finset ℕ) (f : ι → ℕ → ℂ) : + (∑ m ∈ S, ‖∑ p ∈ P, f p m‖ ^ 4) ≤ + ∑ p₁ ∈ P, ∑ p₂ ∈ P, ∑ p₃ ∈ P, ∑ p₄ ∈ P, + ‖∑ m ∈ S, f p₁ m * f p₂ m * conj (f p₃ m) * conj (f p₄ m)‖ := by + rw [minor_arc_fourth_moment_expansion] + repeat' apply sum_le_sum fun _ _ => ?_ + exact Complex.re_le_norm _ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcGeometric.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcGeometric.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b4ceb2998e0a20ae7425d5f2ef4fa5d73b77da2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcGeometric.lean @@ -0,0 +1,55 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShortSumSampling +import Mathlib.Algebra.Field.GeomSum + +namespace OAI + +/-! Literal interval exponential sums used in the minor-arc fourth moment. -/ + +namespace TwoPointCorrelations + +open Finset Complex + +lemma additiveCharacter_pow (α : ℝ) (n : ℕ) : + additiveCharacter α n = additiveCharacter α 1 ^ n := by + induction n with + | zero => simp [additiveCharacter] + | succ n ih => rw [additiveCharacter_nat_add, ih, pow_succ] + +lemma minor_arc_unit_geometric {z : ℂ} (hz : ‖z‖ = 1) (hz1 : z ≠ 1) (a b : ℕ) : + ‖∑ n ∈ Ico a b, z ^ n‖ ≤ 2 / ‖z - 1‖ := by + by_cases hab : a ≤ b + · have he := congrArg norm (geom_sum_Ico_mul z hab) + rw [norm_mul] at he + have hnorm : ‖z ^ b - z ^ a‖ ≤ 2 := by + simpa only [norm_pow, hz, one_pow, one_add_one_eq_two] using norm_sub_le (z ^ b) (z ^ a) + exact (le_div_iff₀ (norm_pos_iff.mpr (sub_ne_zero.mpr hz1))).mpr (he.trans_le hnorm) + · simp [Ico_eq_empty_of_le (le_of_not_ge hab)] + positivity + +/-- The resonant case is kept explicit, rather than assigning an infinite +value to a reciprocal at zero. -/ +noncomputable def minorArcGeometricBound (L α : ℝ) : ℝ := + if additiveCharacter α 1 = 1 then L + else min L (2 / ‖additiveCharacter α 1 - 1‖) + +lemma minor_arc_geometric_bound (α : ℝ) (a b : ℕ) : + ‖∑ n ∈ Ico a b, additiveCharacter α n‖ ≤ + minorArcGeometricBound ((b - a : ℕ) : ℝ) α := by + have htriv : ‖∑ n ∈ Ico a b, additiveCharacter α n‖ ≤ ((b - a : ℕ) : ℝ) := by + apply (norm_sum_le _ _).trans + simp only [norm_additiveCharacter, sum_const, Nat.card_Ico, nsmul_eq_mul, mul_one] + exact le_rfl + unfold minorArcGeometricBound + split_ifs with hz + · exact htriv + · apply le_min htriv + have h := minor_arc_unit_geometric (norm_additiveCharacter α 1) hz a b + have he : (∑ n ∈ Ico a b, additiveCharacter α n) = + ∑ n ∈ Ico a b, additiveCharacter α 1 ^ n := + sum_congr rfl (fun n _ => additiveCharacter_pow α n) + rw [← he] at h + exact h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcHolder.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcHolder.lean new file mode 100644 index 0000000000000000000000000000000000000000..feb1b4d9b70dd32913cc91449a5df88ac61520ba --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcHolder.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcWindowFourth +import Mathlib.Algebra.Order.Chebyshev + +namespace OAI + +/-! The finite fourth-power Hölder step for the minor-arc cofactor sum. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma minor_arc_sum_fourth {ι : Type*} (S : Finset ι) (a : ι → ℝ) : + (∑ i ∈ S, a i) ^ 4 ≤ (S.card : ℝ) ^ 3 * ∑ i ∈ S, a i ^ 4 := by + have h₁ := sq_sum_le_card_mul_sum_sq (s := S) (f := a) + have h₂ := sq_sum_le_card_mul_sum_sq (s := S) (f := fun i => a i ^ 2) + calc + _ = ((∑ i ∈ S, a i) ^ 2) ^ 2 := by ring + _ ≤ ((S.card : ℝ) * ∑ i ∈ S, a i ^ 2) ^ 2 := + pow_le_pow_left₀ (sq_nonneg _) h₁ 2 + _ = (S.card : ℝ) ^ 2 * (∑ i ∈ S, a i ^ 2) ^ 2 := mul_pow _ _ _ + _ ≤ (S.card : ℝ) ^ 2 * ((S.card : ℝ) * ∑ i ∈ S, (a i ^ 2) ^ 2) := + mul_le_mul_of_nonneg_left h₂ (sq_nonneg _) + _ = _ := by simp only [← pow_mul]; ring + +lemma minor_arc_weighted_fourth {ι : Type*} (S : Finset ι) (a b : ι → ℂ) + (ha : ∀ i ∈ S, ‖a i‖ ≤ 1) : + ‖∑ i ∈ S, a i * b i‖ ^ 4 ≤ (S.card : ℝ) ^ 3 * ∑ i ∈ S, ‖b i‖ ^ 4 := by + have hn : ‖∑ i ∈ S, a i * b i‖ ≤ ∑ i ∈ S, ‖b i‖ := by + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro i hi + rw [norm_mul] + simpa only [one_mul] using mul_le_mul_of_nonneg_right (ha i hi) (norm_nonneg (b i)) + exact (pow_le_pow_left₀ (norm_nonneg _) hn 4).trans (minor_arc_sum_fourth S (fun i => ‖b i‖)) + +/-- Polarizing the finite origin sum produces a coefficient of norm one +at every origin, including origins where the short sum vanishes. -/ +lemma minor_arc_norm_sum_duality (S : Finset ℕ) (f : ℕ → ℂ) : + ∃ θ : ℕ → ℂ, (∀ k, ‖θ k‖ = 1) ∧ + (∑ k ∈ S, ‖f k‖) = ‖∑ k ∈ S, θ k * f k‖ := by + classical + choose θ hθnorm hθmul using (fun k => Complex.exists_norm_eq_mul_self (f k)) + refine ⟨θ, hθnorm, ?_⟩ + have he : (∑ k ∈ S, θ k * f k) = ((∑ k ∈ S, ‖f k‖ : ℝ) : ℂ) := by + rw [Complex.ofReal_sum] + exact sum_congr rfl (fun k _ => (hθmul k).symm) + rw [he, Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (sum_nonneg (fun k _ => norm_nonneg (f k)))] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcKernelSymmetry.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcKernelSymmetry.lean new file mode 100644 index 0000000000000000000000000000000000000000..a52c24ec542dab9c65ffc4e8c44b3e8910406d8b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcKernelSymmetry.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcGeometric + +namespace OAI + +/-! Positivity and reflection symmetry of the resonant-safe geometric kernel. -/ + +namespace TwoPointCorrelations + +open Complex +open scoped ComplexConjugate + +lemma minor_arc_geometric_nonneg {L : ℝ} (hL : 0 ≤ L) (α : ℝ) : + 0 ≤ minorArcGeometricBound L α := by + unfold minorArcGeometricBound + split_ifs + · exact hL + · exact le_min hL (by positivity) + +lemma minor_arc_character_neg (α : ℝ) (n : ℕ) : + additiveCharacter (-α) n = conj (additiveCharacter α n) := by + simp only [additiveCharacter, ← Complex.exp_conj, map_mul, + Complex.conj_ofReal, Complex.conj_I] + congr 1 + push_cast + ring + +lemma minor_arc_geometric_neg (L α : ℝ) : + minorArcGeometricBound L (-α) = minorArcGeometricBound L α := by + have hc : conj (additiveCharacter α 1) = 1 ↔ additiveCharacter α 1 = 1 := by + constructor + · intro h + have he := congrArg conj h + simpa only [map_one, conj_conj] using he + · intro h + rw [h, map_one] + unfold minorArcGeometricBound + rw [minor_arc_character_neg] + by_cases h : additiveCharacter α 1 = 1 + · rw [ite_eq_left (hc.mpr h), ite_eq_left h] + · rw [ite_eq_right ((not_congr hc).mpr h), ite_eq_right h] + have he : conj (additiveCharacter α 1) - 1 = conj (additiveCharacter α 1 - 1) := by + rw [map_sub, map_one] + rw [he, norm_conj] + +lemma minor_arc_geometric_natAbs (L α : ℝ) (n : ℤ) : + minorArcGeometricBound L ((n.natAbs : ℝ) * α) = + minorArcGeometricBound L ((n : ℝ) * α) := by + have he : (n.natAbs : ℝ) = |(n : ℝ)| := by + have h := congrArg (fun z : ℤ => (z : ℝ)) (Int.natCast_natAbs n) + simpa only [Int.cast_natCast, Int.cast_abs] using h + rw [he] + by_cases hn : (0 : ℝ) ≤ n + · rw [abs_of_nonneg hn] + · rw [abs_of_neg (lt_of_not_ge hn), neg_mul, minor_arc_geometric_neg] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcLogLog.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcLogLog.lean new file mode 100644 index 0000000000000000000000000000000000000000..72397361bc8c8d18208f19290206438ac36fd367 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcLogLog.lean @@ -0,0 +1,38 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcTypicalSaving + +namespace OAI + +/-! The dyadic index count contributes only a logarithm of a logarithm. -/ + +namespace TwoPointCorrelations + +lemma minor_arc_log_index_bound (H : ℕ) (hH : 1 ≤ H) : + (Nat.log 2 H : ℝ) ≤ 2 * Real.log (H : ℝ) := by + have hH0 : H ≠ 0 := by omega + have hp : (2 : ℝ) ^ Nat.log 2 H ≤ H := by + exact_mod_cast Nat.pow_log_le_self 2 hH0 + have hl := Real.log_le_log (by positivity : (0 : ℝ) < 2 ^ Nat.log 2 H) hp + rw [Real.log_pow] at hl + have hhalf : (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 hm := mul_le_mul_of_nonneg_left hhalf (Nat.cast_nonneg (Nat.log 2 H) : + (0 : ℝ) ≤ Nat.log 2 H) + nlinarith + +lemma minor_arc_dyadic_log_log_bound (H : ℕ) (hH : 2 ≤ H) + (hlogH : 1 ≤ Real.log (H : ℝ)) (hloglogH : 1 ≤ Real.log (Real.log (H : ℝ))) : + 1 + Real.log (Nat.log 2 H : ℝ) ≤ 3 * Real.log (Real.log (H : ℝ)) := by + have hindex : 0 < Nat.log 2 H := lt_of_lt_of_le (by norm_num) + (minor_arc_dyadic_index_pos hH) + have hindex0 : (0 : ℝ) < Nat.log 2 H := by exact_mod_cast hindex + have hlog0 : 0 < Real.log (H : ℝ) := by linarith + have hh := Real.log_le_log hindex0 (minor_arc_log_index_bound H (by omega)) + rw [Real.log_mul (by norm_num : (2 : ℝ) ≠ 0) hlog0.ne'] at hh + have htwo := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcLogSaving.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcLogSaving.lean new file mode 100644 index 0000000000000000000000000000000000000000..d8ecffc7f2f1720d4c7edca3509e3498ceede165 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcLogSaving.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcDyadicSieve +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcDyadicWindows + +namespace OAI + +/-! Taking the fourth root after choosing the published minor-arc +parameter `W = (log H)^5`. -/ + +namespace TwoPointCorrelations + +open Finset Filter + +lemma minor_arc_log_fourth_root (D S X H R : ℝ) (hD : 0 ≤ D) (hX : 0 ≤ X) + (hH : 0 < H) (hlogH : 1 ≤ Real.log H) (hlogR : 0 < Real.log R) + (hbound : S ^ 4 ≤ D * X ^ 4 * H ^ 4 * (1 + Real.log (2 * H)) / + (Real.log H ^ 5 * Real.log R ^ 4)) : + S ≤ (3 * D + 1) * X * H / (Real.log H * Real.log R) := by + have hL : 0 < Real.log H := by linarith + have hlog : 1 + Real.log (2 * H) ≤ 3 * Real.log H := by + rw [Real.log_mul (by norm_num : (2 : ℝ) ≠ 0) hH.ne'] + have htwo := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + linarith + have hK : 1 ≤ 3 * D + 1 := by linarith + have hKpow : 3 * D ≤ (3 * D + 1) ^ 4 := by + have hp := pow_le_pow_right₀ hK (by omega : 1 ≤ 4) + simp only [pow_one] at hp + linarith + have hs : S ^ 4 ≤ 3 * D * (X * H / (Real.log H * Real.log R)) ^ 4 := by + calc + _ ≤ D * X ^ 4 * H ^ 4 * (1 + Real.log (2 * H)) / + (Real.log H ^ 5 * Real.log R ^ 4) := hbound + _ ≤ D * X ^ 4 * H ^ 4 * (3 * Real.log H) / + (Real.log H ^ 5 * Real.log R ^ 4) := by + apply div_le_div_of_nonneg_right _ (by positivity) + exact mul_le_mul_of_nonneg_left hlog (by positivity) + _ = _ := by field_simp [hL.ne', hlogR.ne'] + apply le_of_pow_le_pow_left₀ (by norm_num : (4 : ℕ) ≠ 0) (by positivity) + calc + S ^ 4 ≤ 3 * D * (X * H / (Real.log H * Real.log R)) ^ 4 := hs + _ ≤ (3 * D + 1) ^ 4 * (X * H / (Real.log H * Real.log R)) ^ 4 := + mul_le_mul_of_nonneg_right hKpow (by positivity) + _ = _ := by ring + +theorem minor_arc_dyadic_log_saving : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ R : ℕ in atTop, + ∀ (P : Finset ℕ) (X H : ℕ), 1 ≤ H → H ≤ X → R ≤ X → + 1 ≤ Real.log (H : ℝ) → + (∀ p ∈ P, p.Prime ∧ p ≠ 2 ∧ R ≤ p ∧ p ≤ 2 * R) → + ∀ (a c : ℕ → ℂ), (∀ m, ‖a m‖ ≤ 1) → (∀ p ∈ P, ‖c p‖ ≤ 1) → + (Real.log (H : ℝ)) ^ 5 ≤ (R : ℝ) → + (R : ℝ) ≤ (H : ℝ) / (Real.log (H : ℝ)) ^ 5 → + ∀ (r : ℤ) (q : ℕ), 2 ≤ q → + (Real.log (H : ℝ)) ^ 5 ≤ (q : ℝ) → + (q : ℝ) ≤ (H : ℝ) / (Real.log (H : ℝ)) ^ 5 → + ∀ α : ℝ, IsCoprime (q : ℤ) r → + |α - (r : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2 → + (∑ k ∈ range X, ‖minorArcBilinearWindow P ((X + H) / R + 1) H 1 a c α k‖) ≤ + C * (X : ℝ) * H / (Real.log (H : ℝ) * Real.log (R : ℝ)) := by + obtain ⟨D, hD, hbound⟩ := minor_arc_dyadic_bilinear_sieve + refine ⟨3 * D + 1, by positivity, ?_⟩ + filter_upwards [hbound, eventually_ge_atTop 2] with R hbound hR + intro P X H hH hHX hRX hlogH hP a c ha hc hWR hRH r q hq hWq hqH α hcop happ + have hH0 : (0 : ℝ) < H := by exact_mod_cast (by omega : 0 < H) + have hlogR : 0 < Real.log (R : ℝ) := + Real.log_pos (by exact_mod_cast (by omega : 1 < R)) + have hW : 1 ≤ (Real.log (H : ℝ)) ^ 5 := one_le_pow₀ hlogH + have hh := hbound P X H hH hHX hRX hP a c ha hc + ((Real.log (H : ℝ)) ^ 5) hW hWR hRH r q hq hWq hqH α hcop happ + exact minor_arc_log_fourth_root D _ X H R hD.le (Nat.cast_nonneg X) hH0 hlogH hlogR hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcOriginCount.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcOriginCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..809cc414f3f469ef192f4f0da07127b654aed27e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcOriginCount.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcOriginGeometry + +namespace OAI + +/-! The support of four simultaneous short windows has size `O(X H³)`. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma minor_arc_origin_interval_card (c H : ℕ) : + (Icc (c - H) (c + 2 * H)).card ≤ 3 * H + 1 := by + rw [Nat.card_Icc] + omega + +/-- Only the first origin costs `X`; each of the other three origins +costs at most `3H+1`, independently of the prime quadruple. -/ +theorem minor_arc_origin_quadruples (X H A B C D : ℕ) (hA : 0 < A) + (hB : B ≤ 2 * A) (hC : C ≤ 2 * A) (hD : D ≤ 2 * A) + (T : Finset ((ℕ × ℕ) × (ℕ × ℕ))) + (hT : ∀ v ∈ T, v.1.1 < X ∧ ∃ m : ℕ, + (v.1.1 < A * m ∧ A * m ≤ v.1.1 + H) ∧ + (v.1.2 < B * m ∧ B * m ≤ v.1.2 + H) ∧ + (v.2.1 < C * m ∧ C * m ≤ v.2.1 + H) ∧ + (v.2.2 < D * m ∧ D * m ≤ v.2.2 + H)) : + T.card ≤ X * (3 * H + 1) ^ 3 := by + let box := fun k => + ({k} ×ˢ Icc ((B * k) / A - H) ((B * k) / A + 2 * H)) ×ˢ + (Icc ((C * k) / A - H) ((C * k) / A + 2 * H) ×ˢ + Icc ((D * k) / A - H) ((D * k) / A + 2 * H)) + have hsub : T ⊆ (range X).biUnion box := by + rintro ⟨⟨k, l⟩, ⟨r, s⟩⟩ hv + obtain ⟨hkX, m, hk, hl, hr, hs⟩ := hT _ hv + apply mem_biUnion.mpr + refine ⟨k, mem_range.mpr hkX, ?_⟩ + dsimp [box] + simp only [mem_product, mem_singleton, mem_Icc] + exact ⟨⟨True.intro, minor_arc_origin_bounds A B H k l m hA hB hk hl⟩, + minor_arc_origin_bounds A C H k r m hA hC hk hr, + minor_arc_origin_bounds A D H k s m hA hD hk hs⟩ + have hbox (k : ℕ) : (box k).card ≤ (3 * H + 1) ^ 3 := by + dsimp [box] + simp only [card_product, card_singleton, one_mul] + have h₁ := minor_arc_origin_interval_card ((B * k) / A) H + have h₂ := minor_arc_origin_interval_card ((C * k) / A) H + have h₃ := minor_arc_origin_interval_card ((D * k) / A) H + calc + _ ≤ (3 * H + 1) * ((3 * H + 1) * (3 * H + 1)) := + Nat.mul_le_mul h₁ (Nat.mul_le_mul h₂ h₃) + _ = _ := by ring + calc + T.card ≤ ((range X).biUnion box).card := card_le_card hsub + _ ≤ ∑ k ∈ range X, (box k).card := card_biUnion_le + _ ≤ ∑ _k ∈ range X, (3 * H + 1) ^ 3 := sum_le_sum (fun k _ => hbox k) + _ = X * (3 * H + 1) ^ 3 := by simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcOriginGeometry.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcOriginGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc2f6040c70e77e6046b8ac931db80f99e5ecf63 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcOriginGeometry.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcGeometric +import Mathlib.Tactic + +namespace OAI + +/-! Discrete interval origins: simultaneous prime windows occupy only a +bounded number of origins once the first origin is fixed. -/ + +namespace TwoPointCorrelations + +open Finset + +/-- For factors in a dyadic block, all other origins lie within three +interval lengths of the scaled first origin. This also applies to factors +`d*p`, so the same geometry survives the multiplicative correction. -/ +lemma minor_arc_origin_bounds (A B H k l m : ℕ) (hA : 0 < A) + (hB : B ≤ 2 * A) (hk : k < A * m ∧ A * m ≤ k + H) + (hl : l < B * m ∧ B * m ≤ l + H) : + (B * k) / A - H ≤ l ∧ l ≤ (B * k) / A + 2 * H := by + let c := (B * k) / A + have hlo : A * c ≤ B * k := Nat.mul_div_le _ _ + have hhi : B * k < A * (c + 1) := Nat.lt_mul_div_succ _ hA + have hlow : c ≤ B * m := by + by_cases hB0 : B = 0 + · simp [c, hB0] + · have hBpos : 0 < B := Nat.pos_of_ne_zero hB0 + have hmul : A * c < A * (B * m) := by nlinarith [hk.1] + exact (Nat.le_of_lt ((Nat.mul_lt_mul_left hA).mp hmul)) + constructor + · change c - H ≤ l + omega + · change l ≤ c + 2 * H + have hmul₁ : A * l < A * (B * m) := Nat.mul_lt_mul_of_pos_left hl.1 hA + have hmul₂ : A * (B * m) ≤ B * k + B * H := by + nlinarith [hk.2] + have hmul₃ : B * H ≤ 2 * A * H := Nat.mul_le_mul_right H hB + have hmul : A * l < A * (c + 2 * H + 1) := by nlinarith + have := (Nat.mul_lt_mul_left hA).mp hmul + omega + +lemma minor_arc_origin_count (X A B H k m : ℕ) (hA : 0 < A) + (hB : B ≤ 2 * A) (hk : k < A * m ∧ A * m ≤ k + H) : + ((range X).filter (fun l => l < B * m ∧ B * m ≤ l + H)).card ≤ 3 * H + 1 := by + have hs : (range X).filter (fun l => l < B * m ∧ B * m ≤ l + H) ⊆ + Icc ((B * k) / A - H) ((B * k) / A + 2 * H) := by + intro l hl + exact mem_Icc.mpr (minor_arc_origin_bounds A B H k l m hA hB hk (mem_filter.mp hl).2) + apply (card_le_card hs).trans + rw [Nat.card_Icc] + omega + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcOriginSum.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcOriginSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d775d1f3f305fa9cacc0df081449d7f85a9c705 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcOriginSum.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcWindowProduct +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcOriginCount +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcKernelSymmetry + +namespace OAI + +/-! Summing a fixed prime quadruple over its possible interval origins. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical ComplexConjugate + +lemma minor_arc_origin_kernel_sum (X M A B C D H : ℕ) (hA : 0 < A) + (hB0 : 0 < B) (hC0 : 0 < C) (hD0 : 0 < D) + (hB : B ≤ 2 * A) (hC : C ≤ 2 * A) (hD : D ≤ 2 * A) + (z₁ z₂ z₃ z₄ : ℕ → ℂ) (hz₁ : ∀ k, ‖z₁ k‖ ≤ 1) (hz₂ : ∀ k, ‖z₂ k‖ ≤ 1) + (hz₃ : ∀ k, ‖z₃ k‖ ≤ 1) (hz₄ : ∀ k, ‖z₄ k‖ ≤ 1) + (β₁ β₂ β₃ β₄ V : ℝ) (hV : (H : ℝ) / A + 1 ≤ V) : + (∑ k ∈ range X, ∑ l ∈ range X, ∑ r ∈ range X, ∑ s ∈ range X, + ‖∑ m ∈ range M, + minorArcWindowTerm M A k H (z₁ k) β₁ m * minorArcWindowTerm M B l H (z₂ l) β₂ m * + conj (minorArcWindowTerm M C r H (z₃ r) β₃ m) * + conj (minorArcWindowTerm M D s H (z₄ s) β₄ m)‖) ≤ + (X * (3 * H + 1) ^ 3 : ℕ) * minorArcGeometricBound V (β₁ + β₂ - β₃ - β₄) := by + let Q := ((range X) ×ˢ (range X)) ×ˢ ((range X) ×ˢ (range X)) + let S := fun v : (ℕ × ℕ) × (ℕ × ℕ) => + (minorArcWindowInterval M A v.1.1 H ∩ minorArcWindowInterval M B v.1.2 H) ∩ + (minorArcWindowInterval M C v.2.1 H ∩ minorArcWindowInterval M D v.2.2 H) + let T := Q.filter (fun v => (S v).Nonempty) + let K := minorArcGeometricBound V (β₁ + β₂ - β₃ - β₄) + have hV0 : 0 ≤ V := by + have h : 0 ≤ (H : ℝ) / A := div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) + linarith + have hK : 0 ≤ K := minor_arc_geometric_nonneg hV0 _ + have hcard : T.card ≤ X * (3 * H + 1) ^ 3 := by + apply minor_arc_origin_quadruples X H A B C D hA hB hC hD T + rintro ⟨⟨k, l⟩, ⟨r, s⟩⟩ hv + obtain ⟨hvQ, m, hm⟩ := mem_filter.mp hv + have hkX := (mem_product.mp (mem_product.mp hvQ).1).1 + obtain ⟨hm₁, hm₂⟩ := mem_inter.mp hm + obtain ⟨hmA, hmB⟩ := mem_inter.mp hm₁ + obtain ⟨hmC, hmD⟩ := mem_inter.mp hm₂ + exact ⟨mem_range.mp hkX, m, + ((mem_minorArcWindowInterval M A k H m hA).mp hmA).2, + ((mem_minorArcWindowInterval M B l H m hB0).mp hmB).2, + ((mem_minorArcWindowInterval M C r H m hC0).mp hmC).2, + ((mem_minorArcWindowInterval M D s H m hD0).mp hmD).2⟩ + have hz (k l r s : ℕ) : ‖z₁ k * z₂ l * conj (z₃ r) * conj (z₄ s)‖ ≤ 1 := by + simp only [norm_mul, Complex.norm_conj] + calc + ‖z₁ k‖ * ‖z₂ l‖ * ‖z₃ r‖ * ‖z₄ s‖ ≤ 1 * 1 * 1 * 1 := by + gcongr <;> first | exact hz₁ _ | exact hz₂ _ | exact hz₃ _ | exact hz₄ _ + _ = 1 := by norm_num + calc + _ ≤ ∑ k ∈ range X, ∑ l ∈ range X, ∑ r ∈ range X, ∑ s ∈ range X, + if (S ((k, l), (r, s))).Nonempty then K else 0 := by + repeat' apply sum_le_sum fun _ _ => ?_ + exact minor_arc_window_product_support M A B C D _ _ _ _ H hA _ _ _ _ + β₁ β₂ β₃ β₄ V (hz _ _ _ _) hV + _ = ∑ v ∈ Q, if (S v).Nonempty then K else 0 := by + simp only [Q, sum_product] + _ = (T.card : ℝ) * K := by + rw [← sum_filter] + simp only [T, sum_const, nsmul_eq_mul] + _ ≤ _ := mul_le_mul_of_nonneg_right ((Nat.cast_le (α := ℝ)).mpr hcard) hK + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPacking.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPacking.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5a3090d68f98d2b0531148fa774c617888d67f8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPacking.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcRationalSpacing + +namespace OAI + +/-! Elementary interval packing for separated phase representatives. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma minor_arc_interval_packing {ι : Type*} (S : Finset ι) (x : ι → ℝ) + (δ b : ℝ) (hsep : ∀ i ∈ S, ∀ j ∈ S, i ≠ j → δ ≤ |x i - x j|) : + (S.filter (fun i => b ≤ x i ∧ x i < b + δ)).card ≤ 1 := by + apply card_le_one.mpr + intro i hi j hj + obtain ⟨hiS, hix⟩ := mem_filter.mp hi + obtain ⟨hjS, hjx⟩ := mem_filter.mp hj + by_contra hij + have hh := hsep i hiS j hjS hij + have habs : |x i - x j| < δ := abs_lt.mpr ⟨by linarith, by linarith⟩ + linarith + +lemma minor_arc_absolute_band_packing {ι : Type*} (S : Finset ι) (x : ι → ℝ) + (δ b : ℝ) + (hsep : ∀ i ∈ S, ∀ j ∈ S, i ≠ j → δ ≤ |x i - x j|) : + (S.filter (fun i => b ≤ |x i| ∧ |x i| < b + δ)).card ≤ 2 := by + let P := S.filter (fun i => b ≤ x i ∧ x i < b + δ) + let Q := S.filter (fun i => b ≤ -x i ∧ -x i < b + δ) + have hP : P.card ≤ 1 := minor_arc_interval_packing S x δ b hsep + have hQ : Q.card ≤ 1 := by + apply minor_arc_interval_packing S (fun i => -x i) δ b + intro i hi j hj hij + simpa only [neg_sub_neg, abs_sub_comm] using hsep i hi j hj hij + have hsub : S.filter (fun i => b ≤ |x i| ∧ |x i| < b + δ) ⊆ P ∪ Q := by + intro i hi + obtain ⟨hiS, hix⟩ := mem_filter.mp hi + by_cases hx : 0 ≤ x i + · apply mem_union_left + exact mem_filter.mpr ⟨hiS, by simpa only [abs_of_nonneg hx] using hix⟩ + · apply mem_union_right + exact mem_filter.mpr ⟨hiS, by simpa only [abs_of_neg (lt_of_not_ge hx)] using hix⟩ + have hu := (card_le_card hsub).trans (card_union_le P Q) + omega + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPackingSum.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPackingSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..8066e7886f5c11d3d40443e644b4b58c156c4f68 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPackingSum.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcPacking +import Mathlib.NumberTheory.Harmonic.Bounds + +namespace OAI + +/-! Summing a truncated reciprocal over separated real representatives. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem minor_arc_packing_sum {ι : Type*} (S : Finset ι) (x w : ι → ℝ) + (δ V R : ℝ) (hδ : 0 < δ) (hV : 0 ≤ V) + (hsep : ∀ i ∈ S, ∀ j ∈ S, i ≠ j → δ ≤ |x i - x j|) + (hx : ∀ i ∈ S, |x i| ≤ R) (hw : ∀ i ∈ S, w i ≤ V) + (hwinv : ∀ i ∈ S, 0 < |x i| → w i ≤ 1 / |x i|) : + (∑ i ∈ S, w i) ≤ 2 * V + (2 / δ) * (1 + Real.log (⌈R / δ⌉₊ : ℝ)) := by + let L := ⌈R / δ⌉₊ + let b := fun i => ⌊|x i| / δ⌋₊ + let F := fun j : ℕ => S.filter (fun i => b i = j) + have hindex (i : ι) (hi : i ∈ S) : b i ≤ L := by + apply Nat.floor_le_of_le + exact (div_le_div_of_nonneg_right (hx i hi) hδ.le).trans (Nat.le_ceil _) + have hband (j : ℕ) (i : ι) (hi : i ∈ F j) : + (j : ℝ) * δ ≤ |x i| ∧ |x i| < (j : ℝ) * δ + δ := by + have he : b i = j := (mem_filter.mp hi).2 + have hl := Nat.floor_le (div_nonneg (abs_nonneg (x i)) hδ.le) + have hu := Nat.lt_floor_add_one (|x i| / δ) + change ((b i : ℕ) : ℝ) ≤ |x i| / δ at hl + change |x i| / δ < (b i : ℝ) + 1 at hu + rw [he] at hl hu + constructor + · exact (le_div_iff₀ hδ).mp hl + · have hh := (div_lt_iff₀ hδ).mp hu + nlinarith + have hcard (j : ℕ) : (F j).card ≤ 2 := by + refine (card_le_card (s := F j) (t := S.filter (fun i => + (j : ℝ) * δ ≤ |x i| ∧ |x i| < (j : ℝ) * δ + δ)) ?_).trans + (minor_arc_absolute_band_packing S x δ ((j : ℝ) * δ) hsep) + intro i hi + exact mem_filter.mpr ⟨(mem_filter.mp hi).1, hband j i hi⟩ + have hzero : (∑ i ∈ F 0, w i) ≤ 2 * V := by + calc + _ ≤ ∑ _i ∈ F 0, V := sum_le_sum (fun i hi => hw i (mem_filter.mp hi).1) + _ = ((F 0).card : ℝ) * V := by simp + _ ≤ 2 * V := mul_le_mul_of_nonneg_right (by exact_mod_cast hcard 0) hV + have hpiece (j : ℕ) (hj : j ∈ Icc 1 L) : (∑ i ∈ F j, w i) ≤ 2 / (δ * j) := by + have hj0 : (0 : ℝ) < j := by exact_mod_cast (mem_Icc.mp hj).1 + have hbound (i : ι) (hi : i ∈ F j) : w i ≤ 1 / (δ * j) := by + have hlo := (hband j i hi).1 + have hpos : 0 < |x i| := (mul_pos hj0 hδ).trans_le hlo + apply (hwinv i (mem_filter.mp hi).1 hpos).trans + exact one_div_le_one_div_of_le (mul_pos hδ hj0) (by nlinarith) + calc + _ ≤ ∑ _i ∈ F j, 1 / (δ * j) := sum_le_sum hbound + _ = ((F j).card : ℝ) * (1 / (δ * j)) := by simp + _ ≤ 2 * (1 / (δ * j)) := + mul_le_mul_of_nonneg_right (by exact_mod_cast hcard j) (by positivity) + _ = _ := by ring + have hpartition : (∑ i ∈ S, w i) = ∑ j ∈ Icc 0 L, ∑ i ∈ F j, w i := by + symm + exact sum_fiberwise_of_maps_to (fun i hi => mem_Icc.mpr ⟨Nat.zero_le _, hindex i hi⟩) _ + have hsplit : (∑ j ∈ Icc 0 L, ∑ i ∈ F j, w i) = + (∑ i ∈ F 0, w i) + ∑ j ∈ Icc 1 L, ∑ i ∈ F j, w i := by + have he : Icc 0 L = insert 0 (Icc 1 L) := by + ext j + simp only [mem_Icc, mem_insert] + omega + rw [he, sum_insert (by simp)] + have hharm : (∑ j ∈ Icc 1 L, 2 / (δ * j)) ≤ + (2 / δ) * (1 + Real.log (L : ℝ)) := by + calc + _ = (2 / δ) * (harmonic L : ℝ) := by + rw [harmonic_eq_sum_Icc] + push_cast + rw [mul_sum] + apply sum_congr rfl + intro j _ + ring + _ ≤ _ := mul_le_mul_of_nonneg_left (harmonic_le_one_add_log L) (by positivity) + rw [hpartition, hsplit] + exact add_le_add hzero ((sum_le_sum hpiece).trans hharm) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameterIntegral.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameterIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e7af307c9c121c2e047facfd63b7b6a19573b92 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameterIntegral.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcParameterSaving + +namespace OAI + +/-! Summing the minor-arc estimate over the actual dyadic prime blocks. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +theorem minor_arc_bilinear_parameter_saving : + ∃ C : ℝ, 0 < C ∧ ∃ R₀ : ℕ, + ∀ (P J : Finset ℕ) (X H N : ℕ), 1 ≤ H → H ≤ X → + 1 ≤ Real.log (H : ℝ) → J ⊆ Icc 1 N → + (∀ p ∈ P, Nat.log 2 p ∈ J) → (∀ p ∈ P, p.Prime ∧ p ≠ 2) → + (∀ j ∈ J, R₀ ≤ 2 ^ j ∧ 2 ^ j ≤ X) → + ∀ W : ℝ, 1 ≤ W → + (∀ j ∈ J, W ≤ (2 : ℝ) ^ j ∧ + (2 : ℝ) ^ j ≤ (H : ℝ) / W) → + ∀ (a c : ℕ → ℂ), (∀ m, ‖a m‖ ≤ 1) → (∀ p ∈ P, ‖c p‖ ≤ 1) → + ∀ (r : ℤ) (q : ℕ), 2 ≤ q → + W ≤ (q : ℝ) → + (q : ℝ) ≤ (H : ℝ) / W → + ∀ α : ℝ, IsCoprime (q : ℤ) r → + |α - (r : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2 → + (∑ k ∈ range X, ‖minorArcBilinearWindow P (X + H + 1) H 1 a c α k‖) ≤ + C * (X : ℝ) * H * (1 + Real.log (N : ℝ)) * (Real.log (H : ℝ)/W)^(1/4:ℝ) := by + obtain ⟨D, hD, hbound⟩ := minor_arc_dyadic_parameter_saving + obtain ⟨R₀, hR₀⟩ := eventually_atTop.mp hbound + have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) + refine ⟨D / Real.log 2, div_pos hD hlog2, R₀, ?_⟩ + intro P J X H N hH hHX hlogH hJN hPJ hP hR W hW hgeom a c ha hc r q hq hWq hqH α hcop happ + let M : ℕ → ℕ := fun j => (X + H) / 2 ^ j + 1 + have hcut : ∀ k ∈ range X, ∀ p ∈ P, (k + H) / (1 * p) < X + H + 1 := by + intro k hk p _ + have hkX := mem_range.mp hk + have hd := Nat.div_le_self (k + H) (1 * p) + omega + have hcuts : ∀ j ∈ J, ∀ k ∈ range X, ∀ p ∈ minorArcDyadicPrimes P j, + (k + H) / (1 * p) < M j := by + intro j hj k hk p hp + simp only [one_mul] + exact minor_arc_cofactor_cutoff X H (2 ^ j) p k (by positivity) + (minor_arc_dyadic_primes_bounds P j p hp (hP p (mem_filter.mp hp).1).1.pos).1 + (mem_range.mp hk) + let K : ℝ := D * (X : ℝ) * H * (Real.log (H : ℝ)/W)^(1/4:ℝ) + have hK : 0 ≤ K := by dsimp [K]; positivity + have hblock : ∀ j ∈ J, + (∑ k ∈ range X, ‖minorArcBilinearWindow (minorArcDyadicPrimes P j) (M j) H 1 a c α k‖) ≤ + K / Real.log ((2 : ℝ) ^ j) := by + intro j hj + have hprime : ∀ p ∈ minorArcDyadicPrimes P j, + p.Prime ∧ p ≠ 2 ∧ 2 ^ j ≤ p ∧ p ≤ 2 * 2 ^ j := by + intro p hp + have hpP := (mem_filter.mp hp).1 + exact ⟨(hP p hpP).1, (hP p hpP).2, + minor_arc_dyadic_primes_bounds P j p hp (hP p hpP).1.pos⟩ + have hh := hR₀ (2 ^ j) (hR j hj).1 (minorArcDyadicPrimes P j) X H + hH hHX (hR j hj).2 hlogH hprime a c ha + (fun p hp => hc p (mem_filter.mp hp).1) + W hW (by simpa only [Nat.cast_pow, Nat.cast_ofNat] using (hgeom j hj).1) + (by simpa only [Nat.cast_pow, Nat.cast_ofNat] using (hgeom j hj).2) + r q hq hWq hqH α hcop happ + dsimp [M, K] + convert hh using 1 + push_cast + ring + calc + _ ≤ ∑ j ∈ J, ∑ k ∈ range X, + ‖minorArcBilinearWindow (minorArcDyadicPrimes P j) (M j) H 1 a c α k‖ := + minor_arc_bilinear_dyadic_sum_le J P hPJ X (X + H + 1) H 1 M hcut hcuts a c α + _ ≤ K * (1 + Real.log (N : ℝ)) / Real.log 2 := + minor_arc_weighted_dyadic_log_sum J N hJN K hK _ hblock + _ = _ := by dsimp [K]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameterRanges.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameterRanges.lean new file mode 100644 index 0000000000000000000000000000000000000000..8659285eb8be8fe30451a70657876129a68785aa --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameterRanges.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcLogLog +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcParameterTypical + +namespace OAI + +/-! Verifying every dyadic hypothesis from the actual prime range. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma minor_arc_parameter_range_dyadics (P : Finset ℕ) (H R₀ : ℕ) + (hP : ∀ p ∈ P, p.Prime) (W : ℝ) (hW : 1 ≤ W) + (hrange : ∀ p ∈ P, 2 * R₀ ≤ p ∧ + 2 * W ≤ (p : ℝ) ∧ + (p : ℝ) ≤ (H : ℝ) / W) : + let J := P.image (Nat.log 2) + J ⊆ Icc 1 (Nat.log 2 H) ∧ + (∀ p ∈ P, Nat.log 2 p ∈ J) ∧ + (∀ j ∈ J, R₀ ≤ 2 ^ j ∧ 2 ^ j ≤ H) ∧ + (∀ j ∈ J, W ≤ (2 : ℝ) ^ j ∧ + (2 : ℝ) ^ j ≤ (H : ℝ) / W) := by + dsimp only + have hpH (p : ℕ) (hp : p ∈ P) : p ≤ H := by + have hh := (hrange p hp).2.2 + have hb : (p : ℝ) ≤ H := hh.trans (div_le_self (Nat.cast_nonneg H) hW) + exact_mod_cast hb + refine ⟨?_, fun p hp => mem_image.mpr ⟨p, hp, rfl⟩, ?_, ?_⟩ + · intro j hj + obtain ⟨p, hp, rfl⟩ := mem_image.mp hj + exact mem_Icc.mpr ⟨minor_arc_dyadic_index_pos (hP p hp).two_le, + Nat.log_mono_right (hpH p hp)⟩ + · intro j hj + obtain ⟨p, hp, rfl⟩ := mem_image.mp hj + have hd := minor_arc_dyadic_prime_bounds (hP p hp).pos rfl + constructor + · nlinarith [(hrange p hp).1, hd.2] + · exact hd.1.trans (hpH p hp) + · intro j hj + obtain ⟨p, hp, rfl⟩ := mem_image.mp hj + have hd := minor_arc_dyadic_prime_bounds (hP p hp).pos rfl + have hlo : (2 : ℝ) * (2 : ℝ) ^ Nat.log 2 p ≥ p := by exact_mod_cast hd.2 + have hhi : (2 : ℝ) ^ Nat.log 2 p ≤ p := by exact_mod_cast hd.1 + exact ⟨by linarith [(hrange p hp).2.1], hhi.trans (hrange p hp).2.2⟩ + +theorem minor_arc_typical_parameter_range_saving : + ∃ C : ℝ, 0 < C ∧ ∃ R₀ : ℕ, + ∀ {ι : Type*} (I : Finset ι) (P : ι → Finset ℕ), + (∀ i ∈ I, ∀ p ∈ P i, p.Prime) → Set.PairwiseDisjoint (I : Set ι) P → + ∀ i ∈ I, ∀ (X H : ℕ), 2 ≤ H → H ≤ X → + 1 ≤ Real.log (H : ℝ) → 1 ≤ Real.log (Real.log (H : ℝ)) → + ∀ W : ℝ, 1 ≤ W → + (∀ p ∈ P i, p ≠ 2 ∧ 2 * R₀ ≤ p ∧ + 2 * W ≤ (p : ℝ) ∧ + (p : ℝ) ≤ (H : ℝ) / W) → + ∀ (F : ℕ → ℂ), Multiplicative F → OneBounded F → + ∀ (r : ℤ) (q : ℕ), 2 ≤ q → + W ≤ (q : ℝ) → + (q : ℝ) ≤ (H : ℝ) / W → + ∀ α : ℝ, IsCoprime (q : ℤ) r → + |α - (r : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2 → + shortExponentialIntegral (mrtTypicalCoefficient I P F) X H α ≤ + C * (X : ℝ) * H * Real.log (Real.log (H : ℝ)) * (Real.log (H : ℝ)/W)^(1/4:ℝ) + + 3 * (H : ℝ) * (X + H) * ∑ p ∈ P i, 1 / (p : ℝ) ^ 2 := by + obtain ⟨C, hC, R₀, hbound⟩ := minor_arc_typical_parameter_saving + refine ⟨3 * C, by positivity, R₀, ?_⟩ + intro ι I P hP hdis i hi X H hH hHX hlogH hloglog W hW hrange F hF hFb + r q hq hWq hqH α hcop happ + obtain ⟨hJ, hPJ, hR, hgeom⟩ := minor_arc_parameter_range_dyadics (P i) H R₀ (hP i hi) + W hW (fun p hp => (hrange p hp).2) + have hbound' := hbound I P hP hdis i hi ((P i).image (Nat.log 2)) X H (Nat.log 2 H) + (by omega) hHX hlogH hJ hPJ (fun p hp => (hrange p hp).1) + (fun j hj => ⟨(hR j hj).1, (hR j hj).2.trans hHX⟩) W hW hgeom + F hF hFb r q hq hWq hqH α hcop happ + apply hbound'.trans + apply add_le_add _ le_rfl + have hh := mul_le_mul_of_nonneg_left (minor_arc_dyadic_log_log_bound H hH hlogH hloglog) + (by positivity : 0 ≤ C * (X : ℝ) * H) + have hh' := mul_le_mul_of_nonneg_right hh (Real.rpow_nonneg (show 0 ≤ Real.log (H:ℝ)/W by positivity) (1/4:ℝ)) + convert hh' using 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameterSaving.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameterSaving.lean new file mode 100644 index 0000000000000000000000000000000000000000..e28d8dbf94cc1ff987a3e4eaa53d08d70ce581c8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameterSaving.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcDyadicSieve +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcDyadicWindows + +namespace OAI + +/-! The minor-arc fourth-root estimate retains the freely chosen +Diophantine parameter. This permits a common parameter in both arcs. -/ +namespace TwoPointCorrelations + +open Finset Filter + +lemma minor_arc_parameter_fourth_root (D S X H R W : ℝ) + (hD : 0 ≤ D) (hX : 0 ≤ X) (hH : 0 < H) + (hlogH : 1 ≤ Real.log H) (hlogR : 0 < Real.log R) (hW : 0 < W) + (hbound : S^4 ≤ D*X^4*H^4*(1+Real.log (2*H))/(W*Real.log R^4)) : + S ≤ (3*D+1)*X*H*(Real.log H/W)^(1/4:ℝ)/Real.log R := by + have hlog : 1+Real.log (2*H) ≤ 3*Real.log H := by + rw [Real.log_mul (by norm_num : (2:ℝ) ≠ 0) hH.ne'] + have hh := Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ) < 2) + linarith + have hK : 1 ≤ 3*D+1 := by linarith + have hKpow : 3*D ≤ (3*D+1)^4 := by + have hh := pow_le_pow_right₀ hK (by omega : 1 ≤ 4) + simp only [pow_one] at hh + linarith + have hroot : ((Real.log H/W)^(1/4:ℝ))^4=Real.log H/W := by + rw [← Real.rpow_mul_natCast (by positivity : 0 ≤ Real.log H/W)] + norm_num + have hs : S^4 ≤ 3*D*(X*H*(Real.log H/W)^(1/4:ℝ)/Real.log R)^4 := by + calc + _ ≤ D*X^4*H^4*(1+Real.log (2*H))/(W*Real.log R^4) := hbound + _ ≤ D*X^4*H^4*(3*Real.log H)/(W*Real.log R^4) := by + exact div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_left hlog (by positivity)) (by positivity) + _ = _ := by + rw [div_pow,mul_pow,mul_pow,hroot] + field_simp + apply le_of_pow_le_pow_left₀ (by norm_num : (4:ℕ) ≠ 0) (by positivity) + calc + _ ≤ 3*D*(X*H*(Real.log H/W)^(1/4:ℝ)/Real.log R)^4 := hs + _ ≤ (3*D+1)^4*(X*H*(Real.log H/W)^(1/4:ℝ)/Real.log R)^4 := + mul_le_mul_of_nonneg_right hKpow (by positivity) + _ = _ := by ring + +theorem minor_arc_dyadic_parameter_saving : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ R : ℕ in atTop, + ∀ (P : Finset ℕ) (X H : ℕ), 1 ≤ H → H ≤ X → R ≤ X → + 1 ≤ Real.log (H:ℝ) → + (∀ p ∈ P, p.Prime ∧ p ≠ 2 ∧ R ≤ p ∧ p ≤ 2*R) → + ∀ (a c : ℕ → ℂ), (∀ m, ‖a m‖ ≤ 1) → (∀ p ∈ P, ‖c p‖ ≤ 1) → + ∀ W : ℝ, 1 ≤ W → W ≤ (R:ℝ) → (R:ℝ) ≤ (H:ℝ)/W → + ∀ (r : ℤ) (q : ℕ), 2 ≤ q → W ≤ (q:ℝ) → (q:ℝ) ≤ (H:ℝ)/W → + ∀ α : ℝ, IsCoprime (q:ℤ) r → |α-(r:ℝ)/(q:ℝ)| ≤ 1/(q:ℝ)^2 → + (∑ k ∈ range X, ‖minorArcBilinearWindow P ((X+H)/R+1) H 1 a c α k‖) ≤ + C*(X:ℝ)*H*(Real.log (H:ℝ)/W)^(1/4:ℝ)/Real.log (R:ℝ) := by + obtain ⟨D,hD,hbound⟩ := minor_arc_dyadic_bilinear_sieve + refine ⟨3*D+1,by positivity,?_⟩ + filter_upwards [hbound,eventually_ge_atTop 2] with R hbound hR + intro P X H hH hHX hRX hlogH hP a c ha hc W hW hWR hRH r q hq hWq hqH α hcop happ + have hH0 : (0:ℝ) < H := by exact_mod_cast (by omega : 0 < H) + have hlogR : 0 < Real.log (R:ℝ) := + Real.log_pos (by exact_mod_cast (by omega : 1 < R)) + exact minor_arc_parameter_fourth_root D _ X H R W hD.le (Nat.cast_nonneg X) + hH0 hlogH hlogR (by linarith) + (hbound P X H hH hHX hRX hP a c ha hc W hW hWR hRH r q hq hWq hqH α hcop happ) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameterTypical.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameterTypical.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fa4bc8cab520e78a66adc0469d3ad7e2886cb75 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameterTypical.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcParameterIntegral +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcTypicalIntegral + +namespace OAI + +/-! The minor-arc short-integral estimate for the actual MRT typical set. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem minor_arc_typical_parameter_saving : + ∃ C : ℝ, 0 < C ∧ ∃ R₀ : ℕ, + ∀ {ι : Type*} (I : Finset ι) (P : ι → Finset ℕ), + (∀ i ∈ I, ∀ p ∈ P i, p.Prime) → Set.PairwiseDisjoint (I : Set ι) P → + ∀ i ∈ I, ∀ (J : Finset ℕ) (X H N : ℕ), 1 ≤ H → H ≤ X → + 1 ≤ Real.log (H : ℝ) → J ⊆ Icc 1 N → + (∀ p ∈ P i, Nat.log 2 p ∈ J) → (∀ p ∈ P i, p ≠ 2) → + (∀ j ∈ J, R₀ ≤ 2 ^ j ∧ 2 ^ j ≤ X) → + ∀ W : ℝ, 1 ≤ W → + (∀ j ∈ J, W ≤ (2 : ℝ) ^ j ∧ + (2 : ℝ) ^ j ≤ (H : ℝ) / W) → + ∀ (F : ℕ → ℂ), Multiplicative F → OneBounded F → + ∀ (r : ℤ) (q : ℕ), 2 ≤ q → + W ≤ (q : ℝ) → + (q : ℝ) ≤ (H : ℝ) / W → + ∀ α : ℝ, IsCoprime (q : ℤ) r → + |α - (r : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2 → + shortExponentialIntegral (mrtTypicalCoefficient I P F) X H α ≤ + C * (X : ℝ) * H * (1 + Real.log (N : ℝ)) * (Real.log (H : ℝ)/W)^(1/4:ℝ) + + 3 * (H : ℝ) * (X + H) * ∑ p ∈ P i, 1 / (p : ℝ) ^ 2 := by + obtain ⟨C, hC, R₀, hbound⟩ := minor_arc_bilinear_parameter_saving + refine ⟨C, hC, R₀, ?_⟩ + intro ι I P hP hdis i hi J X H N hH hHX hlogH hJN hPJ hodd hR W hW hgeom + F hF hFb r q hq hWq hqH α hcop happ + let B := mrtTypicalCoefficient (I.erase i) P F + let a := minorArcRamareCofactor (P i) B + have ha : ∀ m, ‖a m‖ ≤ 1 := + minor_arc_ramare_cofactor_bound (P i) B + (mrtTypicalCoefficient_oneBounded (I.erase i) P F hFb) + have hc : ∀ p ∈ P i, ‖F p‖ ≤ 1 := fun p hp => hFb p (hP i hi p hp).pos + have hbil := hbound (P i) J X H N hH hHX hlogH hJN hPJ + (fun p hp => ⟨hP i hi p hp, hodd p hp⟩) hR W hW hgeom a F ha hc + r q hq hWq hqH α hcop happ + have hcut : ∀ p ∈ P i, ∀ k ∈ range X, (k + H) / p < X + H + 1 := by + intro p _ k hk + have hkX := mem_range.mp hk + have hd := Nat.div_le_self (k + H) p + omega + have htyp := minor_arc_typical_integral_le I P hP hdis hi F hF hFb + X H (X + H + 1) hcut α + exact htyp.trans (add_le_add hbil le_rfl) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameters.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..f60a7ed972138148bb550047c2759a13cff538fd --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcParameters.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcPrimeKernel + +namespace OAI + +/-! The explicit minor-arc parameter saving for the four-prime kernel. -/ + +namespace TwoPointCorrelations + +lemma minor_arc_parameter_bound (R H W q V : ℝ) + (hR : 1 ≤ R) (hW : 1 ≤ W) (hWR : W ≤ R) + (hWq : W ≤ q) (hqH : q ≤ H / W) (hRH : R ≤ H / W) + (hV : 0 ≤ V) (hVR : V ≤ H / R) : + 2 * (3 * (4 * R + 1) / q + 1) * (2 * V + 4 * q * (1 + Real.log q)) ≤ + 192 * H * (1 + Real.log H) / W := by + have hR0 : 0 < R := by linarith + have hW0 : 0 < W := by linarith + have hq0 : 0 < q := lt_of_lt_of_le hW0 hWq + have hH1 : 1 ≤ H := by + have hwq : W * q ≤ H := by nlinarith [(le_div_iff₀ hW0).mp hqH] + nlinarith + have hH0 : 0 < H := by linarith + have hqH' : q ≤ H := by + have hmul := (le_div_iff₀ hW0).mp hqH + nlinarith + have hlogq : 0 ≤ Real.log q := Real.log_nonneg (hW.trans hWq) + have hlogH : 0 ≤ Real.log H := Real.log_nonneg hH1 + have hlog : Real.log q ≤ Real.log H := Real.log_le_log hq0 hqH' + have hA : 4 * R + 1 ≤ 5 * R := by linarith + have h₁ : 12 * (4 * R + 1) * V / q ≤ 60 * H / W := by + calc + _ ≤ 12 * (5 * R) * (H / R) / q := by gcongr + _ = 60 * H / q := by field_simp; ring + _ ≤ _ := by gcongr + have h₂ : 24 * (4 * R + 1) * (1 + Real.log q) ≤ + 120 * (H / W) * (1 + Real.log H) := by + calc + _ ≤ 24 * (5 * R) * (1 + Real.log H) := by gcongr + _ = 120 * R * (1 + Real.log H) := by ring + _ ≤ _ := by gcongr + have h₃ : 4 * V ≤ 4 * H / W := by + calc + _ ≤ 4 * (H / R) := mul_le_mul_of_nonneg_left hVR (by norm_num) + _ = 4 * H / R := by ring + _ ≤ _ := by gcongr + have h₄ : 8 * q * (1 + Real.log q) ≤ 8 * (H / W) * (1 + Real.log H) := by + gcongr + have hsmall : 64 * H / W ≤ 64 * (H / W) * (1 + Real.log H) := by + have hnonneg : 0 ≤ 64 * (H / W) := by positivity + calc + 64 * H / W = (64 * (H / W)) * 1 := by ring + _ ≤ (64 * (H / W)) * (1 + Real.log H) := + mul_le_mul_of_nonneg_left (by linarith) hnonneg + have he : 2 * (3 * (4 * R + 1) / q + 1) * (2 * V + 4 * q * (1 + Real.log q)) = + 12 * (4 * R + 1) * V / q + 24 * (4 * R + 1) * (1 + Real.log q) + + 4 * V + 8 * q * (1 + Real.log q) := by field_simp; ring + rw [he] + calc + _ ≤ (60 * H / W + 120 * (H / W) * (1 + Real.log H)) + + 4 * H / W + 8 * (H / W) * (1 + Real.log H) := + add_le_add (add_le_add (add_le_add h₁ h₂) h₃) h₄ + _ = 64 * H / W + 128 * (H / W) * (1 + Real.log H) := by ring + _ ≤ 64 * (H / W) * (1 + Real.log H) + + 128 * (H / W) * (1 + Real.log H) := add_le_add hsmall le_rfl + _ = 192 * H * (1 + Real.log H) / W := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPhaseRepresentatives.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPhaseRepresentatives.lean new file mode 100644 index 0000000000000000000000000000000000000000..495c7dec0d5f705462efdfa969089e38feb180a3 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPhaseRepresentatives.lean @@ -0,0 +1,30 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcPackingSum + +namespace OAI + +/-! Centered representatives preserve the rational separation on the circle. -/ + +namespace TwoPointCorrelations + +lemma minor_arc_integer_zero (z : ℤ) : ((z : ℝ) : UnitAddCircle) = 0 := by + apply (AddCircle.coe_eq_zero_iff (1 : ℝ)).mpr + exact ⟨z, by simp⟩ + +lemma minor_arc_centered_coe (x : ℝ) : + ((x - (round x : ℝ) : ℝ) : UnitAddCircle) = (x : UnitAddCircle) := by + rw [AddCircle.coe_sub, minor_arc_integer_zero, sub_zero] + +lemma minor_arc_centered_difference (x y : ℝ) : + dist (x : UnitAddCircle) (y : UnitAddCircle) ≤ + |(x - (round x : ℝ)) - (y - (round y : ℝ))| := by + have h := minor_arc_circle_norm_le ((x - (round x : ℝ)) - (y - (round y : ℝ))) + rw [AddCircle.coe_sub, minor_arc_centered_coe, minor_arc_centered_coe] at h + simpa only [dist_eq_norm] using h + +lemma minor_arc_centered_small (x : ℝ) : |x - (round x : ℝ)| ≤ 1 / 2 := by + simpa only [UnitAddCircle.norm_eq, abs_one] using + (AddCircle.norm_le_half_period (1 : ℝ) (by norm_num) (x := (x : UnitAddCircle))) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPrimeFourth.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPrimeFourth.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab641f7c19849c11f38696370986f0c49ee01884 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPrimeFourth.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcFourthExpansion + +namespace OAI + +/-! The prime fourth moment is controlled by the rational geometric kernel +at the additive differences p₁+p₂-p₃-p₄. -/ + +namespace TwoPointCorrelations + +open Finset Complex +open scoped ComplexConjugate + +lemma minor_arc_phase_four (α x₁ x₂ x₃ x₄ : ℝ) (m : ℕ) : + additiveCharacter (α * x₁) m * additiveCharacter (α * x₂) m * + conj (additiveCharacter (α * x₃) m) * conj (additiveCharacter (α * x₄) m) = + additiveCharacter (α * (x₁ + x₂ - x₃ - x₄)) m := by + simp only [additiveCharacter, ← Complex.exp_conj, map_mul, + Complex.conj_ofReal, Complex.conj_I] + rw [← Complex.exp_add, ← Complex.exp_add, ← Complex.exp_add] + congr 1 + push_cast + ring + +theorem minor_arc_prime_fourth (P : Finset ℕ) (c : ℕ → ℂ) + (hc : ∀ p ∈ P, ‖c p‖ ≤ 1) (α : ℝ) (a b : ℕ) : + (∑ m ∈ Ico a b, ‖∑ p ∈ P, c p * additiveCharacter (α * p) m‖ ^ 4) ≤ + ∑ p₁ ∈ P, ∑ p₂ ∈ P, ∑ p₃ ∈ P, ∑ p₄ ∈ P, + minorArcGeometricBound ((b - a : ℕ) : ℝ) + (α * ((p₁ : ℝ) + p₂ - p₃ - p₄)) := by + apply (minor_arc_fourth_moment_bound P (Ico a b) + (fun p m => c p * additiveCharacter (α * p) m)).trans + apply sum_le_sum + intro p₁ hp₁ + apply sum_le_sum + intro p₂ hp₂ + apply sum_le_sum + intro p₃ hp₃ + apply sum_le_sum + intro p₄ hp₄ + let d := c p₁ * c p₂ * conj (c p₃) * conj (c p₄) + have hd : ‖d‖ ≤ 1 := by + dsimp [d] + simp only [norm_mul, norm_conj] + calc + ‖c p₁‖ * ‖c p₂‖ * ‖c p₃‖ * ‖c p₄‖ ≤ 1 * 1 * 1 * 1 := by + gcongr <;> first | exact hc _ hp₁ | exact hc _ hp₂ | exact hc _ hp₃ | exact hc _ hp₄ + _ = 1 := by norm_num + have he : (∑ m ∈ Ico a b, + (c p₁ * additiveCharacter (α * p₁) m) * (c p₂ * additiveCharacter (α * p₂) m) * + conj (c p₃ * additiveCharacter (α * p₃) m) * + conj (c p₄ * additiveCharacter (α * p₄) m)) = + d * ∑ m ∈ Ico a b, additiveCharacter (α * ((p₁ : ℝ) + p₂ - p₃ - p₄)) m := by + rw [mul_sum] + apply sum_congr rfl + intro m _ + rw [← minor_arc_phase_four] + dsimp [d] + simp only [map_mul] + ring + rw [he, norm_mul] + calc + _ ≤ 1 * ‖∑ m ∈ Ico a b, additiveCharacter (α * ((p₁ : ℝ) + p₂ - p₃ - p₄)) m‖ := + mul_le_mul_of_nonneg_right hd (norm_nonneg _) + _ ≤ _ := by simpa only [one_mul] using + minor_arc_geometric_bound (α * ((p₁ : ℝ) + p₂ - p₃ - p₄)) a b + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPrimeKernel.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPrimeKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..baddaf9b5379301c0e830baedf2bc1e40df10b4a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPrimeKernel.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcEnergyKernel +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcSignedKernel + +namespace OAI + +/-! The four-prime kernel in MRT (3.3), including arbitrary window lengths. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem minor_arc_prime_difference_kernel (P : Finset ℕ) (N : ℕ) + (hP : ∀ p ∈ P, p ≤ N) (α V : ℝ) (hV : 0 ≤ V) : + (∑ p₁ ∈ P, ∑ p₂ ∈ P, ∑ p₃ ∈ P, ∑ p₄ ∈ P, + minorArcGeometricBound V (α * ((p₁ : ℝ) + p₂ - p₃ - p₄))) ≤ + (Finset.addEnergy P P : ℝ) * + ∑ n ∈ Icc (-(2 * (N : ℤ))) (2 * (N : ℤ)), + minorArcGeometricBound V (α * (n : ℝ)) := by + let S := (P ×ˢ P) ×ˢ (P ×ˢ P) + let f : (ℕ × ℕ) × (ℕ × ℕ) → ℤ := fun v => + ((v.1.1 : ℤ) + v.1.2) - ((v.2.1 : ℤ) + v.2.2) + have hmap : ∀ v ∈ S, f v ∈ Icc (-(2 * (N : ℤ))) (2 * (N : ℤ)) := by + rintro ⟨⟨p, q⟩, ⟨r, s⟩⟩ hv + obtain ⟨hpq, hrs⟩ := mem_product.mp hv + obtain ⟨hp, hq⟩ := mem_product.mp hpq + obtain ⟨hr, hs⟩ := mem_product.mp hrs + have := hP p hp + have := hP q hq + have := hP r hr + have := hP s hs + apply mem_Icc.mpr + dsimp [f] + omega + have he := minor_arc_fiber_sum S (Icc (-(2 * (N : ℤ))) (2 * (N : ℤ))) f + (fun n => minorArcGeometricBound V (α * (n : ℝ))) + (Finset.addEnergy P P : ℝ) hmap + (fun n _ => minor_arc_geometric_nonneg hV _) + (fun n _ => by + have hh := (Nat.cast_le (α := ℝ)).mpr (minor_arc_prime_shifted_fiber P n) + simpa only [S, f] using hh) + convert he using 1 + dsimp [S, f] + simp only [sum_product] + apply sum_congr rfl + intro p hp + apply sum_congr rfl + intro q hq + apply sum_congr rfl + intro r hr + apply sum_congr rfl + intro s hs + congr 1 + push_cast + ring + +theorem minor_arc_prime_kernel_rational (P : Finset ℕ) (N : ℕ) + (hP : ∀ p ∈ P, p ≤ N) (α V : ℝ) (hV : 0 ≤ V) + (a : ℤ) (q : ℕ) (hq : 2 ≤ q) (hcop : IsCoprime (q : ℤ) a) + (happrox : |α - (a : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2) : + (∑ p₁ ∈ P, ∑ p₂ ∈ P, ∑ p₃ ∈ P, ∑ p₄ ∈ P, + minorArcGeometricBound V (α * ((p₁ : ℝ) + p₂ - p₃ - p₄))) ≤ + (Finset.addEnergy P P : ℝ) * + (2 * (3 * (2 * (N : ℝ) + 1) / q + 1) * + (2 * V + 4 * (q : ℝ) * (1 + Real.log (q : ℝ)))) := by + have he := minor_arc_prime_difference_kernel P N hP α V hV + have hk := minor_arc_signed_kernel (2 * N) q α V a hq hV hcop happrox + have hs : (∑ n ∈ Icc (-(2 * (N : ℤ))) (2 * (N : ℤ)), + minorArcGeometricBound V (α * (n : ℝ))) = + ∑ n ∈ Icc (-((2 * N : ℕ) : ℤ)) ((2 * N : ℕ) : ℤ), + minorArcGeometricBound V ((n : ℝ) * α) := by + simp only [Nat.cast_mul, Nat.cast_ofNat, mul_comm α] + rw [hs] at he + apply he.trans + have hm := mul_le_mul_of_nonneg_left hk + (Nat.cast_nonneg (Finset.addEnergy P P) : (0 : ℝ) ≤ _) + simpa only [Nat.cast_mul, Nat.cast_ofNat] using hm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPrimeRanges.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPrimeRanges.lean new file mode 100644 index 0000000000000000000000000000000000000000..4cc69466a1ce2db6147e5ba862c15b87a7b91182 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcPrimeRanges.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcLogLog + +namespace OAI + +/-! Verifying every dyadic hypothesis from the actual prime range. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma minor_arc_prime_range_dyadics (P : Finset ℕ) (H R₀ : ℕ) + (hP : ∀ p ∈ P, p.Prime) (hlogH : 1 ≤ Real.log (H : ℝ)) + (hrange : ∀ p ∈ P, 2 * R₀ ≤ p ∧ + 2 * (Real.log (H : ℝ)) ^ 5 ≤ (p : ℝ) ∧ + (p : ℝ) ≤ (H : ℝ) / (Real.log (H : ℝ)) ^ 5) : + let J := P.image (Nat.log 2) + J ⊆ Icc 1 (Nat.log 2 H) ∧ + (∀ p ∈ P, Nat.log 2 p ∈ J) ∧ + (∀ j ∈ J, R₀ ≤ 2 ^ j ∧ 2 ^ j ≤ H) ∧ + (∀ j ∈ J, (Real.log (H : ℝ)) ^ 5 ≤ (2 : ℝ) ^ j ∧ + (2 : ℝ) ^ j ≤ (H : ℝ) / (Real.log (H : ℝ)) ^ 5) := by + dsimp only + have hW : 1 ≤ (Real.log (H : ℝ)) ^ 5 := one_le_pow₀ hlogH + have hpH (p : ℕ) (hp : p ∈ P) : p ≤ H := by + have hh := (hrange p hp).2.2 + have hb : (p : ℝ) ≤ H := hh.trans (div_le_self (Nat.cast_nonneg H) hW) + exact_mod_cast hb + refine ⟨?_, fun p hp => mem_image.mpr ⟨p, hp, rfl⟩, ?_, ?_⟩ + · intro j hj + obtain ⟨p, hp, rfl⟩ := mem_image.mp hj + exact mem_Icc.mpr ⟨minor_arc_dyadic_index_pos (hP p hp).two_le, + Nat.log_mono_right (hpH p hp)⟩ + · intro j hj + obtain ⟨p, hp, rfl⟩ := mem_image.mp hj + have hd := minor_arc_dyadic_prime_bounds (hP p hp).pos rfl + constructor + · nlinarith [(hrange p hp).1, hd.2] + · exact hd.1.trans (hpH p hp) + · intro j hj + obtain ⟨p, hp, rfl⟩ := mem_image.mp hj + have hd := minor_arc_dyadic_prime_bounds (hP p hp).pos rfl + have hlo : (2 : ℝ) * (2 : ℝ) ^ Nat.log 2 p ≥ p := by exact_mod_cast hd.2 + have hhi : (2 : ℝ) ^ Nat.log 2 p ≤ p := by exact_mod_cast hd.1 + exact ⟨by linarith [(hrange p hp).2.1], hhi.trans (hrange p hp).2.2⟩ + +theorem minor_arc_typical_prime_range_saving : + ∃ C : ℝ, 0 < C ∧ ∃ R₀ : ℕ, + ∀ {ι : Type*} (I : Finset ι) (P : ι → Finset ℕ), + (∀ i ∈ I, ∀ p ∈ P i, p.Prime) → Set.PairwiseDisjoint (I : Set ι) P → + ∀ i ∈ I, ∀ (X H : ℕ), 2 ≤ H → H ≤ X → + 1 ≤ Real.log (H : ℝ) → 1 ≤ Real.log (Real.log (H : ℝ)) → + (∀ p ∈ P i, p ≠ 2 ∧ 2 * R₀ ≤ p ∧ + 2 * (Real.log (H : ℝ)) ^ 5 ≤ (p : ℝ) ∧ + (p : ℝ) ≤ (H : ℝ) / (Real.log (H : ℝ)) ^ 5) → + ∀ (F : ℕ → ℂ), Multiplicative F → OneBounded F → + ∀ (r : ℤ) (q : ℕ), 2 ≤ q → + (Real.log (H : ℝ)) ^ 5 ≤ (q : ℝ) → + (q : ℝ) ≤ (H : ℝ) / (Real.log (H : ℝ)) ^ 5 → + ∀ α : ℝ, IsCoprime (q : ℤ) r → + |α - (r : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2 → + shortExponentialIntegral (mrtTypicalCoefficient I P F) X H α ≤ + C * (X : ℝ) * H * Real.log (Real.log (H : ℝ)) / Real.log (H : ℝ) + + 3 * (H : ℝ) * (X + H) * ∑ p ∈ P i, 1 / (p : ℝ) ^ 2 := by + obtain ⟨C, hC, R₀, hbound⟩ := minor_arc_typical_log_saving + refine ⟨3 * C, by positivity, R₀, ?_⟩ + intro ι I P hP hdis i hi X H hH hHX hlogH hloglog hrange F hF hFb + r q hq hWq hqH α hcop happ + obtain ⟨hJ, hPJ, hR, hgeom⟩ := minor_arc_prime_range_dyadics (P i) H R₀ (hP i hi) + hlogH (fun p hp => (hrange p hp).2) + have hbound' := hbound I P hP hdis i hi ((P i).image (Nat.log 2)) X H (Nat.log 2 H) + (by omega) hHX hlogH hJ hPJ (fun p hp => (hrange p hp).1) + (fun j hj => ⟨(hR j hj).1, (hR j hj).2.trans hHX⟩) hgeom + F hF hFb r q hq hWq hqH α hcop happ + apply hbound'.trans + apply add_le_add _ le_rfl + have hh := mul_le_mul_of_nonneg_left (minor_arc_dyadic_log_log_bound H hH hlogH hloglog) + (by positivity : 0 ≤ C * (X : ℝ) * H) + have hh' := div_le_div_of_nonneg_right hh (by linarith : 0 ≤ Real.log (H : ℝ)) + convert hh' using 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcRamareError.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcRamareError.lean new file mode 100644 index 0000000000000000000000000000000000000000..daee421a8036cddcef4dbc2e36195fff63435a32 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcRamareError.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTGeneralPrimeError + +namespace OAI + +/-! The combined denominator and prime-extraction error for the additive +short-window argument. Both errors are supported on prime squares. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def minorArcRamareApprox (P : Finset ℕ) (A B : ℕ → ℂ) (n : ℕ) : ℂ := + ∑ p ∈ P, if p ∣ n then + A p * B (n / p) / ((finitePrimeDivisorCount P (n / p) + 1 : ℕ) : ℂ) else 0 + +lemma minor_arc_ramare_pointwise (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (C A B : ℕ → ℂ) (hC : OneBounded C) (hA : OneBounded A) (hB : OneBounded B) + (hproduct : ∀ p ∈ P, ∀ m, 0 < m → ¬p ∣ m → C (p * m) = A p * B m) + {n : ℕ} (hn : 0 < n) : + ‖(if finitePrimeDivisorCount P n = 0 then 0 else C n) - + minorArcRamareApprox P A B n‖ ≤ 3 * mrtPrimeSquareCount P n := by + have he : (if finitePrimeDivisorCount P n = 0 then 0 else C n) - + minorArcRamareApprox P A B n = + mrtRamareCorrection P C n + mrtPrimeProductError P (fun _ _ => True) C A B n := by + have hterm (p : ℕ) : + (if p ∣ n ∧ True then + (C n - A p * B (n / p)) / ((finitePrimeDivisorCount P (n / p) + 1 : ℕ) : ℂ) + else 0) = + (if p ∣ n then C n / ((finitePrimeDivisorCount P (n / p) + 1 : ℕ) : ℂ) else 0) - + (if p ∣ n then A p * B (n / p) / + ((finitePrimeDivisorCount P (n / p) + 1 : ℕ) : ℂ) else 0) := by + by_cases hp : p ∣ n <;> simp [hp, sub_div] + have hsum : mrtPrimeProductError P (fun _ _ => True) C A B n = + ∑ p ∈ P, + ((if p ∣ n then C n / ((finitePrimeDivisorCount P (n / p) + 1 : ℕ) : ℂ) else 0) - + (if p ∣ n then A p * B (n / p) / + ((finitePrimeDivisorCount P (n / p) + 1 : ℕ) : ℂ) else 0)) := by + unfold mrtPrimeProductError + apply sum_congr rfl + intro p _ + simpa only [and_true] using hterm p + rw [hsum, sum_sub_distrib] + unfold minorArcRamareApprox mrtRamareCorrection + ring + rw [he] + have hden := mrt_ramare_correction_oneBounded P hP C hC hn + have hprod := mrt_prime_product_error_bound P hP (fun _ _ => True) C A B hC hA hB hproduct hn + exact (norm_add_le _ _).trans (by linarith) + +lemma minor_arc_typical_ramare_pointwise {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (hP : ∀ j ∈ J, ∀ p ∈ P j, p.Prime) + (hdis : Set.PairwiseDisjoint (J : Set ι) P) {j : ι} (hj : j ∈ J) + (F : ℕ → ℂ) (hF : Multiplicative F) (hFb : OneBounded F) + {n : ℕ} (hn : 0 < n) : + ‖mrtTypicalCoefficient J P F n - + minorArcRamareApprox (P j) F (mrtTypicalCoefficient (J.erase j) P F) n‖ ≤ + 3 * mrtPrimeSquareCount (P j) n := by + have hh := minor_arc_ramare_pointwise (P j) (hP j hj) + (mrtTypicalCoefficient J P F) F (mrtTypicalCoefficient (J.erase j) P F) + (mrtTypicalCoefficient_oneBounded J P F hFb) hFb + (mrtTypicalCoefficient_oneBounded (J.erase j) P F hFb) + (fun p hp m hm hpm => mrtTypicalCoefficient_prime_mul_coprime J P hP hdis hj F hF hp hm hpm) + hn + simpa only [mrtTypicalCoefficient, mrtTypical_ramare_supported J P hj F] using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcRamareWindow.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcRamareWindow.lean new file mode 100644 index 0000000000000000000000000000000000000000..7299ac5358a188eb261cbcc1110492b1ebe831aa --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcRamareWindow.lean @@ -0,0 +1,147 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcRamareError +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcBilinearWindow + +namespace OAI + +/-! Exact change of variables from the Ramaré coefficient to the finite +bilinear short-window sum. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def minorArcRamareCofactor (P : Finset ℕ) (B : ℕ → ℂ) (m : ℕ) : ℂ := + if m = 0 then 0 else B m / ((finitePrimeDivisorCount P m + 1 : ℕ) : ℂ) + +lemma minor_arc_ramare_cofactor_bound (P : Finset ℕ) (B : ℕ → ℂ) + (hB : OneBounded B) (m : ℕ) : ‖minorArcRamareCofactor P B m‖ ≤ 1 := by + unfold minorArcRamareCofactor + split_ifs with hm + · simp + · rw [norm_div, Complex.norm_natCast] + apply (div_le_self (norm_nonneg _) (by norm_num)).trans + exact hB m (Nat.pos_of_ne_zero hm) + +lemma minor_arc_bilinear_zero_cofactor (P : Finset ℕ) (M H d : ℕ) + (a c : ℕ → ℂ) (α : ℝ) (k : ℕ) : + minorArcBilinearWindow P M H d (fun m => if m = 0 then 0 else a m) c α k = + minorArcBilinearWindow P M H d a c α k := by + unfold minorArcBilinearWindow + apply sum_congr rfl + intro m _ + by_cases hm : m = 0 + · subst m + simp [minorArcWindowTerm, minorArcWindowInterval] + · simp only [ite_eq_right hm] + +lemma minor_arc_divisibility_window (p M k H : ℕ) (hp : 0 < p) + (hM : (k + H) / p < M) (F : ℕ → ℂ) : + (∑ n ∈ Icc (k + 1) (k + H), if p ∣ n then F n else 0) = + ∑ m ∈ minorArcWindowInterval M p k H, F (p * m) := by + rw [← sum_filter] + symm + apply sum_bij (fun m _ => p * m) + · intro m hm + have hh := (mem_minorArcWindowInterval M p k H m hp).mp hm + exact mem_filter.mpr ⟨mem_Icc.mpr ⟨by omega, hh.2.2⟩, dvd_mul_right p m⟩ + · intro m _ n _ hmn + exact Nat.eq_of_mul_eq_mul_left hp hmn + · intro n hn + obtain ⟨hnI, hpn⟩ := mem_filter.mp hn + have hnI' := mem_Icc.mp hnI + refine ⟨n / p, (mem_minorArcWindowInterval M p k H (n / p) hp).mpr ?_, + Nat.mul_div_cancel' hpn⟩ + have hdiv : n / p ≤ (k + H) / p := Nat.div_le_div_right hnI'.2 + refine ⟨hdiv.trans_lt hM, ?_, ?_⟩ + · rw [Nat.mul_div_cancel' hpn] + omega + · simpa only [Nat.mul_div_cancel' hpn] using hnI'.2 + · intro m _ + rfl + +lemma minor_arc_window_weighted_sum (M p k H : ℕ) (a : ℕ → ℂ) (c : ℂ) (β : ℝ) : + (∑ m ∈ range M, a m * minorArcWindowTerm M p k H c β m) = + ∑ m ∈ minorArcWindowInterval M p k H, a m * (c * additiveCharacter β m) := by + let W := minorArcWindowInterval M p k H + have hsub : W ⊆ range M := by + intro m hm + exact mem_range.mpr ((mem_Ico.mp hm).2.trans_le (min_le_left _ _)) + have hf : (range M).filter (fun m => m ∈ W) = W := by + ext m + simp only [mem_filter] + exact ⟨And.right, fun hm => ⟨hsub hm, hm⟩⟩ + change (∑ m ∈ range M, a m * minorArcWindowTerm M p k H c β m) = + ∑ m ∈ W, a m * (c * additiveCharacter β m) + rw [← hf, sum_filter] + apply sum_congr rfl + intro m _ + change a m * (if m ∈ W then c * additiveCharacter β m else 0) = + if m ∈ W then a m * (c * additiveCharacter β m) else 0 + split_ifs <;> simp + +lemma minor_arc_window_interval_eq_of_cutoff (M A k H : ℕ) + (hM : (k + H) / A < M) : + minorArcWindowInterval M A k H = Ico (k / A + 1) ((k + H) / A + 1) := by + unfold minorArcWindowInterval + rw [min_eq_right (by omega : (k + H) / A + 1 ≤ M)] + +lemma minor_arc_bilinear_cutoff_eq (P : Finset ℕ) (M N H d k : ℕ) + (hM : ∀ p ∈ P, (k + H) / (d * p) < M) + (hN : ∀ p ∈ P, (k + H) / (d * p) < N) + (a c : ℕ → ℂ) (α : ℝ) : + minorArcBilinearWindow P M H d a c α k = + minorArcBilinearWindow P N H d a c α k := by + unfold minorArcBilinearWindow + simp only [mul_sum] + rw [sum_comm, sum_comm (s := range N) (t := P)] + apply sum_congr rfl + intro p hp + rw [minor_arc_window_weighted_sum, minor_arc_window_weighted_sum, + minor_arc_window_interval_eq_of_cutoff M (d * p) k H (hM p hp), + minor_arc_window_interval_eq_of_cutoff N (d * p) k H (hN p hp)] + +lemma minor_arc_ramare_short_eq (P : Finset ℕ) (M H k : ℕ) + (hP : ∀ p ∈ P, 0 < p) (hM : ∀ p ∈ P, (k + H) / p < M) + (A B : ℕ → ℂ) (α : ℝ) : + shortExponentialSum (minorArcRamareApprox P A B) H α k = + minorArcBilinearWindow P M H 1 + (fun m => B m / ((finitePrimeDivisorCount P m + 1 : ℕ) : ℂ)) A α k := by + rw [shortExponentialSum_at_nat] + unfold minorArcRamareApprox minorArcBilinearWindow + simp only [sum_mul, mul_sum, one_mul] + rw [sum_comm, sum_comm (s := range M) (t := P)] + apply sum_congr rfl + intro p hp + have he : (∑ n ∈ Icc (k + 1) (k + H), + (if p ∣ n then A p * B (n / p) / + ((finitePrimeDivisorCount P (n / p) + 1 : ℕ) : ℂ) else 0) * additiveCharacter α n) = + ∑ m ∈ minorArcWindowInterval M p k H, + (A p * B m / ((finitePrimeDivisorCount P m + 1 : ℕ) : ℂ)) * + additiveCharacter α (p * m) := by + simp only [ite_mul, zero_mul] + rw [minor_arc_divisibility_window p M k H (hP p hp) (hM p hp)] + simp only [Nat.mul_div_cancel_left _ (hP p hp)] + rw [he, minor_arc_window_weighted_sum] + apply sum_congr rfl + intro m _ + have hphase : additiveCharacter α (p * m) = additiveCharacter (α * p) m := by + unfold additiveCharacter + congr 1 + push_cast + ring + rw [hphase] + ring + +lemma minor_arc_ramare_short_eq_bounded (P : Finset ℕ) (M H k : ℕ) + (hP : ∀ p ∈ P, 0 < p) (hM : ∀ p ∈ P, (k + H) / p < M) + (A B : ℕ → ℂ) (α : ℝ) : + shortExponentialSum (minorArcRamareApprox P A B) H α k = + minorArcBilinearWindow P M H 1 (minorArcRamareCofactor P B) A α k := by + rw [minor_arc_ramare_short_eq P M H k hP hM] + exact (minor_arc_bilinear_zero_cofactor P M H 1 + (fun m => B m / ((finitePrimeDivisorCount P m + 1 : ℕ) : ℂ)) A α k).symm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcRationalSpacing.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcRationalSpacing.lean new file mode 100644 index 0000000000000000000000000000000000000000..05e65c2c8a81ec63865ab99062c15c971739fd27 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcRationalSpacing.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcCircleKernel +import Mathlib.RingTheory.Coprime.Basic + +namespace OAI + +/-! Separation of a nonintegral rational point, and stability under the +small perturbation used in the minor-arc rational approximation. -/ + +namespace TwoPointCorrelations + +lemma minor_arc_circle_norm_le (x : ℝ) : ‖(x : UnitAddCircle)‖ ≤ |x| := by + rw [UnitAddCircle.norm_eq] + simpa using round_le x (0 : ℤ) + +lemma minor_arc_rational_norm {a q : ℤ} (hq : 0 < q) (hqa : ¬q ∣ a) : + 1 / (q : ℝ) ≤ ‖(((a : ℝ) / (q : ℝ)) : UnitAddCircle)‖ := by + let j := round ((a : ℝ) / (q : ℝ)) + have hz : a - j * q ≠ 0 := by + intro he + apply hqa + refine ⟨j, ?_⟩ + have hh : a = j * q := sub_eq_zero.mp he + simpa only [mul_comm] using hh + have hb : (1 : ℝ) ≤ |(a : ℝ) - (j : ℝ) * q| := by + exact_mod_cast Int.one_le_abs hz + have hqr : (0 : ℝ) < q := by exact_mod_cast hq + rw [UnitAddCircle.norm_eq] + have he : |(a : ℝ) / (q : ℝ) - (j : ℝ)| = |(a : ℝ) - (j : ℝ) * q| / (q : ℝ) := by + calc + _ = |((a : ℝ) - (j : ℝ) * q) / (q : ℝ)| := by congr 1; field_simp + _ = _ := by rw [abs_div, abs_of_pos hqr] + change 1 / (q : ℝ) ≤ |(a : ℝ) / (q : ℝ) - (j : ℝ)| + rw [he] + exact div_le_div_of_nonneg_right hb hqr.le + +lemma minor_arc_perturbed_rational {a q : ℤ} {x : ℝ} (hq : 0 < q) (hqa : ¬q ∣ a) + (hx : |x - (a : ℝ) / (q : ℝ)| ≤ 1 / (2 * (q : ℝ))) : + 1 / (2 * (q : ℝ)) ≤ ‖(x : UnitAddCircle)‖ := by + have hqr : (0 : ℝ) < q := by exact_mod_cast hq + have hrat := minor_arc_rational_norm hq hqa + have herr := (minor_arc_circle_norm_le (x - (a : ℝ) / (q : ℝ))).trans hx + rw [AddCircle.coe_sub] at herr + have ht := norm_le_norm_add_norm_sub (x : UnitAddCircle) (((a : ℝ) / (q : ℝ) : ℝ) : UnitAddCircle) + have he : 1 / (q : ℝ) = 2 * (1 / (2 * (q : ℝ))) := by field_simp + rw [he] at hrat + linarith + +lemma minor_arc_multiple_spacing {α : ℝ} {a q k : ℤ} (hq : 0 < q) + (hqak : ¬q ∣ a * k) (hk : |(k : ℝ)| ≤ (q : ℝ) / 2) + (happrox : |α - (a : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2) : + 1 / (2 * (q : ℝ)) ≤ ‖(((k : ℝ) * α : ℝ) : UnitAddCircle)‖ := by + have hqr : (0 : ℝ) < q := by exact_mod_cast hq + apply minor_arc_perturbed_rational hq hqak + calc + |(k : ℝ) * α - ((a * k : ℤ) : ℝ) / (q : ℝ)| = + |(k : ℝ)| * |α - (a : ℝ) / (q : ℝ)| := by + rw [← abs_mul] + congr 1 + push_cast + ring + _ ≤ ((q : ℝ) / 2) * (1 / (q : ℝ) ^ 2) := + mul_le_mul hk happrox (abs_nonneg _) (by positivity) + _ = 1 / (2 * (q : ℝ)) := by field_simp + +lemma minor_arc_pair_spacing {α : ℝ} {a q m n : ℤ} (hq : 0 < q) + (hcop : IsCoprime q a) (hmn : m ≠ n) + (hshort : |((m - n : ℤ) : ℝ)| ≤ (q : ℝ) / 2) + (happrox : |α - (a : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2) : + 1 / (2 * (q : ℝ)) ≤ dist (((m : ℝ) * α : ℝ) : UnitAddCircle) + (((n : ℝ) * α : ℝ) : UnitAddCircle) := by + have hk : m - n ≠ 0 := sub_ne_zero.mpr hmn + have hnot : ¬q ∣ a * (m - n) := by + intro hh + have hd := hcop.dvd_of_dvd_mul_left hh + have hqr : (0 : ℝ) < q := by exact_mod_cast hq + have hle := Int.natAbs_le_of_dvd_ne_zero hd hk + have hlei : |q| ≤ |m - n| := by + rw [← Int.natCast_natAbs q, ← Int.natCast_natAbs (m - n)] + exact_mod_cast hle + rw [abs_of_pos hq] at hlei + have hler : (q : ℝ) ≤ |((m - n : ℤ) : ℝ)| := by exact_mod_cast hlei + linarith + have h := minor_arc_multiple_spacing hq hnot hshort happrox + rw [dist_eq_norm, ← AddCircle.coe_sub] + convert h using 1 + congr 2 + push_cast + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcSeparatedKernel.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcSeparatedKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..15f26661d6d66f71aa2645a271effe079fde1e6c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcSeparatedKernel.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcPhaseRepresentatives + +namespace OAI + +/-! A finite Vinogradov kernel bound on a separated set of phases. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma minor_arc_kernel_le (L α : ℝ) : minorArcGeometricBound L α ≤ L := by + unfold minorArcGeometricBound + split_ifs + · exact le_rfl + · exact min_le_left _ _ + +theorem minor_arc_separated_kernel {ι : Type*} (S : Finset ι) (θ : ι → ℝ) + (δ V : ℝ) (hδ : 0 < δ) (hV : 0 ≤ V) + (hsep : ∀ i ∈ S, ∀ j ∈ S, i ≠ j → + δ ≤ dist (θ i : UnitAddCircle) (θ j : UnitAddCircle)) : + (∑ i ∈ S, minorArcGeometricBound V (θ i)) ≤ + 2 * V + (2 / δ) * (1 + Real.log (⌈(1 / 2 : ℝ) / δ⌉₊ : ℝ)) := by + let x := fun i => θ i - (round (θ i) : ℝ) + apply minor_arc_packing_sum S x (fun i => minorArcGeometricBound V (θ i)) + δ V (1 / 2) hδ hV + · intro i hi j hj hij + exact (hsep i hi j hj hij).trans (minor_arc_centered_difference (θ i) (θ j)) + · intro i _ + exact minor_arc_centered_small (θ i) + · intro i _ + exact minor_arc_kernel_le V (θ i) + · intro i _ hxi + have hnorm : ‖(θ i : UnitAddCircle)‖ = |x i| := UnitAddCircle.norm_eq + have hb := minor_arc_geometric_circle (L := V) (hnorm.symm ▸ hxi) + apply (hb.trans (min_le_right _ _)).trans + rw [hnorm] + exact one_div_le_one_div_of_le hxi (by linarith) + +theorem minor_arc_rational_block (S : Finset ℤ) (α : ℝ) (a q : ℤ) + (hq : 0 < q) (hcop : IsCoprime q a) (V : ℝ) (hV : 0 ≤ V) + (hwidth : ∀ m ∈ S, ∀ n ∈ S, |((m - n : ℤ) : ℝ)| ≤ (q : ℝ) / 2) + (happrox : |α - (a : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2) : + (∑ n ∈ S, minorArcGeometricBound V ((n : ℝ) * α)) ≤ + 2 * V + 4 * (q : ℝ) * (1 + Real.log (q : ℝ)) := by + have hqr : (0 : ℝ) < q := by exact_mod_cast hq + have hb := minor_arc_separated_kernel S (fun n => (n : ℝ) * α) + (1 / (2 * (q : ℝ))) V (by positivity) hV + (fun m hm n hn hmn => minor_arc_pair_spacing hq hcop hmn (hwidth m hm n hn) happrox) + have hceil : ⌈(1 / 2 : ℝ) / (1 / (2 * (q : ℝ)))⌉₊ = q.toNat := by + rw [show (1 / 2 : ℝ) / (1 / (2 * (q : ℝ))) = (q : ℝ) by field_simp] + exact Nat.ceil_intCast q + have hcast : (q.toNat : ℝ) = q := by exact_mod_cast Int.toNat_of_nonneg hq.le + rw [hceil, hcast] at hb + have he : 2 / (1 / (2 * (q : ℝ))) = 4 * (q : ℝ) := by field_simp; norm_num + rw [he] at hb + exact hb + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcShiftedFiber.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcShiftedFiber.lean new file mode 100644 index 0000000000000000000000000000000000000000..831569dd8de1c2fd41c69427f6022568db75ea82 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcShiftedFiber.lean @@ -0,0 +1,101 @@ +import Mathlib.Combinatorics.Additive.Energy +import Mathlib.Tactic + +namespace OAI + +/-! A shifted additive fiber is bounded by the unshifted additive energy. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +def minorArcValueCount {α : Type*} (S : Finset α) (f : α → ℤ) (n : ℤ) : ℕ := + (S.filter (fun a => f a = n)).card + +lemma minor_arc_value_support {α : Type*} {S : Finset α} {f : α → ℤ} {n : ℤ} + (hn : minorArcValueCount S f n ≠ 0) : n ∈ S.image f := by + obtain ⟨a, ha⟩ := card_ne_zero.mp hn + obtain ⟨haS, han⟩ := mem_filter.mp ha + exact mem_image.mpr ⟨a, haS, han⟩ + +lemma minor_arc_pair_fiber {α : Type*} (S : Finset α) (f : α → ℤ) (h : ℤ) : + ((S ×ˢ S).filter (fun v => f v.1 - f v.2 = h)).card = + ∑ n ∈ S.image f, minorArcValueCount S f n * minorArcValueCount S f (n - h) := by + have hfirst : ((S ×ˢ S).filter (fun v => f v.1 - f v.2 = h)).card = + ∑ a ∈ S, minorArcValueCount S f (f a - h) := by + simp only [card_eq_sum_ones, sum_filter, sum_product, minorArcValueCount] + apply sum_congr rfl + intro a _ + apply sum_congr rfl + intro b _ + have hi : f a - f b = h ↔ f b = f a - h := by omega + by_cases hab : f a - f b = h + · simp only [ite_eq_left hab, ite_eq_left (hi.mp hab)] + · simp only [ite_eq_right hab, ite_eq_right ((not_congr hi).mp hab)] + rw [hfirst, ← sum_fiberwise_of_maps_to (fun a ha => mem_image_of_mem f ha) + (fun a => minorArcValueCount S f (f a - h))] + apply sum_congr rfl + intro n _ + calc + _ = ∑ _a ∈ S.filter (fun a => f a = n), minorArcValueCount S f (n - h) := by + apply sum_congr rfl + intro a ha + rw [(mem_filter.mp ha).2] + _ = _ := by simp only [sum_const, nsmul_eq_mul, Nat.cast_id, minorArcValueCount] + +lemma minor_arc_shifted_value_squares {α : Type*} (S : Finset α) (f : α → ℤ) (h : ℤ) : + (∑ n ∈ S.image f, minorArcValueCount S f (n - h) ^ 2) ≤ + ∑ n ∈ S.image f, minorArcValueCount S f n ^ 2 := by + have hi : Set.InjOn (fun n : ℤ => n - h) (↑(S.image f) : Set ℤ) := by + intro a _ b _ hab + change a - h = b - h at hab + omega + rw [← sum_image (f := fun n : ℤ => minorArcValueCount S f n ^ 2) hi] + apply sum_le_sum_of_ne_zero + intro n _ hn + apply minor_arc_value_support + intro hz + simp only [hz, zero_pow (by norm_num : (2 : ℕ) ≠ 0)] at hn + exact hn rfl + +lemma minor_arc_shifted_pair_card {α : Type*} (S : Finset α) (f : α → ℤ) (h : ℤ) : + ((S ×ˢ S).filter (fun v => f v.1 - f v.2 = h)).card ≤ + ((S ×ˢ S).filter (fun v => f v.1 - f v.2 = 0)).card := by + rw [minor_arc_pair_fiber, minor_arc_pair_fiber] + simp only [sub_zero, ← pow_two] + have he : 2 * (∑ n ∈ S.image f, minorArcValueCount S f n * minorArcValueCount S f (n - h)) ≤ + (∑ n ∈ S.image f, minorArcValueCount S f n ^ 2) + + ∑ n ∈ S.image f, minorArcValueCount S f (n - h) ^ 2 := by + rw [mul_sum, ← sum_add_distrib] + apply sum_le_sum + intro n _ + have he : (2 : ℤ) * minorArcValueCount S f n * minorArcValueCount S f (n - h) ≤ + (minorArcValueCount S f n : ℤ) ^ 2 + (minorArcValueCount S f (n - h) : ℤ) ^ 2 := by + nlinarith [sq_nonneg ((minorArcValueCount S f n : ℤ) - minorArcValueCount S f (n - h))] + simpa only [mul_assoc] using (show + 2 * minorArcValueCount S f n * minorArcValueCount S f (n - h) ≤ + minorArcValueCount S f n ^ 2 + minorArcValueCount S f (n - h) ^ 2 by exact_mod_cast he) + have hs := minor_arc_shifted_value_squares S f h + omega + +/-- Every difference-of-prime-sums fiber has size at most the zero fiber. -/ +theorem minor_arc_prime_shifted_fiber (P : Finset ℕ) (h : ℤ) : + (((P ×ˢ P) ×ˢ (P ×ˢ P)).filter + (fun v => ((v.1.1 : ℤ) + v.1.2) - ((v.2.1 : ℤ) + v.2.2) = h)).card ≤ + Finset.addEnergy P P := by + have he := minor_arc_shifted_pair_card (P ×ˢ P) + (fun v => (v.1 : ℤ) + v.2) h + have hz : (((P ×ˢ P) ×ˢ (P ×ˢ P)).filter + (fun v => ((v.1.1 : ℤ) + v.1.2) - ((v.2.1 : ℤ) + v.2.2) = 0)).card = + Finset.addEnergy P P := by + rw [Finset.addEnergy_eq_card_filter] + apply congrArg Finset.card + apply filter_congr + intro v _ + omega + exact hz ▸ he + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcShortError.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcShortError.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbebb2f6ad42e549c569247469dd7c961053c541 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcShortError.lean @@ -0,0 +1,110 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcRamareError +import Mathlib.Analysis.PSeries + +namespace OAI + +/-! Averaging the prime-square correction over literal short windows. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma minor_arc_square_reciprocal_sum (P : Finset ℕ) (R N : ℕ) (hR : 0 < R) + (hP : ∀ p ∈ P, R ≤ p ∧ p ≤ N) : + (∑ p ∈ P, 1 / (p : ℝ) ^ 2) ≤ 2 / (R : ℝ) := by + have hsub : P ⊆ Ioo (R - 1) (N + 1) := by + intro p hp + have hh := hP p hp + exact mem_Ioo.mpr ⟨by omega, by omega⟩ + calc + _ ≤ ∑ p ∈ Ioo (R - 1) (N + 1), ((p : ℝ) ^ 2)⁻¹ := by + simp only [one_div] + exact sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => by positivity) + _ ≤ 2 / ((R - 1 : ℕ) + 1 : ℝ) := sum_Ioo_inv_sq_le (R - 1) (N + 1) + _ = _ := by rw [Nat.cast_sub (by omega : 1 ≤ R)]; push_cast; ring + +lemma minor_arc_origin_weight_count (X H n : ℕ) : + ((range X).filter (fun k => k < n ∧ n ≤ k + H)).card ≤ H := by + have hs : (range X).filter (fun k => k < n ∧ n ≤ k + H) ⊆ Ico (n - H) n := by + intro k hk + have h := (mem_filter.mp hk).2 + exact mem_Ico.mpr ⟨by omega, h.1⟩ + apply (card_le_card hs).trans + rw [Nat.card_Ico] + omega + +lemma minor_arc_window_mass (X H : ℕ) (w : ℕ → ℝ) (hw : ∀ n, 0 ≤ w n) : + (∑ k ∈ range X, ∑ n ∈ Icc (k + 1) (k + H), w n) ≤ + (H : ℝ) * ∑ n ∈ Icc 1 (X + H), w n := by + have he (k : ℕ) (hk : k ∈ range X) : + (∑ n ∈ Icc (k + 1) (k + H), w n) = + ∑ n ∈ Icc 1 (X + H), if k < n ∧ n ≤ k + H then w n else 0 := by + have hf : (Icc 1 (X + H)).filter (fun n => k < n ∧ n ≤ k + H) = + Icc (k + 1) (k + H) := by + ext n + have hkX := mem_range.mp hk + simp only [mem_filter, mem_Icc] + omega + rw [← sum_filter, hf] + calc + _ = ∑ k ∈ range X, ∑ n ∈ Icc 1 (X + H), + if k < n ∧ n ≤ k + H then w n else 0 := sum_congr rfl he + _ = ∑ n ∈ Icc 1 (X + H), ∑ k ∈ range X, + if k < n ∧ n ≤ k + H then w n else 0 := sum_comm + _ = ∑ n ∈ Icc 1 (X + H), + (((range X).filter (fun k => k < n ∧ n ≤ k + H)).card : ℝ) * w n := by + simp only [← sum_filter, sum_const, nsmul_eq_mul] + _ ≤ ∑ n ∈ Icc 1 (X + H), (H : ℝ) * w n := by + apply sum_le_sum + intro n _ + exact mul_le_mul_of_nonneg_right + ((Nat.cast_le (α := ℝ)).mpr (minor_arc_origin_weight_count X H n)) (hw n) + _ = _ := (mul_sum _ _ _).symm + +lemma minor_arc_prime_square_mass (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (N : ℕ) : + (∑ n ∈ Icc 1 N, mrtPrimeSquareCount P n) ≤ + (N : ℝ) * ∑ p ∈ P, 1 / (p : ℝ) ^ 2 := by + unfold mrtPrimeSquareCount + rw [sum_comm, mul_sum] + apply sum_le_sum + intro p hp + rw [mrt_count_multiples (pow_pos (hP p hp).pos 2)] + convert (Nat.cast_div_le (m := N) (n := p ^ 2) : + ((N / p ^ 2 : ℕ) : ℝ) ≤ (N : ℝ) / (p ^ 2 : ℕ)) using 1 + push_cast + ring + +lemma minor_arc_short_square_error (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (E : ℕ → ℂ) (X H : ℕ) (A : ℝ) (hA : 0 ≤ A) + (hE : ∀ n, 0 < n → n ≤ X + H → ‖E n‖ ≤ A * mrtPrimeSquareCount P n) + (α : ℝ) : + (∑ k ∈ range X, ‖shortExponentialSum E H α k‖) ≤ + A * (H : ℝ) * (X + H) * ∑ p ∈ P, 1 / (p : ℝ) ^ 2 := by + have hpoint (k : ℕ) (hk : k ∈ range X) : + ‖shortExponentialSum E H α k‖ ≤ A * ∑ n ∈ Icc (k + 1) (k + H), + mrtPrimeSquareCount P n := by + rw [shortExponentialSum_at_nat] + apply (norm_sum_le _ _).trans + rw [mul_sum] + apply sum_le_sum + intro n hn + rw [norm_mul, norm_additiveCharacter, mul_one] + have hnI := mem_Icc.mp hn + have hkX := mem_range.mp hk + exact hE n (by omega) (by omega) + calc + _ ≤ ∑ k ∈ range X, A * ∑ n ∈ Icc (k + 1) (k + H), mrtPrimeSquareCount P n := + sum_le_sum hpoint + _ = A * ∑ k ∈ range X, ∑ n ∈ Icc (k + 1) (k + H), mrtPrimeSquareCount P n := + (mul_sum _ _ _).symm + _ ≤ A * ((H : ℝ) * ∑ n ∈ Icc 1 (X + H), mrtPrimeSquareCount P n) := + mul_le_mul_of_nonneg_left (minor_arc_window_mass X H _ (mrtPrimeSquareCount_nonneg P)) hA + _ ≤ A * ((H : ℝ) * ((X + H : ℕ) * ∑ p ∈ P, 1 / (p : ℝ) ^ 2)) := by + apply mul_le_mul_of_nonneg_left _ hA + exact mul_le_mul_of_nonneg_left (minor_arc_prime_square_mass P hP (X + H)) (Nat.cast_nonneg H) + _ = _ := by push_cast; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcSieveSaving.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcSieveSaving.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f48c8febb3517919d8d464bf471bc42bd86c70e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcSieveSaving.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcParameters +import OAI.NumberTheory.TwoPoint.Bounds.SievePrimeEnergy + +namespace OAI + +/-! The four-prime estimate in corrected MRT, equation (3.3). -/ + +namespace TwoPointCorrelations + +open Finset Filter + +/-- The additive-energy sieve and rational kernel give the required uniform +four-prime saving. The prime set may be any subset of the dyadic prime block. -/ +theorem minor_arc_sieve_saving : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ R : ℝ in atTop, + ∀ (P : Finset ℕ) (N : ℕ), + (∀ p ∈ P, p.Prime ∧ p ≠ 2 ∧ p ≤ N) → (N : ℝ) ≤ 2 * R → + ∀ H W V : ℝ, 1 ≤ W → W ≤ R → + ∀ (a : ℤ) (q : ℕ), 2 ≤ q → W ≤ (q : ℝ) → (q : ℝ) ≤ H / W → + R ≤ H / W → 0 ≤ V → V ≤ H / R → + ∀ α : ℝ, IsCoprime (q : ℤ) a → + |α - (a : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2 → + (∑ p₁ ∈ P, ∑ p₂ ∈ P, ∑ p₃ ∈ P, ∑ p₄ ∈ P, + minorArcGeometricBound V (α * ((p₁ : ℝ) + p₂ - p₃ - p₄))) ≤ + C * H * R ^ 3 * (1 + Real.log H) / (W * Real.log R ^ 4) := by + obtain ⟨C, hC, henergy⟩ := sieve_prime_additive_energy + refine ⟨192 * C, by positivity, ?_⟩ + filter_upwards [henergy, eventually_ge_atTop (1 : ℝ)] with R henergy hR + intro P N hP hN H W V hW hWR a q hq hWq hqH hRH hV hVR α hcop happ + have hE := henergy P (fun p hp => + ⟨(hP p hp).1, (hP p hp).2.1, + (show (p : ℝ) ≤ N by exact_mod_cast (hP p hp).2.2).trans hN⟩) + have hkernel := minor_arc_prime_kernel_rational P N (fun p hp => (hP p hp).2.2) + α V hV a q hq hcop happ + have hqpos : (0 : ℝ) < q := by exact_mod_cast (by omega : 0 < q) + have hlogq : 0 ≤ Real.log (q : ℝ) := + Real.log_nonneg (by exact_mod_cast (by omega : 1 ≤ q)) + have hparam := minor_arc_parameter_bound R H W (q : ℝ) V hR hW hWR hWq hqH hRH hV hVR + have hmon : + 2 * (3 * (2 * (N : ℝ) + 1) / q + 1) * + (2 * V + 4 * (q : ℝ) * (1 + Real.log (q : ℝ))) ≤ + 2 * (3 * (4 * R + 1) / q + 1) * + (2 * V + 4 * (q : ℝ) * (1 + Real.log (q : ℝ))) := by + have hnum : 3 * (2 * (N : ℝ) + 1) ≤ 3 * (4 * R + 1) := by linarith + apply mul_le_mul_of_nonneg_right _ (by positivity) + apply mul_le_mul_of_nonneg_left _ (by norm_num) + exact add_le_add (div_le_div_of_nonneg_right hnum hqpos.le) le_rfl + have hparam0 : 0 ≤ 192 * H * (1 + Real.log H) / W := + (by positivity : 0 ≤ + 2 * (3 * (2 * (N : ℝ) + 1) / q + 1) * + (2 * V + 4 * (q : ℝ) * (1 + Real.log (q : ℝ)))) |>.trans (hmon.trans hparam) + calc + _ ≤ (Finset.addEnergy P P : ℝ) * + (192 * H * (1 + Real.log H) / W) := + hkernel.trans (mul_le_mul_of_nonneg_left (hmon.trans hparam) (Nat.cast_nonneg _)) + _ ≤ (C * R ^ 3 / Real.log R ^ 4) * + (192 * H * (1 + Real.log H) / W) := mul_le_mul_of_nonneg_right hE hparam0 + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcSignedKernel.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcSignedKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..f5fb9e503a87282deee3eb4f3101ba928a416035 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcSignedKernel.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcEnergyKernel +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcVinogradov + +namespace OAI + +/-! The rational geometric-kernel bound on a symmetric integer range. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma minor_arc_natAbs_fiber (S : Finset ℤ) (k : ℕ) : + (S.filter (fun n => n.natAbs = k)).card ≤ 2 := by + have hs : S.filter (fun n => n.natAbs = k) ⊆ {(k : ℤ), -(k : ℤ)} := by + intro n hn + have ha : |n| = (k : ℤ) := by + rw [← Int.natCast_natAbs, (mem_filter.mp hn).2] + have he : |n| = |(k : ℤ)| := by simpa only [abs_of_nonneg (Int.natCast_nonneg k)] using ha + rcases abs_eq_abs.mp he with he | he + · simp only [mem_insert, mem_singleton] + exact Or.inl he + · simp only [mem_insert, mem_singleton] + exact Or.inr he + exact (card_le_card hs).trans card_le_two + +theorem minor_arc_signed_kernel (N q : ℕ) (α V : ℝ) (a : ℤ) + (hq : 2 ≤ q) (hV : 0 ≤ V) (hcop : IsCoprime (q : ℤ) a) + (happrox : |α - (a : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2) : + (∑ n ∈ Icc (-(N : ℤ)) (N : ℤ), minorArcGeometricBound V ((n : ℝ) * α)) ≤ + 2 * (3 * ((N : ℝ) + 1) / q + 1) * + (2 * V + 4 * (q : ℝ) * (1 + Real.log (q : ℝ))) := by + let S := Icc (-(N : ℤ)) (N : ℤ) + have hmap : ∀ n ∈ S, n.natAbs ∈ range (N + 1) := by + intro n hn + have hb : (n.natAbs : ℤ) ≤ (N : ℤ) := by + rw [Int.natCast_natAbs] + exact abs_le.mpr (mem_Icc.mp hn) + have hbN : n.natAbs ≤ N := by exact_mod_cast hb + exact mem_range.mpr (by omega) + have he := minor_arc_fiber_sum S (range (N + 1)) Int.natAbs + (fun n => minorArcGeometricBound V ((n : ℝ) * α)) 2 hmap + (fun n _ => minor_arc_geometric_nonneg hV _) + (fun n _ => by + convert (Nat.cast_le (α := ℝ)).mpr (minor_arc_natAbs_fiber S n) using 1 + apply congrArg (fun T : Finset ℤ => (T.card : ℝ)) + ext z + simp only [mem_filter]) + have hs : (∑ n ∈ S, minorArcGeometricBound V ((n.natAbs : ℝ) * α)) = + ∑ n ∈ S, minorArcGeometricBound V ((n : ℝ) * α) := + sum_congr rfl (fun n _ => minor_arc_geometric_natAbs V α n) + rw [hs] at he + have hv := minor_arc_vinogradov (N + 1) q α V a hq hV hcop happrox + have htwice := mul_le_mul_of_nonneg_left hv (by norm_num : (0 : ℝ) ≤ 2) + simp only [Nat.cast_add, Nat.cast_one] at htwice + exact he.trans (by nlinarith [htwice]) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcSquareLogError.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcSquareLogError.lean new file mode 100644 index 0000000000000000000000000000000000000000..ed6854ed21cdf13c113118e4de59e7071bbb4daa --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcSquareLogError.lean @@ -0,0 +1,41 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcPrimeRanges + +namespace OAI + +/-! Absorbing the single prime-square error in the logarithmic saving. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma minor_arc_square_log_error (P : Finset ℕ) (X H : ℕ) (hHX : H ≤ X) + (hlogH : 1 ≤ Real.log (H : ℝ)) (hloglogH : 1 ≤ Real.log (Real.log (H : ℝ))) + (hP : ∀ p ∈ P, (Real.log (H : ℝ)) ^ 5 ≤ (p : ℝ) ∧ p ≤ H) : + 3 * (H : ℝ) * (X + H) * (∑ p ∈ P, 1 / (p : ℝ) ^ 2) ≤ + 12 * (X : ℝ) * H * Real.log (Real.log (H : ℝ)) / Real.log (H : ℝ) := by + let W := (Real.log (H : ℝ)) ^ 5 + have hL : 0 < Real.log (H : ℝ) := by linarith + have hW : 0 < W := by dsimp [W]; positivity + have hR : 0 < ⌈W⌉₊ := Nat.one_le_ceil_iff.mpr hW + have htail := minor_arc_square_reciprocal_sum P ⌈W⌉₊ H hR + (fun p hp => ⟨Nat.ceil_le.mpr (hP p hp).1, (hP p hp).2⟩) + have hsum : (∑ p ∈ P, 1 / (p : ℝ) ^ 2) ≤ 2 / W := + htail.trans (div_le_div_of_nonneg_left (by norm_num) hW (Nat.le_ceil W)) + have hpow : Real.log (H : ℝ) ≤ W := le_self_pow₀ hlogH (by norm_num : (5 : ℕ) ≠ 0) + have hratio : 1 / W ≤ Real.log (Real.log (H : ℝ)) / Real.log (H : ℝ) := by + exact (one_div_le_one_div_of_le hL hpow).trans + (div_le_div_of_nonneg_right hloglogH hL.le) + have hXH : (X : ℝ) + H ≤ 2 * X := by exact_mod_cast (by omega : X + H ≤ 2 * X) + calc + 3 * (H : ℝ) * (X + H) * (∑ p ∈ P, 1 / (p : ℝ) ^ 2) ≤ + 3 * (H : ℝ) * (X + H) * (2 / W) := + mul_le_mul_of_nonneg_left hsum (by positivity) + _ ≤ 3 * (H : ℝ) * (2 * X) * (2 / W) := by gcongr + _ = (12 * (X : ℝ) * H) * (1 / W) := by ring + _ ≤ (12 * (X : ℝ) * H) * (Real.log (Real.log (H : ℝ)) / Real.log (H : ℝ)) := + mul_le_mul_of_nonneg_left hratio (by positivity) + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTheorem.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTheorem.lean new file mode 100644 index 0000000000000000000000000000000000000000..83d969a733b3cb8f2a508681805e2a8d9d4c325a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTheorem.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcSquareLogError + +namespace OAI + +/-! The minor-arc part of corrected MRT, Section 3: the literal typical-set +short integral has the required log-log over log saving. -/ + +namespace TwoPointCorrelations + +open Finset + +theorem minor_arc_typical_short_bound : + ∃ C : ℝ, 0 < C ∧ ∃ R₀ : ℕ, + ∀ {ι : Type*} (I : Finset ι) (P : ι → Finset ℕ), + (∀ i ∈ I, ∀ p ∈ P i, p.Prime) → Set.PairwiseDisjoint (I : Set ι) P → + ∀ i ∈ I, ∀ (X H : ℕ), 2 ≤ H → H ≤ X → + 1 ≤ Real.log (H : ℝ) → 1 ≤ Real.log (Real.log (H : ℝ)) → + (∀ p ∈ P i, p ≠ 2 ∧ 2 * R₀ ≤ p ∧ + 2 * (Real.log (H : ℝ)) ^ 5 ≤ (p : ℝ) ∧ + (p : ℝ) ≤ (H : ℝ) / (Real.log (H : ℝ)) ^ 5) → + ∀ (F : ℕ → ℂ), Multiplicative F → OneBounded F → + ∀ (r : ℤ) (q : ℕ), 2 ≤ q → + (Real.log (H : ℝ)) ^ 5 ≤ (q : ℝ) → + (q : ℝ) ≤ (H : ℝ) / (Real.log (H : ℝ)) ^ 5 → + ∀ α : ℝ, IsCoprime (q : ℤ) r → + |α - (r : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2 → + shortExponentialIntegral (mrtTypicalCoefficient I P F) X H α ≤ + C * (X : ℝ) * H * Real.log (Real.log (H : ℝ)) / Real.log (H : ℝ) := by + obtain ⟨C, hC, R₀, hbound⟩ := minor_arc_typical_prime_range_saving + refine ⟨C + 12, by positivity, R₀, ?_⟩ + intro ι I P hP hdis i hi X H hH hHX hlogH hloglog hrange F hF hFb + r q hq hWq hqH α hcop happ + have ht := hbound I P hP hdis i hi X H hH hHX hlogH hloglog hrange + F hF hFb r q hq hWq hqH α hcop happ + have hW : 1 ≤ (Real.log (H : ℝ)) ^ 5 := one_le_pow₀ hlogH + have hr : ∀ p ∈ P i, (Real.log (H : ℝ)) ^ 5 ≤ (p : ℝ) ∧ p ≤ H := by + intro p hp + have hlow := (hrange p hp).2.2.1 + have hhigh := (hrange p hp).2.2.2 + refine ⟨by linarith, ?_⟩ + have hh : (p : ℝ) ≤ H := hhigh.trans (div_le_self (Nat.cast_nonneg H) hW) + exact_mod_cast hh + have he := minor_arc_square_log_error (P i) X H hHX hlogH hloglog hr + apply ht.trans + convert add_le_add (le_refl (C * (X : ℝ) * H * Real.log (Real.log (H : ℝ)) / + Real.log (H : ℝ))) he using 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTrivial.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTrivial.lean new file mode 100644 index 0000000000000000000000000000000000000000..73f3cdf2c712eb751248ea4b9240f91b4e41b5fb --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTrivial.lean @@ -0,0 +1,36 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ShortSumSampling + +namespace OAI + +/-! The exact trivial bound used for bounded ranges of the short length. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma minor_arc_short_sum_trivial (F : ℕ → ℂ) (hF : OneBounded F) + (H k : ℕ) (α : ℝ) : ‖shortExponentialSum F H α k‖ ≤ H := by + rw [shortExponentialSum_at_nat] + calc + _ ≤ ∑ n ∈ Icc (k + 1) (k + H), ‖F n * additiveCharacter α n‖ := norm_sum_le _ _ + _ ≤ ∑ _n ∈ Icc (k + 1) (k + H), (1 : ℝ) := by + apply sum_le_sum + intro n hn + rw [norm_mul, norm_additiveCharacter, mul_one] + exact hF n (by have hh := (mem_Icc.mp hn).1; omega) + _ = H := by + simp only [sum_const, nsmul_eq_mul, mul_one, Nat.card_Icc] + congr 1 + omega + +lemma minor_arc_short_integral_trivial (F : ℕ → ℂ) (hF : OneBounded F) + (X H : ℕ) (α : ℝ) : shortExponentialIntegral F X H α ≤ (X : ℝ) * H := by + rw [shortExponentialIntegral_eq_sum] + calc + _ ≤ ∑ _k ∈ range X, (H : ℝ) := + sum_le_sum (fun k _ => minor_arc_short_sum_trivial F hF H k α) + _ = _ := by simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTypicalIntegral.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTypicalIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..8601285413ff99d9ebb6261916165bfc9a91660b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTypicalIntegral.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcRamareWindow +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcShortError + +namespace OAI + +/-! The actual typical-set short-sum integral, reduced to the bounded +bilinear window plus its single prime-square error. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem minor_arc_typical_integral_le {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (hP : ∀ j ∈ J, ∀ p ∈ P j, p.Prime) + (hdis : Set.PairwiseDisjoint (J : Set ι) P) {j : ι} (hj : j ∈ J) + (F : ℕ → ℂ) (hF : Multiplicative F) (hFb : OneBounded F) + (X H M : ℕ) (hM : ∀ p ∈ P j, ∀ k ∈ range X, (k + H) / p < M) (α : ℝ) : + shortExponentialIntegral (mrtTypicalCoefficient J P F) X H α ≤ + (∑ k ∈ range X, ‖minorArcBilinearWindow (P j) M H 1 + (minorArcRamareCofactor (P j) (mrtTypicalCoefficient (J.erase j) P F)) F α k‖) + + 3 * (H : ℝ) * (X + H) * ∑ p ∈ P j, 1 / (p : ℝ) ^ 2 := by + let C := mrtTypicalCoefficient J P F + let B := mrtTypicalCoefficient (J.erase j) P F + let A := minorArcRamareApprox (P j) F B + let E := fun n => C n - A n + have herr : (∑ k ∈ range X, ‖shortExponentialSum E H α k‖) ≤ + 3 * (H : ℝ) * (X + H) * ∑ p ∈ P j, 1 / (p : ℝ) ^ 2 := by + apply minor_arc_short_square_error (P j) (hP j hj) E X H 3 (by norm_num) + intro n hn _ + exact minor_arc_typical_ramare_pointwise J P hP hdis hj F hF hFb hn + have hlin (k : ℕ) : shortExponentialSum C H α k = + shortExponentialSum A H α k + shortExponentialSum E H α k := by + simp only [shortExponentialSum_at_nat] + rw [← sum_add_distrib] + apply sum_congr rfl + intro n _ + dsimp [E] + ring + rw [shortExponentialIntegral_eq_sum] + calc + _ ≤ ∑ k ∈ range X, (‖shortExponentialSum A H α k‖ + + ‖shortExponentialSum E H α k‖) := by + apply sum_le_sum + intro k _ + rw [show mrtTypicalCoefficient J P F = C from rfl, hlin] + exact norm_add_le _ _ + _ = (∑ k ∈ range X, ‖minorArcBilinearWindow (P j) M H 1 + (minorArcRamareCofactor (P j) B) F α k‖) + + ∑ k ∈ range X, ‖shortExponentialSum E H α k‖ := by + rw [sum_add_distrib] + congr 1 + apply sum_congr rfl + intro k hk + exact congrArg norm (minor_arc_ramare_short_eq_bounded (P j) M H k + (fun p hp => (hP j hj p hp).pos) (fun p hp => hM p hp k hk) F B α) + _ ≤ _ := add_le_add le_rfl herr + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTypicalRemoval.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTypicalRemoval.lean new file mode 100644 index 0000000000000000000000000000000000000000..0bfbff40dcd08f198f86d5de0c80debd39d38a3c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTypicalRemoval.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTTypicalDensity +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTTypicalCoarse +import OAI.NumberTheory.TwoPoint.Bounds.SmoothWindowSum + +namespace OAI + +/-! Removing the typical-set restriction costs its actual missing density. +This comparison is uniform in the additive frequency and pays the discarded +integers once, before either the major- or minor-arc estimate is applied. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma minor_arc_typical_pointwise_error {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (F : ℕ → ℂ) (hF : OneBounded F) + {n : ℕ} (hn : 0 < n) : + ‖F n - mrtTypicalCoefficient J P F n‖ ≤ + if ¬mrtTypical J P n then (1 : ℝ) else 0 := by + unfold mrtTypicalCoefficient + by_cases h : mrtTypical J P n + · simp [h] + · simpa [h] using hF n hn + +lemma minor_arc_typical_error_sum {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (F : ℕ → ℂ) (hF : OneBounded F) + (X H : ℕ) (α : ℝ) : + shortExponentialIntegral F X H α ≤ + shortExponentialIntegral (mrtTypicalCoefficient J P F) X H α + + (H : ℝ) * ∑ n ∈ range (X + H), + if ¬mrtTypical J P (n + 1) then (1 : ℝ) else 0 := by + have herr := window_error_from_density F (mrtTypicalCoefficient J P F) + (fun n => if ¬mrtTypical J P n then (1 : ℝ) else 0) + (fun _ => by split_ifs <;> positivity) + (fun n hn => minor_arc_typical_pointwise_error J P F hF hn) H X α + simp only [shortExponentialIntegral_eq_sum, norm_shortExponentialSum_eq_window] + calc + _ ≤ ∑ v ∈ range X, + (‖shortWindowSum (mrtTypicalCoefficient J P F) H α v‖ + + ‖shortWindowSum F H α v - + shortWindowSum (mrtTypicalCoefficient J P F) H α v‖) := by + apply sum_le_sum + intro v _ + calc + _ = ‖shortWindowSum (mrtTypicalCoefficient J P F) H α v + + (shortWindowSum F H α v - + shortWindowSum (mrtTypicalCoefficient J P F) H α v)‖ := by congr 1; ring + _ ≤ _ := norm_add_le _ _ + _ ≤ _ := by rw [sum_add_distrib]; exact add_le_add le_rfl herr + +lemma minor_arc_typical_density_sum {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (N : ℕ) [NeZero N] : + (∑ n ∈ range N, if ¬mrtTypical J P (n + 1) then (1 : ℝ) else 0) = + (N : ℝ) * (uniformFiniteLaw (Fin N)).probability + (fun n => ¬mrtTypical J P (1 + n.val)) := by + unfold FiniteLaw.probability FiniteLaw.average uniformFiniteLaw + dsimp only + rw [← mul_sum, Fintype.card_fin, ← mul_assoc] + have hN : (N : ℝ) ≠ 0 := by exact_mod_cast NeZero.ne N + rw [mul_one_div_cancel hN, one_mul] + symm + apply sum_bij (fun n _ => n.val) + · intro n _ + exact mem_range.mpr n.isLt + · intro n _ m _ he + exact Fin.ext he + · intro n hn + exact ⟨⟨n, mem_range.mp hn⟩, mem_univ _, rfl⟩ + · intro n _ + simp only [Nat.add_comm 1] + +theorem minor_arc_remove_typical {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (F : ℕ → ℂ) (hF : OneBounded F) + (X H : ℕ) [NeZero (X + H)] (α δ : ℝ) + (hdensity : (uniformFiniteLaw (Fin (X + H))).probability + (fun n => ¬mrtTypical J P (1 + n.val)) ≤ δ) : + shortExponentialIntegral F X H α ≤ + shortExponentialIntegral (mrtTypicalCoefficient J P F) X H α + + (H : ℝ) * (X + H) * δ := by + apply (minor_arc_typical_error_sum J P F hF X H α).trans + rw [minor_arc_typical_density_sum] + apply add_le_add le_rfl + calc + _ ≤ (H : ℝ) * ((X + H : ℕ) * δ) := + mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left hdensity (Nat.cast_nonneg _)) (Nat.cast_nonneg H) + _ = _ := by push_cast; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTypicalSaving.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTypicalSaving.lean new file mode 100644 index 0000000000000000000000000000000000000000..90b463af84ab7b606d35a27756e6106e468b9211 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcTypicalSaving.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcDyadicIntegral +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcTypicalIntegral + +namespace OAI + +/-! The minor-arc short-integral estimate for the actual MRT typical set. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem minor_arc_typical_log_saving : + ∃ C : ℝ, 0 < C ∧ ∃ R₀ : ℕ, + ∀ {ι : Type*} (I : Finset ι) (P : ι → Finset ℕ), + (∀ i ∈ I, ∀ p ∈ P i, p.Prime) → Set.PairwiseDisjoint (I : Set ι) P → + ∀ i ∈ I, ∀ (J : Finset ℕ) (X H N : ℕ), 1 ≤ H → H ≤ X → + 1 ≤ Real.log (H : ℝ) → J ⊆ Icc 1 N → + (∀ p ∈ P i, Nat.log 2 p ∈ J) → (∀ p ∈ P i, p ≠ 2) → + (∀ j ∈ J, R₀ ≤ 2 ^ j ∧ 2 ^ j ≤ X) → + (∀ j ∈ J, (Real.log (H : ℝ)) ^ 5 ≤ (2 : ℝ) ^ j ∧ + (2 : ℝ) ^ j ≤ (H : ℝ) / (Real.log (H : ℝ)) ^ 5) → + ∀ (F : ℕ → ℂ), Multiplicative F → OneBounded F → + ∀ (r : ℤ) (q : ℕ), 2 ≤ q → + (Real.log (H : ℝ)) ^ 5 ≤ (q : ℝ) → + (q : ℝ) ≤ (H : ℝ) / (Real.log (H : ℝ)) ^ 5 → + ∀ α : ℝ, IsCoprime (q : ℤ) r → + |α - (r : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2 → + shortExponentialIntegral (mrtTypicalCoefficient I P F) X H α ≤ + C * (X : ℝ) * H * (1 + Real.log (N : ℝ)) / Real.log (H : ℝ) + + 3 * (H : ℝ) * (X + H) * ∑ p ∈ P i, 1 / (p : ℝ) ^ 2 := by + obtain ⟨C, hC, R₀, hbound⟩ := minor_arc_bilinear_log_saving + refine ⟨C, hC, R₀, ?_⟩ + intro ι I P hP hdis i hi J X H N hH hHX hlogH hJN hPJ hodd hR hgeom + F hF hFb r q hq hWq hqH α hcop happ + let B := mrtTypicalCoefficient (I.erase i) P F + let a := minorArcRamareCofactor (P i) B + have ha : ∀ m, ‖a m‖ ≤ 1 := + minor_arc_ramare_cofactor_bound (P i) B + (mrtTypicalCoefficient_oneBounded (I.erase i) P F hFb) + have hc : ∀ p ∈ P i, ‖F p‖ ≤ 1 := fun p hp => hFb p (hP i hi p hp).pos + have hbil := hbound (P i) J X H N hH hHX hlogH hJN hPJ + (fun p hp => ⟨hP i hi p hp, hodd p hp⟩) hR hgeom a F ha hc + r q hq hWq hqH α hcop happ + have hcut : ∀ p ∈ P i, ∀ k ∈ range X, (k + H) / p < X + H + 1 := by + intro p _ k hk + have hkX := mem_range.mp hk + have hd := Nat.div_le_self (k + H) p + omega + have htyp := minor_arc_typical_integral_le I P hP hdis hi F hF hFb + X H (X + H + 1) hcut α + exact htyp.trans (add_le_add hbil le_rfl) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcVinogradov.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcVinogradov.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e6de366e955ae3d0ddc632a27652878240b244a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcVinogradov.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcSeparatedKernel + +namespace OAI + +/-! The finite Vinogradov bound obtained by partitioning an integer range +into blocks shorter than half the rational denominator. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma minor_arc_nat_rational_block (S : Finset ℕ) (α : ℝ) (a : ℤ) (q : ℕ) + (hq : 0 < q) (hcop : IsCoprime (q : ℤ) a) (V : ℝ) (hV : 0 ≤ V) + (hwidth : ∀ m ∈ S, ∀ n ∈ S, |(m : ℝ) - n| ≤ (q : ℝ) / 2) + (happrox : |α - (a : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2) : + (∑ n ∈ S, minorArcGeometricBound V ((n : ℝ) * α)) ≤ + 2 * V + 4 * (q : ℝ) * (1 + Real.log (q : ℝ)) := by + let e : ℕ ↪ ℤ := ⟨Nat.cast, Nat.cast_injective⟩ + have hb := minor_arc_rational_block (S.map e) α a (q : ℤ) + (by exact_mod_cast hq) hcop V hV ?_ (by simpa using happrox) + · simpa only [sum_map, e, Function.Embedding.coeFn_mk, Int.cast_natCast] using hb + · intro m hm n hn + obtain ⟨m', hm', rfl⟩ := mem_map.mp hm + obtain ⟨n', hn', rfl⟩ := mem_map.mp hn + simpa only [e, Function.Embedding.coeFn_mk, Int.cast_sub, Int.cast_natCast] using + hwidth m' hm' n' hn' + +theorem minor_arc_vinogradov (N q : ℕ) (α V : ℝ) (a : ℤ) + (hq : 2 ≤ q) (hV : 0 ≤ V) (hcop : IsCoprime (q : ℤ) a) + (happrox : |α - (a : ℝ) / (q : ℝ)| ≤ 1 / (q : ℝ) ^ 2) : + (∑ n ∈ range N, minorArcGeometricBound V ((n : ℝ) * α)) ≤ + (3 * (N : ℝ) / q + 1) * (2 * V + 4 * (q : ℝ) * (1 + Real.log (q : ℝ))) := by + let L := q / 2 + let J := N / L + 1 + let S := fun j : ℕ => (range N).filter (fun n => n / L = j) + have hL : 0 < L := Nat.div_pos hq (by norm_num) + have hLr : (0 : ℝ) < L := by exact_mod_cast hL + have hqr : (0 : ℝ) < q := by exact_mod_cast (by omega : 0 < q) + have hLq : (L : ℝ) ≤ (q : ℝ) / 2 := by + exact Nat.cast_div_le + have hblock (j : ℕ) : (∑ n ∈ S j, minorArcGeometricBound V ((n : ℝ) * α)) ≤ + 2 * V + 4 * (q : ℝ) * (1 + Real.log (q : ℝ)) := by + apply minor_arc_nat_rational_block (S j) α a q (by omega) hcop V hV ?_ happrox + intro m hm n hn + have hmj : m / L = j := (mem_filter.mp hm).2 + have hnj : n / L = j := (mem_filter.mp hn).2 + have hmlo : j * L ≤ m := by simpa only [hmj] using Nat.div_mul_le_self m L + have hnlo : j * L ≤ n := by simpa only [hnj] using Nat.div_mul_le_self n L + have hmhi : m < L * (j + 1) := by simpa only [hmj] using Nat.lt_mul_div_succ m hL + have hnhi : n < L * (j + 1) := by simpa only [hnj] using Nat.lt_mul_div_succ n hL + have hmi : (j : ℝ) * L ≤ m := by exact_mod_cast hmlo + have hni : (j : ℝ) * L ≤ n := by exact_mod_cast hnlo + have hma : (m : ℝ) < L * ((j : ℝ) + 1) := by exact_mod_cast hmhi + have hna : (n : ℝ) < L * ((j : ℝ) + 1) := by exact_mod_cast hnhi + apply (le_of_lt (abs_lt.mpr ⟨?_, ?_⟩)).trans hLq <;> nlinarith + have hpart : (∑ n ∈ range N, minorArcGeometricBound V ((n : ℝ) * α)) = + ∑ j ∈ range J, ∑ n ∈ S j, minorArcGeometricBound V ((n : ℝ) * α) := by + symm + apply sum_fiberwise_of_maps_to + intro n hn + apply mem_range.mpr + have hle : n / L ≤ N / L := Nat.div_le_div_right (mem_range.mp hn).le + omega + have hqL : (q : ℝ) ≤ 3 * (L : ℝ) := by + have hmod := Nat.mod_lt q (by norm_num : 0 < 2) + have hid := Nat.mod_add_div q 2 + have hqq : q ≤ 3 * L := by dsimp [L] at *; omega + exact_mod_cast hqq + have hJ : (J : ℝ) ≤ 3 * (N : ℝ) / q + 1 := by + have hquot : (N : ℝ) / L ≤ 3 * (N : ℝ) / q := by + apply (div_le_div_iff₀ hLr hqr).mpr + nlinarith [mul_le_mul_of_nonneg_left hqL (Nat.cast_nonneg N : (0 : ℝ) ≤ N)] + calc + _ = ((N / L : ℕ) : ℝ) + 1 := by simp [J] + _ ≤ (N : ℝ) / L + 1 := add_le_add Nat.cast_div_le le_rfl + _ ≤ _ := by linarith + have hconstant : 0 ≤ 2 * V + 4 * (q : ℝ) * (1 + Real.log (q : ℝ)) := by + have hlog : 0 ≤ Real.log (q : ℝ) := Real.log_nonneg (by exact_mod_cast (show 1 ≤ q by omega)) + positivity + rw [hpart] + calc + _ ≤ ∑ _j ∈ range J, (2 * V + 4 * (q : ℝ) * (1 + Real.log (q : ℝ))) := + sum_le_sum (fun j _ => hblock j) + _ = (J : ℝ) * (2 * V + 4 * (q : ℝ) * (1 + Real.log (q : ℝ))) := by + simp only [sum_const, card_range, nsmul_eq_mul] + _ ≤ _ := mul_le_mul_of_nonneg_right hJ hconstant + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWindowFourth.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWindowFourth.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f91d10e4f36e891e6d641afbf06cfb1c953943d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWindowFourth.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcOriginSum + +namespace OAI + +/-! The discrete weighted-window fourth moment in MRT's minor-arc argument. -/ + +namespace TwoPointCorrelations + +open Finset + +/-- A prime block contributes only `X (3H+1)^3` possible origin quadruples. +The remaining cancellation is exactly the four-prime geometric kernel. -/ +theorem minor_arc_window_fourth (P : Finset ℕ) (X M H d : ℕ) (hd : 0 < d) + (hP : ∀ p ∈ P, 0 < p ∧ ∀ q ∈ P, q ≤ 2 * p) + (c θ : ℕ → ℂ) (hc : ∀ p ∈ P, ‖c p‖ ≤ 1) (hθ : ∀ k, ‖θ k‖ ≤ 1) + (α V : ℝ) (hV : ∀ p ∈ P, (H : ℝ) / (d * p : ℕ) + 1 ≤ V) : + (∑ m ∈ range M, ‖∑ p ∈ P, ∑ k ∈ range X, + minorArcWindowTerm M (d * p) k H (c p * θ k) (α * p) m‖ ^ 4) ≤ + (X * (3 * H + 1) ^ 3 : ℕ) * + ∑ p₁ ∈ P, ∑ p₂ ∈ P, ∑ p₃ ∈ P, ∑ p₄ ∈ P, + minorArcGeometricBound V (α * ((p₁ : ℝ) + p₂ - p₃ - p₄)) := by + classical + let f := fun v : ℕ × ℕ => + minorArcWindowTerm M (d * v.1) v.2 H (c v.1 * θ v.2) (α * v.1) + have he := minor_arc_fourth_moment_bound (P ×ˢ range X) (range M) f + dsimp [f] at he + simp only [sum_product] at he + simp_rw [sum_comm (s := range X) (t := P)] at he + apply he.trans + simp only [mul_sum] + apply sum_le_sum + intro p₁ hp₁ + apply sum_le_sum + intro p₂ hp₂ + apply sum_le_sum + intro p₃ hp₃ + apply sum_le_sum + intro p₄ hp₄ + have hcoef (p : ℕ) (hp : p ∈ P) (k : ℕ) : ‖c p * θ k‖ ≤ 1 := by + rw [norm_mul] + calc + _ ≤ 1 * 1 := mul_le_mul (hc p hp) (hθ k) (norm_nonneg _) (by norm_num) + _ = 1 := by norm_num + have h := minor_arc_origin_kernel_sum X M (d * p₁) (d * p₂) (d * p₃) (d * p₄) H + (Nat.mul_pos hd (hP p₁ hp₁).1) + (Nat.mul_pos hd (hP p₂ hp₂).1) + (Nat.mul_pos hd (hP p₃ hp₃).1) + (Nat.mul_pos hd (hP p₄ hp₄).1) + (by nlinarith [(hP p₁ hp₁).2 p₂ hp₂]) + (by nlinarith [(hP p₁ hp₁).2 p₃ hp₃]) + (by nlinarith [(hP p₁ hp₁).2 p₄ hp₄]) + (fun k => c p₁ * θ k) (fun k => c p₂ * θ k) + (fun k => c p₃ * θ k) (fun k => c p₄ * θ k) + (hcoef p₁ hp₁) (hcoef p₂ hp₂) (hcoef p₃ hp₃) (hcoef p₄ hp₄) + (α * p₁) (α * p₂) (α * p₃) (α * p₄) V (hV p₁ hp₁) + have hphase : α * (p₁ : ℝ) + α * p₂ - α * p₃ - α * p₄ = + α * ((p₁ : ℝ) + p₂ - p₃ - p₄) := by ring + rw [hphase] at h + exact h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWindowInterval.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWindowInterval.lean new file mode 100644 index 0000000000000000000000000000000000000000..e527000f63ffd589177e50303fc7ecea0d38b473 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWindowInterval.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcOriginGeometry + +namespace OAI + +/-! Exact finite cofactor intervals for discrete short-sum origins. -/ + +namespace TwoPointCorrelations + +open Finset + +/-- The upper cofactor cutoff is exclusive. -/ +def minorArcWindowInterval (M A k H : ℕ) : Finset ℕ := + Ico (k / A + 1) (min M ((k + H) / A + 1)) + +lemma mem_minorArcWindowInterval (M A k H m : ℕ) (hA : 0 < A) : + m ∈ minorArcWindowInterval M A k H ↔ + m < M ∧ k < A * m ∧ A * m ≤ k + H := by + unfold minorArcWindowInterval + rw [mem_Ico, lt_min_iff] + have hlow : k / A < m ↔ k < A * m := by + simpa only [Nat.mul_comm] using (Nat.div_lt_iff_lt_mul hA : k / A < m ↔ k < m * A) + have hhigh : m ≤ (k + H) / A ↔ A * m ≤ k + H := by + simpa only [Nat.mul_comm] using + (Nat.le_div_iff_mul_le hA : m ≤ (k + H) / A ↔ m * A ≤ k + H) + omega + +lemma minor_arc_interval_length (A k H a b : ℕ) (hA : 0 < A) + (hwindow : ∀ m ∈ Ico a b, k < A * m ∧ A * m ≤ k + H) : + ((b - a : ℕ) : ℝ) ≤ (H : ℝ) / A + 1 := by + have hA0 : (0 : ℝ) < A := by exact_mod_cast hA + by_cases hab : a < b + · have ha := (hwindow a (mem_Ico.mpr ⟨le_rfl, hab⟩)).1 + have hb := (hwindow (b - 1) (mem_Ico.mpr ⟨by omega, by omega⟩)).2 + have haR : (k : ℝ) < (A : ℝ) * a := by exact_mod_cast ha + have hbR : (A : ℝ) * (b - 1 : ℕ) ≤ (k : ℝ) + H := by exact_mod_cast hb + rw [Nat.cast_sub (by omega : 1 ≤ b), Nat.cast_one] at hbR + rw [Nat.cast_sub (by omega : a ≤ b)] + rw [show (H : ℝ) / A + 1 = ((H : ℝ) + A) / A by field_simp [hA0.ne']] + apply (le_div_iff₀ hA0).mpr + nlinarith + · rw [Nat.sub_eq_zero_of_le (by omega : b ≤ a), Nat.cast_zero] + positivity + +lemma minor_arc_geometric_mono {L V : ℝ} (h : L ≤ V) (α : ℝ) : + minorArcGeometricBound L α ≤ minorArcGeometricBound V α := by + unfold minorArcGeometricBound + split_ifs + · exact h + · exact min_le_min h le_rfl + +lemma minor_arc_geometric_window (A k H a b : ℕ) (hA : 0 < A) + (hwindow : ∀ m ∈ Ico a b, k < A * m ∧ A * m ≤ k + H) (α : ℝ) : + ‖∑ m ∈ Ico a b, additiveCharacter α m‖ ≤ + minorArcGeometricBound ((H : ℝ) / A + 1) α := + (minor_arc_geometric_bound α a b).trans + (minor_arc_geometric_mono (minor_arc_interval_length A k H a b hA hwindow) α) + +/-- The intersection of four origin windows is again one interval; its +length is controlled by the first prime, regardless of the other origins. -/ +lemma minor_arc_four_window_kernel (M A B C D k l r s H : ℕ) + (hA : 0 < A) (α : ℝ) : + ‖∑ m ∈ (minorArcWindowInterval M A k H ∩ minorArcWindowInterval M B l H) ∩ + (minorArcWindowInterval M C r H ∩ minorArcWindowInterval M D s H), + additiveCharacter α m‖ ≤ minorArcGeometricBound ((H : ℝ) / A + 1) α := by + unfold minorArcWindowInterval + rw [Ico_inter_Ico, Ico_inter_Ico, Ico_inter_Ico] + apply minor_arc_geometric_window A k H _ _ hA + intro m hm + have hm' := mem_Ico.mp hm + have hlow : k / A + 1 ≤ m := le_trans (le_trans (le_max_left _ _) (le_max_left _ _)) hm'.1 + have hhigh : m < (k + H) / A + 1 := + lt_of_lt_of_le hm'.2 (le_trans (min_le_left _ _) (le_trans (min_le_left _ _) (min_le_right _ _))) + have hmlow : k < A * m := by + have hh : k / A < m := by omega + simpa only [Nat.mul_comm] using (Nat.div_lt_iff_lt_mul hA).mp hh + have hmhigh : A * m ≤ k + H := by + have hh : m ≤ (k + H) / A := by omega + simpa only [Nat.mul_comm] using (Nat.le_div_iff_mul_le hA).mp hh + exact ⟨hmlow, hmhigh⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWindowProduct.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWindowProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..b53248329ef6d560f6b27cb4de82f80d93dc56a2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWindowProduct.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcWindowInterval +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcPrimeFourth + +namespace OAI + +/-! One term of the fourth expansion of a weighted short-window sum. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical ComplexConjugate + +noncomputable def minorArcWindowTerm (M A k H : ℕ) (z : ℂ) (β : ℝ) (m : ℕ) : ℂ := + if m ∈ minorArcWindowInterval M A k H then z * additiveCharacter β m else 0 + +lemma minor_arc_window_product (M A B C D k l r s H : ℕ) + (hA : 0 < A) (z₁ z₂ z₃ z₄ : ℂ) (β₁ β₂ β₃ β₄ : ℝ) : + (∑ m ∈ range M, + minorArcWindowTerm M A k H z₁ β₁ m * minorArcWindowTerm M B l H z₂ β₂ m * + conj (minorArcWindowTerm M C r H z₃ β₃ m) * + conj (minorArcWindowTerm M D s H z₄ β₄ m)) = + (z₁ * z₂ * conj z₃ * conj z₄) * + ∑ m ∈ (minorArcWindowInterval M A k H ∩ minorArcWindowInterval M B l H) ∩ + (minorArcWindowInterval M C r H ∩ minorArcWindowInterval M D s H), + additiveCharacter (β₁ + β₂ - β₃ - β₄) m := by + let S := (minorArcWindowInterval M A k H ∩ minorArcWindowInterval M B l H) ∩ + (minorArcWindowInterval M C r H ∩ minorArcWindowInterval M D s H) + let z := z₁ * z₂ * conj z₃ * conj z₄ + have hphase (m : ℕ) : + additiveCharacter β₁ m * additiveCharacter β₂ m * + conj (additiveCharacter β₃ m) * conj (additiveCharacter β₄ m) = + additiveCharacter (β₁ + β₂ - β₃ - β₄) m := by + simpa only [one_mul] using minor_arc_phase_four 1 β₁ β₂ β₃ β₄ m + have he (m : ℕ) : + minorArcWindowTerm M A k H z₁ β₁ m * minorArcWindowTerm M B l H z₂ β₂ m * + conj (minorArcWindowTerm M C r H z₃ β₃ m) * + conj (minorArcWindowTerm M D s H z₄ β₄ m) = + if m ∈ S then z * additiveCharacter (β₁ + β₂ - β₃ - β₄) m else 0 := by + by_cases ha : m ∈ minorArcWindowInterval M A k H + · by_cases hb : m ∈ minorArcWindowInterval M B l H + · by_cases hc : m ∈ minorArcWindowInterval M C r H + · by_cases hd : m ∈ minorArcWindowInterval M D s H + · simp only [minorArcWindowTerm, ha, hb, hc, hd, ite_true, S, mem_inter, + and_self, map_mul, z] + rw [← hphase] + ring + · simp [minorArcWindowTerm, S, ha, hb, hc, hd] + · simp [minorArcWindowTerm, S, ha, hb, hc] + · simp [minorArcWindowTerm, S, ha, hb] + · simp [minorArcWindowTerm, S, ha] + have hsub : S ⊆ range M := by + intro m hm + exact mem_range.mpr ((mem_minorArcWindowInterval M A k H m hA).mp + (mem_inter.mp (mem_inter.mp hm).1).1).1 + have hfilt : (range M).filter (fun m => m ∈ S) = S := by + ext m + simp only [mem_filter] + exact ⟨And.right, fun hm => ⟨hsub hm, hm⟩⟩ + simp_rw [he] + rw [← sum_filter, hfilt, mul_sum] + +lemma minor_arc_window_product_bound (M A B C D k l r s H : ℕ) + (hA : 0 < A) (z₁ z₂ z₃ z₄ : ℂ) (β₁ β₂ β₃ β₄ V : ℝ) + (hz : ‖z₁ * z₂ * conj z₃ * conj z₄‖ ≤ 1) + (hV : (H : ℝ) / A + 1 ≤ V) : + ‖∑ m ∈ range M, + minorArcWindowTerm M A k H z₁ β₁ m * minorArcWindowTerm M B l H z₂ β₂ m * + conj (minorArcWindowTerm M C r H z₃ β₃ m) * + conj (minorArcWindowTerm M D s H z₄ β₄ m)‖ ≤ + minorArcGeometricBound V (β₁ + β₂ - β₃ - β₄) := by + rw [minor_arc_window_product M A B C D k l r s H hA, norm_mul] + calc + _ ≤ 1 * ‖∑ m ∈ (minorArcWindowInterval M A k H ∩ minorArcWindowInterval M B l H) ∩ + (minorArcWindowInterval M C r H ∩ minorArcWindowInterval M D s H), + additiveCharacter (β₁ + β₂ - β₃ - β₄) m‖ := + mul_le_mul_of_nonneg_right hz (norm_nonneg _) + _ ≤ _ := by + rw [one_mul] + exact (minor_arc_four_window_kernel M A B C D k l r s H hA _).trans + (minor_arc_geometric_mono hV _) + +lemma minor_arc_window_product_support (M A B C D k l r s H : ℕ) + (hA : 0 < A) (z₁ z₂ z₃ z₄ : ℂ) (β₁ β₂ β₃ β₄ V : ℝ) + (hz : ‖z₁ * z₂ * conj z₃ * conj z₄‖ ≤ 1) + (hV : (H : ℝ) / A + 1 ≤ V) : + ‖∑ m ∈ range M, + minorArcWindowTerm M A k H z₁ β₁ m * minorArcWindowTerm M B l H z₂ β₂ m * + conj (minorArcWindowTerm M C r H z₃ β₃ m) * + conj (minorArcWindowTerm M D s H z₄ β₄ m)‖ ≤ + if ((minorArcWindowInterval M A k H ∩ minorArcWindowInterval M B l H) ∩ + (minorArcWindowInterval M C r H ∩ minorArcWindowInterval M D s H)).Nonempty + then minorArcGeometricBound V (β₁ + β₂ - β₃ - β₄) else 0 := by + split_ifs with hs + · exact minor_arc_window_product_bound M A B C D k l r s H hA + z₁ z₂ z₃ z₄ β₁ β₂ β₃ β₄ V hz hV + · have hempty := not_nonempty_iff_eq_empty.mp hs + rw [minor_arc_window_product M A B C D k l r s H hA, hempty] + simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWorkingBound.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWorkingBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..faff933b3170e402fbbcc39ad17e9fffc14faf31 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWorkingBound.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcParameterRanges +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcWorkingBand + +namespace OAI + +/-! The typical minor-arc estimate at the common working length. Both +the fourth-root saving and the prime-square remainder fit one rate. -/ +namespace TwoPointCorrelations + +open Finset + +theorem minor_arc_typical_working_bound : + ∃ C : ℝ, 0 < C ∧ ∃ R₀ : ℕ, + ∀ {ι : Type*} (I : Finset ι) (P : ι → Finset ℕ), + (∀ i ∈ I, ∀ p ∈ P i, p.Prime) → Set.PairwiseDisjoint (I:Set ι) P → + ∀ i ∈ I, ∀ X H : ℕ, 2 ≤ H → H ≤ X → + 1 ≤ Real.log (H:ℝ) → 1 ≤ Real.log (Real.log (H:ℝ)) → + ∀ W : ℝ, 1 ≤ W → Real.log (H:ℝ) ≤ W^(1/5:ℝ) → + (∀ p ∈ P i, p ≠ 2 ∧ 2*R₀ ≤ p ∧ 2*W ≤ (p:ℝ) ∧ (p:ℝ) ≤ (H:ℝ)/W) → + ∀ F : ℕ → ℂ, Multiplicative F → OneBounded F → + ∀ r : ℤ, ∀ q : ℕ, 2 ≤ q → W ≤ (q:ℝ) → (q:ℝ) ≤ (H:ℝ)/W → + ∀ α : ℝ, IsCoprime (q:ℤ) r → |α-(r:ℝ)/q| ≤ 1/(q:ℝ)^2 → + shortExponentialIntegral (mrtTypicalCoefficient I P F) X H α ≤ + C*(X:ℝ)*H*majorArcWorkingError W := by + obtain ⟨C,hC,R₀,hbound⟩ := minor_arc_typical_parameter_range_saving + refine ⟨C+12,by positivity,R₀,?_⟩ + intro ι I P hP hdis i hi X H hH hHX hLH hLL W hW hcap hrange F hFm hFb r q hq hWq hqH α hcop happ + have hW0 : 0 < W := by linarith + have hR : 0 < ⌈W⌉₊ := Nat.ceil_pos.mpr hW0 + have hpr : ∀ p ∈ P i, ⌈W⌉₊ ≤ p ∧ p ≤ H := by + intro p hp + have hr := hrange p hp + refine ⟨Nat.ceil_le.mpr (by linarith [hr.2.2.1]),?_⟩ + exact_mod_cast hr.2.2.2.trans (div_le_self (Nat.cast_nonneg H) hW) + have htail : (∑ p ∈ P i, 1/(p:ℝ)^2) ≤ 2/W := by + apply (minor_arc_square_reciprocal_sum (P i) ⌈W⌉₊ H hR hpr).trans + exact div_le_div_of_nonneg_left (by norm_num) hW0 (Nat.le_ceil W) + have hworking := major_arc_minor_working_rate hW hLH hcap + have hinv : W⁻¹ ≤ majorArcWorkingError W := by + calc + _ = W^(-1:ℝ) := (Real.rpow_neg_one W).symm + _ ≤ W^(-1/5:ℝ) := Real.rpow_le_rpow_of_exponent_le hW (by norm_num) + _ ≤ _ := le_mul_of_one_le_left (Real.rpow_nonneg hW0.le _) + (by linarith [Real.log_nonneg hW]) + have hx : (X:ℝ)+(H:ℝ) ≤ 2*(X:ℝ) := by exact_mod_cast (show X+H ≤ 2*X by omega) + have hmain := mul_le_mul_of_nonneg_left hworking (show 0 ≤ C*(X:ℝ)*H by positivity) + have he : 3*(H:ℝ)*(X+H)*(∑ p ∈ P i, 1/(p:ℝ)^2) ≤ + 12*(X:ℝ)*H*majorArcWorkingError W := by + calc + _ ≤ 3*(H:ℝ)*(X+H)*(2/W) := mul_le_mul_of_nonneg_left htail (by positivity) + _ ≤ 3*(H:ℝ)*(2*X)*(2/W) := by gcongr + _ = 12*(X:ℝ)*H*W⁻¹ := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left hinv (by positivity) + apply (hbound I P hP hdis i hi X H hH hHX hLH hLL W hW hrange + F hFm hFb r q hq hWq hqH α hcop happ).trans + have hh := add_le_add hmain he + convert hh using 1 <;> ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWorkingMean.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWorkingMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..9f1d21ac922efa9bb0209db0907b1d8a355617dc --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWorkingMean.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcWorkingParameters + +namespace OAI + +/-! Minor arcs at the same parameter and prime bands as the major arcs. +The original outer logarithm remains fixed while the origin range varies. -/ +namespace TwoPointCorrelations + +open Filter Finset + +theorem minor_arc_actual_working_mean : + ∃ C : ℝ, 0 < C ∧ ∃ W₀ : ℝ, ∀ᶠ L : ℝ in atTop, + ∀ H : ℕ, 0 < H → 1 ≤ Real.log (H:ℝ) → 1 ≤ Real.log (Real.log (H:ℝ)) → + ∀ M : ℝ, 0 ≤ M → + let W := majorArcParameter L H M + let h := majorArcWorkingLength H W + let P := W^(500000:ℕ) + let Q := (h:ℝ)/W^3 + W₀ ≤ W → ∀ Y J : ℕ, h ≤ Y → 1 ≤ J → + ∀ F : ℕ → ℂ, Multiplicative F → OneBounded F → + ∀ r : ℤ, ∀ q : ℕ, W ≤ (q:ℝ) → (q:ℝ) ≤ (h:ℝ)/W → + ∀ α : ℝ, IsCoprime (q:ℤ) r → |α-(r:ℝ)/q| ≤ 1/(q:ℝ)^2 → + shortExponentialIntegral (mrtTypicalCoefficient (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) Y h α ≤ + C*(Y:ℝ)*h*(Real.exp (-M/20)+Real.log (Real.log H)/Real.log H+L^(-1/700:ℝ)) := by + obtain ⟨C,hC,R₀,hminor⟩ := minor_arc_typical_working_bound + obtain ⟨W₀,hW₀⟩ := eventually_atTop.mp + ((minor_arc_actual_working_parameters R₀).and mrt_working_prime_parameters) + refine ⟨21*C,by positivity,W₀,?_⟩ + filter_upwards [major_arc_parameter_rate,eventually_ge_atTop (1:ℝ)] with L hrate hL + intro H hH hLH hLL M hM + dsimp only + intro hWlarge Y J hhY hJ F hFm hFb r q hWq hqh α hcop happ + let W := majorArcParameter L H M + let h := majorArcWorkingLength H W + let P := W^(500000:ℕ) + let Q := (h:ℝ)/W^3 + obtain ⟨_,hWH,_,_⟩ := major_arc_parameter_bounds hL hLH hM + obtain ⟨hwindow,hprime⟩ := hW₀ W hWlarge + obtain ⟨hh,hW,hWh,hLh,hLLh,hcap,hprimes⟩ := hwindow H hH hLH hWH + obtain ⟨hP,hPQ,hLP,_,_,_,_⟩ := hprime.2 H hH hLH hWH + have hq : 2 ≤ q := by exact_mod_cast hprime.1.trans hWq + have hm := hminor (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) + (fun _ _ _ hp => mrtPrimeBand_prime hp) + (major_arc_actual_bands_disjoint hP hPQ (by linarith)) 1 + (mem_Icc.mpr ⟨le_rfl,hJ⟩) Y h hh hhY hLh hLLh W hW hcap hprimes + F hFm hFb r q hq hWq hqh α hcop happ + have hs := hrate (H:ℝ) M hLH hLL hM + rw [mul_div_assoc] at hs + have he : majorArcWorkingError W ≤ + 21*(Real.exp (-M/20)+Real.log (Real.log H)/Real.log H+L^(-1/700:ℝ)) := by + have hshort : 0 ≤ Real.log (Real.log (H:ℝ))/Real.log H := by positivity + have herr : 0 ≤ L^(-1/700:ℝ) := Real.rpow_nonneg (by linarith) _ + linarith only [hs,hshort,herr] + apply hm.trans + have hp := mul_le_mul_of_nonneg_left he (show 0≤C*(Y:ℝ)*h by positivity) + convert hp using 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWorkingParameters.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWorkingParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..d63e550da8fe869f4f006813aed04e573b0ff5b2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/MinorArcWorkingParameters.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.TwoPoint.Fourier.MajorArcBandAvoidance +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTWorkingParameters +import OAI.NumberTheory.TwoPoint.Fourier.MinorArcWorkingBound + +namespace OAI + +/-! The literal first band satisfies all minor-arc support conditions +once the common parameter exceeds a fixed threshold. -/ +namespace TwoPointCorrelations + +open Filter Finset + +theorem minor_arc_actual_working_parameters (R₀ : ℕ) : + ∀ᶠ W : ℝ in atTop, ∀ H : ℕ, 0 < H → 1 ≤ Real.log (H:ℝ) → + W ≤ Real.log (H:ℝ)^5 → + let h := majorArcWorkingLength H W + let P := W^(500000:ℕ) + let Q := (h:ℝ)/W^3 + 2 ≤ h ∧ 1 ≤ W ∧ W ≤ h ∧ 1 ≤ Real.log (h:ℝ) ∧ + 1 ≤ Real.log (Real.log (h:ℝ)) ∧ Real.log (h:ℝ) ≤ W^(1/5:ℝ) ∧ + (∀ p ∈ mrtPrimeBand (mrtBandLower P Q 1) (mrtBandUpper Q 1), + p ≠ 2 ∧ 2*R₀ ≤ p ∧ 2*W ≤ (p:ℝ) ∧ (p:ℝ) ≤ (h:ℝ)/W) := by + have hlog : Tendsto (fun W:ℝ => Real.log W) atTop atTop := Real.tendsto_log_atTop + filter_upwards [mrt_working_prime_parameters,major_arc_working_length_power 2, + (hlog.comp hlog).eventually (eventually_ge_atTop (1:ℝ)), + hlog.eventually (eventually_ge_atTop (1:ℝ)), + eventually_ge_atTop ((2*R₀:ℕ):ℝ)] with W hp hpower hLL hL hR + intro H hH hLH hWH + dsimp only + obtain ⟨hW,hpar⟩ := hp + obtain ⟨hP,hPQ,_,_,_,_,_⟩ := hpar H hH hLH hWH + let h := majorArcWorkingLength H W + let P := W^(500000:ℕ) + let Q := (h:ℝ)/W^3 + have hW1 : 1 ≤ W := by linarith + have hW0 : 0 < W := by linarith + have hhpow : W^2 ≤ (h:ℝ) := hpower H hH hLH hWH + have hWh : W ≤ (h:ℝ) := (le_self_pow₀ hW1 (by decide : (2:ℕ)≠0)).trans hhpow + have hh : 2 ≤ h := by exact_mod_cast hW.trans hWh + have hLh : 1 ≤ Real.log (h:ℝ) := hL.trans (Real.log_le_log hW0 hWh) + have hLLh : 1 ≤ Real.log (Real.log (h:ℝ)) := + hLL.trans (Real.log_le_log (by linarith : 0 < Real.log W) + (Real.log_le_log hW0 hWh)) + have hcap : Real.log (h:ℝ) ≤ W^(1/5:ℝ) := by + have hl := Real.log_le_log (by exact_mod_cast (show 0 0`; its norm is at most +`4 * ‖s‖ / re s`, using the exact period bound rather than a new input. +-/ + +namespace TwoPointCorrelations + +open Finset Filter MeasureTheory +open scoped BigOperators Classical Topology + +noncomputable def modFiveSummatory (χ : DirichletCharacter ℂ 5) (t : ℝ) : ℂ := + ∑ n ∈ Icc 1 ⌊t⌋₊, χ (n : ZMod 5) + +noncomputable def modFiveAbelKernel (χ : DirichletCharacter ℂ 5) (s : ℂ) (t : ℝ) : ℂ := + modFiveSummatory χ t * (t : ℂ) ^ (-(s + 1)) + +noncomputable def modFiveAbelIntegral (χ : DirichletCharacter ℂ 5) (s : ℂ) : ℂ := + s * ∫ t in Set.Ioi (1 : ℝ), modFiveAbelKernel χ s t + +lemma modFiveSummatory_measurable (χ : DirichletCharacter ℂ 5) : + Measurable (modFiveSummatory χ) := by + exact (measurable_from_nat (f := fun N => ∑ n ∈ Icc 1 N, χ (n : ZMod 5))).comp + Nat.measurable_floor + +lemma modFiveSummatory_norm (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) (t : ℝ) : + ‖modFiveSummatory χ t‖ ≤ 4 := + modFive_character_Icc_norm χ hχ ⌊t⌋₊ + +lemma modFiveAbelKernel_measurable (χ : DirichletCharacter ℂ 5) (s : ℂ) : + AEStronglyMeasurable (modFiveAbelKernel χ s) (volume.restrict (Set.Ioi (1 : ℝ))) := by + have hpow : ContinuousOn (fun t : ℝ => (t : ℂ) ^ (-(s + 1))) (Set.Ioi (1 : ℝ)) := by + intro t ht + exact (Complex.continuousAt_ofReal_cpow_const _ _ + (Or.inr (zero_lt_one.trans ht).ne')).continuousWithinAt + exact (modFiveSummatory_measurable χ).aestronglyMeasurable.mul + (hpow.aestronglyMeasurable measurableSet_Ioi) + +lemma modFiveAbelKernel_norm_le (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) + (s : ℂ) {t : ℝ} (ht : 1 < t) : + ‖modFiveAbelKernel χ s t‖ ≤ 4 * t ^ (-(s.re + 1)) := by + rw [modFiveAbelKernel, norm_mul, + Complex.norm_cpow_eq_rpow_re_of_pos (zero_lt_one.trans ht), Complex.neg_re, + Complex.add_re, Complex.one_re] + exact mul_le_mul_of_nonneg_right (modFiveSummatory_norm χ hχ t) + (Real.rpow_nonneg (zero_lt_one.trans ht).le _) + +theorem modFiveAbelKernel_integrable (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) + {s : ℂ} (hs : 0 < s.re) : + IntegrableOn (modFiveAbelKernel χ s) (Set.Ioi (1 : ℝ)) := by + have hmajor : IntegrableOn (fun t : ℝ => 4 * t ^ (-(s.re + 1))) (Set.Ioi (1 : ℝ)) := + (integrableOn_Ioi_rpow_of_lt (by linarith : -(s.re + 1) < -1) zero_lt_one).const_mul 4 + refine hmajor.mono' (modFiveAbelKernel_measurable χ s) ?_ + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + exact modFiveAbelKernel_norm_le χ hχ s ht + +lemma modFiveAbelKernel_integral_norm (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) + {s : ℂ} (hs : 0 < s.re) : + ‖∫ t in Set.Ioi (1 : ℝ), modFiveAbelKernel χ s t‖ ≤ 4 / s.re := by + have hexp : -(s.re + 1) < -1 := by linarith + calc + _ ≤ ∫ t in Set.Ioi (1 : ℝ), 4 * t ^ (-(s.re + 1)) := by + apply norm_integral_le_of_norm_le + ((integrableOn_Ioi_rpow_of_lt hexp zero_lt_one).const_mul 4) + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + exact modFiveAbelKernel_norm_le χ hχ s ht + _ = 4 / s.re := by + rw [integral_const_mul, integral_Ioi_rpow_of_lt hexp zero_lt_one, Real.one_rpow] + field_simp [ne_of_gt hs] + ring + +theorem modFiveAbelIntegral_norm (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) + {s : ℂ} (hs : 0 < s.re) : + ‖modFiveAbelIntegral χ s‖ ≤ 4 * ‖s‖ / s.re := by + rw [modFiveAbelIntegral, norm_mul] + calc + _ ≤ ‖s‖ * (4 / s.re) := + mul_le_mul_of_nonneg_left (modFiveAbelKernel_integral_norm χ hχ hs) (norm_nonneg s) + _ = _ := by ring + +theorem modFiveAbelIntegral_eq_LFunction (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) + {s : ℂ} (hs : 1 < s.re) : + modFiveAbelIntegral χ s = DirichletCharacter.LFunction χ s := + (modFive_LFunction_Abel χ hχ hs).symm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveAbelContinuation.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveAbelContinuation.lean new file mode 100644 index 0000000000000000000000000000000000000000..6721009c548ab96b22a7d065b9e1d7aeb31c9e7c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveAbelContinuation.lean @@ -0,0 +1,125 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveAbelBounds +import Mathlib.Analysis.MellinTransform +import Mathlib.Analysis.Analytic.Uniqueness +import Mathlib.Analysis.Convex.Topology + +namespace OAI + +/-! Continue the bounded-partial-sum Abel integral to `re s > 0`. + +The Mellin differentiation theorem gives holomorphy without differentiating +an improperly convergent Dirichlet series. The identity principle then +identifies it with the existing entire Dirichlet L-function. In particular +each of the three modulus-five functions has a uniform linear growth bound +on `re s ≥ 1/2`. +-/ + +namespace TwoPointCorrelations + +open Filter MeasureTheory Asymptotics +open scoped BigOperators Classical Topology + +noncomputable def modFiveAbelInput (χ : DirichletCharacter ℂ 5) : ℝ → ℂ := + (Set.Ioi (1 : ℝ)).indicator (modFiveSummatory χ) + +lemma modFiveAbelInput_measurable (χ : DirichletCharacter ℂ 5) : + Measurable (modFiveAbelInput χ) := + (modFiveSummatory_measurable χ).indicator measurableSet_Ioi + +lemma modFiveAbelInput_norm (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) (t : ℝ) : + ‖modFiveAbelInput χ t‖ ≤ 4 := by + by_cases ht : 1 < t + · simpa only [modFiveAbelInput, Set.mem_Ioi, Set.indicator_apply, ite_eq_left ht] using + modFiveSummatory_norm χ hχ t + · simp only [modFiveAbelInput, Set.mem_Ioi, Set.indicator_apply, ite_eq_right ht, norm_zero] + norm_num + +lemma modFiveAbelInput_locallyIntegrable (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) : + LocallyIntegrableOn (modFiveAbelInput χ) (Set.Ioi (0 : ℝ)) := by + refine (locallyIntegrableOn_const (s := Set.Ioi (0 : ℝ)) (4 : ℝ)).mono + (modFiveAbelInput_measurable χ).aestronglyMeasurable ?_ + exact Eventually.of_forall fun t => by simpa using modFiveAbelInput_norm χ hχ t + +lemma modFiveAbelInput_bigO_atTop (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) : + modFiveAbelInput χ =O[atTop] (fun t : ℝ => t ^ (-(0 : ℝ))) := by + refine IsBigO.of_bound 4 (Eventually.of_forall fun t => ?_) + simpa only [neg_zero, Real.rpow_zero, norm_one, mul_one] using modFiveAbelInput_norm χ hχ t + +lemma modFiveAbelInput_bigO_zero (χ : DirichletCharacter ℂ 5) (b : ℝ) : + modFiveAbelInput χ =O[𝓝[>] (0 : ℝ)] (fun t : ℝ => t ^ (-b)) := by + refine IsBigO.of_bound 0 ?_ + filter_upwards [(eventually_lt_nhds (show (0 : ℝ) < 1 by norm_num)).filter_mono + nhdsWithin_le_nhds] with t ht + have hnot : t ∉ Set.Ioi (1 : ℝ) := by change ¬1 < t; linarith + simp only [modFiveAbelInput, Set.indicator_of_notMem hnot, norm_zero, zero_mul, le_refl] + +lemma modFiveAbelIntegral_eq_mellin (χ : DirichletCharacter ℂ 5) (s : ℂ) : + modFiveAbelIntegral χ s = s * mellin (modFiveAbelInput χ) (-s) := by + unfold modFiveAbelIntegral mellin + congr 1 + have heq : (fun t : ℝ => (t : ℂ) ^ (-s - 1) • modFiveAbelInput χ t) = + (Set.Ioi (1 : ℝ)).indicator (modFiveAbelKernel χ s) := by + funext t + by_cases ht : 1 < t + · simp only [modFiveAbelInput, Set.indicator_apply, Set.mem_Ioi, ite_eq_left ht, + smul_eq_mul, modFiveAbelKernel] + rw [show -s - 1 = -(s + 1) by ring, mul_comm] + · have hn : t ∉ Set.Ioi (1 : ℝ) := ht + simp only [modFiveAbelInput, Set.indicator_of_notMem hn, smul_zero] + rw [heq, setIntegral_indicator measurableSet_Ioi] + rw [Set.inter_eq_right.mpr (show Set.Ioi (1 : ℝ) ⊆ Set.Ioi (0 : ℝ) from + fun t ht => lt_trans (show (0 : ℝ) < 1 from zero_lt_one) ht)] + +theorem modFiveAbelIntegral_differentiableAt (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) + {s : ℂ} (hs : 0 < s.re) : DifferentiableAt ℂ (modFiveAbelIntegral χ) s := by + have hm : DifferentiableAt ℂ (mellin (modFiveAbelInput χ)) (-s) := by + apply mellin_differentiableAt_of_isBigO_rpow + (modFiveAbelInput_locallyIntegrable χ hχ) (modFiveAbelInput_bigO_atTop χ hχ) + (b := -s.re - 1) + · simpa only [Complex.neg_re] using neg_neg_of_pos hs + · exact modFiveAbelInput_bigO_zero χ _ + · simp only [Complex.neg_re] + linarith + have heq : modFiveAbelIntegral χ = fun z => z * mellin (modFiveAbelInput χ) (-z) := + funext (modFiveAbelIntegral_eq_mellin χ) + rw [heq] + exact differentiableAt_id.mul (hm.comp s differentiableAt_id.neg) + +/-- The bounded-partial-sum integral is the existing L-function on the +entire half-plane of convergence of that integral. -/ +theorem modFiveAbelIntegral_eq_LFunction_of_pos (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) {s : ℂ} (hs : 0 < s.re) : + modFiveAbelIntegral χ s = DirichletCharacter.LFunction χ s := by + let U : Set ℂ := {z | 0 < z.re} + have ho : IsOpen U := isOpen_lt continuous_const Complex.continuous_re + have hc : Convex ℝ U := (convex_Ioi (0 : ℝ)).linear_preimage Complex.reLm + have hF : AnalyticOnNhd ℂ (DirichletCharacter.LFunction χ) U := + (DirichletCharacter.differentiable_LFunction hχ).differentiableOn.analyticOnNhd ho + have hG : AnalyticOnNhd ℂ (modFiveAbelIntegral χ) U := by + apply DifferentiableOn.analyticOnNhd _ ho + intro z hz + exact (modFiveAbelIntegral_differentiableAt χ hχ hz).differentiableWithinAt + have heq : DirichletCharacter.LFunction χ =ᶠ[𝓝 (2 : ℂ)] modFiveAbelIntegral χ := by + filter_upwards [(isOpen_lt continuous_const Complex.continuous_re).mem_nhds + (show 1 < (2 : ℂ).re by norm_num)] with z hz + exact (modFiveAbelIntegral_eq_LFunction χ hχ hz).symm + exact (hF.eqOn_of_preconnected_of_eventuallyEq hG hc.isPreconnected + (show (2 : ℂ) ∈ U by change 0 < (2 : ℂ).re; norm_num) heq hs).symm + +theorem modFive_LFunction_norm_le (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) + {s : ℂ} (hs : 0 < s.re) : + ‖DirichletCharacter.LFunction χ s‖ ≤ 4 * ‖s‖ / s.re := by + rw [← modFiveAbelIntegral_eq_LFunction_of_pos χ hχ hs] + exact modFiveAbelIntegral_norm χ hχ hs + +theorem modFive_LFunction_norm_halfPlane (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) + {s : ℂ} (hs : (1 / 2 : ℝ) ≤ s.re) : + ‖DirichletCharacter.LFunction χ s‖ ≤ 8 * ‖s‖ := by + have hs0 : 0 < s.re := by linarith + apply (modFive_LFunction_norm_le χ hχ hs0).trans + apply (div_le_iff₀ hs0).mpr + nlinarith [norm_nonneg s] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveCenterBounds.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveCenterBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..26a4c7b61e7f489521aa4dcafebebb1a3b5f2811 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveCenterBounds.lean @@ -0,0 +1,114 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveAbelContinuation + +namespace OAI + +/-! Uniform lower bounds on `Re s = 2`, from the exact Möbius inverse. +Together with the Abel upper bound these give the polynomial bound for a +normalized analytic disk used in the fixed-modulus zero-free argument. +-/ + +namespace TwoPointCorrelations + +open Complex ArithmeticFunction +open scoped BigOperators Classical LSeries.notation ArithmeticFunction.Moebius + +noncomputable def modFiveInverseConstant : ℝ := + 1 + ∑' n : ℕ, ‖LSeries.term (1 : ℕ → ℂ) (2 : ℂ) n‖ + +lemma modFiveInverseConstant_pos : 0 < modFiveInverseConstant := by + unfold modFiveInverseConstant + have : 0 ≤ ∑' n : ℕ, ‖LSeries.term (1 : ℕ → ℂ) (2 : ℂ) n‖ := + tsum_nonneg fun _ => norm_nonneg _ + linarith + +lemma modFive_twisted_moebius_norm (χ : DirichletCharacter ℂ 5) (n : ℕ) : + ‖χ (n : ZMod 5) * ((μ n : ℤ) : ℂ)‖ ≤ 1 := by + rw [norm_mul] + have hμ : ‖((μ n : ℤ) : ℂ)‖ ≤ 1 := by + rw [Complex.norm_intCast] + exact_mod_cast (show |μ n| ≤ 1 from abs_moebius_le_one) + exact (mul_le_mul (χ.norm_le_one _) hμ (norm_nonneg _) zero_le_one).trans_eq (one_mul 1) + +lemma modFive_inverse_series_norm_le (χ : DirichletCharacter ℂ 5) + {s : ℂ} (hs : s.re = 2) : + ‖LSeries (fun n => χ (n : ZMod 5) * ((μ n : ℤ) : ℂ)) s‖ ≤ + modFiveInverseConstant := by + have hσ : 1 < s.re := by rw [hs]; norm_num + have hm := χ.LSeriesSummable_mul (ArithmeticFunction.LSeriesSummable_moebius_iff.mpr hσ) + have hbase : Summable (fun n : ℕ => ‖LSeries.term (1 : ℕ → ℂ) (2 : ℂ) n‖) := + (LSeriesSummable_one_iff.mpr (by norm_num : 1 < (2 : ℂ).re)).norm + calc + _ ≤ ∑' n : ℕ, ‖LSeries.term (fun n => χ (n : ZMod 5) * ((μ n : ℤ) : ℂ)) s n‖ := + norm_tsum_le_tsum_norm hm.norm + _ ≤ ∑' n : ℕ, ‖LSeries.term (1 : ℕ → ℂ) (2 : ℂ) n‖ := by + apply Summable.tsum_le_tsum (fun n => ?_) hm.norm hbase + simp only [LSeries.norm_term_eq, hs, Complex.re_ofNat, Pi.one_apply, norm_one] + split_ifs with hn + · rfl + · exact div_le_div_of_nonneg_right (modFive_twisted_moebius_norm χ n) + (Real.rpow_nonneg n.cast_nonneg _) + _ ≤ modFiveInverseConstant := by unfold modFiveInverseConstant; linarith + +/-- Uniform reciprocal bound, independent of the imaginary part and character. -/ +theorem modFive_LFunction_inv_norm (χ : DirichletCharacter ℂ 5) + {s : ℂ} (hs : s.re = 2) : + ‖(DirichletCharacter.LFunction χ s)⁻¹‖ ≤ modFiveInverseConstant := by + have hσ : 1 < s.re := by rw [hs]; norm_num + have heq := DirichletCharacter.LSeries.mul_mu_eq_one χ hσ + have hn := χ.LSeries_ne_zero_of_one_lt_re hσ + have hi : (LSeries (fun n => χ (n : ZMod 5)) s)⁻¹ = + LSeries (fun n => χ (n : ZMod 5) * ((μ n : ℤ) : ℂ)) s := by + apply (mul_left_cancel₀ hn) + simpa only [mul_inv_cancel₀ hn, Pi.mul_def] using heq.symm + rw [DirichletCharacter.LFunction_eq_LSeries χ hσ, hi] + exact modFive_inverse_series_norm_le χ hs + +noncomputable def modFiveNormalizedLFunction (χ : DirichletCharacter ℂ 5) (t : ℝ) + (z : ℂ) : ℂ := + DirichletCharacter.LFunction χ ((2 : ℂ) + Complex.I * (t : ℂ) + (3 / 2 : ℂ) * z) / + DirichletCharacter.LFunction χ ((2 : ℂ) + Complex.I * (t : ℂ)) + +lemma modFiveNormalizedLFunction_zero (χ : DirichletCharacter ℂ 5) (t : ℝ) : + modFiveNormalizedLFunction χ t 0 = 1 := by + simp only [modFiveNormalizedLFunction, mul_zero, add_zero] + exact div_self (χ.LFunction_ne_zero_of_one_le_re (Or.inr (by + intro h; have := congrArg Complex.re h; norm_num at this)) (by norm_num)) + +lemma modFiveNormalizedLFunction_differentiable (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (t : ℝ) : + Differentiable ℂ (modFiveNormalizedLFunction χ t) := by + unfold modFiveNormalizedLFunction + have ha : Differentiable ℂ (fun z : ℂ => (2 : ℂ) + Complex.I * (t : ℂ) + (3 / 2 : ℂ) * z) := by + fun_prop + exact ((DirichletCharacter.differentiable_LFunction hχ).comp ha).div_const _ + +lemma modFiveNormalizedLFunction_norm (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (t : ℝ) {z : ℂ} (hz : ‖z‖ ≤ 1) : + ‖modFiveNormalizedLFunction χ t z‖ ≤ + 8 * modFiveInverseConstant * (|t| + 4) := by + let s : ℂ := (2 : ℂ) + Complex.I * (t : ℂ) + (3 / 2 : ℂ) * z + have hr : -(1 : ℝ) ≤ z.re := by + have h := (abs_re_le_norm z).trans hz + exact (abs_le.mp h).1 + have hs : (1 / 2 : ℝ) ≤ s.re := by + norm_num [s, Complex.mul_re] + linarith + have hsbound : ‖s‖ ≤ |t| + 4 := by + calc + ‖s‖ ≤ ‖(2 : ℂ) + Complex.I * (t : ℂ)‖ + ‖(3 / 2 : ℂ) * z‖ := norm_add_le _ _ + _ ≤ (‖(2 : ℂ)‖ + ‖Complex.I * (t : ℂ)‖) + ‖(3 / 2 : ℂ) * z‖ := + add_le_add (norm_add_le _ _) le_rfl + _ = 2 + |t| + (3 / 2 : ℝ) * ‖z‖ := by + norm_num [norm_mul] + _ ≤ |t| + 4 := by linarith + have hn := modFive_LFunction_norm_halfPlane χ hχ hs + have hi := modFive_LFunction_inv_norm χ (s := (2 : ℂ) + Complex.I * (t : ℂ)) + (by simp) + unfold modFiveNormalizedLFunction + rw [div_eq_mul_inv, norm_mul] + exact (mul_le_mul hn hi (norm_nonneg _) (by positivity)).trans (by + nlinarith [modFiveInverseConstant_pos]) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveCharacterSums.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveCharacterSums.lean new file mode 100644 index 0000000000000000000000000000000000000000..60a9015a6ea26712ef0e31ce29f59948a11571bf --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveCharacterSums.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveLFunctions +import Mathlib.NumberTheory.LSeries.SumCoeff + +namespace OAI + +/-! Bounded character sums and the exact Abel integral for modulus five. + +Periodicity and the vanishing sum over one period give an absolute bound +four, independent of the character and of the cutoff. This is the first +analytic estimate for the three nonprincipal L-functions. +-/ + +namespace TwoPointCorrelations + +open Finset Filter Asymptotics MeasureTheory +open scoped BigOperators Classical Topology + +local instance : Fact (1 < (5 : ℕ)) := ⟨by decide⟩ + +lemma modFive_character_shift (χ : DirichletCharacter ℂ 5) (k n : ℕ) : + χ ((5 * k + n : ℕ) : ZMod 5) = χ (n : ZMod 5) := by + simp only [Nat.cast_add, Nat.cast_mul, ZMod.natCast_self, zero_mul, zero_add] + +lemma modFive_character_period_sum (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) : + (∑ n ∈ range 5, χ (n : ZMod 5)) = 0 := by + have hs := χ.sum_eq_zero_of_ne_one hχ + rw [sum_zmod_five] at hs + simpa only [sum_range_succ, sum_range_zero, zero_add, + Nat.cast_zero, Nat.cast_one, Nat.cast_ofNat] using hs + +lemma modFive_character_full_periods (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) + (k : ℕ) : (∑ n ∈ range (5 * k), χ (n : ZMod 5)) = 0 := by + induction k with + | zero => simp + | succ k ih => + rw [Nat.mul_succ, sum_range_add, ih, zero_add] + simp_rw [modFive_character_shift] + exact modFive_character_period_sum χ hχ + +/-- A complete number of periods can be removed exactly. -/ +lemma modFive_character_prefix_remainder (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (N : ℕ) : + (∑ n ∈ range N, χ (n : ZMod 5)) = + ∑ n ∈ range (N % 5), χ (n : ZMod 5) := by + have hN : N = 5 * (N / 5) + N % 5 := by omega + conv_lhs => rw [hN, sum_range_add, modFive_character_full_periods χ hχ, zero_add] + exact sum_congr rfl fun n _ => modFive_character_shift χ (N / 5) n + +theorem modFive_character_prefix_norm (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (N : ℕ) : + ‖∑ n ∈ range N, χ (n : ZMod 5)‖ ≤ 4 := by + rw [modFive_character_prefix_remainder χ hχ] + calc + _ ≤ ∑ n ∈ range (N % 5), ‖χ (n : ZMod 5)‖ := norm_sum_le _ _ + _ ≤ ∑ _n ∈ range (N % 5), (1 : ℝ) := sum_le_sum fun n _ => χ.norm_le_one _ + _ = (N % 5 : ℕ) := by simp + _ ≤ 4 := by exact_mod_cast (show N % 5 ≤ 4 by omega) + +lemma modFive_character_Icc_eq (χ : DirichletCharacter ℂ 5) (N : ℕ) : + (∑ n ∈ Icc 1 N, χ (n : ZMod 5)) = ∑ n ∈ range (N + 1), χ (n : ZMod 5) := by + rw [Nat.range_succ_eq_Icc_zero] + have hset : Icc 1 N = Ioc 0 N := by ext n; simp; omega + rw [hset, ← add_sum_Ioc_eq_sum_Icc (Nat.zero_le N), Nat.cast_zero, + MulChar.map_zero χ, zero_add] + +theorem modFive_character_Icc_norm (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (N : ℕ) : + ‖∑ n ∈ Icc 1 N, χ (n : ZMod 5)‖ ≤ 4 := by + rw [modFive_character_Icc_eq] + exact modFive_character_prefix_norm χ hχ (N + 1) + +lemma modFive_character_sum_bigO (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) : + (fun N : ℕ => ∑ n ∈ Icc 1 N, χ (n : ZMod 5)) =O[atTop] + (fun N : ℕ => (N : ℝ) ^ (0 : ℝ)) := by + refine isBigO_iff.mpr ⟨4, Eventually.of_forall fun N => ?_⟩ + simpa only [Real.rpow_zero, norm_one, mul_one] using modFive_character_Icc_norm χ hχ N + +/-- The exact integral on the initial half-plane. Bounded partial sums will +allow continuation of its right side to the larger half-plane `re s > 0`. -/ +theorem modFive_LFunction_Abel (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) + {s : ℂ} (hs : 1 < s.re) : + DirichletCharacter.LFunction χ s = + s * ∫ t in Set.Ioi (1 : ℝ), + (∑ n ∈ Icc 1 ⌊t⌋₊, χ (n : ZMod 5)) * (t : ℂ) ^ (-(s + 1)) := by + rw [DirichletCharacter.LFunction_eq_LSeries χ hs] + exact LSeries_eq_mul_integral (fun n => χ (n : ZMod 5)) (by norm_num : (0 : ℝ) ≤ 0) + (by linarith : (0 : ℝ) < s.re) (χ.LSeriesSummable_of_one_lt_re hs) + (modFive_character_sum_bigO χ hχ) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveContourKernel.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveContourKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..49bcd4a238680066813b20ee22e87096e7f3cd15 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveContourKernel.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveLFunctions +import Mathlib.Analysis.MellinInversion +import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals +import Mathlib.Analysis.SpecialFunctions.Pow.Continuity +import PrimeNumberTheoremAnd.Erdos970.ResidueCalcOnRectangles + +namespace OAI + +/-! Elementary kernel estimates for the finite Perron rectangle. +The vertical side has an integrable quadratic majorant, while each +horizontal side has the explicit inverse-square height saving. +-/ + +namespace TwoPointCorrelations + +open Complex + +noncomputable def modFivePerronKernel (x : ℝ) (s : ℂ) : ℂ := + (x : ℂ) ^ s / (s * (s + 1)) + +lemma modFive_perron_denominator_vertical {σ : ℝ} (hσ : 1 / 2 ≤ σ) (t : ℝ) : + (1 + t ^ 2) / 4 ≤ + ‖((σ : ℂ) + (t : ℂ) * Complex.I) * + ((σ : ℂ) + (t : ℂ) * Complex.I + 1)‖ := by + let z : ℂ := (σ : ℂ) + (t : ℂ) * Complex.I + have hnorm : ‖z‖ ≤ ‖z + 1‖ := by + apply (sq_le_sq₀ (norm_nonneg _) (norm_nonneg _)).mp + simp only [Complex.sq_norm, Complex.normSq_apply, z, Complex.add_re, + Complex.add_im, Complex.ofReal_re, Complex.ofReal_im, Complex.mul_re, + Complex.mul_im, Complex.I_re, Complex.I_im, Complex.one_re, Complex.one_im] + nlinarith + have hm := mul_le_mul_of_nonneg_left hnorm (norm_nonneg z) + rw [← sq, Complex.sq_norm] at hm + have hz : Complex.normSq z = σ ^ 2 + t ^ 2 := by + simp [Complex.normSq_apply, z] + ring + rw [hz] at hm + rw [norm_mul] + change (1 + t ^ 2) / 4 ≤ ‖z‖ * ‖z + 1‖ + nlinarith [sq_nonneg t, sq_nonneg (σ - 1 / 2)] + +lemma modFive_perron_denominator_horizontal (σ t : ℝ) : + t ^ 2 ≤ ‖((σ : ℂ) + (t : ℂ) * Complex.I) * + ((σ : ℂ) + (t : ℂ) * Complex.I + 1)‖ := by + let z : ℂ := (σ : ℂ) + (t : ℂ) * Complex.I + have h1 : |t| ≤ ‖z‖ := by simpa [z] using Complex.abs_im_le_norm z + have h2 : |t| ≤ ‖z + 1‖ := by simpa [z] using Complex.abs_im_le_norm (z + 1) + have hm := mul_le_mul h1 h2 (abs_nonneg t) (norm_nonneg z) + simpa only [← sq, sq_abs, norm_mul] using hm + +lemma modFive_perron_kernel_vertical {x σ : ℝ} (hx : 0 < x) (hσ : 1 / 2 ≤ σ) (t : ℝ) : + ‖modFivePerronKernel x ((σ : ℂ) + (t : ℂ) * Complex.I)‖ ≤ + 4 * x ^ σ / (1 + t ^ 2) := by + have hp : 0 < (1 + t ^ 2) / 4 := by positivity + have hd := modFive_perron_denominator_vertical hσ t + rw [modFivePerronKernel, norm_div, Complex.norm_cpow_eq_rpow_re_of_pos hx] + simp only [Complex.add_re, Complex.ofReal_re, Complex.mul_re, Complex.ofReal_im, + Complex.I_re, Complex.I_im, mul_zero, zero_mul, sub_self, add_zero] + exact (div_le_div_of_nonneg_left (Real.rpow_nonneg hx.le _) hp hd).trans_eq (by + field_simp) + +lemma modFive_perron_kernel_horizontal {x : ℝ} (hx : 0 < x) (σ : ℝ) + {t : ℝ} (ht : t ≠ 0) : + ‖modFivePerronKernel x ((σ : ℂ) + (t : ℂ) * Complex.I)‖ ≤ x ^ σ / t ^ 2 := by + rw [modFivePerronKernel, norm_div, Complex.norm_cpow_eq_rpow_re_of_pos hx] + simp only [Complex.add_re, Complex.ofReal_re, Complex.mul_re, Complex.ofReal_im, + Complex.I_re, Complex.I_im, mul_zero, zero_mul, sub_self, add_zero] + exact div_le_div_of_nonneg_left (Real.rpow_nonneg hx.le _) (sq_pos_of_ne_zero ht) + (modFive_perron_denominator_horizontal σ t) + +lemma modFivePerronKernel_integrable {x σ : ℝ} (hx : 0 < x) (hσ : 1 / 2 ≤ σ) : + MeasureTheory.Integrable (fun t : ℝ => + modFivePerronKernel x ((σ : ℂ) + (t : ℂ) * Complex.I)) := by + have h0 : ∀ t : ℝ, (σ : ℂ) + (t : ℂ) * Complex.I ≠ 0 := by + intro t ht + have he := congrArg Complex.re ht + norm_num at he + linarith + have h1 : ∀ t : ℝ, (σ : ℂ) + (t : ℂ) * Complex.I + 1 ≠ 0 := by + intro t ht + have he := congrArg Complex.re ht + norm_num at he + linarith + have hcont : Continuous (fun t : ℝ => + modFivePerronKernel x ((σ : ℂ) + (t : ℂ) * Complex.I)) := by + unfold modFivePerronKernel + apply Continuous.div + · exact (show Continuous (fun t : ℝ => (σ : ℂ) + (t : ℂ) * Complex.I) by + fun_prop).const_cpow (Or.inl (Complex.ofReal_ne_zero.mpr hx.ne')) + · fun_prop + · intro t + exact mul_ne_zero (h0 t) (h1 t) + have hmaj : MeasureTheory.Integrable (fun t : ℝ => 4 * x ^ σ / (1 + t ^ 2)) := by + simpa only [div_eq_mul_inv] using + (integrable_inv_one_add_sq.const_mul (4 * x ^ σ)) + apply hmaj.mono' hcont.aestronglyMeasurable + exact Filter.Eventually.of_forall (modFive_perron_kernel_vertical hx hσ) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveContourRegion.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveContourRegion.lean new file mode 100644 index 0000000000000000000000000000000000000000..23a3ba2fe2404dfab35db2eba391fd0a6d310bcd --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveContourRegion.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveStripBound +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveContourKernel + +namespace OAI + +/-! A common closed zero-free rectangle and its uniform logarithmic- +derivative bound. This prepares the finite contour shift without a +height-dependent analyticity assumption. +-/ + +namespace TwoPointCorrelations + +open Complex Set + +theorem modFive_logderiv_rectangles : ∃ a C : ℝ, + 0 < a ∧ a ≤ 1 / 4 ∧ 0 < C ∧ + ∀ (χ : DirichletCharacter ℂ 5), χ ≠ 1 → ∀ T : ℝ, 2 ≤ T → + ∀ s : ℂ, 1 - a / Real.log (T + 2) ≤ s.re → s.re ≤ 2 → |s.im| ≤ T → + DirichletCharacter.LFunction χ s ≠ 0 ∧ + ‖deriv (DirichletCharacter.LFunction χ) s / DirichletCharacter.LFunction χ s‖ ≤ + C * Real.log (T + 2) ^ 2 := by + obtain ⟨c, C, hc, hC, hbound⟩ := modFive_logderiv_strip_bound + let a := min c (1 / 4) + have ha : 0 < a := lt_min hc (by norm_num) + have hac : a ≤ c := min_le_left _ _ + refine ⟨a, C, ha, min_le_right _ _, hC, ?_⟩ + intro χ hχ T hT s hs hs2 ht + have hH : 0 < Real.log (T + 2) := Real.log_pos (by linarith) + have hh := modFive_log_height_pos s.im + have hlog : Real.log (|s.im| + 2) ≤ Real.log (T + 2) := + Real.log_le_log (by positivity) (by linarith) + have hdiv : a / Real.log (T + 2) ≤ c / Real.log (|s.im| + 2) := + (div_le_div_of_nonneg_left ha.le hh hlog).trans + (div_le_div_of_nonneg_right hac hh.le) + have hs' : 1 - c / Real.log (|s.im| + 2) ≤ s.re := by linarith + have he : (s.re : ℂ) + Complex.I * (s.im : ℂ) = s := by + apply Complex.ext <;> simp + have hb := hbound χ hχ s.im s.re hs' hs2 + rw [he] at hb + refine ⟨hb.1, hb.2.trans ?_⟩ + exact mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hh.le hlog 2) hC.le + +lemma modFive_logderiv_differentiableAt (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) {s : ℂ} (hs : DirichletCharacter.LFunction χ s ≠ 0) : + DifferentiableAt ℂ (fun z => + -deriv (DirichletCharacter.LFunction χ) z / DirichletCharacter.LFunction χ z) s := by + have hf := DirichletCharacter.differentiable_LFunction hχ + exact ((hf.analyticAt s).deriv.differentiableAt.neg).div (hf s) hs + +lemma modFive_perron_integrand_differentiableAt (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) {x : ℝ} (hx : 0 < x) {s : ℂ} + (hs : DirichletCharacter.LFunction χ s ≠ 0) (hs0 : s ≠ 0) (hs1 : s + 1 ≠ 0) : + DifferentiableAt ℂ (fun z => + (-deriv (DirichletCharacter.LFunction χ) z / DirichletCharacter.LFunction χ z) * + modFivePerronKernel x z) s := by + apply (modFive_logderiv_differentiableAt χ hχ hs).mul + unfold modFivePerronKernel + apply DifferentiableAt.div + · exact differentiableAt_id.const_cpow (Or.inl (Complex.ofReal_ne_zero.mpr hx.ne')) + · fun_prop + · exact mul_ne_zero hs0 hs1 + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveHighZeros.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveHighZeros.lean new file mode 100644 index 0000000000000000000000000000000000000000..16db9a7360579d4a3f0e8f5914404d53f3883a2c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveHighZeros.lean @@ -0,0 +1,167 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveLogGrowth +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePrincipalCorrection +import StrongPNT.Erdos970.PNT4_ZeroFreeRegion + +namespace OAI + +/-! The high-height logarithmic zero-free strip for nonprincipal characters +modulo five. The zeta estimates are existing proved theorems; all character +estimates come from the finite-period Abel bounds and the disk expansion. +-/ + +namespace TwoPointCorrelations + +open Complex +open scoped Classical + +lemma modFive_principal_neg_logderiv_re {s : ℂ} (hs : 1 < s.re) : + (-deriv (DirichletCharacter.LFunction (1 : DirichletCharacter ℂ 5)) s / + DirichletCharacter.LFunction (1 : DirichletCharacter ℂ 5) s).re ≤ + (-deriv riemannZeta s / riemannZeta s).re + Real.log 5 / 4 := by + have h := (Complex.abs_re_le_norm _).trans (modFive_principal_logderiv_error hs) + rw [Complex.sub_re] at h + have := (abs_le.mp h).2 + linarith + +lemma modFive_square_logderiv_bound : ∃ C : ℝ, 0 < C ∧ + ∀ (χ : DirichletCharacter ℂ 5) (t δ : ℝ), 2 < |t| → 0 < δ → δ < 1 → + (-deriv (DirichletCharacter.LFunction (χ ^ 2)) + ((1 + δ : ℝ) + Complex.I * ((2 * t : ℝ) : ℂ)) / + DirichletCharacter.LFunction (χ ^ 2) + ((1 + δ : ℝ) + Complex.I * ((2 * t : ℝ) : ℂ))).re ≤ + C * Real.log (|t| + 2) := by + obtain ⟨C, hC, hchar⟩ := modFive_logderiv_growth_constant + obtain ⟨Z, hZ, hzeta⟩ := Erdos970.lem_Z2bound + let A := Real.log 5 / (4 * Real.log 2) + have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hlog5 : 0 < Real.log 5 := Real.log_pos (by norm_num) + have hA : 0 ≤ A := by dsimp [A]; positivity + refine ⟨2 * C + Z + A + 1, by linarith, ?_⟩ + intro χ t δ ht hδ hδ1 + have hH : 0 < Real.log (|t| + 2) := modFive_log_height_pos t + by_cases hχ : χ ^ 2 = 1 + · rw [hχ] + let s : ℂ := ((1 + δ : ℝ) : ℂ) + Complex.I * ((2 * t : ℝ) : ℂ) + have hs : 1 < s.re := by dsimp [s]; norm_num; linarith + have hp := modFive_principal_neg_logderiv_re hs + have hz := hzeta t ht δ ⟨hδ, hδ1⟩ + have hpoint : s = (1 : ℂ) + (δ : ℂ) + 2 * (t : ℂ) * Complex.I := by + dsimp [s] + push_cast + ring + simp only [Erdos970.logDerivZeta, ← neg_div] at hz + rw [← hpoint] at hz + have ha : Real.log 5 / 4 ≤ A * Real.log (|t| + 2) := by + have hl : Real.log 2 ≤ Real.log (|t| + 2) := + Real.log_le_log (by norm_num) (by linarith [abs_nonneg t]) + have hm := mul_le_mul_of_nonneg_left hl hA + have he : A * Real.log 2 = Real.log 5 / 4 := by dsimp [A]; field_simp + rw [he] at hm + exact hm + change _ ≤ (2 * C + Z + A + 1) * Real.log (|t| + 2) + linarith [mul_pos hC hH] + · have hc := (hchar (χ ^ 2) hχ (2 * t) (1 + δ) (by linarith) (by linarith)).1 + have hd := modFive_log_double_height t + have hm := mul_le_mul_of_nonneg_left hd hC.le + linarith [mul_pos (show 0 < Z by linarith) hH, mul_nonneg hA hH.le] + +lemma modFive_zero_free_arithmetic {D H δ ε : ℝ} (hD : 0 < D) (hH : 0 < H) + (hδ : δ = 1 / (10 * D * H)) (hε : 0 ≤ ε) (hεu : ε ≤ δ / 4) : + 3 / δ + D * H - 4 / (δ + ε) < 0 := by + have hd : 0 < δ := by rw [hδ]; positivity + have hde : 0 < δ + ε := by linarith + have hinv : 16 / (5 * δ) ≤ 4 / (δ + ε) := by + apply (div_le_div_iff₀ (by positivity : 0 < 5 * δ) hde).mpr + nlinarith + have heq : 3 / δ + D * H - 16 / (5 * δ) = -(D * H) := by + rw [hδ] + field_simp [hD.ne', hH.ne'] + ring + have hle : 3 / δ + D * H - 4 / (δ + ε) ≤ 3 / δ + D * H - 16 / (5 * δ) := by + linarith + rw [heq] at hle + exact hle.trans_lt (neg_neg_of_pos (mul_pos hD hH)) + +/-- A uniform logarithmic zero-free strip at sufficiently large height. +All constants are independent of the choice of nonprincipal character. -/ +theorem modFive_nonprincipal_high_zero_free : ∃ c : ℝ, 0 < c ∧ ∃ T : ℝ, 2 < T ∧ + ∀ (χ : DirichletCharacter ℂ 5), χ ≠ 1 → ∀ (t β : ℝ), T ≤ |t| → + 1 - c / Real.log (|t| + 2) ≤ β → + DirichletCharacter.LFunction χ ((β : ℂ) + Complex.I * (t : ℂ)) ≠ 0 := by + obtain ⟨C, hC, hchar⟩ := modFive_logderiv_growth_constant + obtain ⟨S, hS, hsquare⟩ := modFive_square_logderiv_bound + obtain ⟨δ0, hδ0, Z, hZ, hzeta⟩ := Erdos970.uniform_bound_Z0 + let D := 3 * Z + 4 * C + S + 1 + have hD1 : 1 ≤ D := by dsimp [D]; linarith + have hD : 0 < D := zero_lt_one.trans_le hD1 + let b := 1 / (10 * D) + have hb : 0 < b := by dsimp [b]; positivity + have hbsmall : b ≤ 1 / 10 := by + dsimp [b] + apply (div_le_iff₀ (by positivity : 0 < 10 * D)).mpr + linarith + let T := Real.exp (1 + b / δ0) + 3 + have hT : 2 < T := by dsimp [T]; linarith [Real.exp_pos (1 + b / δ0)] + refine ⟨b / 4, by positivity, T, hT, ?_⟩ + intro χ hχ t β ht hβ hzero + have ht2 : 2 < |t| := hT.trans_le ht + let H := Real.log (|t| + 2) + have hHlarge : 1 + b / δ0 < H := by + apply (Real.lt_log_iff_exp_lt (by positivity : 0 < |t| + 2)).mpr + dsimp [T] at ht + linarith + have hH1 : 1 < H := by have := div_pos hb hδ0; linarith + have hH : 0 < H := zero_lt_one.trans hH1 + let δ := b / H + have hd : 0 < δ := div_pos hb hH + have hdsmall : δ ≤ b := by + apply (div_le_iff₀ hH).mpr + nlinarith + have hd1 : δ < 1 := by linarith + have hd0 : δ < δ0 := by + apply (div_lt_iff₀ hH).mpr + have hm := (div_lt_iff₀ hδ0).mp (show b / δ0 < H by linarith) + simpa only [mul_comm] using hm + have hβ1 : β < 1 := by + by_contra! h + exact χ.LFunction_ne_zero_of_one_le_re (Or.inl hχ) (by simpa using h) hzero + let ε := 1 - β + have hε : 0 ≤ ε := by dsimp [ε]; linarith + have hεu : ε ≤ δ / 4 := by + dsimp [ε, δ, H] at * + have he : (b / 4) / Real.log (|t| + 2) = (b / Real.log (|t| + 2)) / 4 := by ring + rw [he] at hβ + linarith + have hβlow : 3 / 4 ≤ β := by dsimp [ε] at hεu; linarith + have hc := (hchar χ hχ t (1 + δ) (by linarith) (by linarith)).2 β hβlow hβ1.le hzero + have hs := hsquare χ t δ ht2 hd hd1 + have hz := hzeta δ hd hd0 + have hp := modFive_logderiv_positivity χ (σ := 1 + δ) (by linarith) t + have hpoint : ((1 + δ : ℝ) : ℂ) = (1 : ℂ) + (δ : ℂ) := by push_cast; rfl + simp only [Erdos970.logDerivZeta, ← neg_div] at hz + rw [← hpoint] at hz + have hdist : 1 + δ - β = δ + ε := by dsimp [ε]; ring + rw [hdist] at hc + have hcost : 3 * Z + (4 * C + S) * H ≤ D * H := by + dsimp [D] + nlinarith [mul_nonneg hZ (show 0 ≤ H - 1 by linarith)] + have hpos : 0 ≤ 3 / δ + D * H - 4 / (δ + ε) := by + have hm := add_le_add + (add_le_add (mul_le_mul_of_nonneg_left hz (by norm_num : (0 : ℝ) ≤ 3)) + (mul_le_mul_of_nonneg_left hc (by norm_num : (0 : ℝ) ≤ 4))) hs + have hexp : 3 * (1 / δ + Z) + + 4 * (C * Real.log (|t| + 2) - 1 / (δ + ε)) + S * Real.log (|t| + 2) = + 3 / δ + (3 * Z + (4 * C + S) * H) - 4 / (δ + ε) := by + dsimp [H] + ring + rw [hexp] at hm + have hh := hp.trans hm + linarith only [hh, hcost] + have hδeq : δ = 1 / (10 * D * H) := by + change (1 / (10 * D)) / H = 1 / (10 * D * H) + field_simp + exact (not_lt_of_ge hpos) (modFive_zero_free_arithmetic hD hH hδeq hε hεu) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveInputExtension.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveInputExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..09c99ebdb7d2b723950db11ed39f4d4666d60694 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveInputExtension.lean @@ -0,0 +1,97 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveMangoldt + +namespace OAI + +/-! Finite-cutoff completion of the fixed modulus-five prime input. +An eventual quantitative Mangoldt estimate suffices, since the remaining +bounded cutoffs are controlled by one finite nonnegative Mangoldt sum. -/ + +namespace TwoPointCorrelations + +open Finset Filter + +lemma modFivePsi_nonneg (one : Bool) (x : ℝ) : 0 ≤ modFivePsi one x := by + apply sum_nonneg + intro n hn + unfold modFiveMangoldtWeight + split_ifs + · exact ArithmeticFunction.vonMangoldt_nonneg + · rfl + +lemma modFivePsi_le_psi (one : Bool) {x y : ℝ} (hxy : x ≤ y) : + modFivePsi one x ≤ Chebyshev.psi y := by + rw [modFivePsi, Chebyshev.psi_eq_sum_Icc] + calc + _ ≤ ∑ n ∈ Icc 0 ⌊x⌋₊, ArithmeticFunction.vonMangoldt n := by + apply sum_le_sum + intro n hn + unfold modFiveMangoldtWeight + split_ifs + · rfl + · exact ArithmeticFunction.vonMangoldt_nonneg + _ ≤ _ := sum_le_sum_of_subset_of_nonneg + (Icc_subset_Icc_right (Nat.floor_le_floor hxy)) + (fun n _ _ => ArithmeticFunction.vonMangoldt_nonneg) + +lemma modFiveDensity_bounds (one : Bool) : 0 ≤ modFiveDensity one ∧ modFiveDensity one ≤ 1 := by + cases one <;> norm_num [modFiveDensity] + +lemma modFivePsi_bounded_cutoffs (one : Bool) {x Y : ℝ} (hx : 0 ≤ x) (hxy : x ≤ Y) : + |modFivePsi one x - modFiveDensity one * x| ≤ Chebyshev.psi Y + Y := by + have hd := modFiveDensity_bounds one + have hm : 0 ≤ modFiveDensity one * x := mul_nonneg hd.1 hx + calc + _ ≤ |modFivePsi one x| + |modFiveDensity one * x| := abs_sub _ _ + _ = modFivePsi one x + modFiveDensity one * x := by + rw [abs_of_nonneg (modFivePsi_nonneg one x), abs_of_nonneg hm] + _ ≤ _ := add_le_add (modFivePsi_le_psi one hxy) + ((mul_le_mul_of_nonneg_right hd.2 hx).trans_eq (one_mul x) |>.trans hxy) + +theorem modFiveThetaInput_of_eventual_psi (c C : ℝ) (hc : 0 < c) (hC : 0 ≤ C) + (hbound : ∀ᶠ x : ℝ in atTop, ∀ one : Bool, + |modFivePsi one x - modFiveDensity one * x| ≤ + C * x * Real.exp (-c * Real.sqrt (Real.log x))) : + ModFiveThetaInput := by + obtain ⟨X, hX⟩ := eventually_atTop.mp hbound + let Y := max 2 X + let M := Chebyshev.psi Y + Y + let K := M * Real.exp (c * Real.sqrt (Real.log Y)) + have hY2 : 2 ≤ Y := le_max_left _ _ + have hM : 0 ≤ M := add_nonneg (Chebyshev.psi_nonneg _) (by dsimp [Y]; positivity) + have hK : 0 ≤ K := mul_nonneg hM (Real.exp_pos _).le + apply modFiveThetaInput_of_psi c (max C K) hc (hC.trans (le_max_left _ _)) + intro one x hx + by_cases hlarge : Y ≤ x + · exact (hX x ((le_max_right _ _).trans hlarge) one).trans + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right (le_max_left C K) + (by linarith)) (Real.exp_pos _).le) + · have hxy : x ≤ Y := (lt_of_not_ge hlarge).le + have hnorm := modFivePsi_bounded_cutoffs one (by linarith) hxy + have hroot : Real.sqrt (Real.log x) ≤ Real.sqrt (Real.log Y) := + Real.sqrt_le_sqrt (Real.log_le_log (by linarith) hxy) + have hexp : Real.exp (-c * Real.sqrt (Real.log Y)) ≤ + Real.exp (-c * Real.sqrt (Real.log x)) := + Real.exp_le_exp.mpr (mul_le_mul_of_nonpos_left hroot (neg_nonpos.mpr hc.le)) + have hprod : 1 ≤ Real.exp (c * Real.sqrt (Real.log Y)) * + Real.exp (-c * Real.sqrt (Real.log x)) := by + calc + 1 = Real.exp (c * Real.sqrt (Real.log Y)) * + Real.exp (-c * Real.sqrt (Real.log Y)) := by rw [← Real.exp_add]; simp + _ ≤ _ := mul_le_mul_of_nonneg_left hexp (Real.exp_pos _).le + have hm : M ≤ K * Real.exp (-c * Real.sqrt (Real.log x)) := by + have hh := mul_le_mul_of_nonneg_left hprod hM + simpa only [mul_one, K, mul_assoc] using hh + apply hnorm.trans (hm.trans ?_) + calc + K * Real.exp (-c * Real.sqrt (Real.log x)) ≤ + (K * x) * Real.exp (-c * Real.sqrt (Real.log x)) := + mul_le_mul_of_nonneg_right + (by simpa only [mul_one] using + mul_le_mul_of_nonneg_left (by linarith : 1 ≤ x) hK) + (Real.exp_pos _).le + _ ≤ _ := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (le_max_right C K) (by linarith)) (Real.exp_pos _).le + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveLFunctions.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveLFunctions.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7fad8d98a2954a9b8ceca6e3e474ac0d51a1e06 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveLFunctions.lean @@ -0,0 +1,127 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveMangoldt +import Mathlib.NumberTheory.LSeries.Nonvanishing + +namespace OAI + +/-! The three analytic functions needed for the fixed modulus-five input. + +Every nonprincipal character modulo five is determined here by its value at +two, which is one of `-1`, `I`, or `-I`. Its L-function is an explicit finite +linear combination of the existing Hurwitz zeta functions. The final +identity identifies the corresponding Mangoldt Dirichlet series with the +negative logarithmic derivative on the half-plane of absolute convergence. +-/ + +namespace TwoPointCorrelations + +open Finset Complex HurwitzZeta +open scoped BigOperators Classical + +local instance : Fact (1 < (5 : ℕ)) := ⟨by decide⟩ + +lemma sum_zmod_five (f : ZMod 5 → ℂ) : + (∑ a : ZMod 5, f a) = f 0 + f 1 + f 2 + f 3 + f 4 := by + have hu : (univ : Finset (ZMod 5)) = {0, 1, 2, 3, 4} := by decide + rw [hu, sum_insert (by decide : (0 : ZMod 5) ∉ ({1, 2, 3, 4} : Finset (ZMod 5))), + sum_insert (by decide : (1 : ZMod 5) ∉ ({2, 3, 4} : Finset (ZMod 5))), + sum_insert (by decide : (2 : ZMod 5) ∉ ({3, 4} : Finset (ZMod 5))), + sum_insert (by decide : (3 : ZMod 5) ∉ ({4} : Finset (ZMod 5))), sum_singleton] + ring_nf + +lemma modFive_character_four (χ : DirichletCharacter ℂ 5) : + χ (4 : ZMod 5) = χ (2 : ZMod 5) ^ 2 := by + rw [← map_pow] + congr 1 + +lemma modFive_character_three (χ : DirichletCharacter ℂ 5) : + χ (3 : ZMod 5) = χ (2 : ZMod 5) ^ 3 := by + rw [← map_pow] + congr 1 + +lemma modFive_character_fourth_pow (χ : DirichletCharacter ℂ 5) : + χ (2 : ZMod 5) ^ 4 = 1 := by + rw [← map_pow, show (2 : ZMod 5) ^ 4 = 1 by decide, map_one] + +lemma modFive_character_sum_values (χ : DirichletCharacter ℂ 5) : + (∑ a : ZMod 5, χ a) = + 1 + χ (2 : ZMod 5) + χ (2 : ZMod 5) ^ 3 + χ (2 : ZMod 5) ^ 2 := by + rw [sum_zmod_five, MulChar.map_zero χ, map_one, + modFive_character_three, modFive_character_four] + ring_nf + +lemma modFive_nonprincipal_at_two (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) : + χ (2 : ZMod 5) ≠ 1 := by + intro heq + have hzero := χ.sum_eq_zero_of_ne_one hχ + rw [modFive_character_sum_values, heq] at hzero + norm_num at hzero + +/-- The nonprincipal characters require only these three possible values. -/ +theorem modFive_nonprincipal_parameter (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) : + χ (2 : ZMod 5) = -1 ∨ χ (2 : ZMod 5) = Complex.I ∨ + χ (2 : ZMod 5) = -Complex.I := by + let z := χ (2 : ZMod 5) + have hz4 : z ^ 4 = 1 := modFive_character_fourth_pow χ + have hz2 : (z ^ 2) ^ 2 = (1 : ℂ) ^ 2 := by simpa only [← pow_mul, one_pow] using hz4 + rcases sq_eq_sq_iff_eq_or_eq_neg.mp hz2 with h | h + · have hsq : z ^ 2 = (1 : ℂ) ^ 2 := by simpa only [one_pow] using h + rcases sq_eq_sq_iff_eq_or_eq_neg.mp hsq with h | h + · exact False.elim (modFive_nonprincipal_at_two χ hχ h) + · exact Or.inl h + · have hsq : z ^ 2 = Complex.I ^ 2 := by simpa only [Complex.I_sq] using h + exact Or.inr (sq_eq_sq_iff_eq_or_eq_neg.mp hsq) + +/-- An explicit analytic function for each of the three parameters. -/ +noncomputable def modFiveHurwitzCombination (z s : ℂ) : ℂ := + (5 : ℂ) ^ (-s) * + (hurwitzZeta (ZMod.toAddCircle (1 : ZMod 5)) s + + z * hurwitzZeta (ZMod.toAddCircle (2 : ZMod 5)) s + + z ^ 3 * hurwitzZeta (ZMod.toAddCircle (3 : ZMod 5)) s + + z ^ 2 * hurwitzZeta (ZMod.toAddCircle (4 : ZMod 5)) s) + +theorem modFive_LFunction_eq (χ : DirichletCharacter ℂ 5) (s : ℂ) : + DirichletCharacter.LFunction χ s = + modFiveHurwitzCombination (χ (2 : ZMod 5)) s := by + unfold DirichletCharacter.LFunction ZMod.LFunction modFiveHurwitzCombination + rw [sum_zmod_five] + rw [MulChar.map_zero χ, map_one, modFive_character_three, modFive_character_four] + ring_nf + +/-- The Dirichlet-series coefficients whose partial sums are required. -/ +noncomputable def modFiveMangoldtTwist (χ : DirichletCharacter ℂ 5) (n : ℕ) : ℂ := + χ (n : ZMod 5) * (ArithmeticFunction.vonMangoldt n : ℂ) + +lemma modFiveTwistedPsi_eq (χ : DirichletCharacter ℂ 5) (x : ℝ) : + modFiveTwistedPsi χ x = ∑ n ∈ Icc 0 ⌊x⌋₊, modFiveMangoldtTwist χ n := by + unfold modFiveTwistedPsi modFiveMangoldtTwist + exact sum_congr rfl fun n _ => mul_comm _ _ + +/-- Identification with existing analytic functions on `re s > 1`. -/ +theorem modFive_twisted_LSeries_eq (χ : DirichletCharacter ℂ 5) {s : ℂ} + (hs : 1 < s.re) : + LSeries (modFiveMangoldtTwist χ) s = + -deriv (modFiveHurwitzCombination (χ (2 : ZMod 5))) s / + modFiveHurwitzCombination (χ (2 : ZMod 5)) s := by + have heq : DirichletCharacter.LFunction χ = + modFiveHurwitzCombination (χ (2 : ZMod 5)) := funext (modFive_LFunction_eq χ) + rw [← heq, DirichletCharacter.deriv_LFunction_eq_deriv_LSeries χ hs, + DirichletCharacter.LFunction_eq_LSeries χ hs] + exact χ.LSeries_twist_vonMangoldt_eq hs + +theorem modFive_nonprincipal_differentiable (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) : + Differentiable ℂ (modFiveHurwitzCombination (χ (2 : ZMod 5))) := by + have heq : DirichletCharacter.LFunction χ = + modFiveHurwitzCombination (χ (2 : ZMod 5)) := funext (modFive_LFunction_eq χ) + rw [← heq] + exact DirichletCharacter.differentiable_LFunction hχ + +theorem modFive_nonprincipal_nonzero (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) {s : ℂ} (hs : 1 ≤ s.re) : + modFiveHurwitzCombination (χ (2 : ZMod 5)) s ≠ 0 := by + rw [← modFive_LFunction_eq] + exact χ.LFunction_ne_zero_of_one_le_re (Or.inl hχ) hs + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveLogDerivative.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveLogDerivative.lean new file mode 100644 index 0000000000000000000000000000000000000000..d5eac3747b3c2ae69f532b50b1a4456d8d2fee3f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveLogDerivative.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveCenterBounds +import StrongPNT.Erdos970.PNT2_LogDerivative + +namespace OAI + +/-! Fixed-radius logarithmic-derivative expansion for the three modulus-five +functions. The analytic disk estimate uses explicit holomorphy, finite-zero, +normalization and growth hypotheses. +-/ + +namespace TwoPointCorrelations + +open Complex Filter +open scoped BigOperators Classical Topology + +noncomputable def modFiveNormalizedZeros (χ : DirichletCharacter ℂ 5) (t : ℝ) : Set ℂ := + Erdos970.zerosetKfR (7 / 8) (by norm_num) (modFiveNormalizedLFunction χ t) + +lemma modFiveNormalizedZeros_finite (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (t : ℝ) : (modFiveNormalizedZeros χ t).Finite := by + apply Erdos970.lem_Contra_finiteKR (7 / 8) (by norm_num) (by norm_num) + (modFiveNormalizedLFunction χ t) + · intro z _ + exact (modFiveNormalizedLFunction_differentiable χ hχ t).analyticAt z + · refine ⟨0, by simp, ?_⟩ + rw [modFiveNormalizedLFunction_zero] + exact one_ne_zero + +noncomputable def modFiveLogDerivativeConstant : ℝ := + 16 * (4 / 5 : ℝ) ^ 2 / ((4 / 5 : ℝ) - 3 / 4) ^ 3 + + 1 / (((15 / 16 : ℝ) ^ 2 / (7 / 8) - 7 / 8) * Real.log ((15 / 16 : ℝ) / (7 / 8))) + +/-- Exact finite zero-sum approximation on the inner disk. -/ +theorem modFiveNormalized_logderiv (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (t : ℝ) {z : ℂ} (hz : ‖z‖ ≤ 3 / 4) + (hn : modFiveNormalizedLFunction χ t z ≠ 0) : + ‖deriv (modFiveNormalizedLFunction χ t) z / modFiveNormalizedLFunction χ t z - + ∑ ρ ∈ (modFiveNormalizedZeros_finite χ hχ t).toFinset, + (analyticOrderAt (modFiveNormalizedLFunction χ t) ρ).toNat / (z - ρ)‖ ≤ + modFiveLogDerivativeConstant * + Real.log (8 * modFiveInverseConstant * (|t| + 4)) := by + let f := modFiveNormalizedLFunction χ t + have hf : ∀ w ∈ Metric.closedBall (0 : ℂ) 1, AnalyticAt ℂ f w := by + intro w _ + exact (modFiveNormalizedLFunction_differentiable χ hχ t).analyticAt w + have hf0 : f 0 = 1 := modFiveNormalizedLFunction_zero χ t + have hfin : (Erdos970.zerosetKfR (7 / 8) (by norm_num) f).Finite := + modFiveNormalizedZeros_finite χ hχ t + have hfactor : ∀ ρ : ℂ, ∃ g : ℂ → ℂ, AnalyticAt ℂ g ρ ∧ g ρ ≠ 0 ∧ + (ρ ∈ Erdos970.zerosetKfR (7 / 8) (by norm_num) f → + ∀ᶠ w in 𝓝 ρ, f w = (w - ρ) ^ (analyticOrderAt f ρ).toNat * g w) := by + intro ρ + by_cases hρ : ρ ∈ Erdos970.zerosetKfR (7 / 8) (by norm_num) f + · obtain ⟨g, hg, hgne, heq⟩ := Erdos970.lem_analytic_zero_factor + (15 / 16) (7 / 8) (by norm_num) (by norm_num) (by norm_num) f hf + (by rw [hf0]; exact one_ne_zero) ρ hρ + exact ⟨g, hg, hgne, fun _ => heq⟩ + · exact ⟨fun _ => 1, analyticAt_const, one_ne_zero, fun h => (hρ h).elim⟩ + let g : ℂ → ℂ → ℂ := fun ρ => Classical.choose (hfactor ρ) + have hg : ∀ ρ ∈ Erdos970.zerosetKfR (7 / 8) (by norm_num) f, + AnalyticAt ℂ (g ρ) ρ ∧ g ρ ρ ≠ 0 ∧ + ∀ᶠ w in 𝓝 ρ, f w = (w - ρ) ^ (analyticOrderAt f ρ).toNat * g ρ w := by + intro ρ hρ + exact ⟨(Classical.choose_spec (hfactor ρ)).1, + (Classical.choose_spec (hfactor ρ)).2.1, + (Classical.choose_spec (hfactor ρ)).2.2 hρ⟩ + have hK : 1 ≤ modFiveInverseConstant := by + unfold modFiveInverseConstant + have hsum : 0 ≤ ∑' n : ℕ, ‖LSeries.term (1 : ℕ → ℂ) (2 : ℂ) n‖ := + tsum_nonneg fun _ => norm_nonneg _ + linarith + have hB : 1 < 8 * modFiveInverseConstant * (|t| + 4) := by + nlinarith [abs_nonneg t] + have hbound : ∀ w ∈ Metric.closedBall (0 : ℂ) (15 / 16 : ℝ), + ‖f w‖ ≤ 8 * modFiveInverseConstant * (|t| + 4) := by + intro w hw + apply modFiveNormalizedLFunction_norm χ hχ t + have hw' : ‖w‖ ≤ 15 / 16 := by simpa using hw + linarith + have hz' : z ∈ Metric.closedBall (0 : ℂ) (3 / 4 : ℝ) \ + Erdos970.zerosetKfR (7 / 8) (by norm_num) f := by + refine ⟨by simpa using hz, ?_⟩ + intro h + exact hn h.2 + exact Erdos970.final_ineq1 (8 * modFiveInverseConstant * (|t| + 4)) hB + (3 / 4) (4 / 5) (15 / 16) (7 / 8) + (by norm_num) (by norm_num) (by norm_num) (by norm_num) (by norm_num) + f hf hf0 hfin hg hbound z hz' + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveLogGrowth.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveLogGrowth.lean new file mode 100644 index 0000000000000000000000000000000000000000..74baf2e0b3af9e42dd8e1d55b4ecf27aedaf67f7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveLogGrowth.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveZeroTerms + +namespace OAI + +/-! Uniform logarithmic growth constants for the fixed disk estimate. +These elementary inequalities expose a single constant independent of the +character and the height, ready for the zero-free-region calculation. +-/ + +namespace TwoPointCorrelations + +lemma modFiveLogDerivativeConstant_pos : 0 < modFiveLogDerivativeConstant := by + have hl : 0 < Real.log ((15 / 16 : ℝ) / (7 / 8)) := Real.log_pos (by norm_num) + unfold modFiveLogDerivativeConstant + positivity + +lemma modFive_log_height_pos (t : ℝ) : 0 < Real.log (|t| + 2) := + Real.log_pos (by linarith [abs_nonneg t]) + +lemma modFive_log_double_height (t : ℝ) : + Real.log (|2 * t| + 2) ≤ 2 * Real.log (|t| + 2) := by + rw [abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 2)] + calc + _ ≤ Real.log ((|t| + 2) ^ 2) := by + apply Real.log_le_log (by positivity) + nlinarith [abs_nonneg t, sq_nonneg (|t|)] + _ = 2 * Real.log (|t| + 2) := by rw [Real.log_pow]; norm_num + +lemma modFive_log_disk_growth (t : ℝ) : + Real.log (8 * modFiveInverseConstant * (|t| + 4)) ≤ + (Real.log (16 * modFiveInverseConstant) / Real.log 2 + 1) * + Real.log (|t| + 2) := by + have hK : 1 ≤ modFiveInverseConstant := by + unfold modFiveInverseConstant + exact le_add_of_nonneg_right (tsum_nonneg fun _ => norm_nonneg _) + have hA : 0 < 16 * modFiveInverseConstant := by positivity + have hlogA : 0 ≤ Real.log (16 * modFiveInverseConstant) := + Real.log_nonneg (by linarith) + have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hlog : Real.log 2 ≤ Real.log (|t| + 2) := + Real.log_le_log (by norm_num) (by linarith [abs_nonneg t]) + have hratio : Real.log (16 * modFiveInverseConstant) ≤ + (Real.log (16 * modFiveInverseConstant) / Real.log 2) * Real.log (|t| + 2) := by + calc + _ = (Real.log (16 * modFiveInverseConstant) / Real.log 2) * Real.log 2 := + (div_mul_cancel₀ _ hlog2.ne').symm + _ ≤ _ := mul_le_mul_of_nonneg_left hlog (div_nonneg hlogA hlog2.le) + calc + _ ≤ Real.log ((16 * modFiveInverseConstant) * (|t| + 2)) := by + apply Real.log_le_log (by positivity) + nlinarith [mul_nonneg modFiveInverseConstant_pos.le (abs_nonneg t)] + _ = Real.log (16 * modFiveInverseConstant) + Real.log (|t| + 2) := + Real.log_mul hA.ne' (by positivity) + _ ≤ _ := by nlinarith + +/-- One absolute constant controls every nonprincipal modulus-five +logarithmic derivative to the right of one. -/ +theorem modFive_logderiv_growth_constant : ∃ C : ℝ, 0 < C ∧ + ∀ (χ : DirichletCharacter ℂ 5), χ ≠ 1 → ∀ (t : ℝ) (σ : ℝ), + 1 < σ → σ ≤ 2 → + (-deriv (DirichletCharacter.LFunction χ) ((σ : ℂ) + Complex.I * (t : ℂ)) / + DirichletCharacter.LFunction χ ((σ : ℂ) + Complex.I * (t : ℂ))).re ≤ + C * Real.log (|t| + 2) ∧ + ∀ β : ℝ, 3 / 4 ≤ β → β ≤ 1 → + DirichletCharacter.LFunction χ ((β : ℂ) + Complex.I * (t : ℂ)) = 0 → + (-deriv (DirichletCharacter.LFunction χ) ((σ : ℂ) + Complex.I * (t : ℂ)) / + DirichletCharacter.LFunction χ ((σ : ℂ) + Complex.I * (t : ℂ))).re ≤ + C * Real.log (|t| + 2) - 1 / (σ - β) := by + let C := (2 / 3 : ℝ) * modFiveLogDerivativeConstant * + (Real.log (16 * modFiveInverseConstant) / Real.log 2 + 1) + have hC : 0 < C := by + have hD := modFiveLogDerivativeConstant_pos + have hK := modFiveInverseConstant_pos + have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hK1 : 1 ≤ modFiveInverseConstant := by + unfold modFiveInverseConstant + exact le_add_of_nonneg_right (tsum_nonneg fun _ => norm_nonneg _) + have hlogK : 0 ≤ Real.log (16 * modFiveInverseConstant) := + Real.log_nonneg (by linarith) + dsimp [C] + positivity + refine ⟨C, hC, ?_⟩ + intro χ hχ t σ hσ hσ2 + have hE : (2 / 3 : ℝ) * modFiveLogDerivativeConstant * + Real.log (8 * modFiveInverseConstant * (|t| + 4)) ≤ C * Real.log (|t| + 2) := by + dsimp [C] + calc + _ ≤ ((2 / 3 : ℝ) * modFiveLogDerivativeConstant) * + ((Real.log (16 * modFiveInverseConstant) / Real.log 2 + 1) * + Real.log (|t| + 2)) := + mul_le_mul_of_nonneg_left (modFive_log_disk_growth t) + (mul_nonneg (by norm_num) modFiveLogDerivativeConstant_pos.le) + _ = _ := by ring + refine ⟨(modFive_neg_logderiv_re_le χ hχ t hσ hσ2).trans hE, ?_⟩ + intro β hβ hβ1 hzero + exact (modFive_neg_logderiv_re_le_of_zero χ hχ t hσ hσ2 hβ hβ1 hzero).trans + (sub_le_sub_right hE _) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveLowZeros.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveLowZeros.lean new file mode 100644 index 0000000000000000000000000000000000000000..51915f16da66cf035a9687377b71b403284db81e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveLowZeros.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveHighZeros +import Mathlib.Topology.MetricSpace.Thickening + +namespace OAI + +/-! Compact-height completion of the fixed-modulus zero-free strip. +The compactness step is simultaneous for the finite family of characters, +using the already proved nonvanishing on the line `Re s = 1`. +-/ + +namespace TwoPointCorrelations + +open Complex Set Metric +open scoped Classical + +lemma modFive_compact_height_zero_free (T : ℝ) : ∃ r : ℝ, 0 < r ∧ + ∀ (χ : DirichletCharacter ℂ 5), χ ≠ 1 → ∀ s : ℂ, + 1 - r ≤ s.re → |s.im| ≤ T → DirichletCharacter.LFunction χ s ≠ 0 := by + let K : Set ℂ := (fun t : ℝ => (1 : ℂ) + Complex.I * (t : ℂ)) '' Icc (-T) T + let U : Set ℂ := ⋂ χ : DirichletCharacter ℂ 5, + if χ = 1 then univ else {s | DirichletCharacter.LFunction χ s ≠ 0} + have hK : IsCompact K := isCompact_Icc.image (by fun_prop) + have hU : IsOpen U := by + apply isOpen_iInter_of_finite + intro χ + by_cases hχ : χ = 1 + · simp only [hχ, ite_true, isOpen_univ] + · simp only [hχ, ite_false] + exact isOpen_ne_fun (DirichletCharacter.differentiable_LFunction hχ).continuous + continuous_const + have hKU : K ⊆ U := by + rintro _ ⟨t, ht, rfl⟩ + apply mem_iInter.mpr + intro χ + by_cases hχ : χ = 1 + · simp only [hχ, ite_true, mem_univ] + · simp only [hχ, ite_false, mem_ofPred_eq] + exact χ.LFunction_ne_zero_of_one_le_re (Or.inl hχ) (by simp) + obtain ⟨r, hr, hrU⟩ := hK.exists_thickening_subset_open hU hKU + refine ⟨r / 2, half_pos hr, ?_⟩ + intro χ hχ s hs ht + by_cases hs1 : 1 ≤ s.re + · exact χ.LFunction_ne_zero_of_one_le_re (Or.inl hχ) hs1 + · have hs1' : s.re < 1 := lt_of_not_ge hs1 + have hp : (1 : ℂ) + Complex.I * (s.im : ℂ) ∈ K := + ⟨s.im, abs_le.mp ht, rfl⟩ + have hdist : dist s ((1 : ℂ) + Complex.I * (s.im : ℂ)) < r := by + have heq : s - ((1 : ℂ) + Complex.I * (s.im : ℂ)) = ((s.re - 1 : ℝ) : ℂ) := by + apply Complex.ext <;> simp + rw [dist_eq_norm, heq, Complex.norm_real, Real.norm_eq_abs, + abs_of_neg (sub_neg.mpr hs1')] + linarith + have hmem : s ∈ U := hrU (mem_thickening_iff.mpr ⟨_, hp, hdist⟩) + have h := mem_iInter.mp hmem χ + simpa only [hχ, ite_false, mem_ofPred_eq] using h + +/-- The full fixed-modulus logarithmic zero-free region, including bounded +heights. Its constant is uniform across the three nonprincipal characters. -/ +theorem modFive_nonprincipal_zero_free : ∃ c : ℝ, 0 < c ∧ + ∀ (χ : DirichletCharacter ℂ 5), χ ≠ 1 → ∀ (t β : ℝ), + 1 - c / Real.log (|t| + 2) ≤ β → + DirichletCharacter.LFunction χ ((β : ℂ) + Complex.I * (t : ℂ)) ≠ 0 := by + obtain ⟨c, hc, T, hT, hhigh⟩ := modFive_nonprincipal_high_zero_free + obtain ⟨r, hr, hlow⟩ := modFive_compact_height_zero_free T + have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) + refine ⟨min c (r * Real.log 2), lt_min hc (mul_pos hr hlog2), ?_⟩ + intro χ hχ t β hβ + have hH : 0 < Real.log (|t| + 2) := modFive_log_height_pos t + by_cases ht : T ≤ |t| + · apply hhigh χ hχ t β ht + have hdiv := div_le_div_of_nonneg_right (min_le_left c (r * Real.log 2)) hH.le + linarith + · apply hlow χ hχ ((β : ℂ) + Complex.I * (t : ℂ)) + · have hlog : Real.log 2 ≤ Real.log (|t| + 2) := + Real.log_le_log (by norm_num) (by linarith [abs_nonneg t]) + have hdiv : min c (r * Real.log 2) / Real.log (|t| + 2) ≤ r := by + apply (div_le_iff₀ hH).mpr + exact (min_le_right _ _).trans (mul_le_mul_of_nonneg_left hlog hr.le) + simpa using (show 1 - r ≤ β by linarith) + · simpa using (le_of_lt (lt_of_not_ge ht)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveMangoldt.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveMangoldt.lean new file mode 100644 index 0000000000000000000000000000000000000000..d7263bf856fd9674d31d360181140e3f4f6e6ae9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveMangoldt.lean @@ -0,0 +1,185 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePrimes +import Mathlib.NumberTheory.Chebyshev +import Mathlib.NumberTheory.DirichletCharacter.Orthogonality +import Mathlib.RingTheory.RootsOfUnity.AlgebraicallyClosed +import Mathlib.Analysis.Complex.Polynomial.Basic + +namespace OAI + +/-! Exact finite reductions for the fixed modulus-five prime input. + +The only primes-versus-prime-powers loss is the existing elementary +Chebyshev bound. These identities convert quantitative Dirichlet L-function +estimates into the selected logarithmically weighted prime estimates. +-/ + +namespace TwoPointCorrelations + +open Finset +open scoped BigOperators Classical + +def modFiveResidue (one : Bool) (n : ℕ) : Prop := + if one then n % 5 = 1 else n % 5 ≠ 1 + +noncomputable def modFiveMangoldtWeight (one : Bool) (n : ℕ) : ℝ := + if modFiveResidue one n then ArithmeticFunction.vonMangoldt n else 0 + +noncomputable def modFivePsi (one : Bool) (x : ℝ) : ℝ := + ∑ n ∈ Icc 0 ⌊x⌋₊, modFiveMangoldtWeight one n + +noncomputable def modFiveTwistedPsi (χ : DirichletCharacter ℂ 5) (x : ℝ) : ℂ := + ∑ n ∈ Icc 0 ⌊x⌋₊, + (ArithmeticFunction.vonMangoldt n : ℂ) * χ (n : ZMod 5) + +lemma modFivePrime_iff (one : Bool) (n : ℕ) : + ModFivePrime one n ↔ n.Prime ∧ modFiveResidue one n := by + rfl + +lemma modFive_logWeight_eq (one : Bool) (n : ℕ) : + modFiveLogWeight one n = + if modFiveResidue one n then (if n.Prime then Real.log n else 0) else 0 := by + by_cases hp : n.Prime <;> by_cases hr : modFiveResidue one n <;> + simp [modFiveLogWeight, modFivePrime_iff, hp, hr] + +lemma modFive_weight_difference (one : Bool) (n : ℕ) : + modFiveMangoldtWeight one n - modFiveLogWeight one n = + if modFiveResidue one n ∧ ¬n.Prime then ArithmeticFunction.vonMangoldt n else 0 := by + rw [modFive_logWeight_eq] + by_cases hp : n.Prime + · simp [modFiveMangoldtWeight, hp, ArithmeticFunction.vonMangoldt_apply_prime hp] + · by_cases hr : modFiveResidue one n <;> simp [modFiveMangoldtWeight, hp, hr] + +lemma modFive_weight_difference_nonneg (one : Bool) (n : ℕ) : + 0 ≤ modFiveMangoldtWeight one n - modFiveLogWeight one n := by + rw [modFive_weight_difference] + split_ifs + · exact ArithmeticFunction.vonMangoldt_nonneg + · rfl + +lemma modFive_weight_difference_le (one : Bool) (n : ℕ) : + modFiveMangoldtWeight one n - modFiveLogWeight one n ≤ + ArithmeticFunction.vonMangoldt n - (if n.Prime then Real.log n else 0) := by + rw [modFive_weight_difference] + by_cases hp : n.Prime + · simp [hp, ArithmeticFunction.vonMangoldt_apply_prime hp] + · simp only [hp, ↓reduceIte, sub_zero] + split_ifs + · rfl + · exact ArithmeticFunction.vonMangoldt_nonneg + +/-- Restricting the prime-power error to either selection cannot increase it. -/ +theorem modFivePsi_sub_theta_bounds (one : Bool) (x : ℝ) : + 0 ≤ modFivePsi one x - modFiveTheta one x ∧ + modFivePsi one x - modFiveTheta one x ≤ Chebyshev.psi x - Chebyshev.theta x := by + have hsum : modFivePsi one x - modFiveTheta one x = + ∑ n ∈ Icc 0 ⌊x⌋₊, + (modFiveMangoldtWeight one n - modFiveLogWeight one n) := by + simp only [modFivePsi, modFiveTheta, sum_sub_distrib] + rw [hsum] + constructor + · exact sum_nonneg fun n _ => modFive_weight_difference_nonneg one n + · rw [Chebyshev.psi_eq_sum_Icc, Chebyshev.theta_eq_sum_Icc, sum_filter, + ← sum_sub_distrib] + exact sum_le_sum fun n _ => modFive_weight_difference_le one n + +/-- The elementary loss in passing from a von Mangoldt estimate to primes. -/ +theorem modFivePsi_sub_theta_abs_le (one : Bool) {x : ℝ} (hx : 1 ≤ x) : + |modFivePsi one x - modFiveTheta one x| ≤ 2 * Real.sqrt x * Real.log x := by + rw [abs_of_nonneg (modFivePsi_sub_theta_bounds one x).1] + exact (modFivePsi_sub_theta_bounds one x).2.trans (Chebyshev.psi_sub_theta_le hx) + +lemma modFiveMangoldtWeight_complement (n : ℕ) : + modFiveMangoldtWeight false n + modFiveMangoldtWeight true n = + ArithmeticFunction.vonMangoldt n := by + by_cases hn : n % 5 = 1 <;> simp [modFiveMangoldtWeight, modFiveResidue, hn] + +lemma modFivePsi_complement (x : ℝ) : + modFivePsi false x + modFivePsi true x = Chebyshev.psi x := by + rw [modFivePsi, modFivePsi, ← sum_add_distrib, Chebyshev.psi_eq_sum_Icc] + exact sum_congr rfl fun n _ => modFiveMangoldtWeight_complement n + +lemma modFive_character_sum (n : ℕ) : + (∑ χ : DirichletCharacter ℂ 5, χ (n : ZMod 5)) = + if n % 5 = 1 then (4 : ℂ) else 0 := by + have heq : (n : ZMod 5) = 1 ↔ n % 5 = 1 := by + simpa only [Nat.cast_one, Nat.mod_eq_of_lt (by decide : 1 < 5)] using + (ZMod.natCast_eq_natCast_iff' n 1 5) + simp only [DirichletCharacter.sum_characters_eq, heq] + norm_num [Nat.totient_prime (by decide : Nat.Prime 5)] + +/-- Exact character expansion; no asymptotic input is used here. -/ +theorem modFivePsi_true_character_sum (x : ℝ) : + (4 : ℂ) * (modFivePsi true x : ℂ) = + ∑ χ : DirichletCharacter ℂ 5, modFiveTwistedPsi χ x := by + simp only [modFivePsi, modFiveTwistedPsi, Complex.ofReal_sum, mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro n hn + rw [← mul_sum, modFive_character_sum] + by_cases h : n % 5 = 1 <;> + simp [modFiveMangoldtWeight, modFiveResidue, h, mul_comm] + +lemma sqrt_mul_log_le_exp_sqrt (c : ℝ) {x : ℝ} (hx : 1 ≤ x) : + Real.sqrt x * Real.log x ≤ + 4 * Real.exp (c ^ 2) * x * Real.exp (-c * Real.sqrt (Real.log x)) := by + have hxp : 0 < x := zero_lt_one.trans_le hx + have hy : 0 ≤ Real.log x := Real.log_nonneg hx + have hsquare := sq_nonneg (Real.sqrt (Real.log x) / 2 - c) + have hsqrt := Real.sq_sqrt hy + have hcs : c * Real.sqrt (Real.log x) ≤ Real.log x / 4 + c ^ 2 := by + nlinarith + have hlog : Real.log x ≤ 4 * Real.exp (Real.log x / 4) := by + have he := Real.add_one_le_exp (Real.log x / 4) + linarith + have hexp : Real.exp (-Real.log x / 4) ≤ + Real.exp (c ^ 2) * Real.exp (-c * Real.sqrt (Real.log x)) := by + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + linarith + have hid : Real.sqrt x * Real.exp (Real.log x / 4) = + x * Real.exp (-Real.log x / 4) := by + rw [Real.sqrt_eq_rpow, Real.rpow_def_of_pos hxp] + conv_rhs => lhs; rw [← Real.exp_log hxp] + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + calc + Real.sqrt x * Real.log x ≤ Real.sqrt x * (4 * Real.exp (Real.log x / 4)) := + mul_le_mul_of_nonneg_left hlog (Real.sqrt_nonneg x) + _ = 4 * (x * Real.exp (-Real.log x / 4)) := by rw [← hid]; ring + _ ≤ 4 * (x * (Real.exp (c ^ 2) * + Real.exp (-c * Real.sqrt (Real.log x)))) := by + exact mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left hexp hxp.le) (by norm_num) + _ = _ := by ring + +/-- A quantitative estimate for the selected von Mangoldt sums gives the +exact prime estimate used by the application, with unchanged exponent. -/ +theorem modFiveThetaInput_of_psi (c C : ℝ) (hc : 0 < c) (hC : 0 ≤ C) + (hpsi : ∀ (one : Bool) (x : ℝ), 2 ≤ x → + |modFivePsi one x - modFiveDensity one * x| ≤ + C * x * Real.exp (-c * Real.sqrt (Real.log x))) : + ModFiveThetaInput := by + refine ⟨c, C + 8 * Real.exp (c ^ 2), hc, by positivity, ?_⟩ + intro one x hx + have herr := modFivePsi_sub_theta_abs_le one (show 1 ≤ x by linarith) + have habsorb := sqrt_mul_log_le_exp_sqrt c (show 1 ≤ x by linarith) + calc + |modFiveTheta one x - modFiveDensity one * x| = + |(modFivePsi one x - modFiveDensity one * x) - + (modFivePsi one x - modFiveTheta one x)| := by congr 1; ring + _ ≤ |modFivePsi one x - modFiveDensity one * x| + + |modFivePsi one x - modFiveTheta one x| := abs_sub _ _ + _ ≤ C * x * Real.exp (-c * Real.sqrt (Real.log x)) + + 2 * (Real.sqrt x * Real.log x) := by + exact add_le_add (hpsi one x hx) (by simpa [mul_assoc] using herr) + _ ≤ C * x * Real.exp (-c * Real.sqrt (Real.log x)) + + 2 * (4 * Real.exp (c ^ 2) * x * + Real.exp (-c * Real.sqrt (Real.log x))) := by + exact add_le_add le_rfl + (mul_le_mul_of_nonneg_left habsorb (show (0 : ℝ) ≤ 2 by norm_num)) + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePerronInversion.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePerronInversion.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c60671500dd58915c82e0c5bcaf78c027aed579 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePerronInversion.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveContourKernel + +namespace OAI + +/-! Triangular Perron inversion from Mellin inversion. The triangular +function is a difference of two elementary Mellin transforms. -/ + +namespace TwoPointCorrelations + +open Complex Set MeasureTheory +open scoped Classical + +noncomputable def modFiveTriangle (x : ℝ) : ℂ := + ((max (1 - x) 0 : ℝ) : ℂ) + +lemma modFiveTriangle_hasMellin {s : ℂ} (hs : 0 < s.re) : + HasMellin modFiveTriangle s (1 / (s * (s + 1))) := by + have h0 := hasMellin_one_Ioc hs + have h1 := hasMellin_cpow_Ioc (1 : ℂ) (s := s) (by simpa using (show 0 < s.re + 1 by linarith)) + have hd := hasMellin_sub h0.1 h1.1 + rw [h0.2, h1.2] at hd + have he : ∀ t ∈ Ioi (0 : ℝ), modFiveTriangle t = + (Ioc (0 : ℝ) 1).indicator (fun _ => (1 : ℂ)) t - + (Ioc (0 : ℝ) 1).indicator (fun u => (u : ℂ) ^ (1 : ℂ)) t := by + intro t ht + by_cases ht1 : t ≤ 1 + · have hm : t ∈ Ioc (0 : ℝ) 1 := ⟨ht, ht1⟩ + simp [modFiveTriangle, indicator_of_mem hm, max_eq_left (sub_nonneg.mpr ht1)] + · have hm : t ∉ Ioc (0 : ℝ) 1 := fun h => ht1 h.2 + simp [modFiveTriangle, indicator_of_notMem hm, max_eq_right (by linarith : 1 - t ≤ 0)] + have hc : MellinConvergent modFiveTriangle s := by + exact hd.1.congr_fun (fun t ht => by rw [he t ht]) measurableSet_Ioi + refine ⟨hc, ?_⟩ + calc + mellin modFiveTriangle s = mellin + (fun t => (Ioc (0 : ℝ) 1).indicator (fun _ => (1 : ℂ)) t - + (Ioc (0 : ℝ) 1).indicator (fun u => (u : ℂ) ^ (1 : ℂ)) t) s := by + unfold mellin + apply setIntegral_congr_fun measurableSet_Ioi + intro t ht + dsimp only + rw [he t ht] + _ = 1 / s - 1 / (s + 1) := hd.2 + _ = _ := by + have hs0 : s ≠ 0 := by intro h; simp [h] at hs + have hs1 : s + 1 ≠ 0 := by intro h; have := congrArg Complex.re h; simp at this; linarith + field_simp + ring + +lemma modFiveTriangle_continuous : Continuous modFiveTriangle := by + unfold modFiveTriangle + fun_prop + +lemma modFiveTriangle_verticalIntegrable {σ : ℝ} (hσ : 1 / 2 ≤ σ) : + Complex.VerticalIntegrable (mellin modFiveTriangle) σ := by + have hi := modFivePerronKernel_integrable (by norm_num : (0 : ℝ) < 1) hσ + apply hi.congr + filter_upwards [] with t + have hs : 0 < (((σ : ℂ) + (t : ℂ) * Complex.I)).re := by simpa using (show 0 < σ by linarith) + rw [(modFiveTriangle_hasMellin hs).2] + simp [modFivePerronKernel] + +theorem modFivePerron_inversion {x σ : ℝ} (hx : 0 < x) (hσ : 1 / 2 ≤ σ) : + Erdos970.VerticalIntegral' (modFivePerronKernel x) σ = modFiveTriangle (1 / x) := by + have hsp : 0 < σ := by linarith + have hi := mellinInv_mellin_eq σ modFiveTriangle (one_div_pos.mpr hx) + (modFiveTriangle_hasMellin (by simpa using hsp)).1 + (modFiveTriangle_verticalIntegrable hσ) (modFiveTriangle_continuous.continuousAt) + have hpoint : ∀ t : ℝ, + ((1 / x : ℝ) : ℂ) ^ (-((σ : ℂ) + (t : ℂ) * Complex.I)) * + mellin modFiveTriangle ((σ : ℂ) + (t : ℂ) * Complex.I) = + modFivePerronKernel x ((σ : ℂ) + (t : ℂ) * Complex.I) := by + intro t + rw [show (1 / x : ℝ) = x⁻¹ by ring, Complex.ofReal_inv, + Complex.inv_cpow_ofReal_nonneg hx.le, Complex.cpow_neg, inv_inv, + (modFiveTriangle_hasMellin (by simpa using hsp)).2] + unfold modFivePerronKernel + ring + have hconst : (1 / (2 * (Real.pi : ℂ) * Complex.I)) * Complex.I = + ((1 / (2 * Real.pi) : ℝ) : ℂ) := by + push_cast + field_simp + rw [← hi] + simp only [Erdos970.VerticalIntegral', Erdos970.VerticalIntegral, mellinInv, + smul_eq_mul, ← mul_assoc, hconst] + congr 1 + apply integral_congr_ae + exact Filter.Eventually.of_forall fun t => (hpoint t).symm + +lemma modFivePerron_gt_one {x σ : ℝ} (hx : 1 < x) (hσ : 1 / 2 ≤ σ) : + Erdos970.VerticalIntegral' (modFivePerronKernel x) σ = 1 - 1 / (x : ℂ) := by + rw [modFivePerron_inversion (zero_lt_one.trans hx) hσ] + have hi : (1 : ℝ) / x ≤ 1 := (div_le_one (zero_lt_one.trans hx)).mpr hx.le + rw [modFiveTriangle, max_eq_left (sub_nonneg.mpr hi)] + push_cast + rfl + +lemma modFivePerron_lt_one {x σ : ℝ} (hx : 0 < x) (hx1 : x < 1) (hσ : 1 / 2 ≤ σ) : + Erdos970.VerticalIntegral' (modFivePerronKernel x) σ = 0 := by + rw [modFivePerron_inversion hx hσ] + have hi : (1 : ℝ) ≤ 1 / x := (le_div_iff₀ hx).mpr (by simpa using hx1.le) + rw [modFiveTriangle, max_eq_right (sub_nonpos.mpr hi)] + rfl + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePerronParameters.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePerronParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..f171bb34f8546d01b42200e8e3c3394caae5325e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePerronParameters.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveSmoothedContour +import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics + +namespace OAI + +/-! Elementary parameter choices for the smoothed Perron bound. The +height is exp(y) and the original cutoff is exp(y²). -/ + +namespace TwoPointCorrelations + +open Filter + +lemma modFive_perron_height {y : ℝ} (hy : 2 ≤ y) : + 2 ≤ Real.exp y ∧ y ≤ Real.log (Real.exp y + 2) ∧ + Real.log (Real.exp y + 2) ≤ 2 * y := by + have he : 2 ≤ Real.exp y := by linarith [Real.add_one_le_exp y] + refine ⟨he, ?_, ?_⟩ + · simpa only [Real.log_exp] using + Real.log_le_log (Real.exp_pos y) (by linarith : Real.exp y ≤ Real.exp y + 2) + · have hh : Real.exp y + 2 ≤ Real.exp (2 * y) := by + rw [show 2 * y = y + y by ring, Real.exp_add] + nlinarith + simpa only [Real.log_exp] using Real.log_le_log (by positivity) hh + +lemma modFive_perron_right_power {y : ℝ} (hy : 0 < y) : + (Real.exp (y ^ 2)) ^ (1 + 1 / y ^ 2) = Real.exp (y ^ 2 + 1) := by + rw [Real.rpow_def_of_pos (Real.exp_pos _), Real.log_exp] + congr 1 + field_simp + +lemma modFive_perron_left_power {a y H : ℝ} (ha : 0 ≤ a) (hy : 0 < y) + (hH : 0 < H) (hHle : H ≤ 2 * y) : + (Real.exp (y ^ 2)) ^ (1 - a / H) ≤ Real.exp (y ^ 2 - a * y / 2) := by + have hq : y / 2 ≤ y ^ 2 / H := (le_div_iff₀ hH).mpr (by nlinarith) + have hm := mul_le_mul_of_nonneg_left hq ha + have he : a * (y ^ 2 / H) = y ^ 2 * (a / H) := by ring + rw [he] at hm + rw [Real.rpow_def_of_pos (Real.exp_pos _), Real.log_exp] + apply Real.exp_le_exp.mpr + nlinarith + +lemma modFive_perron_polynomial_absorption (K c : ℝ) (hc : 0 < c) : + ∀ᶠ y : ℝ in atTop, K * y ^ 2 * Real.exp (1 - c * y) ≤ 1 := by + have ht := (tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero 2 c hc).const_mul + (K * Real.exp 1) + simp only [mul_zero] at ht + have he : (fun y : ℝ => K * y ^ 2 * Real.exp (1 - c * y)) = + (fun y : ℝ => (K * Real.exp 1) * (y ^ (2 : ℝ) * Real.exp (-c * y))) := by + funext y + rw [Real.rpow_two, show 1 - c * y = 1 + (-c * y) by ring, Real.exp_add] + ring + rw [← he] at ht + exact (ht.eventually (gt_mem_nhds (by norm_num : (0 : ℝ) < 1))).mono fun _ h => h.le + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePerronSeries.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePerronSeries.lean new file mode 100644 index 0000000000000000000000000000000000000000..f8f141442b4efd70c39f2d553ba6676da72bdea8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePerronSeries.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePerronInversion + +namespace OAI + +/-! Absolute interchange for the triangular Perron kernel. The estimate is +proved for any absolutely convergent Dirichlet series and then specialized +to the actual twisted von Mangoldt series. +-/ + +namespace TwoPointCorrelations + +open Complex MeasureTheory Erdos970 +open scoped BigOperators + +lemma modFivePerron_term_kernel (a : ℕ → ℂ) {n : ℕ} (hn : n ≠ 0) + {x : ℝ} (hx : 0 < x) (s : ℂ) : + LSeries.term a s n * modFivePerronKernel x s = + a n * modFivePerronKernel (x / (n : ℝ)) s := by + rw [LSeries.term_of_ne_zero hn] + unfold modFivePerronKernel + rw [Complex.ofReal_div, Complex.div_cpow_ofReal_nonneg hx.le (Nat.cast_nonneg n)] + push_cast + ring + +lemma modFivePerron_term_integrable (a : ℕ → ℂ) (n : ℕ) {x σ : ℝ} + (hx : 0 < x) (hσ : 1 / 2 ≤ σ) : + Integrable (fun t : ℝ => LSeries.term a ((σ : ℂ) + (t : ℂ) * Complex.I) n * + modFivePerronKernel x ((σ : ℂ) + (t : ℂ) * Complex.I)) := by + by_cases hn : n = 0 + · subst n + simp + · simp_rw [modFivePerron_term_kernel a hn hx] + exact (modFivePerronKernel_integrable (div_pos hx (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn))) + hσ).const_mul (a n) + +lemma modFivePerron_term_norm (a : ℕ → ℂ) (n : ℕ) (x σ t : ℝ) : + ‖LSeries.term a ((σ : ℂ) + (t : ℂ) * Complex.I) n * + modFivePerronKernel x ((σ : ℂ) + (t : ℂ) * Complex.I)‖ = + ‖LSeries.term a (σ : ℂ) n‖ * + ‖modFivePerronKernel x ((σ : ℂ) + (t : ℂ) * Complex.I)‖ := by + rw [norm_mul] + congr 1 + simp [LSeries.norm_term_eq] + +theorem modFivePerron_series_interchange (a : ℕ → ℂ) {x σ : ℝ} + (hx : 0 < x) (hσ : 1 / 2 ≤ σ) (ha : LSeriesSummable a (σ : ℂ)) : + VerticalIntegral' (fun s => LSeries a s * modFivePerronKernel x s) σ = + ∑' n : ℕ, VerticalIntegral' + (fun s => LSeries.term a s n * modFivePerronKernel x s) σ := by + have hi := modFivePerronKernel_integrable hx hσ + have hterms := fun n => modFivePerron_term_integrable a n hx hσ + have hnorm : Summable (fun n : ℕ => ∫ t : ℝ, + ‖LSeries.term a ((σ : ℂ) + (t : ℂ) * Complex.I) n * + modFivePerronKernel x ((σ : ℂ) + (t : ℂ) * Complex.I)‖) := by + simp_rw [modFivePerron_term_norm, integral_const_mul] + exact ha.norm.mul_right _ + have he := integral_tsum_of_summable_integral_norm hterms hnorm + simp only [VerticalIntegral', VerticalIntegral, smul_eq_mul] + rw [tsum_mul_left, tsum_mul_left, he] + congr 2 + apply integral_congr_ae + exact Filter.Eventually.of_forall fun _ => tsum_mul_right.symm + +lemma modFivePerron_term_value (a : ℕ → ℂ) {n : ℕ} (hn : n ≠ 0) + {x σ : ℝ} (hx : 0 < x) (hσ : 1 / 2 ≤ σ) (hxn : x ≠ (n : ℝ)) : + VerticalIntegral' (fun s => LSeries.term a s n * modFivePerronKernel x s) σ = + if (n : ℝ) < x then a n * ((1 - (n : ℝ) / x : ℝ) : ℂ) else 0 := by + have hn' : 0 < (n : ℝ) := Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn) + have hk : (fun s => LSeries.term a s n * modFivePerronKernel x s) = + fun s => a n * modFivePerronKernel (x / (n : ℝ)) s := by + funext s + exact modFivePerron_term_kernel a hn hx s + rw [hk] + have hconst : VerticalIntegral' (fun s => a n * modFivePerronKernel (x / (n : ℝ)) s) σ = + a n * VerticalIntegral' (modFivePerronKernel (x / (n : ℝ))) σ := by + simp only [VerticalIntegral', VerticalIntegral, smul_eq_mul, integral_const_mul] + ring + rw [hconst] + by_cases hnlt : (n : ℝ) < x + · rw [ite_eq_left hnlt] + have hp := modFivePerron_gt_one ((one_lt_div hn').mpr hnlt) hσ + change VerticalIntegral' (modFivePerronKernel (x / (n : ℝ))) σ = _ at hp + rw [hp] + congr 1 + push_cast + field_simp + · rw [ite_eq_right hnlt] + have hlt : x < (n : ℝ) := lt_of_le_of_ne (le_of_not_gt hnlt) hxn + have hp := modFivePerron_lt_one (div_pos hx hn') ((div_lt_one hn').mpr hlt) hσ + change VerticalIntegral' (modFivePerronKernel (x / (n : ℝ))) σ = 0 at hp + rw [hp, mul_zero] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePerronShift.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePerronShift.lean new file mode 100644 index 0000000000000000000000000000000000000000..182f3c523471d2eb99ad16eca9e894b3cb4edb49 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePerronShift.lean @@ -0,0 +1,114 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveRectangleShift + +namespace OAI + +/-! Quantitative finite contour shift for the actual twisted Mangoldt +integrand. The left side stays inside the proved zero-free rectangle and +the two horizontal sides are bounded explicitly. +-/ + +namespace TwoPointCorrelations + +open Complex Set Erdos970 + +noncomputable def modFivePerronIntegrand (χ : DirichletCharacter ℂ 5) + (x : ℝ) (s : ℂ) : ℂ := + (-deriv (DirichletCharacter.LFunction χ) s / DirichletCharacter.LFunction χ s) * + modFivePerronKernel x s + +theorem modFive_finite_perron_shift : ∃ a C : ℝ, + 0 < a ∧ a ≤ 1 / 4 ∧ 0 < C ∧ + ∀ (χ : DirichletCharacter ℂ 5), χ ≠ 1 → ∀ T x b : ℝ, + 2 ≤ T → 1 ≤ x → 1 - a / Real.log (T + 2) ≤ b → b ≤ 2 → + ‖VIntegral (modFivePerronIntegrand χ x) b (-T) T‖ ≤ + 4 * Real.pi * C * Real.log (T + 2) ^ 2 * x ^ (1 - a / Real.log (T + 2)) + + 2 * (b - (1 - a / Real.log (T + 2))) * + (C * Real.log (T + 2) ^ 2 * x ^ b / T ^ 2) := by + obtain ⟨a, C, ha, ha4, hC, hreg⟩ := modFive_logderiv_rectangles + refine ⟨a, C, ha, ha4, hC, ?_⟩ + intro χ hχ T x b hT hx hab hb2 + let A := 1 - a / Real.log (T + 2) + let H := Real.log (T + 2) + have hTp : 0 < T := by linarith + have hxp : 0 < x := zero_lt_one.trans_le hx + have hH : 0 < H := Real.log_pos (by linarith) + have hHhalf : 1 / 2 ≤ H := by + simpa only [abs_of_nonneg hTp.le] using modFive_log_height_ge_half T + have hAhalf : 1 / 2 ≤ A := by + have hadiv : a / H ≤ 1 / 2 := by + apply (div_le_iff₀ hH).mpr + linarith + dsimp [A, H] at * + linarith + have heval (σ t : ℝ) (hσ : A ≤ σ) (hσ2 : σ ≤ 2) (ht : |t| ≤ T) : + DirichletCharacter.LFunction χ ((σ : ℂ) + (t : ℂ) * Complex.I) ≠ 0 ∧ + ‖-deriv (DirichletCharacter.LFunction χ) ((σ : ℂ) + (t : ℂ) * Complex.I) / + DirichletCharacter.LFunction χ ((σ : ℂ) + (t : ℂ) * Complex.I)‖ ≤ C * H ^ 2 := by + have he := hreg χ hχ T hT ((σ : ℂ) + (t : ℂ) * Complex.I) + (by + have hr : ((σ : ℂ) + (t : ℂ) * Complex.I).re = σ := by simp + rw [hr] + exact hσ) (by simpa using hσ2) (by simpa using ht) + exact ⟨he.1, by simpa only [neg_div, norm_neg] using he.2⟩ + have hf : DifferentiableOn ℂ (modFivePerronIntegrand χ x) + (Rectangle ((A : ℂ) - Complex.I * (T : ℂ)) ((b : ℂ) + Complex.I * (T : ℂ))) := by + intro s hs + have hab' : A ≤ b := hab + have hs' : s.re ∈ Icc A b ∧ s.im ∈ Icc (-T) T := by + simpa [Rectangle, Complex.mem_reProdIm, uIcc_of_le hab', uIcc_of_le (show -T ≤ T by linarith)] using hs + have hn := (hreg χ hχ T hT s hs'.1.1 (hs'.1.2.trans hb2) (abs_le.mpr hs'.2)).1 + have hs0 : s ≠ 0 := by + intro he + have hre := hs'.1.1 + rw [he] at hre + simp only [Complex.zero_re] at hre + linarith + have hs1 : s + 1 ≠ 0 := by + intro he + have hre := congrArg Complex.re he + simp only [Complex.add_re, Complex.one_re, Complex.zero_re] at hre + linarith [hs'.1.1] + exact (modFive_perron_integrand_differentiableAt χ hχ hxp hn hs0 hs1).differentiableWithinAt + have hside (t : ℝ) (ht : |t| = T) : + ∀ σ ∈ Icc A b, ‖modFivePerronIntegrand χ x ((σ : ℂ) + (t : ℂ) * Complex.I)‖ ≤ + C * H ^ 2 * x ^ b / T ^ 2 := by + intro σ hσ + have ht0 : t ≠ 0 := by intro he; simp [he] at ht; linarith + have ht2 : t ^ 2 = T ^ 2 := by rw [← sq_abs, ht] + have hlog := (heval σ t hσ.1 (hσ.2.trans hb2) ht.le).2 + have hk := modFive_perron_kernel_horizontal hxp σ ht0 + have hpow : x ^ σ ≤ x ^ b := Real.rpow_le_rpow_of_exponent_le hx hσ.2 + calc + _ = ‖-deriv (DirichletCharacter.LFunction χ) ((σ : ℂ) + (t : ℂ) * Complex.I) / + DirichletCharacter.LFunction χ ((σ : ℂ) + (t : ℂ) * Complex.I)‖ * + ‖modFivePerronKernel x ((σ : ℂ) + (t : ℂ) * Complex.I)‖ := norm_mul _ _ + _ ≤ (C * H ^ 2) * (x ^ σ / t ^ 2) := + mul_le_mul hlog hk (norm_nonneg _) (mul_nonneg hC.le (sq_nonneg H)) + _ ≤ _ := by + rw [ht2, ← mul_div_assoc] + exact div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hpow + (mul_nonneg hC.le (sq_nonneg H))) (sq_nonneg T) + have hv : ‖VIntegral (modFivePerronIntegrand χ x) A (-T) T‖ ≤ + (4 * C * H ^ 2 * x ^ A) * Real.pi := by + apply modFive_vertical_quadratic_bound hTp.le (by positivity) + intro t ht + have hlog := (heval A t le_rfl (hab.trans hb2) (abs_le.mpr ht)).2 + have hk := modFive_perron_kernel_vertical hxp hAhalf t + calc + _ = ‖-deriv (DirichletCharacter.LFunction χ) ((A : ℂ) + (t : ℂ) * Complex.I) / + DirichletCharacter.LFunction χ ((A : ℂ) + (t : ℂ) * Complex.I)‖ * + ‖modFivePerronKernel x ((A : ℂ) + (t : ℂ) * Complex.I)‖ := norm_mul _ _ + _ ≤ (C * H ^ 2) * (4 * x ^ A / (1 + t ^ 2)) := + mul_le_mul hlog hk (norm_nonneg _) (mul_nonneg hC.le (sq_nonneg H)) + _ = _ := by ring + have hs := modFive_rectangle_shift_bound hab hf + (hside T (abs_of_nonneg hTp.le)) (hside (-T) (by simp [abs_of_nonneg hTp.le])) + calc + _ ≤ (4 * C * H ^ 2 * x ^ A) * Real.pi + + 2 * (C * H ^ 2 * x ^ b / T ^ 2) * (b - A) := + hs.trans (add_le_add hv le_rfl) + _ = _ := by dsimp [A, H]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePositivity.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePositivity.lean new file mode 100644 index 0000000000000000000000000000000000000000..6381800e07ecdb9b6e1e8bc79d861bfe9adab9ac --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePositivity.lean @@ -0,0 +1,126 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveAbelContinuation + +namespace OAI + +/-! The de la Vallée Poussin positivity inequality for modulus five. +The proof is termwise and uses the actual Mangoldt Dirichlet series. +It does not assume a zero-free region or a prime-number estimate. +-/ + +namespace TwoPointCorrelations + +open Complex ArithmeticFunction +open scoped BigOperators Classical LSeries.notation + +lemma modFive_three_four_one_nonneg {z : ℂ} (hz : ‖z‖ ≤ 1) : + 0 ≤ 3 + 4 * z.re + (z ^ 2).re := by + have hn : z.re ^ 2 + z.im ^ 2 ≤ 1 := by + have := sq_le_sq₀ (norm_nonneg z) zero_le_one |>.mpr hz + simpa only [Complex.sq_norm, Complex.normSq_apply, ← sq, one_pow] using this + have hs := sq_nonneg (z.re + 1) + simp only [pow_two, Complex.mul_re] + nlinarith + +lemma modFive_phase_norm (n : ℕ) (hn : n ≠ 0) (t : ℝ) : + ‖(n : ℂ) ^ (-(Complex.I * (t : ℂ)))‖ = 1 := by + rw [Complex.norm_natCast_cpow_of_pos (Nat.pos_of_ne_zero hn)] + simp + +lemma modFive_twisted_phase_norm (χ : DirichletCharacter ℂ 5) + (n : ℕ) (hn : n ≠ 0) (t : ℝ) : + ‖χ (n : ZMod 5) * (n : ℂ) ^ (-(Complex.I * (t : ℂ)))‖ ≤ 1 := by + rw [norm_mul, modFive_phase_norm n hn t, mul_one] + exact χ.norm_le_one _ + +lemma modFive_real_mangoldt_term (σ : ℝ) (n : ℕ) (hn : n ≠ 0) : + LSeries.term (fun m => (vonMangoldt m : ℂ)) (σ : ℂ) n = + ((vonMangoldt n * (n : ℝ) ^ (-σ) : ℝ) : ℂ) := by + rw [LSeries.term_of_ne_zero hn, div_eq_mul_inv, ← Complex.cpow_neg, + ← Complex.ofReal_neg, ← Complex.ofReal_natCast, + ← Complex.ofReal_cpow n.cast_nonneg, Complex.ofReal_mul] + +lemma modFive_twisted_mangoldt_term (χ : DirichletCharacter ℂ 5) + (σ t : ℝ) (n : ℕ) (hn : n ≠ 0) : + LSeries.term (modFiveMangoldtTwist χ) ((σ : ℂ) + Complex.I * (t : ℂ)) n = + ((vonMangoldt n * (n : ℝ) ^ (-σ) : ℝ) : ℂ) * + (χ (n : ZMod 5) * (n : ℂ) ^ (-(Complex.I * (t : ℂ)))) := by + rw [LSeries.term_of_ne_zero hn, div_eq_mul_inv, ← Complex.cpow_neg, neg_add, + Complex.cpow_add _ _ (by exact_mod_cast hn)] + rw [← Complex.ofReal_neg, ← Complex.ofReal_natCast, + ← Complex.ofReal_cpow n.cast_nonneg] + simp only [modFiveMangoldtTwist, Complex.ofReal_mul] + ring + +lemma modFive_double_phase (χ : DirichletCharacter ℂ 5) (n : ℕ) (t : ℝ) : + (χ ^ 2) (n : ZMod 5) * (n : ℂ) ^ (-(Complex.I * ((2 * t : ℝ) : ℂ))) = + (χ (n : ZMod 5) * (n : ℂ) ^ (-(Complex.I * (t : ℂ)))) ^ 2 := by + rw [χ.pow_apply' (by decide : 2 ≠ 0)] + rw [show -(Complex.I * ((2 * t : ℝ) : ℂ)) = + (2 : ℕ) * (-(Complex.I * (t : ℂ))) by push_cast; ring, + Complex.cpow_nat_mul, mul_pow] + +lemma modFive_mangoldt_term_positivity (χ : DirichletCharacter ℂ 5) + (σ t : ℝ) (n : ℕ) : + 0 ≤ 3 * (LSeries.term (fun m => (vonMangoldt m : ℂ)) (σ : ℂ) n).re + + 4 * (LSeries.term (modFiveMangoldtTwist χ) + ((σ : ℂ) + Complex.I * (t : ℂ)) n).re + + (LSeries.term (modFiveMangoldtTwist (χ ^ 2)) + ((σ : ℂ) + Complex.I * ((2 * t : ℝ) : ℂ)) n).re := by + rcases eq_or_ne n 0 with rfl | hn + · simp only [LSeries.term_zero, Complex.zero_re, mul_zero, add_zero, le_refl] + rw [modFive_real_mangoldt_term σ n hn, + modFive_twisted_mangoldt_term χ σ t n hn, + modFive_twisted_mangoldt_term (χ ^ 2) σ (2 * t) n hn, + modFive_double_phase] + simp only [Complex.ofReal_re, Complex.mul_re, Complex.ofReal_im, zero_mul, sub_zero] + have hpoly := modFive_three_four_one_nonneg (modFive_twisted_phase_norm χ n hn t) + simp only [Complex.mul_re] at hpoly + have ha : 0 ≤ vonMangoldt n * (n : ℝ) ^ (-σ) := + mul_nonneg vonMangoldt_nonneg (Real.rpow_nonneg n.cast_nonneg _) + nlinarith [mul_nonneg ha hpoly] + +/-- Positivity of the three actual, absolutely convergent Mangoldt series. -/ +theorem modFive_mangoldt_series_positivity (χ : DirichletCharacter ℂ 5) + {σ : ℝ} (hσ : 1 < σ) (t : ℝ) : + 0 ≤ 3 * (LSeries (fun m => (vonMangoldt m : ℂ)) (σ : ℂ)).re + + 4 * (LSeries (modFiveMangoldtTwist χ) ((σ : ℂ) + Complex.I * (t : ℂ))).re + + (LSeries (modFiveMangoldtTwist (χ ^ 2)) + ((σ : ℂ) + Complex.I * ((2 * t : ℝ) : ℂ))).re := by + have hs0 : 1 < (σ : ℂ).re := hσ + have hs1 : 1 < ((σ : ℂ) + Complex.I * (t : ℂ)).re := by simpa using hσ + have hs2 : 1 < ((σ : ℂ) + Complex.I * ((2 * t : ℝ) : ℂ)).re := by simpa using hσ + have h0 := Complex.hasSum_re (LSeriesSummable_vonMangoldt hs0).LSeriesHasSum + have h1 := Complex.hasSum_re (χ.LSeriesSummable_twist_vonMangoldt hs1).LSeriesHasSum + have h2 := Complex.hasSum_re ((χ ^ 2).LSeriesSummable_twist_vonMangoldt hs2).LSeriesHasSum + exact (((h0.mul_left 3).add (h1.mul_left 4)).add h2).nonneg + (modFive_mangoldt_term_positivity χ σ t) + +lemma modFive_twisted_series_logderiv (χ : DirichletCharacter ℂ 5) + {s : ℂ} (hs : 1 < s.re) : + LSeries (modFiveMangoldtTwist χ) s = + -deriv (DirichletCharacter.LFunction χ) s / DirichletCharacter.LFunction χ s := by + rw [DirichletCharacter.deriv_LFunction_eq_deriv_LSeries χ hs, + DirichletCharacter.LFunction_eq_LSeries χ hs] + exact χ.LSeries_twist_vonMangoldt_eq hs + +/-- The fixed-character logarithmic-derivative inequality needed by the +quantitative zero-free-region proof. -/ +theorem modFive_logderiv_positivity (χ : DirichletCharacter ℂ 5) + {σ : ℝ} (hσ : 1 < σ) (t : ℝ) : + 0 ≤ 3 * (-deriv riemannZeta (σ : ℂ) / riemannZeta (σ : ℂ)).re + + 4 * (-deriv (DirichletCharacter.LFunction χ) + ((σ : ℂ) + Complex.I * (t : ℂ)) / + DirichletCharacter.LFunction χ ((σ : ℂ) + Complex.I * (t : ℂ))).re + + (-deriv (DirichletCharacter.LFunction (χ ^ 2)) + ((σ : ℂ) + Complex.I * ((2 * t : ℝ) : ℂ)) / + DirichletCharacter.LFunction (χ ^ 2) + ((σ : ℂ) + Complex.I * ((2 * t : ℝ) : ℂ))).re := by + have h := modFive_mangoldt_series_positivity χ hσ t + rw [LSeries_vonMangoldt_eq_deriv_riemannZeta_div hσ, + modFive_twisted_series_logderiv χ (by simpa using hσ), + modFive_twisted_series_logderiv (χ ^ 2) (by simpa using hσ)] at h + exact h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrimeBands.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrimeBands.lean new file mode 100644 index 0000000000000000000000000000000000000000..28026ec1dc95a047ad6f89e4197d298fd38e08db --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrimeBands.lean @@ -0,0 +1,104 @@ +import OAI.NumberTheory.TwoPoint.Bounds.ReciprocalPrimeBands + +namespace OAI + +/-! Concrete modulus-five supplies and their reciprocal masses. We use +half-open bands `(exp A, exp B]`; this harmless endpoint convention makes +adjacent supplies exactly disjoint and matches finite Abel summation. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +noncomputable def deletedModFiveLogWeight (E : Finset ℕ) (one : Bool) (p : ℕ) : ℝ := + if ModFivePrime one p ∧ p ∉ E then Real.log p else 0 + +lemma partialSum_deletedModFive (E : Finset ℕ) (one : Bool) (x : ℝ) : + partialCoefficientSum (deletedModFiveLogWeight E one) x = + deletedModFiveTheta E one x := by + unfold partialCoefficientSum deletedModFiveTheta deletedModFivePrimes + modFivePrimesUpTo deletedModFiveLogWeight + rw [sdiff_eq_filter, sum_filter, sum_filter] + apply sum_congr rfl + intro p hp + by_cases h : ModFivePrime one p <;> by_cases he : p ∈ E <;> simp [h, he] + +noncomputable def modFivePrimeBand (E : Finset ℕ) (one : Bool) (a b : ℝ) : Finset ℕ := + (Ioc ⌊a⌋₊ ⌊b⌋₊).filter (fun p => ModFivePrime one p ∧ p ∉ E) + +lemma modFivePrimeBand_mem {E : Finset ℕ} {one : Bool} {a b : ℝ} + (ha : 0 ≤ a) (hb : 0 ≤ b) {p : ℕ} : + p ∈ modFivePrimeBand E one a b ↔ + a < (p : ℝ) ∧ (p : ℝ) ≤ b ∧ ModFivePrime one p ∧ p ∉ E := by + simp only [modFivePrimeBand, mem_filter, mem_Ioc] + rw [Nat.floor_lt ha, Nat.le_floor_iff hb] + tauto + +lemma modFivePrimeBand_sum (E : Finset ℕ) (one : Bool) (a b : ℝ) : + (∑ p ∈ modFivePrimeBand E one a b, 1 / (p : ℝ)) = + ∑ p ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, reciprocalLog p * deletedModFiveLogWeight E one p := by + rw [modFivePrimeBand, sum_filter] + apply sum_congr rfl + intro p hp + by_cases hs : ModFivePrime one p ∧ p ∉ E + · have hl : Real.log (p : ℝ) ≠ 0 := + (Real.log_pos (by exact_mod_cast hs.1.1.one_lt)).ne' + rw [ite_eq_left hs] + unfold deletedModFiveLogWeight + rw [ite_eq_left hs] + unfold reciprocalLog + field_simp + · simp [deletedModFiveLogWeight, hs] + +/-- Both selected prime classes have their correct logarithmic-band mass, +uniformly over the upper endpoint and with any fixed finite exclusions. -/ +theorem ModFiveThetaInput.band_error (hP : ModFiveThetaInput) (E : Finset ℕ) : + ∃ K : ℝ, 0 ≤ K ∧ ∀ (one : Bool) (A B : ℝ), 1 ≤ A → A ≤ B → + |(∑ p ∈ modFivePrimeBand E one (Real.exp A) (Real.exp B), 1 / (p : ℝ)) - + modFiveDensity one * (Real.log B - Real.log A)| ≤ 4 * K / A := by + obtain ⟨K, hK, h⟩ := hP.deleted_log_error E + refine ⟨K, hK, fun one A B hA hAB => ?_⟩ + rw [modFivePrimeBand_sum] + have hh := reciprocal_band_error (deletedModFiveLogWeight E one) (modFiveDensity one) + K (Real.exp A) (Real.exp B) hK (Real.exp_le_exp.mpr hA) + (Real.exp_le_exp.mpr hAB) (fun x hx => by + rw [partialSum_deletedModFive] + apply h one x + have h2 : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + exact h2.trans ((Real.exp_le_exp.mpr hA).trans hx.1)) + simpa only [Real.log_exp] using hh + +/-- The concrete centered-prime supplies have reciprocal mass in `[W,2W]` +once their lower logarithmic endpoint exceeds one fixed threshold. -/ +theorem ModFiveThetaInput.centered_band_mass (hP : ModFiveThetaInput) + (E : Finset ℕ) (W : ℝ) (hW : 0 < W) : + ∃ A₀ : ℝ, 1 ≤ A₀ ∧ ∀ A : ℝ, A₀ ≤ A → + W ≤ (∑ p ∈ modFivePrimeBand E true (Real.exp A) + (Real.exp (A * Real.exp (6 * W))), 1 / (p : ℝ)) ∧ + (∑ p ∈ modFivePrimeBand E true (Real.exp A) + (Real.exp (A * Real.exp (6 * W))), 1 / (p : ℝ)) ≤ 2 * W := by + obtain ⟨K, hK, h⟩ := hP.band_error E + refine ⟨max 1 (8 * K / W), le_max_left _ _, fun A hA => ?_⟩ + have hA1 : 1 ≤ A := (le_max_left _ _).trans hA + have hA0 : 0 < A := zero_lt_one.trans_le hA1 + have hB : A ≤ A * Real.exp (6 * W) := by + have hh := mul_le_mul_of_nonneg_left (Real.one_le_exp (by positivity : 0 ≤ 6 * W)) hA0.le + simpa only [mul_one] using hh + have hmass := h true A (A * Real.exp (6 * W)) hA1 hB + have he : Real.log (A * Real.exp (6 * W)) - Real.log A = 6 * W := by + rw [Real.log_mul hA0.ne' (Real.exp_pos _).ne', Real.log_exp] + ring + rw [he] at hmass + have hsmall : 4 * K / A ≤ W / 2 := by + have hh := (div_le_iff₀ hW).mp ((le_max_right 1 (8 * K / W)).trans hA) + apply (div_le_iff₀ hA0).mpr + nlinarith [hh] + have hh := abs_le.mp hmass + norm_num [modFiveDensity] at hh + simp only [one_div] + constructor <;> linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrimeNumberTheorem.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrimeNumberTheorem.lean new file mode 100644 index 0000000000000000000000000000000000000000..07f7af13e1563ad7b99fe1ce926806f6860616a7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrimeNumberTheorem.lean @@ -0,0 +1,122 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePsiDecay +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveZetaPsi +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveInputExtension + +namespace OAI + +/-! The fixed modulus-five prime number theorem follows from the three +nonprincipal contour estimates, the zeta prime number theorem, and finite +character orthogonality. -/ + +namespace TwoPointCorrelations + +open Filter Finset +open scoped BigOperators Classical + +local instance : Fact (1 < (5 : ℕ)) := ⟨by decide⟩ + +lemma modFive_character_card : Fintype.card (DirichletCharacter ℂ 5) = 4 := by + have hh := modFive_character_sum 1 + simp only [Nat.cast_one, map_one, sum_const, card_univ, nsmul_eq_mul, mul_one, + show 1 % 5 = 1 by decide, ↓reduceIte] at hh + exact_mod_cast hh + +lemma modFive_rate_mono {a b x : ℝ} (hab : a ≤ b) : + Real.exp (-b * Real.sqrt (Real.log x)) ≤ Real.exp (-a * Real.sqrt (Real.log x)) := by + apply Real.exp_le_exp.mpr + exact mul_le_mul_of_nonneg_right (neg_le_neg hab) (Real.sqrt_nonneg _) + +theorem modFive_all_character_error : ∃ c C : ℝ, 0 < c ∧ 0 < C ∧ + ∀ᶠ x : ℝ in atTop, ∀ χ : DirichletCharacter ℂ 5, + ‖modFiveTwistedPsi χ x - (if χ = 1 then (x : ℂ) else 0)‖ ≤ + C * x * Real.exp (-c * Real.sqrt (Real.log x)) := by + obtain ⟨a, ha, hnp⟩ := modFive_nonprincipal_psi_decay + obtain ⟨b, B, hb, hB, hpr⟩ := modFive_principal_psi_decay + refine ⟨min a b, B + 2, lt_min ha hb, by positivity, ?_⟩ + filter_upwards [hnp, hpr, eventually_ge_atTop (1 : ℝ)] with x hnp hpr hx χ + by_cases hχ : χ = 1 + · subst χ + rw [ite_eq_left rfl] + calc + _ ≤ B * x * Real.exp (-b * Real.sqrt (Real.log x)) := hpr + _ ≤ (B + 2) * x * Real.exp (-(min a b) * Real.sqrt (Real.log x)) := by + apply mul_le_mul + · exact mul_le_mul_of_nonneg_right (by linarith : B ≤ B + 2) (by linarith) + · exact modFive_rate_mono (min_le_right _ _) + · exact (Real.exp_pos _).le + · positivity + · rw [ite_eq_right hχ, sub_zero] + calc + _ ≤ 2 * x * Real.exp (-a * Real.sqrt (Real.log x)) := hnp χ hχ + _ ≤ (B + 2) * x * Real.exp (-(min a b) * Real.sqrt (Real.log x)) := by + apply mul_le_mul + · exact mul_le_mul_of_nonneg_right (by linarith : 2 ≤ B + 2) (by linarith) + · exact modFive_rate_mono (min_le_left _ _) + · exact (Real.exp_pos _).le + · positivity + +lemma modFive_selected_psi_error {x E : ℝ} + (h : ∀ χ : DirichletCharacter ℂ 5, + ‖modFiveTwistedPsi χ x - (if χ = 1 then (x : ℂ) else 0)‖ ≤ E) : + |modFivePsi true x - x / 4| ≤ E := by + have he : (4 : ℂ) * ((modFivePsi true x - x / 4 : ℝ) : ℂ) = + ∑ χ : DirichletCharacter ℂ 5, + (modFiveTwistedPsi χ x - (if χ = 1 then (x : ℂ) else 0)) := by + rw [sum_sub_distrib] + simp only [sum_ite_eq', mem_univ, ↓reduceIte] + rw [← modFivePsi_true_character_sum] + push_cast + ring + have hn : 4 * |modFivePsi true x - x / 4| ≤ 4 * E := by + calc + _ = ‖(4 : ℂ) * ((modFivePsi true x - x / 4 : ℝ) : ℂ)‖ := by + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs] + norm_num + _ ≤ ∑ χ : DirichletCharacter ℂ 5, + ‖modFiveTwistedPsi χ x - (if χ = 1 then (x : ℂ) else 0)‖ := by + rw [he] + exact norm_sum_le _ _ + _ ≤ ∑ _χ : DirichletCharacter ℂ 5, E := sum_le_sum fun χ _ => h χ + _ = _ := by simp [modFive_character_card] + linarith + +theorem modFive_eventual_psi : ∃ c C : ℝ, 0 < c ∧ 0 ≤ C ∧ + ∀ᶠ x : ℝ in atTop, ∀ one : Bool, + |modFivePsi one x - modFiveDensity one * x| ≤ + C * x * Real.exp (-c * Real.sqrt (Real.log x)) := by + obtain ⟨a, A, ha, hA, hchars⟩ := modFive_all_character_error + obtain ⟨b, B, hb, hB, hzeta⟩ := modFive_zeta_psi_decay + refine ⟨min a b, A + B, lt_min ha hb, by positivity, ?_⟩ + filter_upwards [hchars, hzeta, eventually_ge_atTop (1 : ℝ)] with x hchars hzeta hx one + have htrue : |modFivePsi true x - (1 / 4) * x| ≤ + A * x * Real.exp (-(min a b) * Real.sqrt (Real.log x)) := by + have hh := modFive_selected_psi_error hchars + have he : x / 4 = (1 / 4 : ℝ) * x := by ring + rw [he] at hh + exact hh.trans (mul_le_mul_of_nonneg_left (modFive_rate_mono (min_le_left _ _)) + (by positivity)) + have hz : |Chebyshev.psi x - x| ≤ + B * x * Real.exp (-(min a b) * Real.sqrt (Real.log x)) := + hzeta.trans (mul_le_mul_of_nonneg_left (modFive_rate_mono (min_le_right _ _)) + (by positivity)) + cases one + · have he : modFivePsi false x - (3 / 4) * x = + (Chebyshev.psi x - x) - (modFivePsi true x - (1 / 4) * x) := by + linear_combination modFivePsi_complement x + change |modFivePsi false x - (3 / 4) * x| ≤ _ + rw [he] + exact (abs_sub _ _).trans ((add_le_add hz htrue).trans_eq (by ring)) + · change |modFivePsi true x - (1 / 4) * x| ≤ _ + exact htrue.trans (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (by linarith : A ≤ A + B) (by linarith)) + (Real.exp_pos _).le) + +/-- The logarithmically weighted prime estimate in the two selected +modulus-five classes, obtained by contour integration and orthogonality. -/ +theorem modFiveThetaInput : ModFiveThetaInput := by + obtain ⟨c, C, hc, hC, h⟩ := modFive_eventual_psi + exact modFiveThetaInput_of_eventual_psi c C hc hC h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrimes.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrimes.lean new file mode 100644 index 0000000000000000000000000000000000000000..15237702415ee31165a30675c566137834e193ac --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrimes.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.TwoPoint.Bounds.MertensScale +import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics + +namespace OAI + +/-! The fixed modulus-five prime-number input used by the manuscript. + +Published source: D. Koukoulopoulos, *The Distribution of Prime Numbers*, +AMS, 2019, Theorem 12.1 (Siegel--Walfisz), with modulus 5 fixed. That theorem +is stated for the prime-counting function. `ModFiveThetaInput` is its standard +partial-summation consequence for the logarithmically weighted prime count, +specialized to the two selections needed here. The complementary selection +includes the single prime 5, which changes the error by a bounded amount. +Source: https://dms.umontreal.ca/~koukoulo/documents/publications/primes.pdf + +The estimate includes every prime in the selected classes. Removing a finite +exceptional prime set contributes an explicit finite-deletion correction. +-/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical Topology + +def ModFivePrime (one : Bool) (p : ℕ) : Prop := + p.Prime ∧ if one then p % 5 = 1 else p % 5 ≠ 1 + +noncomputable def modFiveDensity (one : Bool) : ℝ := if one then 1 / 4 else 3 / 4 + +noncomputable def modFivePrimesUpTo (one : Bool) (x : ℝ) : Finset ℕ := + (Icc 0 ⌊x⌋₊).filter (ModFivePrime one) + +noncomputable def modFiveLogWeight (one : Bool) (p : ℕ) : ℝ := + if ModFivePrime one p then Real.log p else 0 + +noncomputable def modFiveTheta (one : Bool) (x : ℝ) : ℝ := + ∑ p ∈ Icc 0 ⌊x⌋₊, modFiveLogWeight one p + +noncomputable def deletedModFivePrimes (E : Finset ℕ) (one : Bool) (x : ℝ) : Finset ℕ := + modFivePrimesUpTo one x \ E + +noncomputable def deletedModFiveTheta (E : Finset ℕ) (one : Bool) (x : ℝ) : ℝ := + ∑ p ∈ deletedModFivePrimes E one x, Real.log p + +/-- The precise published input: a fixed-modulus consequence of +Koukoulopoulos, Theorem 12.1, before any application-dependent exclusions. -/ +def ModFiveThetaInput : Prop := + ∃ c C : ℝ, 0 < c ∧ 0 ≤ C ∧ ∀ (one : Bool) (x : ℝ), 2 ≤ x → + |modFiveTheta one x - modFiveDensity one * x| ≤ + C * x * Real.exp (-c * Real.sqrt (Real.log x)) + +lemma modFiveTheta_eq_sum (one : Bool) (x : ℝ) : + modFiveTheta one x = ∑ p ∈ modFivePrimesUpTo one x, Real.log p := by + simp [modFiveTheta, modFivePrimesUpTo, modFiveLogWeight, sum_filter] + +lemma modFivePrimesUpTo_prime {one : Bool} {x : ℝ} {p : ℕ} + (hp : p ∈ modFivePrimesUpTo one x) : p.Prime := + (mem_filter.mp hp).2.1 + +lemma modFivePrimesUpTo_le {one : Bool} {x : ℝ} (hx : 0 ≤ x) {p : ℕ} + (hp : p ∈ modFivePrimesUpTo one x) : (p : ℝ) ≤ x := + (Nat.le_floor_iff hx).mp (mem_Icc.mp (mem_filter.mp hp).1).2 + +lemma modFivePrimesUpTo_mono (one : Bool) {x y : ℝ} (hxy : x ≤ y) : + modFivePrimesUpTo one x ⊆ modFivePrimesUpTo one y := by + intro p hp + obtain ⟨hp, hsel⟩ := mem_filter.mp hp + exact mem_filter.mpr ⟨mem_Icc.mpr ⟨(mem_Icc.mp hp).1, + (mem_Icc.mp hp).2.trans (Nat.floor_le_floor hxy)⟩, hsel⟩ + +lemma modFivePrimesUpTo_disjoint (x y : ℝ) : + Disjoint (modFivePrimesUpTo true x) (modFivePrimesUpTo false y) := by + apply disjoint_left.mpr + intro p hp hq + have hp' := (mem_filter.mp hp).2.2 + have hq' := (mem_filter.mp hq).2.2 + change p % 5 = 1 at hp' + change p % 5 ≠ 1 at hq' + exact hq' hp' + +lemma log_nat_nonneg (p : ℕ) : 0 ≤ Real.log (p : ℝ) := by + by_cases hp : p = 0 + · simp [hp] + · exact Real.log_nonneg (by exact_mod_cast Nat.one_le_iff_ne_zero.mpr hp) + +/-- The entire cost of removing a finite exceptional prime set is explicit. -/ +lemma deletedModFiveTheta_error (E : Finset ℕ) (one : Bool) (x : ℝ) : + |deletedModFiveTheta E one x - modFiveTheta one x| ≤ + ∑ p ∈ E, Real.log p := by + rw [modFiveTheta_eq_sum] + have he : deletedModFiveTheta E one x - + (∑ p ∈ modFivePrimesUpTo one x, Real.log p) = + -(∑ p ∈ modFivePrimesUpTo one x ∩ E, Real.log p) := by + unfold deletedModFiveTheta deletedModFivePrimes + have hs := sum_sdiff (f := fun p : ℕ => Real.log (p : ℝ)) + (inter_subset_left : modFivePrimesUpTo one x ∩ E ⊆ modFivePrimesUpTo one x) + rw [sdiff_inter_self_left] at hs + linarith + rw [he, abs_neg, abs_of_nonneg (sum_nonneg (fun p _ => log_nat_nonneg p))] + exact sum_le_sum_of_subset_of_nonneg inter_subset_right (fun p _ _ => log_nat_nonneg p) + +theorem ModFiveThetaInput.deleted_error (hP : ModFiveThetaInput) : + ∃ c C : ℝ, 0 < c ∧ 0 ≤ C ∧ ∀ (E : Finset ℕ) (one : Bool) (x : ℝ), 2 ≤ x → + |deletedModFiveTheta E one x - modFiveDensity one * x| ≤ + C * x * Real.exp (-c * Real.sqrt (Real.log x)) + ∑ p ∈ E, Real.log p := by + obtain ⟨c, C, hc, hC, h⟩ := hP + refine ⟨c, C, hc, hC, fun E one x hx => ?_⟩ + calc + _ = |(modFiveTheta one x - modFiveDensity one * x) + + (deletedModFiveTheta E one x - modFiveTheta one x)| := by congr 1; ring + _ ≤ |modFiveTheta one x - modFiveDensity one * x| + + |deletedModFiveTheta E one x - modFiveTheta one x| := abs_add_le _ _ + _ ≤ _ := add_le_add (h one x hx) (deletedModFiveTheta_error E one x) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrincipalCorrection.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrincipalCorrection.lean new file mode 100644 index 0000000000000000000000000000000000000000..39111af888532aecb2e48d982c0beda0449fe2de --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrincipalCorrection.lean @@ -0,0 +1,103 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePositivity +import Mathlib.Analysis.Calculus.LogDeriv + +namespace OAI + +/-! The principal modulus-five logarithmic derivative differs from the +ordinary zeta logarithmic derivative by a single, uniformly bounded Euler +factor. This is proved directly from the existing change-of-level identity. +-/ + +namespace TwoPointCorrelations + +open Complex Filter +open scoped Classical Topology + +noncomputable def modFiveEulerFactor (s : ℂ) : ℂ := 1 - (5 : ℂ) ^ (-s) + +lemma modFive_principal_eq {s : ℂ} (hs : s ≠ 1) : + DirichletCharacter.LFunction (1 : DirichletCharacter ℂ 5) s = + modFiveEulerFactor s * riemannZeta s := by + have h := DirichletCharacter.LFunctionTrivChar_eq_mul_riemannZeta (N := 5) hs + have hp : (5 : ℕ).primeFactors = {5} := (show Nat.Prime 5 by decide).primeFactors + simpa only [DirichletCharacter.LFunctionTrivChar, hp, Finset.prod_singleton, + Nat.cast_ofNat, modFiveEulerFactor] using h + +lemma modFiveEulerFactor_cpow_norm {s : ℂ} (hs : 1 ≤ s.re) : + ‖(5 : ℂ) ^ (-s)‖ ≤ 1 / 5 := by + change ‖((5 : ℝ) : ℂ) ^ (-s)‖ ≤ 1 / 5 + rw [Complex.norm_cpow_eq_rpow_re_of_pos (by norm_num : (0 : ℝ) < 5)] + have he : -s.re ≤ -(1 : ℝ) := by linarith + have hb := Real.rpow_le_rpow_of_exponent_le (by norm_num : (1 : ℝ) ≤ 5) he + norm_num at hb ⊢ + exact hb + +lemma modFiveEulerFactor_norm_ge {s : ℂ} (hs : 1 ≤ s.re) : + 4 / 5 ≤ ‖modFiveEulerFactor s‖ := by + have h := norm_sub_norm_le (1 : ℂ) ((5 : ℂ) ^ (-s)) + have hp := modFiveEulerFactor_cpow_norm hs + simp only [norm_one] at h + unfold modFiveEulerFactor + linarith + +lemma modFiveEulerFactor_ne_zero {s : ℂ} (hs : 1 ≤ s.re) : + modFiveEulerFactor s ≠ 0 := by + have h := modFiveEulerFactor_norm_ge hs + intro heq + rw [heq, norm_zero] at h + norm_num at h + +lemma modFiveEulerFactor_hasDeriv (s : ℂ) : + HasDerivAt modFiveEulerFactor ((5 : ℂ) ^ (-s) * Complex.log 5) s := by + have hp := (hasDerivAt_id s).neg.const_cpow (c := (5 : ℂ)) (Or.inl (by norm_num)) + change HasDerivAt (fun z => 1 - (5 : ℂ) ^ (-z)) _ s + convert hp.const_sub (1 : ℂ) using 1 <;> simp + +lemma modFiveEulerFactor_logderiv_norm {s : ℂ} (hs : 1 ≤ s.re) : + ‖deriv modFiveEulerFactor s / modFiveEulerFactor s‖ ≤ Real.log 5 / 4 := by + rw [(modFiveEulerFactor_hasDeriv s).deriv, norm_div, norm_mul] + have hl : ‖Complex.log (5 : ℂ)‖ = Real.log 5 := by + change ‖Complex.log ((5 : ℝ) : ℂ)‖ = Real.log 5 + rw [← Complex.ofReal_log (by norm_num : (0 : ℝ) ≤ 5), Complex.norm_real, + Real.norm_eq_abs, abs_of_pos (Real.log_pos (by norm_num))] + rw [hl] + have hd := modFiveEulerFactor_norm_ge hs + have hp := modFiveEulerFactor_cpow_norm hs + have hlog : 0 ≤ Real.log 5 := (Real.log_pos (by norm_num)).le + apply (div_le_iff₀ (lt_of_lt_of_le (by norm_num : (0 : ℝ) < 4 / 5) hd)).mpr + nlinarith + +/-- Exact principal-character correction, in logarithmic-derivative form. -/ +theorem modFive_principal_logderiv {s : ℂ} (hs : 1 < s.re) : + deriv (DirichletCharacter.LFunction (1 : DirichletCharacter ℂ 5)) s / + DirichletCharacter.LFunction (1 : DirichletCharacter ℂ 5) s = + deriv modFiveEulerFactor s / modFiveEulerFactor s + + deriv riemannZeta s / riemannZeta s := by + have hs1 : s ≠ 1 := by intro h; rw [h] at hs; norm_num at hs + have heq : DirichletCharacter.LFunction (1 : DirichletCharacter ℂ 5) =ᶠ[𝓝 s] + fun z => modFiveEulerFactor z * riemannZeta z := by + filter_upwards [eventually_ne_nhds hs1] with z hz + exact modFive_principal_eq hz + have h := (logDeriv_congr_nhds heq).eq_of_nhds + rw [logDeriv_fun_mul s (modFiveEulerFactor_ne_zero hs.le) + (riemannZeta_ne_zero_of_one_le_re hs.le) + (modFiveEulerFactor_hasDeriv s).differentiableAt + (differentiableAt_riemannZeta hs1)] at h + exact h + +/-- The correction at the exceptional prime has an absolute bound. -/ +theorem modFive_principal_logderiv_error {s : ℂ} (hs : 1 < s.re) : + ‖(-deriv (DirichletCharacter.LFunction (1 : DirichletCharacter ℂ 5)) s / + DirichletCharacter.LFunction (1 : DirichletCharacter ℂ 5) s) - + (-deriv riemannZeta s / riemannZeta s)‖ ≤ Real.log 5 / 4 := by + simp only [neg_div] + rw [modFive_principal_logderiv hs] + have he : -(deriv modFiveEulerFactor s / modFiveEulerFactor s + + deriv riemannZeta s / riemannZeta s) - -(deriv riemannZeta s / riemannZeta s) = + -(deriv modFiveEulerFactor s / modFiveEulerFactor s) := by ring + rw [he, norm_neg] + exact modFiveEulerFactor_logderiv_norm hs.le + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrincipalPsi.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrincipalPsi.lean new file mode 100644 index 0000000000000000000000000000000000000000..59bd2d1603a0580786f1fd0e458454c35bcf51e9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePrincipalPsi.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveUnsmoothing +import StrongPNT.Erdos970.PNT5_Strong + +namespace OAI + +/-! The principal character only removes powers of five. For the required +error bound it is enough to charge the prime 5 once, and all remaining +terms to the already proved elementary prime-power error. -/ + +namespace TwoPointCorrelations + +open Complex ArithmeticFunction Finset +open scoped BigOperators Classical + +local instance : Fact (1 < (5 : ℕ)) := ⟨by decide⟩ + +lemma modFive_principal_term_bound (n : ℕ) : + ‖modFiveMangoldtTwist 1 n - (vonMangoldt n : ℂ)‖ ≤ + (if n = 5 then Real.log 5 else 0) + + (vonMangoldt n - if n.Prime then Real.log n else 0) := by + by_cases hp : n.Prime + · by_cases hn : n = 5 + · subst n + have hz : (1 : DirichletCharacter ℂ 5) (5 : ZMod 5) = 0 := by + rw [show (5 : ZMod 5) = 0 by decide, MulChar.map_zero] + rw [modFiveMangoldtTwist] + simp only [Nat.cast_ofNat] + rw [hz, zero_mul, zero_sub, norm_neg, vonMangoldt_apply_prime hp] + simp only [hp, ↓reduceIte, Nat.cast_ofNat, sub_self, add_zero] + rw [Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (Real.log_nonneg (by norm_num : (1 : ℝ) ≤ 5))] + · have hcop : n.Coprime 5 := hp.coprime_iff_not_dvd.mpr (by + intro hd + exact hn ((Nat.prime_dvd_prime_iff_eq hp (by decide : Nat.Prime 5)).mp hd)) + have hu : IsUnit (n : ZMod 5) := (ZMod.isUnit_iff_coprime n 5).mpr hcop + have hone : (1 : DirichletCharacter ℂ 5) (n : ZMod 5) = 1 := MulChar.one_apply hu + simp [modFiveMangoldtTwist, hone, hp, hn, vonMangoldt_apply_prime hp] + · have hn : n ≠ 5 := by intro he; subst n; exact hp (by decide) + by_cases hu : IsUnit (n : ZMod 5) + · have hone : (1 : DirichletCharacter ℂ 5) (n : ZMod 5) = 1 := MulChar.one_apply hu + simp [modFiveMangoldtTwist, hone, hp, hn, vonMangoldt_nonneg] + · have hzero : (1 : DirichletCharacter ℂ 5) (n : ZMod 5) = 0 := MulChar.map_nonunit _ hu + simp [modFiveMangoldtTwist, hzero, hp, hn, abs_of_nonneg vonMangoldt_nonneg] + +lemma modFive_principal_psi_error {x : ℝ} (hx : 1 ≤ x) : + ‖modFiveTwistedPsi 1 x - (Chebyshev.psi x : ℂ)‖ ≤ + Real.log 5 + 2 * Real.sqrt x * Real.log x := by + have hid : modFiveTwistedPsi 1 x - (Chebyshev.psi x : ℂ) = + ∑ n ∈ Icc 0 ⌊x⌋₊, (modFiveMangoldtTwist 1 n - (vonMangoldt n : ℂ)) := by + rw [modFiveTwistedPsi_eq, Chebyshev.psi_eq_sum_Icc, Complex.ofReal_sum, + sum_sub_distrib] + have hfive : (∑ n ∈ Icc 0 ⌊x⌋₊, if n = 5 then Real.log 5 else 0) ≤ Real.log 5 := by + by_cases h5 : 5 ∈ Icc 0 ⌊x⌋₊ + · simp [h5] + · simp [h5, Real.log_nonneg (by norm_num : (1 : ℝ) ≤ 5)] + have hrem : (∑ n ∈ Icc 0 ⌊x⌋₊, + (vonMangoldt n - if n.Prime then Real.log n else 0)) = + Chebyshev.psi x - Chebyshev.theta x := by + rw [sum_sub_distrib, Chebyshev.psi_eq_sum_Icc, Chebyshev.theta_eq_sum_Icc, sum_filter] + rw [hid] + calc + _ ≤ ∑ n ∈ Icc 0 ⌊x⌋₊, ‖modFiveMangoldtTwist 1 n - (vonMangoldt n : ℂ)‖ := + norm_sum_le _ _ + _ ≤ ∑ n ∈ Icc 0 ⌊x⌋₊, + ((if n = 5 then Real.log 5 else 0) + + (vonMangoldt n - if n.Prime then Real.log n else 0)) := + sum_le_sum fun n _ => modFive_principal_term_bound n + _ = (∑ n ∈ Icc 0 ⌊x⌋₊, if n = 5 then Real.log 5 else 0) + + (Chebyshev.psi x - Chebyshev.theta x) := by rw [sum_add_distrib, hrem] + _ ≤ _ := add_le_add hfive (Chebyshev.psi_sub_theta_le hx) + +lemma modFive_chebyshevPsi_eq {x : ℝ} (hx : 0 ≤ x) : + Erdos970.ChebyshevPsi x = Chebyshev.psi x := by + rw [Erdos970.ChebyshevPsi, Nat.floor_add_one hx, Nat.range_succ_eq_Icc_zero, + Chebyshev.psi_eq_sum_Icc] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePsiDecay.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePsiDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae4df6780951feecb4e2f3e81636f22f87e9c81f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFivePsiDecay.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveUnsmoothingScale + +namespace OAI + +/-! Removal of the nonintegral-cutoff condition. The Mangoldt sums only +depend on the floor; the midpoint of the same unit interval is always an +admissible triangular cutoff. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma modFive_half_cutoff_nonnat (N : ℕ) : + ∀ n : ℕ, (N : ℝ) + 1 / 2 ≠ (n : ℝ) := by + intro n he + have hh : (2 : ℝ) * (N : ℝ) + 1 = 2 * (n : ℝ) := by linarith + have hn : 2 * N + 1 = 2 * n := by exact_mod_cast hh + omega + +lemma modFive_half_cutoff_floor (N : ℕ) : + ⌊(N : ℝ) + 1 / 2⌋₊ = N := by + apply (Nat.floor_eq_iff (by positivity)).mpr + constructor <;> linarith + +lemma modFive_half_cutoff_geometry {x : ℝ} (hx : 4 ≤ x) : + x / 2 ≤ (⌊x⌋₊ : ℝ) + 1 / 2 ∧ + (⌊x⌋₊ : ℝ) + 1 / 2 ≤ 2 * x ∧ + Real.sqrt (Real.log x) / 2 ≤ Real.sqrt (Real.log ((⌊x⌋₊ : ℝ) + 1 / 2)) := by + have hxp : 0 < x := by linarith + have hfloor := Nat.floor_le hxp.le + have hfloorlt := Nat.lt_floor_add_one x + have htlow : x / 2 ≤ (⌊x⌋₊ : ℝ) + 1 / 2 := by linarith + have hthi : (⌊x⌋₊ : ℝ) + 1 / 2 ≤ 2 * x := by linarith + refine ⟨htlow, hthi, ?_⟩ + have htp : 0 < (⌊x⌋₊ : ℝ) + 1 / 2 := by positivity + have hlogx : 2 * Real.log 2 ≤ Real.log x := by + have hh := Real.log_le_log (by norm_num : (0 : ℝ) < 4) hx + have he : Real.log (4 : ℝ) = 2 * Real.log 2 := by + rw [show (4 : ℝ) = 2 * 2 by norm_num, Real.log_mul (by norm_num) (by norm_num)] + ring + linarith + have hlogt : Real.log x - Real.log 2 ≤ Real.log ((⌊x⌋₊ : ℝ) + 1 / 2) := by + have hh := Real.log_le_log (by positivity : (0 : ℝ) < x / 2) htlow + rwa [Real.log_div hxp.ne' (by norm_num)] at hh + have hlogtnonneg : 0 ≤ Real.log ((⌊x⌋₊ : ℝ) + 1 / 2) := + Real.log_nonneg (by linarith) + apply (sq_le_sq₀ (by positivity) (Real.sqrt_nonneg _)).mp + rw [Real.sq_sqrt hlogtnonneg, div_pow, Real.sq_sqrt (Real.log_nonneg (by linarith))] + have hlog2 : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) + norm_num + linarith + +/-- The full real-cutoff estimate for every nonprincipal character mod 5. -/ +theorem modFive_nonprincipal_psi_decay : ∃ c : ℝ, 0 < c ∧ + ∀ᶠ x : ℝ in atTop, ∀ χ : DirichletCharacter ℂ 5, χ ≠ 1 → + ‖modFiveTwistedPsi χ x‖ ≤ 2 * x * Real.exp (-c * Real.sqrt (Real.log x)) := by + obtain ⟨c, hc, hbound⟩ := modFive_unsmoothed_decay_nonnat + obtain ⟨X, hX⟩ := eventually_atTop.mp hbound + refine ⟨c / 2, by positivity, ?_⟩ + filter_upwards [eventually_ge_atTop (max 4 (2 * X))] with x hx χ hχ + have hx4 : 4 ≤ x := (le_max_left _ _).trans hx + obtain ⟨htlow, hthi, hroot⟩ := modFive_half_cutoff_geometry hx4 + let t := (⌊x⌋₊ : ℝ) + 1 / 2 + have htX : X ≤ t := by + have hlarge : 2 * X ≤ x := (le_max_right _ _).trans hx + dsimp [t] + linarith + have ht : 0 < t := by dsimp [t]; positivity + have hsum : modFiveTwistedPsi χ t = modFiveTwistedPsi χ x := by + simp only [modFiveTwistedPsi, t, modFive_half_cutoff_floor] + have hm := hX t htX χ hχ (modFive_half_cutoff_nonnat ⌊x⌋₊) + rw [hsum] at hm + have he : Real.exp (-c * Real.sqrt (Real.log t)) ≤ + Real.exp (-(c / 2) * Real.sqrt (Real.log x)) := by + apply Real.exp_le_exp.mpr + have hh := mul_le_mul_of_nonpos_left hroot (neg_nonpos.mpr hc.le) + dsimp [t] at * + nlinarith + exact hm.trans (mul_le_mul hthi he (Real.exp_pos _).le (by linarith)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveRectangleShift.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveRectangleShift.lean new file mode 100644 index 0000000000000000000000000000000000000000..fd3d76d5e898120ad615bf89da8c1dc066ea4eb4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveRectangleShift.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveContourRegion + +namespace OAI + +/-! The exact finite rectangle shift, with an explicit horizontal cost. +All functions are complex scalar functions, as needed for the three fixed +nonprincipal Dirichlet L-functions. +-/ + +namespace TwoPointCorrelations + +open Complex Set Erdos970 MeasureTheory intervalIntegral + +lemma modFive_rectangle_shift {f : ℂ → ℂ} {a b T : ℝ} + (hf : DifferentiableOn ℂ f (Rectangle ((a : ℂ) - Complex.I * (T : ℂ)) + ((b : ℂ) + Complex.I * (T : ℂ)))) : + VIntegral f b (-T) T = + VIntegral f a (-T) T + HIntegral f a b T - HIntegral f a b (-T) := by + have hz := Erdos970.HolomorphicOn.vanishesOnRectangle hf (subset_refl _) + simp only [RectangleIntegral, Complex.sub_re, Complex.add_re, Complex.sub_im, + Complex.add_im, Complex.ofReal_re, Complex.ofReal_im, Complex.mul_re, + Complex.mul_im, Complex.I_re, Complex.I_im, zero_mul, mul_zero, one_mul, + zero_sub, sub_zero, add_zero, zero_add] at hz + linear_combination hz + +lemma modFive_rectangle_shift_bound {f : ℂ → ℂ} {a b T B : ℝ} + (hab : a ≤ b) + (hf : DifferentiableOn ℂ f (Rectangle ((a : ℂ) - Complex.I * (T : ℂ)) + ((b : ℂ) + Complex.I * (T : ℂ)))) + (hup : ∀ σ ∈ Icc a b, ‖f ((σ : ℂ) + (T : ℂ) * Complex.I)‖ ≤ B) + (hdown : ∀ σ ∈ Icc a b, ‖f ((σ : ℂ) + ((-T : ℝ) : ℂ) * Complex.I)‖ ≤ B) : + ‖VIntegral f b (-T) T‖ ≤ ‖VIntegral f a (-T) T‖ + 2 * B * (b - a) := by + have htop : ‖HIntegral f a b T‖ ≤ B * (b - a) := by + have hpoint : ∀ σ ∈ uIoc a b, ‖f ((σ : ℂ) + (T : ℂ) * Complex.I)‖ ≤ B := by + intro σ hσ + exact hup σ (Ioc_subset_Icc_self (by simpa [uIoc_of_le hab] using hσ)) + simpa only [HIntegral, abs_of_nonneg (sub_nonneg.mpr hab)] using + intervalIntegral.norm_integral_le_of_norm_le_const hpoint + have hbot : ‖HIntegral f a b (-T)‖ ≤ B * (b - a) := by + have hpoint : ∀ σ ∈ uIoc a b, ‖f ((σ : ℂ) + ((-T : ℝ) : ℂ) * Complex.I)‖ ≤ B := by + intro σ hσ + exact hdown σ (Ioc_subset_Icc_self (by simpa [uIoc_of_le hab] using hσ)) + simpa only [HIntegral, abs_of_nonneg (sub_nonneg.mpr hab)] using + intervalIntegral.norm_integral_le_of_norm_le_const hpoint + rw [modFive_rectangle_shift hf] + calc + _ ≤ ‖VIntegral f a (-T) T + HIntegral f a b T‖ + ‖HIntegral f a b (-T)‖ := norm_sub_le _ _ + _ ≤ (‖VIntegral f a (-T) T‖ + ‖HIntegral f a b T‖) + ‖HIntegral f a b (-T)‖ := + add_le_add (norm_add_le _ _) le_rfl + _ ≤ _ := by linarith + +lemma modFive_vertical_quadratic_bound {f : ℂ → ℂ} {σ T D : ℝ} + (hT : 0 ≤ T) (hD : 0 ≤ D) + (hf : ∀ t ∈ Icc (-T) T, ‖f ((σ : ℂ) + (t : ℂ) * Complex.I)‖ ≤ D / (1 + t ^ 2)) : + ‖VIntegral f σ (-T) T‖ ≤ D * Real.pi := by + rw [VIntegral, norm_smul, Complex.norm_I, one_mul] + have hgi : IntervalIntegrable (fun t : ℝ => D / (1 + t ^ 2)) volume (-T) T := by + simpa only [div_eq_mul_inv] using (integrable_inv_one_add_sq.const_mul D).intervalIntegrable + have hb := intervalIntegral.norm_integral_le_of_norm_le (by linarith : -T ≤ T) + (Filter.Eventually.of_forall fun t ht => hf t ⟨ht.1.le, ht.2⟩) hgi + refine hb.trans ?_ + simp only [div_eq_mul_inv, intervalIntegral.integral_const_mul, integral_inv_one_add_sq] + apply mul_le_mul_of_nonneg_left _ hD + linarith [Real.arctan_lt_pi_div_two T, Real.neg_pi_div_two_lt_arctan (-T)] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveRightBound.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveRightBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f1e16ea2af2bf03e89c7b6b69155a93826151b2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveRightBound.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePerronShift +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveSmoothedPsi + +namespace OAI + +/-! Absolute convergence bounds on the right Perron line. The twisted +series is dominated term by term by the untwisted Mangoldt series, whose +pole has the explicit reciprocal-distance bound. -/ + +namespace TwoPointCorrelations + +open Complex ArithmeticFunction Erdos970 +open scoped BigOperators + +lemma modFive_mangoldt_norm (χ : DirichletCharacter ℂ 5) (n : ℕ) : + ‖modFiveMangoldtTwist χ n‖ ≤ ‖(vonMangoldt n : ℂ)‖ := by + unfold modFiveMangoldtTwist + rw [norm_mul] + exact (mul_le_mul_of_nonneg_right (χ.norm_le_one _) (norm_nonneg _)).trans_eq + (one_mul _) + +lemma modFive_logderiv_right_domination (χ : DirichletCharacter ℂ 5) + {σ : ℝ} (hσ : 1 < σ) (t : ℝ) : + ‖-deriv (DirichletCharacter.LFunction χ) ((σ : ℂ) + (t : ℂ) * Complex.I) / + DirichletCharacter.LFunction χ ((σ : ℂ) + (t : ℂ) * Complex.I)‖ ≤ + ‖-deriv riemannZeta (σ : ℂ) / riemannZeta (σ : ℂ)‖ := by + let s : ℂ := (σ : ℂ) + (t : ℂ) * Complex.I + have hs : 1 < s.re := by simpa [s] using hσ + have hsum := χ.LSeriesSummable_twist_vonMangoldt hs + have hsum0 := LSeriesSummable_vonMangoldt (s := (σ : ℂ)) hσ + have hterm (n : ℕ) : ‖LSeries.term (modFiveMangoldtTwist χ) s n‖ ≤ + ‖LSeries.term (fun m => (vonMangoldt m : ℂ)) (σ : ℂ) n‖ := by + have he : ‖LSeries.term (modFiveMangoldtTwist χ) s n‖ = + ‖LSeries.term (modFiveMangoldtTwist χ) (σ : ℂ) n‖ := by + simp only [LSeries.norm_term_eq, s, add_re, ofReal_re, mul_I_re, ofReal_im, + neg_zero, add_zero] + rw [he] + exact LSeries.norm_term_le _ (modFive_mangoldt_norm χ n) + have heq : (∑' n, ‖LSeries.term (fun m => (vonMangoldt m : ℂ)) (σ : ℂ) n‖) = + ‖-deriv riemannZeta (σ : ℂ) / riemannZeta (σ : ℂ)‖ := by + rw [helper_norm_neg_logDeriv_eq_tsum_norm σ hσ] + apply tsum_congr + intro n + by_cases hn : n = 0 + · subst n + simp + · rw [LSeries.term_of_ne_zero hn] + rw [← modFive_twisted_series_logderiv χ hs] + change ‖∑' n, LSeries.term (modFiveMangoldtTwist χ) s n‖ ≤ _ + exact (norm_tsum_le_tsum_norm hsum.norm).trans + ((hsum.norm.tsum_le_tsum hterm hsum0.norm).trans_eq heq) + +/-- A uniform right-line bound, valid for every character, with only the +explicit simple-pole dependence on the distance from one. -/ +theorem modFive_logderiv_right_bound : ∃ C : ℝ, 0 < C ∧ + ∀ (χ : DirichletCharacter ℂ 5) (δ t : ℝ), 0 < δ → + ‖-deriv (DirichletCharacter.LFunction χ) (((1 + δ : ℝ) : ℂ) + (t : ℂ) * Complex.I) / + DirichletCharacter.LFunction χ (((1 + δ : ℝ) : ℂ) + (t : ℂ) * Complex.I)‖ ≤ + 1 / δ + C := by + obtain ⟨C, hC, hbound⟩ := Z0bound_const + refine ⟨C, lt_trans zero_lt_one hC, ?_⟩ + intro χ δ t hδ + have hmain := modFive_logderiv_right_domination χ (by linarith : 1 < 1 + δ) t + have hz := hbound δ hδ + have hz' : ‖-deriv riemannZeta (((1 + δ : ℝ) : ℂ)) / + riemannZeta (((1 + δ : ℝ) : ℂ)) - 1 / (δ : ℂ)‖ ≤ C := by + simpa only [Complex.ofReal_add, Complex.ofReal_one, logDerivZeta, neg_div] using hz + have hn : ‖(1 : ℂ) / (δ : ℂ)‖ = 1 / δ := by + simp [abs_of_pos hδ] + have hb := norm_le_insert' (-deriv riemannZeta (((1 + δ : ℝ) : ℂ)) / + riemannZeta (((1 + δ : ℝ) : ℂ))) (1 / (δ : ℂ)) + exact hmain.trans (hb.trans (by rw [hn]; linarith)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveSmoothedContour.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveSmoothedContour.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad08ca5d292413866c5134b957b522cf04867883 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveSmoothedContour.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveVerticalTails + +namespace OAI + +/-! A finite quantitative contour bound for the actual smoothed twisted +Mangoldt sums, using the zero-free region and the inverse-square tail +estimate. -/ + +namespace TwoPointCorrelations + +open Complex Erdos970 + +lemma modFive_perron_normalization : ‖(1 / (2 * Real.pi * Complex.I) : ℂ)‖ ≤ 1 := by + have hp : 1 ≤ 2 * Real.pi := by linarith [Real.pi_gt_three] + simp only [norm_div, norm_one, norm_mul, norm_ofNat, Complex.norm_real, + Real.norm_eq_abs, abs_of_pos Real.pi_pos, norm_I, mul_one] + exact (div_le_one (by positivity : 0 < 2 * Real.pi)).mpr hp + +theorem modFive_smoothed_contour_bound : ∃ a C D : ℝ, + 0 < a ∧ a ≤ 1 / 4 ∧ 0 < C ∧ 0 < D ∧ + ∀ (χ : DirichletCharacter ℂ 5), χ ≠ 1 → ∀ T x δ : ℝ, + 2 ≤ T → 1 ≤ x → 0 < δ → δ ≤ 1 → + (∀ n : ℕ, x ≠ (n : ℝ)) → + ‖modFiveSmoothedPsi χ x‖ ≤ + 4 * Real.pi * C * Real.log (T + 2) ^ 2 * x ^ (1 - a / Real.log (T + 2)) + + 4 * C * Real.log (T + 2) ^ 2 * x ^ (1 + δ) / T ^ 2 + + 2 * (1 / δ + D) * x ^ (1 + δ) / T := by + obtain ⟨a, C, ha, ha4, hC, hfinite⟩ := modFive_finite_perron_shift + obtain ⟨D, hD, htail⟩ := modFive_perron_tail_bound + refine ⟨a, C, D, ha, ha4, hC, hD, ?_⟩ + intro χ hχ T x δ hT hx hδ hδ1 hxnat + have hxpos : 0 < x := zero_lt_one.trans_le hx + have hH : 0 < Real.log (T + 2) := Real.log_pos (by linarith) + have hleft : 1 - a / Real.log (T + 2) ≤ 1 + δ := by + have hd := div_nonneg ha.le hH.le + linarith + have hfin := hfinite χ hχ T x (1 + δ) hT hx hleft (by linarith) + have hta := htail χ hχ δ x T hδ hxpos (by linarith) + have hlength : 1 + δ - (1 - a / Real.log (T + 2)) ≤ 2 := by + have hlog : 1 / 2 ≤ Real.log (T + 2) := by + simpa only [abs_of_nonneg (by linarith : 0 ≤ T)] using modFive_log_height_ge_half T + have hdiv : a / Real.log (T + 2) ≤ 1 := (div_le_one hH).mpr (by linarith) + linarith + have hfin' : ‖VIntegral (modFivePerronIntegrand χ x) (1 + δ) (-T) T‖ ≤ + 4 * Real.pi * C * Real.log (T + 2) ^ 2 * x ^ (1 - a / Real.log (T + 2)) + + 4 * C * Real.log (T + 2) ^ 2 * x ^ (1 + δ) / T ^ 2 := by + apply hfin.trans + apply add_le_add le_rfl + calc + _ ≤ 2 * 2 * (C * Real.log (T + 2) ^ 2 * x ^ (1 + δ) / T ^ 2) := + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hlength (by norm_num)) + (by positivity) + _ = _ := by ring + have hvert : ‖VerticalIntegral (modFivePerronIntegrand χ x) (1 + δ)‖ ≤ + ‖VIntegral (modFivePerronIntegrand χ x) (1 + δ) (-T) T‖ + + 2 * (1 / δ + D) * x ^ (1 + δ) / T := by + exact (norm_le_insert' _ _).trans (add_le_add le_rfl hta) + rw [modFiveSmoothedPsi_perron χ hxpos (by linarith : 1 < 1 + δ) hxnat] + change ‖(1 / (2 * Real.pi * Complex.I)) • + VerticalIntegral (modFivePerronIntegrand χ x) (1 + δ)‖ ≤ _ + rw [norm_smul] + calc + _ ≤ ‖VerticalIntegral (modFivePerronIntegrand χ x) (1 + δ)‖ := + (mul_le_mul_of_nonneg_right modFive_perron_normalization (norm_nonneg _)).trans_eq + (one_mul _) + _ ≤ _ := hvert.trans (add_le_add hfin' le_rfl) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveSmoothedDecay.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveSmoothedDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..23e906ae0040378d4550c339589ffa54d2cbd824 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveSmoothedDecay.lean @@ -0,0 +1,123 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePerronParameters +import Mathlib.Analysis.Real.Sqrt + +namespace OAI + +/-! Exponential decay for the actual triangularly smoothed nonprincipal +Mangoldt sums, obtained by the explicit Perron height exp(sqrt(log x)). -/ + +namespace TwoPointCorrelations + +open Filter + +lemma modFive_contour_parameter_bound {a C D y : ℝ} + (ha : 0 < a) (ha4 : a ≤ 1 / 4) (hC : 0 < C) (hD : 0 < D) (hy : 2 ≤ y) : + 4 * Real.pi * C * Real.log (Real.exp y + 2) ^ 2 * + (Real.exp (y ^ 2)) ^ (1 - a / Real.log (Real.exp y + 2)) + + 4 * C * Real.log (Real.exp y + 2) ^ 2 * + (Real.exp (y ^ 2)) ^ (1 + 1 / y ^ 2) / (Real.exp y) ^ 2 + + 2 * (1 / (1 / y ^ 2) + D) * + (Real.exp (y ^ 2)) ^ (1 + 1 / y ^ 2) / Real.exp y ≤ + (16 * Real.pi * C + 16 * C + 2 * (1 + D)) * y ^ 2 * + Real.exp (y ^ 2 + 1 - a * y / 2) := by + have hyp : 0 < y := by linarith + obtain ⟨_, hHlo, hHhi⟩ := modFive_perron_height hy + have hHpos : 0 < Real.log (Real.exp y + 2) := hyp.trans_le hHlo + have hHsq : Real.log (Real.exp y + 2) ^ 2 ≤ 4 * y ^ 2 := by + convert pow_le_pow_left₀ hHpos.le hHhi 2 using 1; ring + have hleft := modFive_perron_left_power ha.le hyp hHpos hHhi + have hright := modFive_perron_right_power hyp + have hheight : (Real.exp y) ^ 2 = Real.exp (2 * y) := by + rw [pow_two, ← Real.exp_add] + congr 1 + ring + let F := Real.exp (y ^ 2 + 1 - a * y / 2) + have hF : 0 ≤ F := (Real.exp_pos _).le + have h1 : 4 * Real.pi * C * Real.log (Real.exp y + 2) ^ 2 * + (Real.exp (y ^ 2)) ^ (1 - a / Real.log (Real.exp y + 2)) ≤ + (16 * Real.pi * C * y ^ 2) * F := by + have hp : (Real.exp (y ^ 2)) ^ (1 - a / Real.log (Real.exp y + 2)) ≤ F := + hleft.trans (Real.exp_le_exp.mpr (by linarith)) + have hc : 4 * Real.pi * C * Real.log (Real.exp y + 2) ^ 2 ≤ + 16 * Real.pi * C * y ^ 2 := by + convert mul_le_mul_of_nonneg_left hHsq + (by positivity : 0 ≤ 4 * Real.pi * C) using 1; ring + exact mul_le_mul hc hp (Real.rpow_nonneg (Real.exp_pos _).le _) + (by positivity) + have h2 : 4 * C * Real.log (Real.exp y + 2) ^ 2 * + (Real.exp (y ^ 2)) ^ (1 + 1 / y ^ 2) / (Real.exp y) ^ 2 ≤ + (16 * C * y ^ 2) * F := by + have he : Real.exp (y ^ 2 + 1 - 2 * y) ≤ F := by + apply Real.exp_le_exp.mpr + nlinarith + rw [hright, hheight, mul_div_assoc, ← Real.exp_sub] + have hc : 4 * C * Real.log (Real.exp y + 2) ^ 2 ≤ 16 * C * y ^ 2 := by + convert mul_le_mul_of_nonneg_left hHsq (by positivity : 0 ≤ 4 * C) + using 1; ring + exact mul_le_mul hc + he (Real.exp_pos _).le (by positivity) + have h3 : 2 * (1 / (1 / y ^ 2) + D) * + (Real.exp (y ^ 2)) ^ (1 + 1 / y ^ 2) / Real.exp y ≤ + (2 * (1 + D) * y ^ 2) * F := by + have he : Real.exp (y ^ 2 + 1 - y) ≤ F := by + apply Real.exp_le_exp.mpr + nlinarith + rw [one_div_one_div, hright, mul_div_assoc, ← Real.exp_sub] + have hysq : 1 ≤ y ^ 2 := by nlinarith + have hc : 2 * (y ^ 2 + D) ≤ 2 * (1 + D) * y ^ 2 := by + nlinarith [mul_nonneg hD.le (sub_nonneg.mpr hysq)] + exact mul_le_mul hc + he (Real.exp_pos _).le (by positivity) + exact (add_le_add (add_le_add h1 h2) h3).trans_eq (by dsimp [F]; ring) + +/-- Uniform over the three nonprincipal characters. -/ +theorem modFive_smoothed_decay_exp_square : ∃ c : ℝ, 0 < c ∧ + ∀ᶠ y : ℝ in atTop, ∀ χ : DirichletCharacter ℂ 5, χ ≠ 1 → + (∀ n : ℕ, Real.exp (y ^ 2) ≠ (n : ℝ)) → + ‖modFiveSmoothedPsi χ (Real.exp (y ^ 2))‖ ≤ Real.exp (y ^ 2 - c * y) := by + obtain ⟨a, C, D, ha, ha4, hC, hD, hbound⟩ := modFive_smoothed_contour_bound + let c := a / 4 + let K := 16 * Real.pi * C + 16 * C + 2 * (1 + D) + have hc : 0 < c := by dsimp [c]; positivity + refine ⟨c, hc, ?_⟩ + filter_upwards [eventually_ge_atTop (2 : ℝ), modFive_perron_polynomial_absorption K c hc] + with y hy hpoly χ hχ hxnat + have hyp : 0 < y := by linarith + have hδ : 0 < 1 / y ^ 2 := by positivity + have hδ1 : 1 / y ^ 2 ≤ 1 := (div_le_one (by positivity)).mpr (by nlinarith) + have hx1 : 1 ≤ Real.exp (y ^ 2) := Real.one_le_exp (sq_nonneg y) + have hmain := hbound χ hχ (Real.exp y) (Real.exp (y ^ 2)) (1 / y ^ 2) + (modFive_perron_height hy).1 hx1 hδ hδ1 hxnat + have hnum := modFive_contour_parameter_bound ha ha4 hC hD hy + apply (hmain.trans hnum).trans + have he : K * y ^ 2 * Real.exp (y ^ 2 + 1 - a * y / 2) = + (K * y ^ 2 * Real.exp (1 - c * y)) * Real.exp (y ^ 2 - c * y) := by + have hexp : y ^ 2 + 1 - a * y / 2 = (1 - c * y) + (y ^ 2 - c * y) := by + dsimp [c] + ring + rw [hexp, Real.exp_add] + ring + change K * y ^ 2 * Real.exp (y ^ 2 + 1 - a * y / 2) ≤ _ + rw [he] + exact (mul_le_mul_of_nonneg_right hpoly (Real.exp_pos _).le).trans_eq (one_mul _) + +/-- The original real-cutoff form of the smoothed prime estimate. -/ +theorem modFive_smoothed_decay : ∃ c : ℝ, 0 < c ∧ + ∀ᶠ x : ℝ in atTop, ∀ χ : DirichletCharacter ℂ 5, χ ≠ 1 → + (∀ n : ℕ, x ≠ (n : ℝ)) → + ‖modFiveSmoothedPsi χ x‖ ≤ x * Real.exp (-c * Real.sqrt (Real.log x)) := by + obtain ⟨c, hc, hbound⟩ := modFive_smoothed_decay_exp_square + refine ⟨c, hc, ?_⟩ + have hcomp := (Real.tendsto_sqrt_atTop.comp Real.tendsto_log_atTop).eventually hbound + filter_upwards [hcomp, eventually_ge_atTop (1 : ℝ)] with x hmain hx χ hχ hxnat + dsimp only [Function.comp_def] at hmain + have hxpos : 0 < x := zero_lt_one.trans_le hx + have hs : Real.sqrt (Real.log x) ^ 2 = Real.log x := + Real.sq_sqrt (Real.log_nonneg hx) + have hb := hmain χ hχ (by simpa only [hs, Real.exp_log hxpos] using hxnat) + simpa only [hs, Real.exp_log hxpos, sub_eq_add_neg, Real.exp_add, + neg_mul] using hb + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveSmoothedPsi.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveSmoothedPsi.lean new file mode 100644 index 0000000000000000000000000000000000000000..d41654e6e095d622b252061837b7bf7e7a0fb473 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveSmoothedPsi.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePerronSeries +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePositivity + +namespace OAI + +/-! The exact triangular Perron formula for the twisted von Mangoldt sums. +Nonintegral real cutoffs avoid the irrelevant boundary value of the scalar +kernel; later we use half-integral cutoffs to recover every integer sum. +-/ + +namespace TwoPointCorrelations + +open Complex MeasureTheory Finset Erdos970 +open scoped BigOperators Classical + +noncomputable def modFiveSmoothedPsi (χ : DirichletCharacter ℂ 5) (x : ℝ) : ℂ := + ∑ n ∈ Icc 1 ⌊x⌋₊, + modFiveMangoldtTwist χ n * ((1 - (n : ℝ) / x : ℝ) : ℂ) + +theorem modFivePerron_finite_sum (a : ℕ → ℂ) {x σ : ℝ} + (hx : 0 < x) (hσ : 1 / 2 ≤ σ) (ha : LSeriesSummable a (σ : ℂ)) + (hxnat : ∀ n : ℕ, x ≠ (n : ℝ)) : + VerticalIntegral' (fun s => LSeries a s * modFivePerronKernel x s) σ = + ∑ n ∈ Icc 1 ⌊x⌋₊, a n * ((1 - (n : ℝ) / x : ℝ) : ℂ) := by + rw [modFivePerron_series_interchange a hx hσ ha] + have hz : ∀ n ∉ Icc 1 ⌊x⌋₊, + VerticalIntegral' (fun s => LSeries.term a s n * modFivePerronKernel x s) σ = 0 := by + intro n hn + by_cases hn0 : n = 0 + · subst n + simp [VerticalIntegral', VerticalIntegral] + · rw [modFivePerron_term_value a hn0 hx hσ (hxnat n)] + have hn1 : 1 ≤ n := Nat.one_le_iff_ne_zero.mpr hn0 + have hnlarge : ⌊x⌋₊ < n := by + by_contra! h + exact hn (mem_Icc.mpr ⟨hn1, h⟩) + have hxn : x < (n : ℝ) := Nat.lt_of_floor_lt hnlarge + exact ite_eq_right (not_lt.mpr hxn.le) + rw [tsum_eq_sum hz] + apply sum_congr rfl + intro n hn + have hn1 := (mem_Icc.mp hn).1 + have hn0 : n ≠ 0 := by omega + rw [modFivePerron_term_value a hn0 hx hσ (hxnat n)] + have hnle : (n : ℝ) ≤ x := (Nat.cast_le.mpr (mem_Icc.mp hn).2).trans (Nat.floor_le hx.le) + have hnlt : (n : ℝ) < x := lt_of_le_of_ne hnle (hxnat n).symm + rw [ite_eq_left hnlt] + +theorem modFiveSmoothedPsi_perron (χ : DirichletCharacter ℂ 5) {x σ : ℝ} + (hx : 0 < x) (hσ : 1 < σ) (hxnat : ∀ n : ℕ, x ≠ (n : ℝ)) : + modFiveSmoothedPsi χ x = + VerticalIntegral' (fun s => + (-deriv (DirichletCharacter.LFunction χ) s / DirichletCharacter.LFunction χ s) * + modFivePerronKernel x s) σ := by + have ha : LSeriesSummable (modFiveMangoldtTwist χ) (σ : ℂ) := + χ.LSeriesSummable_twist_vonMangoldt (by simpa using hσ) + rw [modFiveSmoothedPsi, ← modFivePerron_finite_sum (modFiveMangoldtTwist χ) hx + (by linarith) ha hxnat] + simp only [VerticalIntegral', VerticalIntegral] + congr 2 + apply integral_congr_ae + filter_upwards [] with t + rw [modFive_twisted_series_logderiv χ (by simpa using hσ)] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveStripBound.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveStripBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..57b73cf147d6f3766ad937129eeafe1d2a989f63 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveStripBound.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveZeroDistance + +namespace OAI + +/-! Full logarithmic-derivative control in a narrower zero-free strip. +Jensen counts all nearby zeros, and their proved horizontal separation +bounds the entire pole sum, including at bounded height. +-/ + +namespace TwoPointCorrelations + +open Complex +open scoped Classical + +theorem modFive_logderiv_strip_bound : ∃ c C : ℝ, 0 < c ∧ 0 < C ∧ + ∀ (χ : DirichletCharacter ℂ 5), χ ≠ 1 → ∀ (t σ : ℝ), + 1 - c / Real.log (|t| + 2) ≤ σ → σ ≤ 2 → + DirichletCharacter.LFunction χ ((σ : ℂ) + Complex.I * (t : ℂ)) ≠ 0 ∧ + ‖deriv (DirichletCharacter.LFunction χ) ((σ : ℂ) + Complex.I * (t : ℂ)) / + DirichletCharacter.LFunction χ ((σ : ℂ) + Complex.I * (t : ℂ))‖ ≤ + C * Real.log (|t| + 2) ^ 2 := by + obtain ⟨c0, hc0, hfree0⟩ := modFive_nonprincipal_zero_free + let c := min c0 (1 / 4) + have hc : 0 < c := lt_min hc0 (by norm_num) + have hcsmall : c ≤ 1 / 4 := min_le_right _ _ + have hfree : ∀ (χ : DirichletCharacter ℂ 5), χ ≠ 1 → ∀ (t β : ℝ), + 1 - c / Real.log (|t| + 2) ≤ β → + DirichletCharacter.LFunction χ ((β : ℂ) + Complex.I * (t : ℂ)) ≠ 0 := by + intro χ hχ t β hβ + apply hfree0 χ hχ t β + have hd := div_le_div_of_nonneg_right (min_le_left c0 (1 / 4)) + (modFive_log_height_pos t).le + linarith + let P := 1 / Real.log ((15 / 16 : ℝ) / (7 / 8)) + have hP : 0 < P := by dsimp [P]; exact one_div_pos.mpr (Real.log_pos (by norm_num)) + let A := Real.log (16 * modFiveInverseConstant) / Real.log 2 + 1 + have hA : 0 < A := by + have hK : 1 ≤ modFiveInverseConstant := by + unfold modFiveInverseConstant + exact le_add_of_nonneg_right (tsum_nonneg fun _ => norm_nonneg _) + have hlog : 0 ≤ Real.log (16 * modFiveInverseConstant) := Real.log_nonneg (by linarith) + have hl2 : 0 < Real.log 2 := Real.log_pos (by norm_num) + dsimp [A] + positivity + let C := A * (2 * modFiveLogDerivativeConstant + 6 * P / c) + have hC : 0 < C := by + dsimp [C] + exact mul_pos hA (add_pos (mul_pos (by norm_num) modFiveLogDerivativeConstant_pos) + (div_pos (mul_pos (by norm_num) hP) hc)) + refine ⟨c / 4, C, by positivity, hC, ?_⟩ + intro χ hχ t σ hσ hσ2 + let H := Real.log (|t| + 2) + have hH : 0 < H := modFive_log_height_pos t + have hHhalf : 1 / 2 ≤ H := modFive_log_height_ge_half t + have hσ' : 1 - c / (4 * H) ≤ σ := by + have he : (c / 4) / H = c / (4 * H) := by ring + change 1 - (c / 4) / H ≤ σ at hσ + rwa [he] at hσ + have hsmall : c / (4 * H) ≤ 1 / 8 := by + apply (div_le_iff₀ (by positivity : 0 < 4 * H)).mpr + nlinarith + have hσlow : 7 / 8 ≤ σ := by linarith + have hne : DirichletCharacter.LFunction χ ((σ : ℂ) + Complex.I * (t : ℂ)) ≠ 0 := by + apply hfree χ hχ t σ + have hi : c / (4 * H) ≤ c / H := + div_le_div_of_nonneg_left hc.le hH (by linarith) + linarith + refine ⟨hne, ?_⟩ + let z := modFiveRealDiskPoint σ + have hz : ‖z‖ ≤ 3 / 4 := by + rw [show z = modFiveRealDiskPoint σ from rfl, modFiveRealDiskPoint, + Complex.norm_real, Real.norm_eq_abs] + apply abs_le.mpr + constructor <;> linarith + have hp : DirichletCharacter.LFunction χ (modFivePhysicalPoint t z) ≠ 0 := by + rwa [modFivePhysicalPoint_real] + have hn : modFiveNormalizedLFunction χ t z ≠ 0 := + div_ne_zero hp (χ.LFunction_ne_zero_of_one_le_re (Or.inl hχ) (by norm_num)) + have hd : ∀ ρ ∈ modFiveNormalizedZeros χ t, c / (6 * H) ≤ ‖z - ρ‖ := by + intro ρ hρ + exact modFive_zero_distance_of_strip hc hfree χ hχ t σ hσ' hρ + have he := modFive_normalized_logderiv_norm χ hχ t hz hn + (show 0 < c / (6 * H) by positivity) hd + have hcoef : 0 ≤ modFiveLogDerivativeConstant + P / (c / (6 * H)) := by + exact add_nonneg modFiveLogDerivativeConstant_pos.le (div_nonneg hP.le (by positivity)) + have hlog := mul_le_mul_of_nonneg_left (modFive_log_disk_growth t) hcoef + have htotal := he.trans hlog + have hrecip : P / (c / (6 * H)) = (6 * P / c) * H := by + field_simp + change _ ≤ (modFiveLogDerivativeConstant + P / (c / (6 * H))) * (A * H) at htotal + rw [hrecip] at htotal + have hlinear : H ≤ 2 * H ^ 2 := by nlinarith + have hmul := mul_le_mul_of_nonneg_left hlinear + (mul_nonneg hA.le modFiveLogDerivativeConstant_pos.le) + have htotal' : ‖deriv (modFiveNormalizedLFunction χ t) z / + modFiveNormalizedLFunction χ t z‖ ≤ C * H ^ 2 := by + dsimp [C] + nlinarith only [htotal, hmul] + rw [modFiveNormalized_logderiv_eq χ hχ t z hp, norm_mul, modFivePhysicalPoint_real] at htotal' + norm_num at htotal' + apply (le_mul_of_one_le_left (norm_nonneg _) + (by norm_num : (1 : ℝ) ≤ 3 / 2)).trans + simpa only [norm_div] using htotal' + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveUnsmoothing.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveUnsmoothing.lean new file mode 100644 index 0000000000000000000000000000000000000000..006ebcb8e01bb780d125d4d0a8e1f1c8a54e64e7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveUnsmoothing.lean @@ -0,0 +1,151 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveSmoothedPsi +import Mathlib.Algebra.BigOperators.Intervals + +namespace OAI + +/-! Exact finite differences for the triangularly smoothed Mangoldt sum. +The error is confined to the short interval at the upper endpoint. -/ + +namespace TwoPointCorrelations + +open Complex Finset ArithmeticFunction +open scoped BigOperators + +lemma modFive_smoothed_scale (χ : DirichletCharacter ℂ 5) {x : ℝ} (hx : x ≠ 0) : + (x : ℂ) * modFiveSmoothedPsi χ x = + ∑ n ∈ Icc 1 ⌊x⌋₊, modFiveMangoldtTwist χ n * ((x - (n : ℝ) : ℝ) : ℂ) := by + rw [modFiveSmoothedPsi, mul_sum] + apply sum_congr rfl + intro n hn + have hxc : (x : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr hx + push_cast + field_simp + +lemma modFive_smoothed_difference (χ : DirichletCharacter ℂ 5) {x : ℝ} + (hx : 0 < x) (m : ℕ) : + (((x + m : ℝ) : ℂ) * modFiveSmoothedPsi χ (x + m) - + (x : ℂ) * modFiveSmoothedPsi χ x) = + (m : ℂ) * (∑ n ∈ Icc 1 ⌊x⌋₊, modFiveMangoldtTwist χ n) + + ∑ n ∈ Icc (⌊x⌋₊ + 1) (⌊x⌋₊ + m), + modFiveMangoldtTwist χ n * ((x + m - (n : ℝ) : ℝ) : ℂ) := by + rw [modFive_smoothed_scale χ (by positivity), modFive_smoothed_scale χ hx.ne', + Nat.floor_add_natCast hx.le] + have hsplit (f : ℕ → ℂ) : + (∑ n ∈ Icc 1 (⌊x⌋₊ + m), f n) = + (∑ n ∈ Icc 1 ⌊x⌋₊, f n) + (∑ n ∈ Icc (⌊x⌋₊ + 1) (⌊x⌋₊ + m), f n) := by + simpa only [Ico_add_one_right_eq_Icc] using + (sum_Ico_consecutive f (by omega : 1 ≤ ⌊x⌋₊ + 1) + (by omega : ⌊x⌋₊ + 1 ≤ (⌊x⌋₊ + m) + 1)).symm + rw [hsplit] + have hmain : + (∑ n ∈ Icc 1 ⌊x⌋₊, + modFiveMangoldtTwist χ n * ((x + m - (n : ℝ) : ℝ) : ℂ)) - + (∑ n ∈ Icc 1 ⌊x⌋₊, + modFiveMangoldtTwist χ n * ((x - (n : ℝ) : ℝ) : ℂ)) = + (m : ℂ) * (∑ n ∈ Icc 1 ⌊x⌋₊, modFiveMangoldtTwist χ n) := by + rw [← sum_sub_distrib, mul_sum] + apply sum_congr rfl + intro n hn + push_cast + ring + linear_combination hmain + +lemma modFive_mangoldt_norm_le_log (χ : DirichletCharacter ℂ 5) (n : ℕ) : ‖modFiveMangoldtTwist χ n‖ ≤ Real.log (n : ℝ) := by + unfold modFiveMangoldtTwist + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg vonMangoldt_nonneg] + exact (mul_le_mul_of_nonneg_right (χ.norm_le_one _) vonMangoldt_nonneg).trans + (by simpa using (vonMangoldt_le_log (n := n))) + +lemma modFive_smoothed_remainder (χ : DirichletCharacter ℂ 5) {x : ℝ} + (hx : 0 < x) (m : ℕ) : + ‖∑ n ∈ Icc (⌊x⌋₊ + 1) (⌊x⌋₊ + m), + modFiveMangoldtTwist χ n * ((x + m - (n : ℝ) : ℝ) : ℂ)‖ ≤ + (m : ℝ) ^ 2 * Real.log (x + m) := by + have hy : 0 < x + (m : ℝ) := by positivity + have hpoint (n : ℕ) (hn : n ∈ Icc (⌊x⌋₊ + 1) (⌊x⌋₊ + m)) : + ‖modFiveMangoldtTwist χ n * ((x + m - (n : ℝ) : ℝ) : ℂ)‖ ≤ + Real.log (x + m) * m := by + obtain ⟨hnlo, hnhi⟩ := mem_Icc.mp hn + have hn1 : 1 ≤ n := by omega + have hnx : x < (n : ℝ) := (Nat.lt_floor_add_one x).trans_le (by exact_mod_cast hnlo) + have hny : (n : ℝ) ≤ x + m := by + have hb := Nat.floor_le hx.le + have hc : (n : ℝ) ≤ (⌊x⌋₊ : ℝ) + m := by exact_mod_cast hnhi + linarith + have hwt : 0 ≤ x + m - (n : ℝ) := by linarith + have hwtm : x + m - (n : ℝ) ≤ (m : ℝ) := by linarith + have hlog : ‖modFiveMangoldtTwist χ n‖ ≤ Real.log (x + m) := + (modFive_mangoldt_norm_le_log χ n).trans + (Real.log_le_log (by exact_mod_cast (show 0 < n by omega)) hny) + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg hwt] + exact mul_le_mul hlog hwtm hwt (le_trans (norm_nonneg _) hlog) + have hc : #(Icc (⌊x⌋₊ + 1) (⌊x⌋₊ + m)) = m := by + rw [Nat.card_Icc] + omega + calc + _ ≤ ∑ n ∈ Icc (⌊x⌋₊ + 1) (⌊x⌋₊ + m), + ‖modFiveMangoldtTwist χ n * ((x + m - (n : ℝ) : ℝ) : ℂ)‖ := norm_sum_le _ _ + _ ≤ ∑ _n ∈ Icc (⌊x⌋₊ + 1) (⌊x⌋₊ + m), Real.log (x + m) * m := + sum_le_sum hpoint + _ = _ := by rw [sum_const, hc, nsmul_eq_mul]; ring + +lemma modFive_twistedPsi_sum (χ : DirichletCharacter ℂ 5) (x : ℝ) : + modFiveTwistedPsi χ x = ∑ n ∈ Icc 1 ⌊x⌋₊, modFiveMangoldtTwist χ n := by + have he : (∑ n ∈ Icc 1 ⌊x⌋₊, modFiveMangoldtTwist χ n) = + ∑ n ∈ Icc 0 ⌊x⌋₊, modFiveMangoldtTwist χ n := by + apply sum_subset + · intro n hn + obtain ⟨hn1, hnN⟩ := mem_Icc.mp hn + exact mem_Icc.mpr ⟨by omega, hnN⟩ + · intro n hn hnot + have hn0 : n = 0 := by + have := mem_Icc.mp hn + have hn1 : ¬1 ≤ n := by + intro hn1 + exact hnot (mem_Icc.mpr ⟨hn1, this.2⟩) + omega + subst n + simp [modFiveMangoldtTwist] + rw [he, modFiveTwistedPsi] + apply sum_congr rfl + intro n hn + simp only [modFiveMangoldtTwist, mul_comm] + +/-- A completely finite unsmoothing inequality, with the short-interval +cost bounded only by the elementary Mangoldt estimate Λ(n)≤log n. -/ +theorem modFive_unsmoothing_bound (χ : DirichletCharacter ℂ 5) {x : ℝ} + (hx : 0 < x) {m : ℕ} (hm : 0 < m) : + ‖modFiveTwistedPsi χ x‖ ≤ + ((x + m) * ‖modFiveSmoothedPsi χ (x + m)‖ + + x * ‖modFiveSmoothedPsi χ x‖ + (m : ℝ) ^ 2 * Real.log (x + m)) / m := by + have hmp : 0 < (m : ℝ) := by exact_mod_cast hm + have he := modFive_smoothed_difference χ hx m + have halg : (m : ℂ) * (∑ n ∈ Icc 1 ⌊x⌋₊, modFiveMangoldtTwist χ n) = + (((x + m : ℝ) : ℂ) * modFiveSmoothedPsi χ (x + m) - + (x : ℂ) * modFiveSmoothedPsi χ x) - + ∑ n ∈ Icc (⌊x⌋₊ + 1) (⌊x⌋₊ + m), + modFiveMangoldtTwist χ n * ((x + m - (n : ℝ) : ℝ) : ℂ) := by + linear_combination -he + rw [modFive_twistedPsi_sum] + apply (le_div_iff₀ hmp).mpr + calc + _ = ‖(m : ℂ) * (∑ n ∈ Icc 1 ⌊x⌋₊, modFiveMangoldtTwist χ n)‖ := by + rw [norm_mul, Complex.norm_natCast] + ring + _ ≤ ‖((x + m : ℝ) : ℂ) * modFiveSmoothedPsi χ (x + m) - + (x : ℂ) * modFiveSmoothedPsi χ x‖ + + ‖∑ n ∈ Icc (⌊x⌋₊ + 1) (⌊x⌋₊ + m), + modFiveMangoldtTwist χ n * ((x + m - (n : ℝ) : ℝ) : ℂ)‖ := by + rw [halg] + exact norm_sub_le _ _ + _ ≤ (‖((x + m : ℝ) : ℂ) * modFiveSmoothedPsi χ (x + m)‖ + + ‖(x : ℂ) * modFiveSmoothedPsi χ x‖) + (m : ℝ) ^ 2 * Real.log (x + m) := + add_le_add (norm_sub_le _ _) (modFive_smoothed_remainder χ hx m) + _ = _ := by + rw [norm_mul, norm_mul, Complex.norm_real, Complex.norm_real, + Real.norm_eq_abs, Real.norm_eq_abs, abs_of_pos hx, + abs_of_pos (by positivity : 0 < x + (m : ℝ))] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveUnsmoothingScale.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveUnsmoothingScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..83ecbb422f1dbc93eeded6a95c88a826d13f3136 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveUnsmoothingScale.lean @@ -0,0 +1,166 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveUnsmoothing +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveSmoothedDecay + +namespace OAI + +/-! The finite-difference step with the actual short interval length. +A ceiling is used so that both triangular cutoffs have the same fractional +part, and the resulting exponential saving only loses a fixed factor. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma modFive_nonnat_add {x : ℝ} (hx : 0 ≤ x) + (hxn : ∀ n : ℕ, x ≠ (n : ℝ)) (m : ℕ) : + ∀ n : ℕ, x + m ≠ (n : ℝ) := by + intro n he + have hmn : m ≤ n := by exact_mod_cast (show (m : ℝ) ≤ n by linarith) + apply hxn (n - m) + rw [Nat.cast_sub hmn] + linarith + +lemma modFive_unsmoothing_numeric (χ : DirichletCharacter ℂ 5) + {x c : ℝ} (hx : 1 ≤ x) (hc : 0 < c) {m : ℕ} (hm : 0 < m) + (hmlow : x * Real.exp (-(c / 2) * Real.sqrt (Real.log x)) ≤ m) + (hmhigh : (m : ℝ) ≤ 2 * (x * Real.exp (-(c / 2) * Real.sqrt (Real.log x)))) + (hsx : ‖modFiveSmoothedPsi χ x‖ ≤ x * Real.exp (-c * Real.sqrt (Real.log x))) + (hsy : ‖modFiveSmoothedPsi χ (x + m)‖ ≤ + (x + m) * Real.exp (-c * Real.sqrt (Real.log (x + m)))) : + ‖modFiveTwistedPsi χ x‖ ≤ + x * (10 + 2 * Real.log (3 * x)) * Real.exp (-(c / 2) * Real.sqrt (Real.log x)) := by + let S := Real.sqrt (Real.log x) + let E := Real.exp (-c * S) + let e := Real.exp (-(c / 2) * S) + let v := x * e + have hxp : 0 < x := zero_lt_one.trans_le hx + have hmp : 0 < (m : ℝ) := by exact_mod_cast hm + have hep : 0 < e := Real.exp_pos _ + have hvp : 0 < v := mul_pos hxp hep + have hS : 0 ≤ S := Real.sqrt_nonneg _ + have he1 : e ≤ 1 := Real.exp_le_one_iff.mpr + (mul_nonpos_of_nonpos_of_nonneg (by linarith : -(c / 2) ≤ 0) hS) + have hm2 : (m : ℝ) ≤ 2 * x := hmhigh.trans (by + exact mul_le_mul_of_nonneg_left (mul_le_of_le_one_right hxp.le he1) (by norm_num)) + have hy3 : x + (m : ℝ) ≤ 3 * x := by linarith + have hyp : 0 < x + (m : ℝ) := by positivity + have hlog : Real.log (x + m) ≤ Real.log (3 * x) := + Real.log_le_log hyp hy3 + have hlognonneg : 0 ≤ Real.log (3 * x) := Real.log_nonneg (by linarith) + have hSmono : S ≤ Real.sqrt (Real.log (x + m)) := + Real.sqrt_le_sqrt (Real.log_le_log hxp (le_add_of_nonneg_right (Nat.cast_nonneg m))) + have hEmono : Real.exp (-c * Real.sqrt (Real.log (x + m))) ≤ E := by + apply Real.exp_le_exp.mpr + exact mul_le_mul_of_nonpos_left hSmono (neg_nonpos.mpr hc.le) + have hybound : ‖modFiveSmoothedPsi χ (x + m)‖ ≤ (x + m) * E := + hsy.trans (mul_le_mul_of_nonneg_left hEmono hyp.le) + have hquad : (x + (m : ℝ)) ^ 2 ≤ 9 * x ^ 2 := by nlinarith + have hnum : (x + m) * ‖modFiveSmoothedPsi χ (x + m)‖ + + x * ‖modFiveSmoothedPsi χ x‖ ≤ 10 * x ^ 2 * E := by + have hyb := mul_le_mul_of_nonneg_left hybound hyp.le + have hxb := mul_le_mul_of_nonneg_left hsx hxp.le + have hqb := mul_le_mul_of_nonneg_right hquad (Real.exp_pos (-c * S)).le + change x * ‖modFiveSmoothedPsi χ x‖ ≤ x * (x * E) at hxb + nlinarith + have hupper := modFive_unsmoothing_bound χ hxp hm + have hquot : 10 * x ^ 2 * E / (m : ℝ) ≤ 10 * x ^ 2 * E / v := + div_le_div_of_nonneg_left (by dsimp [E]; positivity) hvp hmlow + have htail : (m : ℝ) * Real.log (x + m) ≤ 2 * v * Real.log (3 * x) := by + calc + _ ≤ (m : ℝ) * Real.log (3 * x) := mul_le_mul_of_nonneg_left hlog hmp.le + _ ≤ _ := mul_le_mul_of_nonneg_right hmhigh hlognonneg + have hEe : E = e ^ 2 := by + dsimp [E, e] + rw [pow_two, ← Real.exp_add] + congr 1 + ring + calc + _ ≤ (10 * x ^ 2 * E + (m : ℝ) ^ 2 * Real.log (x + m)) / m := + hupper.trans (div_le_div_of_nonneg_right (add_le_add hnum le_rfl) hmp.le) + _ = 10 * x ^ 2 * E / m + (m : ℝ) * Real.log (x + m) := by + field_simp + _ ≤ 10 * x ^ 2 * E / v + 2 * v * Real.log (3 * x) := add_le_add hquot htail + _ = _ := by + change 10 * x ^ 2 * E / v + 2 * v * Real.log (3 * x) = + x * (10 + 2 * Real.log (3 * x)) * e + rw [hEe] + dsimp [v] + field_simp + +lemma modFive_unsmoothing_scale (c : ℝ) (hc : 0 < c) : + ∀ᶠ x : ℝ in atTop, + 1 ≤ x * Real.exp (-(c / 2) * Real.sqrt (Real.log x)) ∧ + (10 + 2 * Real.log (3 * x)) * + Real.exp (-(c / 4) * Real.sqrt (Real.log x)) ≤ 1 := by + have hp := modFive_perron_polynomial_absorption 16 (c / 4) (by positivity) + have hs := (Real.tendsto_sqrt_atTop.comp Real.tendsto_log_atTop).eventually + ((eventually_ge_atTop (max 1 (c / 2))).and hp) + filter_upwards [hs, eventually_ge_atTop (1 : ℝ)] with x h hx + let S := Real.sqrt (Real.log x) + have hxp : 0 < x := zero_lt_one.trans_le hx + have hS1 : 1 ≤ S := (le_max_left _ _).trans h.1 + have hSc : c / 2 ≤ S := (le_max_right _ _).trans h.1 + have hS0 : 0 ≤ S := Real.sqrt_nonneg _ + have hSsq : S ^ 2 = Real.log x := Real.sq_sqrt (Real.log_nonneg hx) + constructor + · have he : x * Real.exp (-(c / 2) * S) = Real.exp (S ^ 2 - (c / 2) * S) := by + rw [hSsq, sub_eq_add_neg, Real.exp_add, Real.exp_log hxp] + congr 1 + ring_nf + change 1 ≤ x * Real.exp (-(c / 2) * S) + rw [he] + apply Real.one_le_exp + nlinarith [mul_nonneg hS0 (sub_nonneg.mpr hSc)] + · have hlog3 : Real.log 3 ≤ 2 := by + have hh := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 3) + linarith + have hcoef : 10 + 2 * Real.log (3 * x) ≤ 16 * S ^ 2 := by + rw [Real.log_mul (by norm_num : (3 : ℝ) ≠ 0) hxp.ne'] + nlinarith [sq_nonneg (S - 1)] + have he : Real.exp (-(c / 4) * S) ≤ Real.exp (1 - (c / 4) * S) := + Real.exp_le_exp.mpr (by linarith) + exact (mul_le_mul hcoef he (Real.exp_pos _).le (by positivity)).trans h.2 + +/-- The nonprincipal twisted Mangoldt sum has a quantitative exponential +saving. Nonintegral cutoffs suffice here and are removed by floor transfer. -/ +theorem modFive_unsmoothed_decay_nonnat : ∃ c : ℝ, 0 < c ∧ + ∀ᶠ x : ℝ in atTop, ∀ χ : DirichletCharacter ℂ 5, χ ≠ 1 → + (∀ n : ℕ, x ≠ (n : ℝ)) → + ‖modFiveTwistedPsi χ x‖ ≤ x * Real.exp (-c * Real.sqrt (Real.log x)) := by + obtain ⟨c, hc, hs⟩ := modFive_smoothed_decay + obtain ⟨X, hX⟩ := eventually_atTop.mp hs + refine ⟨c / 4, by positivity, ?_⟩ + filter_upwards [eventually_ge_atTop X, eventually_ge_atTop (1 : ℝ), + modFive_unsmoothing_scale c hc] with x hxX hx hscale χ hχ hxnat + let S := Real.sqrt (Real.log x) + let v := x * Real.exp (-(c / 2) * S) + let m := ⌈v⌉₊ + have hxp : 0 < x := zero_lt_one.trans_le hx + have hv1 : 1 ≤ v := hscale.1 + have hvp : 0 < v := zero_lt_one.trans_le hv1 + have hmlo : v ≤ (m : ℝ) := Nat.le_ceil v + have hm : 0 < m := by + have hmp : 0 < (m : ℝ) := hvp.trans_le hmlo + exact_mod_cast hmp + have hmhi : (m : ℝ) ≤ 2 * v := by + have hh : (m : ℝ) < v + 1 := Nat.ceil_lt_add_one hvp.le + linarith + have hys : X ≤ x + (m : ℝ) := + hxX.trans (le_add_of_nonneg_right (Nat.cast_nonneg m)) + have hnum := modFive_unsmoothing_numeric χ hx hc hm hmlo hmhi + (hX x hxX χ hχ hxnat) + (hX (x + m) hys χ hχ (modFive_nonnat_add (by linarith) hxnat m)) + have he : x * (10 + 2 * Real.log (3 * x)) * Real.exp (-(c / 2) * S) = + (x * Real.exp (-(c / 4) * S)) * + ((10 + 2 * Real.log (3 * x)) * Real.exp (-(c / 4) * S)) := by + have harg : -(c / 2) * S = -(c / 4) * S + -(c / 4) * S := by ring + rw [harg, Real.exp_add] + ring + apply hnum.trans + change x * (10 + 2 * Real.log (3 * x)) * Real.exp (-(c / 2) * S) ≤ _ + rw [he] + exact (mul_le_mul_of_nonneg_left hscale.2 (by positivity)).trans_eq (mul_one _) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveVerticalTails.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveVerticalTails.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7b2a63368257c62bc7edffdd5d9947bc4122d43 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveVerticalTails.lean @@ -0,0 +1,113 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveRightBound +import Mathlib.MeasureTheory.Measure.Lebesgue.Integral + +namespace OAI + +/-! The two tails of the actual Perron integral. The inverse-square +majorant gives explicit inverse-height bounds after integration. -/ + +namespace TwoPointCorrelations + +open Complex MeasureTheory Set Erdos970 + +lemma modFive_inverse_square_tail {f : ℝ → ℂ} {T D : ℝ} + (hT : 0 < T) (hbound : ∀ t ∈ Ioi T, ‖f t‖ ≤ D / t ^ 2) : + ‖∫ t in Ioi T, f t‖ ≤ D / T := by + have hi : IntegrableOn (fun t : ℝ => D * t ^ (-2 : ℝ)) (Ioi T) := + (integrableOn_Ioi_rpow_of_lt (by norm_num : (-2 : ℝ) < -1) hT).const_mul D + have he : (∫ t in Ioi T, D * t ^ (-2 : ℝ)) = D / T := by + rw [integral_const_mul, integral_Ioi_rpow_of_lt (by norm_num : (-2 : ℝ) < -1) hT] + norm_num [Real.rpow_neg_one, div_eq_mul_inv] + apply (norm_integral_le_of_norm_le hi ?_).trans_eq he + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + convert hbound t ht using 1 + rw [Real.rpow_neg (le_of_lt (hT.trans ht)), Real.rpow_two, div_eq_mul_inv] + +lemma modFive_vertical_tails {f : ℂ → ℂ} {σ T D : ℝ} + (hT : 0 < T) + (hf : Integrable (fun t : ℝ => f ((σ : ℂ) + (t : ℂ) * Complex.I))) + (hbound : ∀ t : ℝ, T ≤ |t| → + ‖f ((σ : ℂ) + (t : ℂ) * Complex.I)‖ ≤ D / t ^ 2) : + ‖VerticalIntegral f σ - VIntegral f σ (-T) T‖ ≤ 2 * D / T := by + have hup : ‖∫ t in Ioi T, f ((σ : ℂ) + (t : ℂ) * Complex.I)‖ ≤ D / T := by + apply modFive_inverse_square_tail hT + intro t ht + exact hbound t (by rw [abs_of_pos (hT.trans ht)]; exact ht.le) + have hdown : ‖∫ t in Iic (-T), f ((σ : ℂ) + (t : ℂ) * Complex.I)‖ ≤ D / T := by + rw [← integral_comp_neg_Ioi T] + apply modFive_inverse_square_tail hT + intro t ht + have hb := hbound (-t) (by rw [abs_neg, abs_of_pos (hT.trans ht)]; exact ht.le) + simpa only [neg_sq] using hb + have he := verticalIntegral_split_three (f := f) (σ := σ) (-T) T hf + rw [he] + have halg (a b c : ℂ) : a + b + c - b = a + c := by ring + rw [halg] + calc + _ ≤ ‖Complex.I • (∫ t in Iic (-T), f ((σ : ℂ) + (t : ℂ) * Complex.I))‖ + + ‖Complex.I • (∫ t in Ici T, f ((σ : ℂ) + (t : ℂ) * Complex.I))‖ := norm_add_le _ _ + _ = ‖∫ t in Iic (-T), f ((σ : ℂ) + (t : ℂ) * Complex.I)‖ + + ‖∫ t in Ioi T, f ((σ : ℂ) + (t : ℂ) * Complex.I)‖ := by + rw [norm_smul, norm_smul, norm_I, one_mul, one_mul, integral_Ici_eq_integral_Ioi] + _ ≤ D / T + D / T := add_le_add hdown hup + _ = _ := by ring + +lemma modFive_perron_integrable (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) + {x σ B : ℝ} (hx : 0 < x) (hσ : 1 < σ) (hB : 0 ≤ B) + (hbound : ∀ t : ℝ, + ‖-deriv (DirichletCharacter.LFunction χ) ((σ : ℂ) + (t : ℂ) * Complex.I) / + DirichletCharacter.LFunction χ ((σ : ℂ) + (t : ℂ) * Complex.I)‖ ≤ B) : + Integrable (fun t : ℝ => modFivePerronIntegrand χ x ((σ : ℂ) + (t : ℂ) * Complex.I)) := by + have hc : Continuous (fun t : ℝ => + modFivePerronIntegrand χ x ((σ : ℂ) + (t : ℂ) * Complex.I)) := by + apply continuous_iff_continuousAt.mpr + intro t + have hsr : 1 ≤ ((σ : ℂ) + (t : ℂ) * Complex.I).re := by simpa using hσ.le + have hn := χ.LFunction_ne_zero_of_one_le_re (Or.inl hχ) hsr + have h0 : (σ : ℂ) + (t : ℂ) * Complex.I ≠ 0 := by + intro he + have hr := congrArg Complex.re he + simp only [add_re, ofReal_re, mul_I_re, ofReal_im, neg_zero, add_zero, zero_re] at hr + linarith + have h1 : (σ : ℂ) + (t : ℂ) * Complex.I + 1 ≠ 0 := by + intro he + have hr := congrArg Complex.re he + simp only [add_re, ofReal_re, mul_I_re, ofReal_im, neg_zero, add_zero, + one_re, zero_re] at hr + linarith + have hline : ContinuousAt (fun t : ℝ => (σ : ℂ) + (t : ℂ) * Complex.I) t := by + fun_prop + exact (modFive_perron_integrand_differentiableAt χ hχ hx hn h0 h1).continuousAt.comp (f := fun t : ℝ => (σ : ℂ) + (t : ℂ) * Complex.I) hline + have hi : Integrable (fun t : ℝ => B * (4 * x ^ σ / (1 + t ^ 2))) := by + simpa only [div_eq_mul_inv, mul_assoc] using + (integrable_inv_one_add_sq.const_mul (B * (4 * x ^ σ))) + apply hi.mono' hc.aestronglyMeasurable + exact Filter.Eventually.of_forall fun t => by + rw [modFivePerronIntegrand, norm_mul] + exact mul_le_mul (hbound t) (modFive_perron_kernel_vertical hx (by linarith) t) + (norm_nonneg _) hB + +/-- Uniform tails of the actual nonprincipal Perron integrals. -/ +theorem modFive_perron_tail_bound : ∃ C : ℝ, 0 < C ∧ + ∀ (χ : DirichletCharacter ℂ 5), χ ≠ 1 → ∀ δ x T : ℝ, + 0 < δ → 0 < x → 0 < T → + ‖VerticalIntegral (modFivePerronIntegrand χ x) (1 + δ) - + VIntegral (modFivePerronIntegrand χ x) (1 + δ) (-T) T‖ ≤ + 2 * (1 / δ + C) * x ^ (1 + δ) / T := by + obtain ⟨C, hC, hb⟩ := modFive_logderiv_right_bound + refine ⟨C, hC, ?_⟩ + intro χ hχ δ x T hδ hx hT + have hB : 0 ≤ 1 / δ + C := by positivity + have hi := modFive_perron_integrable χ hχ hx (by linarith : 1 < 1 + δ) hB + (hb χ δ · hδ) + have ht := modFive_vertical_tails hT hi (D := (1 / δ + C) * x ^ (1 + δ)) ?_ + · simpa only [mul_assoc] using ht + intro t ht + have ht0 : t ≠ 0 := by intro he; simp [he] at ht; linarith + rw [modFivePerronIntegrand, norm_mul] + exact (mul_le_mul (hb χ δ t hδ) (modFive_perron_kernel_horizontal hx (1 + δ) ht0) + (norm_nonneg _) hB).trans_eq (by ring) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveZeroCount.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveZeroCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..c8ef0304db1e54b41cb1e9a744f1c98d1c747f28 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveZeroCount.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveLogGrowth + +namespace OAI + +/-! Jensen's bound for the total multiplicity in the fixed normalized disk. +This counts actual zeros, with their analytic multiplicities, and will control +the entire logarithmic derivative once a zero-free strip supplies distance. -/ + +namespace TwoPointCorrelations + +open Complex Filter +open scoped BigOperators Classical Topology + +theorem modFive_normalized_zero_count (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (t : ℝ) : + (∑ ρ ∈ (modFiveNormalizedZeros_finite χ hχ t).toFinset, + ((analyticOrderAt (modFiveNormalizedLFunction χ t) ρ).toNat : ℝ)) ≤ + (1 / Real.log ((15 / 16 : ℝ) / (7 / 8))) * + Real.log (8 * modFiveInverseConstant * (|t| + 4)) := by + let f := modFiveNormalizedLFunction χ t + have hf : ∀ z ∈ Metric.closedBall (0 : ℂ) 1, AnalyticAt ℂ f z := by + intro z _ + exact (modFiveNormalizedLFunction_differentiable χ hχ t).analyticAt z + have hf0 : f 0 = 1 := modFiveNormalizedLFunction_zero χ t + have hfactor : ∀ ρ : ℂ, ∃ g : ℂ → ℂ, AnalyticAt ℂ g ρ ∧ g ρ ≠ 0 ∧ + (ρ ∈ Erdos970.zerosetKfR (7 / 8) (by norm_num) f → + ∀ᶠ w in 𝓝 ρ, f w = (w - ρ) ^ (analyticOrderAt f ρ).toNat * g w) := by + intro ρ + by_cases hρ : ρ ∈ Erdos970.zerosetKfR (7 / 8) (by norm_num) f + · obtain ⟨g, hg, hgne, heq⟩ := Erdos970.lem_analytic_zero_factor + (15 / 16) (7 / 8) (by norm_num) (by norm_num) (by norm_num) f hf + (by rw [hf0]; exact one_ne_zero) ρ hρ + exact ⟨g, hg, hgne, fun _ => heq⟩ + · exact ⟨fun _ => 1, analyticAt_const, one_ne_zero, fun h => (hρ h).elim⟩ + let g : ℂ → ℂ → ℂ := fun ρ => Classical.choose (hfactor ρ) + have hg : ∀ ρ ∈ Erdos970.zerosetKfR (7 / 8) (by norm_num) f, + AnalyticAt ℂ (g ρ) ρ ∧ g ρ ρ ≠ 0 ∧ + ∀ᶠ w in 𝓝 ρ, f w = (w - ρ) ^ (analyticOrderAt f ρ).toNat * g ρ w := by + intro ρ hρ + exact ⟨(Classical.choose_spec (hfactor ρ)).1, + (Classical.choose_spec (hfactor ρ)).2.1, + (Classical.choose_spec (hfactor ρ)).2.2 hρ⟩ + have hK : 1 ≤ modFiveInverseConstant := by + unfold modFiveInverseConstant + exact le_add_of_nonneg_right (tsum_nonneg fun _ => norm_nonneg _) + have hB : 1 < 8 * modFiveInverseConstant * (|t| + 4) := by + nlinarith [abs_nonneg t] + exact Erdos970.lem_sum_m_rho_bound + (8 * modFiveInverseConstant * (|t| + 4)) (15 / 16) (7 / 8) hB + (by norm_num) (by norm_num) (by norm_num) f hf + (by rw [hf0]; exact one_ne_zero) hf0 (modFiveNormalizedZeros_finite χ hχ t) g + (fun z hz => modFiveNormalizedLFunction_norm χ hχ t (hz.trans (by norm_num))) hg + +/-- A distance lower bound controls every pole term at once. -/ +theorem modFive_normalized_logderiv_norm (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (t : ℝ) {z : ℂ} (hz : ‖z‖ ≤ 3 / 4) + (hn : modFiveNormalizedLFunction χ t z ≠ 0) {η : ℝ} (hη : 0 < η) + (hd : ∀ ρ ∈ modFiveNormalizedZeros χ t, η ≤ ‖z - ρ‖) : + ‖deriv (modFiveNormalizedLFunction χ t) z / modFiveNormalizedLFunction χ t z‖ ≤ + (modFiveLogDerivativeConstant + + (1 / Real.log ((15 / 16 : ℝ) / (7 / 8))) / η) * + Real.log (8 * modFiveInverseConstant * (|t| + 4)) := by + let S := (modFiveNormalizedZeros_finite χ hχ t).toFinset + let m : ℂ → ℕ := fun ρ => (analyticOrderAt (modFiveNormalizedLFunction χ t) ρ).toNat + have hsum : ‖∑ ρ ∈ S, (m ρ : ℂ) / (z - ρ)‖ ≤ (∑ ρ ∈ S, (m ρ : ℝ)) / η := by + calc + _ ≤ ∑ ρ ∈ S, ‖(m ρ : ℂ) / (z - ρ)‖ := norm_sum_le _ _ + _ ≤ ∑ ρ ∈ S, (m ρ : ℝ) / η := by + apply Finset.sum_le_sum + intro ρ hρ + rw [norm_div, Complex.norm_natCast] + exact div_le_div_of_nonneg_left (Nat.cast_nonneg _) hη + (hd ρ ((modFiveNormalizedZeros_finite χ hχ t).mem_toFinset.mp hρ)) + _ = _ := by rw [Finset.sum_div] + have hcount := div_le_div_of_nonneg_right (modFive_normalized_zero_count χ hχ t) hη.le + have herr := modFiveNormalized_logderiv χ hχ t hz hn + have htri := norm_add_le + (deriv (modFiveNormalizedLFunction χ t) z / modFiveNormalizedLFunction χ t z - + ∑ ρ ∈ S, (m ρ : ℂ) / (z - ρ)) + (∑ ρ ∈ S, (m ρ : ℂ) / (z - ρ)) + rw [sub_add_cancel] at htri + calc + _ ≤ modFiveLogDerivativeConstant * + Real.log (8 * modFiveInverseConstant * (|t| + 4)) + + ((1 / Real.log ((15 / 16 : ℝ) / (7 / 8))) * + Real.log (8 * modFiveInverseConstant * (|t| + 4))) / η := by + exact htri.trans (add_le_add herr (hsum.trans hcount)) + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveZeroDistance.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveZeroDistance.lean new file mode 100644 index 0000000000000000000000000000000000000000..4005989f3ab322d8a2d5c2a02eaecbf80454ac47 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveZeroDistance.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveLowZeros +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveZeroCount + +namespace OAI + +/-! Quantitative separation between the inner evaluation point and all zeros +in the fixed disk. The only strip used below is the one already proved for +the actual modulus-five L-functions. +-/ + +namespace TwoPointCorrelations + +open Complex +open scoped Classical + +lemma modFive_log_height_ge_half (t : ℝ) : 1 / 2 ≤ Real.log (|t| + 2) := by + have hlog : 1 / 2 ≤ Real.log 2 := by + have h := Real.one_sub_inv_le_log_of_pos (by norm_num : (0 : ℝ) < 2) + norm_num at h ⊢ + exact h + exact hlog.trans (Real.log_le_log (by norm_num) (by linarith [abs_nonneg t])) + +lemma modFive_physical_zero_height (χ : DirichletCharacter ℂ 5) (t : ℝ) + {ρ : ℂ} (hρ : ρ ∈ modFiveNormalizedZeros χ t) : + |(modFivePhysicalPoint t ρ).im| ≤ |t| + 2 := by + have hn : ‖ρ‖ ≤ 7 / 8 := by simpa using hρ.1 + have hi := (Complex.abs_im_le_norm ρ).trans hn + have he : (modFivePhysicalPoint t ρ).im = t + (3 / 2 : ℝ) * ρ.im := by + simp [modFivePhysicalPoint, Complex.mul_im] + rw [he] + calc + _ ≤ |t| + |(3 / 2 : ℝ) * ρ.im| := abs_add_le _ _ + _ = |t| + (3 / 2 : ℝ) * |ρ.im| := by rw [abs_mul]; norm_num + _ ≤ _ := by linarith + +lemma modFive_physical_zero_log_height (χ : DirichletCharacter ℂ 5) (t : ℝ) + {ρ : ℂ} (hρ : ρ ∈ modFiveNormalizedZeros χ t) : + Real.log (|(modFivePhysicalPoint t ρ).im| + 2) ≤ 2 * Real.log (|t| + 2) := by + calc + _ ≤ Real.log ((|t| + 2) ^ 2) := by + apply Real.log_le_log (by positivity) + have h := modFive_physical_zero_height χ t hρ + nlinarith [abs_nonneg t, sq_nonneg (|t|)] + _ = _ := by rw [Real.log_pow]; norm_num + +lemma modFive_zero_distance_of_strip {c : ℝ} (hc : 0 < c) + (hfree : ∀ (χ : DirichletCharacter ℂ 5), χ ≠ 1 → ∀ (t β : ℝ), + 1 - c / Real.log (|t| + 2) ≤ β → + DirichletCharacter.LFunction χ ((β : ℂ) + Complex.I * (t : ℂ)) ≠ 0) + (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) (t σ : ℝ) + (hσ : 1 - c / (4 * Real.log (|t| + 2)) ≤ σ) + {ρ : ℂ} (hρ : ρ ∈ modFiveNormalizedZeros χ t) : + c / (6 * Real.log (|t| + 2)) ≤ ‖modFiveRealDiskPoint σ - ρ‖ := by + let v := modFivePhysicalPoint t ρ + have hzero : DirichletCharacter.LFunction χ ((v.re : ℂ) + Complex.I * (v.im : ℂ)) = 0 := by + have he : (v.re : ℂ) + Complex.I * (v.im : ℂ) = v := by + apply Complex.ext <;> simp + rw [he] + exact modFiveNormalizedZeros_physical_zero χ t hρ + have hv : v.re < 1 - c / Real.log (|v.im| + 2) := by + by_contra! h + exact hfree χ hχ v.im v.re h hzero + have hH := modFive_log_height_pos t + have hvH := modFive_log_height_pos v.im + have hlog := modFive_physical_zero_log_height χ t hρ + have hinv : c / (2 * Real.log (|t| + 2)) ≤ c / Real.log (|v.im| + 2) := + div_le_div_of_nonneg_left hc.le hvH hlog + have hgap : c / (4 * Real.log (|t| + 2)) ≤ σ - v.re := by + have he : c / (2 * Real.log (|t| + 2)) = 2 * (c / (4 * Real.log (|t| + 2))) := by ring + rw [he] at hinv + linarith + have hre : (modFiveRealDiskPoint σ - ρ).re = (2 / 3 : ℝ) * (σ - v.re) := by + dsimp [modFiveRealDiskPoint, v, modFivePhysicalPoint] + simp only [Complex.ofReal_re, Complex.mul_re, + Complex.I_re, Complex.I_im, Complex.ofReal_im] + norm_num + ring + calc + _ = (2 / 3 : ℝ) * (c / (4 * Real.log (|t| + 2))) := by ring + _ ≤ (2 / 3 : ℝ) * (σ - v.re) := mul_le_mul_of_nonneg_left hgap (by norm_num) + _ = (modFiveRealDiskPoint σ - ρ).re := hre.symm + _ ≤ |(modFiveRealDiskPoint σ - ρ).re| := le_abs_self _ + _ ≤ _ := Complex.abs_re_le_norm _ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveZeroTerms.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveZeroTerms.lean new file mode 100644 index 0000000000000000000000000000000000000000..be6942ad30b8c0e05e8321606e59d20ca2547b51 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveZeroTerms.lean @@ -0,0 +1,214 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveLogDerivative + +namespace OAI + +/-! Transfer the normalized disk expansion back to the actual L-functions. +Every zero in the finite disk lies left of the line of evaluation, so its +logarithmic-derivative contribution has nonnegative real part. +-/ + +namespace TwoPointCorrelations + +open Complex Finset +open scoped BigOperators Classical + +noncomputable def modFivePhysicalPoint (t : ℝ) (z : ℂ) : ℂ := + (2 : ℂ) + Complex.I * (t : ℂ) + (3 / 2 : ℂ) * z + +noncomputable def modFiveRealDiskPoint (σ : ℝ) : ℂ := + (((2 / 3 : ℝ) * (σ - 2) : ℝ) : ℂ) + +lemma modFivePhysicalPoint_real (σ t : ℝ) : + modFivePhysicalPoint t (modFiveRealDiskPoint σ) = + (σ : ℂ) + Complex.I * (t : ℂ) := by + unfold modFivePhysicalPoint modFiveRealDiskPoint + push_cast + ring + +lemma modFiveNormalizedLFunction_deriv (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (t : ℝ) (z : ℂ) : + deriv (modFiveNormalizedLFunction χ t) z = + (deriv (DirichletCharacter.LFunction χ) (modFivePhysicalPoint t z) * (3 / 2 : ℂ)) / + DirichletCharacter.LFunction χ ((2 : ℂ) + Complex.I * (t : ℂ)) := by + have ha : HasDerivAt (modFivePhysicalPoint t) (3 / 2 : ℂ) z := by + exact (hasDerivAt_const_mul (3 / 2 : ℂ)).const_add + ((2 : ℂ) + Complex.I * (t : ℂ)) + exact (((DirichletCharacter.differentiable_LFunction hχ _).hasDerivAt.comp z ha).div_const + (DirichletCharacter.LFunction χ ((2 : ℂ) + Complex.I * (t : ℂ)))).deriv + +lemma modFiveNormalized_logderiv_eq (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (t : ℝ) (z : ℂ) + (hn : DirichletCharacter.LFunction χ (modFivePhysicalPoint t z) ≠ 0) : + deriv (modFiveNormalizedLFunction χ t) z / modFiveNormalizedLFunction χ t z = + (3 / 2 : ℂ) * + (deriv (DirichletCharacter.LFunction χ) (modFivePhysicalPoint t z) / + DirichletCharacter.LFunction χ (modFivePhysicalPoint t z)) := by + have hc : DirichletCharacter.LFunction χ ((2 : ℂ) + Complex.I * (t : ℂ)) ≠ 0 := + χ.LFunction_ne_zero_of_one_le_re (Or.inl hχ) (by norm_num) + rw [modFiveNormalizedLFunction_deriv χ hχ] + change (_ / _) / (DirichletCharacter.LFunction χ (modFivePhysicalPoint t z) / _) = _ + field_simp [hn, hc] + +lemma modFiveNormalizedZeros_physical_zero (χ : DirichletCharacter ℂ 5) + (t : ℝ) {ρ : ℂ} (hρ : ρ ∈ modFiveNormalizedZeros χ t) : + DirichletCharacter.LFunction χ (modFivePhysicalPoint t ρ) = 0 := by + have hzero : modFiveNormalizedLFunction χ t ρ = 0 := hρ.2 + have hc : DirichletCharacter.LFunction χ ((2 : ℂ) + Complex.I * (t : ℂ)) ≠ 0 := + χ.LFunction_ne_zero_of_one_le_re (Or.inr (by + intro h; have := congrArg Complex.re h; norm_num at this)) (by norm_num) + exact (div_eq_zero_iff.mp hzero).resolve_right hc + +lemma modFiveNormalizedZeros_re (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (t : ℝ) {ρ : ℂ} (hρ : ρ ∈ modFiveNormalizedZeros χ t) : + ρ.re < -(2 / 3 : ℝ) := by + by_contra! h + have hs : 1 ≤ (modFivePhysicalPoint t ρ).re := by + norm_num [modFivePhysicalPoint, Complex.mul_re] + linarith + exact χ.LFunction_ne_zero_of_one_le_re (Or.inl hχ) hs + (modFiveNormalizedZeros_physical_zero χ t hρ) + +lemma modFiveRealDiskPoint_norm {σ : ℝ} (hσ : 1 < σ) (hσ2 : σ ≤ 2) : + ‖modFiveRealDiskPoint σ‖ ≤ 3 / 4 := by + rw [modFiveRealDiskPoint, Complex.norm_real, Real.norm_eq_abs] + apply abs_le.mpr + constructor <;> linarith + +lemma modFive_zeroTerm_re_nonneg (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (t : ℝ) {σ : ℝ} (hσ : 1 < σ) + {ρ : ℂ} (hρ : ρ ∈ modFiveNormalizedZeros χ t) : + 0 ≤ (((analyticOrderAt (modFiveNormalizedLFunction χ t) ρ).toNat : ℂ) / + (modFiveRealDiskPoint σ - ρ)).re := by + have hr := modFiveNormalizedZeros_re χ hχ t hρ + have hd : 0 ≤ (modFiveRealDiskPoint σ - ρ).re := by + simp only [Complex.sub_re, modFiveRealDiskPoint, Complex.ofReal_re] + linarith + rw [Complex.div_re] + simp only [Complex.natCast_re, Complex.natCast_im, zero_mul, zero_div, add_zero] + exact div_nonneg (mul_nonneg (Nat.cast_nonneg _) hd) (Complex.normSq_nonneg _) + +/-- A logarithmic-derivative upper bound to the right of one, obtained by +dropping the nonnegative zero terms from the actual finite expansion. -/ +theorem modFive_neg_logderiv_re_le (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (t : ℝ) {σ : ℝ} (hσ : 1 < σ) (hσ2 : σ ≤ 2) : + (-deriv (DirichletCharacter.LFunction χ) ((σ : ℂ) + Complex.I * (t : ℂ)) / + DirichletCharacter.LFunction χ ((σ : ℂ) + Complex.I * (t : ℂ))).re ≤ + (2 / 3 : ℝ) * modFiveLogDerivativeConstant * + Real.log (8 * modFiveInverseConstant * (|t| + 4)) := by + let z := modFiveRealDiskPoint σ + have hp : DirichletCharacter.LFunction χ (modFivePhysicalPoint t z) ≠ 0 := by + rw [modFivePhysicalPoint_real] + exact χ.LFunction_ne_zero_of_one_le_re (Or.inl hχ) (by simpa using hσ.le) + have hn : modFiveNormalizedLFunction χ t z ≠ 0 := by + exact div_ne_zero hp (χ.LFunction_ne_zero_of_one_le_re (Or.inl hχ) (by norm_num)) + have he := modFiveNormalized_logderiv χ hχ t (modFiveRealDiskPoint_norm hσ hσ2) hn + have hre := (Complex.abs_re_le_norm _).trans he + have hs : 0 ≤ ∑ ρ ∈ (modFiveNormalizedZeros_finite χ hχ t).toFinset, + (((analyticOrderAt (modFiveNormalizedLFunction χ t) ρ).toNat : ℂ) / (z - ρ)).re := by + apply sum_nonneg + intro ρ hρ + exact modFive_zeroTerm_re_nonneg χ hχ t hσ + ((modFiveNormalizedZeros_finite χ hχ t).mem_toFinset.mp hρ) + rw [Complex.sub_re, Complex.re_sum] at hre + have hlow := (abs_le.mp hre).1 + rw [modFiveNormalized_logderiv_eq χ hχ t z hp, modFivePhysicalPoint_real] at hlow + norm_num [Complex.mul_re] at hlow + simp only [neg_div, Complex.neg_re] + nlinarith + +lemma modFive_zero_multiplicity_pos (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (t : ℝ) {ρ : ℂ} (hρ : ρ ∈ modFiveNormalizedZeros χ t) : + 1 ≤ (analyticOrderAt (modFiveNormalizedLFunction χ t) ρ).toNat := by + have hf : ∀ z ∈ Metric.closedBall (0 : ℂ) 1, + AnalyticAt ℂ (modFiveNormalizedLFunction χ t) z := by + intro z _ + exact (modFiveNormalizedLFunction_differentiable χ hχ t).analyticAt z + have hf0 : modFiveNormalizedLFunction χ t 0 ≠ 0 := by + rw [modFiveNormalizedLFunction_zero] + exact one_ne_zero + have hfinite := Erdos970.lem_m_rho_is_nat (15 / 16) (7 / 8) + (by norm_num) (by norm_num) (modFiveNormalizedLFunction χ t) hf hf0 + (by norm_num) ρ hρ + have hpos := Erdos970.lem_m_rho_ge_1 (15 / 16) (7 / 8) + (by norm_num) (by norm_num) (modFiveNormalizedLFunction χ t) hf hf0 + (by norm_num) ρ hρ + simpa using ENat.toNat_le_toNat hpos hfinite + +lemma modFive_real_zero_mem (χ : DirichletCharacter ℂ 5) + (t : ℝ) {β : ℝ} (hβ : 3 / 4 ≤ β) (hβ1 : β ≤ 1) + (hzero : DirichletCharacter.LFunction χ ((β : ℂ) + Complex.I * (t : ℂ)) = 0) : + modFiveRealDiskPoint β ∈ modFiveNormalizedZeros χ t := by + have hn : ‖modFiveRealDiskPoint β‖ ≤ 7 / 8 := by + rw [modFiveRealDiskPoint, Complex.norm_real, Real.norm_eq_abs] + apply abs_le.mpr + constructor <;> linarith + refine ⟨by simpa using hn, ?_⟩ + change DirichletCharacter.LFunction χ + (modFivePhysicalPoint t (modFiveRealDiskPoint β)) / _ = 0 + rw [modFivePhysicalPoint_real, hzero, zero_div] + +/-- A zero at height `t` contributes its full reciprocal distance; the +other zeros have nonnegative real contributions. -/ +lemma modFive_zero_sum_lower (χ : DirichletCharacter ℂ 5) (hχ : χ ≠ 1) + (t : ℝ) {σ β : ℝ} (hσ : 1 < σ) (hβ : 3 / 4 ≤ β) (hβ1 : β ≤ 1) + (hzero : DirichletCharacter.LFunction χ ((β : ℂ) + Complex.I * (t : ℂ)) = 0) : + (3 / 2 : ℝ) / (σ - β) ≤ + ∑ ρ ∈ (modFiveNormalizedZeros_finite χ hχ t).toFinset, + (((analyticOrderAt (modFiveNormalizedLFunction χ t) ρ).toNat : ℂ) / + (modFiveRealDiskPoint σ - ρ)).re := by + let w := modFiveRealDiskPoint β + have hw := modFive_real_zero_mem χ t hβ hβ1 hzero + have hm := modFive_zero_multiplicity_pos χ hχ t hw + have hd0 : 0 < σ - β := by linarith + have hd : 0 < (2 / 3 : ℝ) * (σ - β) := mul_pos (by norm_num) hd0 + have hdiff : modFiveRealDiskPoint σ - w = + (((2 / 3 : ℝ) * (σ - β) : ℝ) : ℂ) := by + dsimp [w, modFiveRealDiskPoint] + push_cast + ring + have hterm : (3 / 2 : ℝ) / (σ - β) ≤ + (((analyticOrderAt (modFiveNormalizedLFunction χ t) w).toNat : ℂ) / + (modFiveRealDiskPoint σ - w)).re := by + rw [hdiff] + change (3 / 2 : ℝ) / (σ - β) ≤ + ((((analyticOrderAt (modFiveNormalizedLFunction χ t) w).toNat : ℝ) : ℂ) / + (((2 / 3 : ℝ) * (σ - β) : ℝ) : ℂ)).re + rw [← Complex.ofReal_div, Complex.ofReal_re] + calc + _ = 1 / ((2 / 3 : ℝ) * (σ - β)) := by field_simp [ne_of_gt hd0] + _ ≤ _ := div_le_div_of_nonneg_right (by exact_mod_cast hm) hd.le + exact hterm.trans (single_le_sum + (fun ρ hρ => modFive_zeroTerm_re_nonneg χ hχ t hσ + ((modFiveNormalizedZeros_finite χ hχ t).mem_toFinset.mp hρ)) + ((modFiveNormalizedZeros_finite χ hχ t).mem_toFinset.mpr hw)) + +/-- The one-zero upper bound, with its negative reciprocal term retained. -/ +theorem modFive_neg_logderiv_re_le_of_zero (χ : DirichletCharacter ℂ 5) + (hχ : χ ≠ 1) (t : ℝ) {σ β : ℝ} (hσ : 1 < σ) (hσ2 : σ ≤ 2) + (hβ : 3 / 4 ≤ β) (hβ1 : β ≤ 1) + (hzero : DirichletCharacter.LFunction χ ((β : ℂ) + Complex.I * (t : ℂ)) = 0) : + (-deriv (DirichletCharacter.LFunction χ) ((σ : ℂ) + Complex.I * (t : ℂ)) / + DirichletCharacter.LFunction χ ((σ : ℂ) + Complex.I * (t : ℂ))).re ≤ + (2 / 3 : ℝ) * modFiveLogDerivativeConstant * + Real.log (8 * modFiveInverseConstant * (|t| + 4)) - 1 / (σ - β) := by + let z := modFiveRealDiskPoint σ + have hp : DirichletCharacter.LFunction χ (modFivePhysicalPoint t z) ≠ 0 := by + rw [modFivePhysicalPoint_real] + exact χ.LFunction_ne_zero_of_one_le_re (Or.inl hχ) (by simpa using hσ.le) + have hn : modFiveNormalizedLFunction χ t z ≠ 0 := + div_ne_zero hp (χ.LFunction_ne_zero_of_one_le_re (Or.inl hχ) (by norm_num)) + have he := modFiveNormalized_logderiv χ hχ t (modFiveRealDiskPoint_norm hσ hσ2) hn + have hre := (Complex.abs_re_le_norm _).trans he + have hs := modFive_zero_sum_lower χ hχ t hσ hβ hβ1 hzero + have hfrac : (3 / 2 : ℝ) / (σ - β) = (3 / 2 : ℝ) * (1 / (σ - β)) := by ring + rw [hfrac] at hs + rw [Complex.sub_re, Complex.re_sum] at hre + have hlow := (abs_le.mp hre).1 + rw [modFiveNormalized_logderiv_eq χ hχ t z hp, modFivePhysicalPoint_real] at hlow + norm_num [Complex.mul_re] at hlow + simp only [neg_div, Complex.neg_re] + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveZetaPsi.lean b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveZetaPsi.lean new file mode 100644 index 0000000000000000000000000000000000000000..60593bf380deb5e87cc7cbf3a5fce734f9f87a97 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Fourier/ModFiveZetaPsi.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePrincipalPsi + +namespace OAI + +/-! The principal twisted Mangoldt estimate from the already proved zeta +prime number theorem, with the elementary five-power correction retained. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma modFive_constant_absorption (c : ℝ) {x : ℝ} (hx : 1 ≤ x) : + 1 ≤ Real.exp (c ^ 2) * x * Real.exp (-c * Real.sqrt (Real.log x)) := by + have hxp : 0 < x := zero_lt_one.trans_le hx + have hsq := Real.sq_sqrt (Real.log_nonneg hx) + have hn : 0 ≤ c ^ 2 + Real.log x - c * Real.sqrt (Real.log x) := by + nlinarith [sq_nonneg (Real.sqrt (Real.log x) - c / 2), sq_nonneg c] + have he : Real.exp (c ^ 2) * x * Real.exp (-c * Real.sqrt (Real.log x)) = + Real.exp (c ^ 2 + Real.log x - c * Real.sqrt (Real.log x)) := by + calc + _ = Real.exp (c ^ 2) * Real.exp (Real.log x) * + Real.exp (-c * Real.sqrt (Real.log x)) := by rw [Real.exp_log hxp] + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + rw [he] + exact Real.one_le_exp hn + +theorem modFive_zeta_psi_decay : ∃ c C : ℝ, 0 < c ∧ 0 < C ∧ + ∀ᶠ x : ℝ in atTop, |Chebyshev.psi x - x| ≤ + C * x * Real.exp (-c * Real.sqrt (Real.log x)) := by + obtain ⟨c, hc, hO⟩ := Erdos970.Strong_PNT + obtain ⟨C, hC⟩ := hO.bound + refine ⟨c, |C| + 1, hc, by positivity, ?_⟩ + filter_upwards [hC, eventually_ge_atTop (1 : ℝ)] with x h hx + change ‖Erdos970.ChebyshevPsi x - x‖ ≤ + C * ‖x * Real.exp (-c * (Real.log x) ^ ((1 : ℝ) / 2))‖ at h + rw [modFive_chebyshevPsi_eq (by linarith : 0 ≤ x), ← Real.sqrt_eq_rpow] at h + change |Chebyshev.psi x - x| ≤ C * |x * Real.exp (-c * Real.sqrt (Real.log x))| at h + have hp : 0 < x * Real.exp (-c * Real.sqrt (Real.log x)) := + mul_pos (by linarith) (Real.exp_pos _) + rw [abs_of_pos hp] at h + calc + _ ≤ C * (x * Real.exp (-c * Real.sqrt (Real.log x))) := h + _ ≤ (|C| + 1) * (x * Real.exp (-c * Real.sqrt (Real.log x))) := + mul_le_mul_of_nonneg_right (by linarith [le_abs_self C]) (by positivity) + _ = _ := by ring + +theorem modFive_principal_psi_decay : ∃ c C : ℝ, 0 < c ∧ 0 < C ∧ + ∀ᶠ x : ℝ in atTop, ‖modFiveTwistedPsi 1 x - (x : ℂ)‖ ≤ + C * x * Real.exp (-c * Real.sqrt (Real.log x)) := by + obtain ⟨c, C, hc, hC, hbound⟩ := modFive_zeta_psi_decay + let K := C + (Real.log 5 + 8) * Real.exp (c ^ 2) + have hlog5 : 0 ≤ Real.log 5 := Real.log_nonneg (by norm_num) + refine ⟨c, K, hc, by dsimp [K]; positivity, ?_⟩ + filter_upwards [hbound, eventually_ge_atTop (1 : ℝ)] with x hb hx + have herr := modFive_principal_psi_error hx + have hp := sqrt_mul_log_le_exp_sqrt c hx + have hone := mul_le_mul_of_nonneg_left (modFive_constant_absorption c hx) hlog5 + have hcast : ‖(Chebyshev.psi x : ℂ) - (x : ℂ)‖ = |Chebyshev.psi x - x| := by + rw [← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] + calc + _ = ‖(modFiveTwistedPsi 1 x - (Chebyshev.psi x : ℂ)) + + ((Chebyshev.psi x : ℂ) - (x : ℂ))‖ := by congr 1; ring + _ ≤ ‖modFiveTwistedPsi 1 x - (Chebyshev.psi x : ℂ)‖ + + ‖(Chebyshev.psi x : ℂ) - (x : ℂ)‖ := norm_add_le _ _ + _ ≤ (Real.log 5 + 2 * Real.sqrt x * Real.log x) + + C * x * Real.exp (-c * Real.sqrt (Real.log x)) := by + rw [hcast] + exact add_le_add herr hb + _ ≤ K * x * Real.exp (-c * Real.sqrt (Real.log x)) := by + dsimp [K] + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszAffineAmplitude.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszAffineAmplitude.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e051bde5238c2861cfd8a7f6d705338c97d2bcd --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszAffineAmplitude.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszStationaryPhase +import Mathlib.MeasureTheory.Integral.IntervalIntegral.IntegrationByParts + +namespace OAI + +/-! Affine amplitudes for the two pieces of a compact triangular weight. -/ +namespace TwoPointCorrelations + +open MeasureTheory + +lemma halasz_affine_amplitude_bound (f : ℝ → ℂ) (a b m c B : ℝ) + (hab : a ≤ b) (hi : IntervalIntegrable f volume a b) + (hc : ∀ x ∈ Set.Icc a b, ContinuousAt f x) (hm : StronglyMeasurable f) + (hB : ∀ x ∈ Set.Icc a b, ‖∫ y in a..x, f y‖ ≤ B) : + ‖∫ x in a..b, (m*x+c : ℝ)*f x‖ ≤ (|m*b+c|+|m| *(b-a))*B := by + let F : ℝ → ℂ := fun x => ∫ y in a..x, f y + have hF : ContinuousOn F (Set.uIcc a b) := + intervalIntegral.continuousOn_primitive_interval' hi (Set.left_mem_uIcc) + have hdF (x : ℝ) (hx : x ∈ Set.Icc a b) : HasDerivAt F (f x) x := by + apply intervalIntegral.integral_hasDerivAt_right + (hi.mono_set (by simpa only [Set.uIcc_of_le hab, Set.uIcc_of_le hx.1] using + Set.Icc_subset_Icc le_rfl hx.2)) + hm.stronglyMeasurableAtFilter (hc x hx) + have hdm (x : ℝ) : HasDerivAt (fun y : ℝ => (m*y+c : ℂ)) (m:ℂ) x := by + convert (((hasDerivAt_id x).const_mul m).add_const c).ofReal_comp using 1 <;> simp + have hmc : ContinuousOn (fun x : ℝ => (m*x+c : ℂ)) (Set.uIcc a b) := + (continuous_const.mul Complex.continuous_ofReal |>.add continuous_const).continuousOn + have hmi : IntervalIntegrable (fun _ : ℝ => (m:ℂ)) volume a b := intervalIntegrable_const + have he := intervalIntegral.integral_mul_deriv_eq_deriv_mul_of_hasDerivAt hmc hF + (fun x _ => hdm x) + (fun x hx => hdF x (by + rw [min_eq_left hab, max_eq_right hab] at hx + exact ⟨hx.1.le, hx.2.le⟩)) hmi hi + change (∫ x in a..b, (m*x+c : ℂ)*f x) = _ at he + have hzero : F a = 0 := intervalIntegral.integral_same + rw [hzero, mul_zero, sub_zero] at he + have hnorm : ‖∫ x in a..b, (m:ℂ)*F x‖ ≤ |m| *B*(b-a) := by + have hh := intervalIntegral.norm_integral_le_of_norm_le_const + (a := a) (b := b) (C := |m| *B) (f := fun x => (m:ℂ)*F x) (by + intro x hx + have hx' : x ∈ Set.Icc a b := by + rw [Set.uIoc_of_le hab] at hx + exact ⟨hx.1.le, hx.2⟩ + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_left (hB x hx') (abs_nonneg m)) + simpa only [abs_of_nonneg (sub_nonneg.mpr hab)] using hh + have hb := hB b ⟨hab, le_rfl⟩ + have hprod : ‖(m*b+c : ℂ)*F b‖ ≤ |m*b+c| *B := by + rw [norm_mul] + norm_cast + simpa only [Real.norm_eq_abs] using mul_le_mul_of_nonneg_left hb (abs_nonneg (m*b+c)) + push_cast + rw [he] + exact (norm_sub_le _ _).trans (by nlinarith) + +lemma halasz_log_stationary_affine (u v a b m c : ℝ) (hu : 0 < u) + (ha : 0 < a) (hab : a ≤ b) : + ‖∫ x in a..b, (m*x+c : ℝ)*halaszLogPhase u v x‖ ≤ + (|m*b+c|+|m| *(b-a))*(10*b/Real.sqrt u) := by + apply halasz_affine_amplitude_bound _ _ _ _ _ _ hab + ((halasz_log_phase_continuousOn u v a b ha).intervalIntegrable_of_Icc hab) + (fun x hx => (halasz_log_phase_deriv u v x (ha.trans_le hx.1).ne').continuousAt) + (by + have hm : Measurable (halaszLogPhase u v) := by unfold halaszLogPhase; fun_prop + exact hm.stronglyMeasurable) + intro x hx + exact (halasz_log_stationary_integral u v a x hu ha hx.1).trans + (div_le_div_of_nonneg_right (by linarith [hx.2]) (Real.sqrt_nonneg u)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszAvoidPrimes.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszAvoidPrimes.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba898e52868cbb816e0bca608c91aa576d47d195 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszAvoidPrimes.lean @@ -0,0 +1,104 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDistinctMoment +import Mathlib.Data.Nat.Factorization.Basic +import Mathlib.Data.Nat.Dist + +namespace OAI + +/-! A small family of primes contains a prime preserving distinctness +of both long tuples. Only the prime supply is analytic. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma halasz_large_prime_divisors {L r m : ℕ} (hL : 0 p∣m)).card p∣m) + have hsub : D⊆m.primeFactors := by + intro p hp + obtain ⟨hpP,hpm⟩ := mem_filter.mp hp + exact Nat.mem_primeFactors.mpr ⟨(hP p hpP).1,hpm,hm.ne'⟩ + have hdvd : (∏ p∈D, p)∣m := + (prod_dvd_prod_of_subset D m.primeFactors id hsub).trans (Nat.prod_primeFactors_dvd m) + have hprod : L^D.card≤∏ p∈D, p := by + calc + L^D.card = ∏ _p∈D, L := by simp + _ ≤ ∏ p∈D, p := prod_le_prod (fun p hp => (hP p (mem_filter.mp hp).1).2) + by_contra! hn + change r≤D.card at hn + have hpow : L^r≤L^D.card := Nat.pow_le_pow_right hL hn + have hle := Nat.le_of_dvd hm hdvd + exact (not_lt_of_ge (hpow.trans (hprod.trans hle))) hbound + +lemma halasz_congruent_prime_count {L r N : ℕ} (hL : 0 (((a.val+1:ℕ):ZMod p)=((b.val+1:ℕ):ZMod p)))).card≤r := by + let m := Nat.dist (a.val+1) (b.val+1) + have hm : 0 hab (Fin.ext (by omega))) + have hmN : m ¬Function.Injective + (fun i => (((x i).val+1:ℕ):ZMod p)))).card≤ℓ^2*r := by + let I := (univ : Finset (Fin ℓ × Fin ℓ)).filter (fun ij => ij.1≠ij.2) + let B := fun ij : Fin ℓ × Fin ℓ => P.filter (fun p => + ((((x ij.1).val+1:ℕ):ZMod p)=(((x ij.2).val+1:ℕ):ZMod p))) + have hsub : (P.filter (fun p => ¬Function.Injective + (fun i => (((x i).val+1:ℕ):ZMod p))))⊆I.biUnion B := by + intro p hp + obtain ⟨hpP,hbad⟩ := mem_filter.mp hp + obtain ⟨i,j,hij,hne⟩ := Function.not_injective_iff.mp hbad + exact mem_biUnion.mpr ⟨(i,j),mem_filter.mpr ⟨mem_univ _,hne⟩, + mem_filter.mpr ⟨hpP,hij⟩⟩ + have hI : I.card≤ℓ^2 := by + calc + I.card ≤ (univ : Finset (Fin ℓ × Fin ℓ)).card := card_filter_le _ _ + _ = ℓ^2 := by simp [pow_two] + calc + _ ≤ (I.biUnion B).card := card_le_card hsub + _ ≤ I.card*r := card_biUnion_le_card_mul I B r (fun ij hij => + halasz_congruent_prime_count hL hN P hP _ _ (fun h => (mem_filter.mp hij).2 (hx h))) + _ ≤ ℓ^2*r := Nat.mul_le_mul_right _ hI + +theorem halasz_exists_good_prime {L r N ℓ : ℕ} (hL : 0 (((x i).val+1:ℕ):ZMod p)) ∧ + Function.Injective (fun i => (((y i).val+1:ℕ):ZMod p)) := by + let Bx := P.filter (fun p => ¬Function.Injective (fun i => (((x i).val+1:ℕ):ZMod p))) + let By := P.filter (fun p => ¬Function.Injective (fun i => (((y i).val+1:ℕ):ZMod p))) + by_contra! hn + have hsub : P⊆Bx∪By := by + intro p hp + by_cases hxp : Function.Injective (fun i => (((x i).val+1:ℕ):ZMod p)) + · exact mem_union_right _ (mem_filter.mpr ⟨hp,hn p hp hxp⟩) + · exact mem_union_left _ (mem_filter.mpr ⟨hp,hxp⟩) + have hbX := halasz_bad_residue_prime_count hL hN P hP x hx + have hbY := halasz_bad_residue_prime_count hL hN P hP y hy + have hbad := (card_le_card hsub).trans (card_union_le Bx By) + change P.card≤Bx.card+By.card at hbad + change Bx.card≤ℓ^2*r at hbX + change By.card≤ℓ^2*r at hbY + omega + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBalancedMoment.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBalancedMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..729f767df9e448133eb8fd8778dbe0572cf330c6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBalancedMoment.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMomentInterpolation + +namespace OAI + +/-! Equal total moments bound each mixed moment. This will be applied +to the ordinary polynomial sum and its doubled-frequency version. -/ +namespace TwoPointCorrelations + +open MeasureTheory + +theorem halasz_equal_moment_bound {k a b : ℕ} (ha : 0 ‖F x‖^(a+b)) + (fun x => ‖G x‖^(a+b)) (hF.norm.pow _) (hG.norm.pow _) + (fun _ => by positivity) (fun _ => by positivity) hθ0 hθ1 + simp_rw [hpowF,hpowG] at h + rw [← he] at h + have hJ : 0≤∫ x, ‖F x‖^(a+b) ∂halaszVinogradovHaar k := + integral_nonneg (fun _ => by positivity) + exact h.trans (by simpa only [add_sub_cancel,Real.rpow_one] using + Real.le_rpow_add hJ θ (1-θ)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandDensity.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..92b6da6474047117060ac318f543ee9559ead5e6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandDensity.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTypicalCount +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTBandSeparation + +namespace OAI + +/-! Literal natural-indexed MRT bands in the dyadic density and +pairwise-disjointness interfaces used by the energy estimates. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical + +lemma halasz_actual_bands_disjoint (P Q : ℝ) (J : ℕ) + (hP : 2 ≤ P) (hPQ : P ≤ Q) (hlogP : 1 < Real.log P) : + Set.PairwiseDisjoint (Icc 1 J : Set ℕ) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) := by + have hh := mrt_actual_bands_pairwise_disjoint P Q J hP hPQ hlogP + intro i hi j hj hij + exact @hh ⟨i, hi⟩ (Set.mem_univ _) ⟨j, hj⟩ (Set.mem_univ _) + (fun he => hij (congrArg Subtype.val he)) + +theorem halasz_actual_band_density : ∃ C : ℝ, 0 < C ∧ + ∀ᶠ L : ℝ in atTop, ∀ (P Q : ℝ) (J : ℕ), + 2 ≤ P → P ≤ Q → 1 ≤ Real.log Q → + (∀ j ∈ Icc 1 J, mrtBandUpper Q j ≤ Real.exp (L ^ (99 / 100 : ℝ))) → + ∀ N : ℕ, 0 < N → + (1 / 2 : ℝ) * Real.exp (L ^ (199 / 200 : ℝ)) ≤ N → + (((Ioc N (2*N)).filter (fun n => ¬mrtTypical (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) n)).card : ℝ) / N ≤ + C * Real.log P / Real.log Q := by + obtain ⟨C, hC, hd⟩ := mrt_typical_density + refine ⟨C, hC, ?_⟩ + filter_upwards [hd] with L hd + intro P Q J hP hPQ hlogQ hmax N hN hscale + have : NeZero N := ⟨hN.ne'⟩ + let V := fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j) + have heq (n : ℕ) : + mrtTypical univ (fun j : {j : ℕ // j ∈ (Icc 1 J : Finset ℕ)} => V j) n ↔ + mrtTypical (Icc 1 J) V n := by simp [mrtTypical] + have hp := hd P Q J hP hPQ hlogQ hmax (N+1) N hscale + change (uniformFiniteLaw (Fin N)).probability + (fun n => ¬mrtTypical univ + (fun j : {j : ℕ // j ∈ (Icc 1 J : Finset ℕ)} => V j) (N+1+n.val)) ≤ _ at hp + have hp' : (uniformFiniteLaw (Fin N)).probability + (fun n => ¬mrtTypical (Icc 1 J) V (N+1+n.val)) ≤ + C * Real.log P / Real.log Q := by simpa only [heq] using hp + exact halasz_typical_dyadic_density_bound (Icc 1 J) V _ hp' + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandNearEnergy.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandNearEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..50a71eb5fa1d170222b3c76a17badafdcc85b3fc --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandNearEnergy.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTypicalCount + +namespace OAI + +/-! Near-frequency energy for the literal MRT prime-band family, combining +centered cancellation with the exceptional-density bound. -/ + +namespace TwoPointCorrelations + +open Finset Filter MeasureTheory +open scoped Classical + +theorem halasz_band_near_energy : ∃ C : ℝ, 0 < C ∧ + ∀ᶠ L : ℝ in atTop, ∀ᶠ N : ℕ in atTop, + ∀ (P Q : ℝ) (J : ℕ), 2 ≤ P → P ≤ Q → 1 ≤ Real.log Q → + (∀ j ∈ Icc 1 J, mrtBandUpper Q j ≤ Real.exp (L ^ (99 / 100 : ℝ))) → + (1 / 2 : ℝ) * Real.exp (L ^ (199 / 200 : ℝ)) ≤ N → + ∀ X : ℕ, N ≤ 2 * X → X ≤ N ^ 3 → + ∀ (F : ℕ → ℂ), F 1 = 1 → Multiplicative F → OneBounded F → + ∀ (t T M : ℝ), 0 ≤ M → |t| + Real.log (2 * N : ℕ) ^ 8 ≤ T → + (∀ v : ℝ, |v| ≤ T → M ≤ squaredDistance F (mrtArchimedeanTwist v) X) → + squaredDistance F (mrtArchimedeanTwist t) X ≤ Real.log (Real.log X) / 10 → + (∫ u in -((Real.log N) ^ (1 / (16 : ℝ)))..((Real.log N) ^ (1 / (16 : ℝ))), + ‖mrtDyadicPolynomial (mrtTypicalCoefficient (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) + N (t + u)‖ ^ 2) ≤ + C * (Real.log P / Real.log Q + Real.exp (-M) + + (Real.log N) ^ (-1 / (16 : ℝ))) := by + obtain ⟨C₁, hC₁, hnear⟩ := halasz_centered_typical_energy + obtain ⟨C₂, hC₂, hdensity⟩ := mrt_typical_density + let C := 48 * Real.exp 1 * C₂ + C₁ + refine ⟨C, by dsimp [C]; positivity, ?_⟩ + filter_upwards [hdensity] with L hdensity + filter_upwards [hnear, eventually_ge_atTop 2] with N hnear hN2 + have : NeZero N := ⟨by omega⟩ + intro P Q J hP hPQ hQ hmax hN X hNX hXN F hF1 hFm hFb t T M hM hT hd hsmall + let V := fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j) + have heq (n : ℕ) : + mrtTypical univ (fun j : {j : ℕ // j ∈ (Icc 1 J : Finset ℕ)} => V j) n ↔ + mrtTypical (Icc 1 J) V n := by + simp [mrtTypical] + have hp := hdensity P Q J hP hPQ hQ hmax (N + 1) N hN + change (uniformFiniteLaw (Fin N)).probability + (fun n => ¬mrtTypical univ + (fun j : {j : ℕ // j ∈ (Icc 1 J : Finset ℕ)} => V j) (N + 1 + n.val)) ≤ _ at hp + have hp' : (uniformFiniteLaw (Fin N)).probability + (fun n => ¬mrtTypical (Icc 1 J) V (N + 1 + n.val)) ≤ + C₂ * Real.log P / Real.log Q := by + simpa only [heq] using hp + have hcount := halasz_typical_dyadic_density_bound (Icc 1 J) V _ hp' + have hh := hnear X hNX hXN F hF1 hFm hFb t T M hM hT hd hsmall (Icc 1 J) V + have hR : 0 ≤ Real.log P / Real.log Q := div_nonneg + (Real.log_nonneg (by linarith)) (by linarith) + have hB : 0 ≤ Real.exp (-M) + (Real.log N) ^ (-1 / (16 : ℝ)) := by positivity + have hA : 0 ≤ 48 * Real.exp 1 * C₂ := by positivity + calc + _ ≤ 48 * Real.exp 1 * + (C₂ * Real.log P / Real.log Q) + + C₁ * (Real.exp (-M) + (Real.log N) ^ (-1 / (16 : ℝ))) := by + apply hh.trans + have hs := mul_le_mul_of_nonneg_left hcount (by positivity : 0 ≤ 48 * Real.exp 1) + simpa only [mul_div_assoc, add_comm] using add_le_add_right hs + (C₁ * (Real.exp (-M) + (Real.log N) ^ (-1 / (16 : ℝ)))) + _ = (48 * Real.exp 1 * C₂) * (Real.log P / Real.log Q) + + C₁ * (Real.exp (-M) + (Real.log N) ^ (-1 / (16 : ℝ))) := by ring + _ ≤ _ := by + dsimp [C] + nlinarith [mul_nonneg hA hB, mul_nonneg hC₁.le hR] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandPartition.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..996610d056b10e1cbfd093f628fd61d11b58e302 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandPartition.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLogBands +import Mathlib.Data.Nat.Log + +namespace OAI + +/-! A finite geometric partition of log(X/p), using base-two bands. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def halaszBandIndex (y : ℝ) : ℕ := Nat.log 2 ⌊y / Real.log 2⌋₊ + +noncomputable def halaszBandScale (j : ℕ) : ℝ := Real.log 2 * 2 ^ j + +lemma halasz_band_scale_bounds {y : ℝ} (hy : Real.log 2 ≤ y) : + halaszBandScale (halaszBandIndex y) ≤ y ∧ + y < 2 * halaszBandScale (halaszBandIndex y) := by + have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hy0 : 0 ≤ y / Real.log 2 := div_nonneg (htwo.le.trans hy) htwo.le + have hfloor : 1 ≤ ⌊y / Real.log 2⌋₊ := + (Nat.le_floor_iff hy0).mpr ((le_div_iff₀ htwo).mpr (by simpa using hy)) + have hlow := Nat.pow_log_le_self 2 (by omega : ⌊y / Real.log 2⌋₊ ≠ 0) + have hhigh := Nat.lt_pow_succ_log_self (by norm_num : 1 < 2) ⌊y / Real.log 2⌋₊ + have hlowR : (2 : ℝ) ^ halaszBandIndex y ≤ (⌊y / Real.log 2⌋₊ : ℝ) := by + exact_mod_cast hlow + have hhighR : (⌊y / Real.log 2⌋₊ : ℝ) + 1 ≤ (2 : ℝ) ^ (halaszBandIndex y + 1) := by + exact_mod_cast hhigh + constructor + · have h := hlowR.trans (Nat.floor_le hy0) + have hh := (le_div_iff₀ htwo).mp h + simpa only [halaszBandScale, mul_comm] using hh + · have h := (Nat.lt_floor_add_one (y / Real.log 2)).trans_le hhighR + have hh := (div_lt_iff₀ htwo).mp h + simpa only [halaszBandScale, pow_succ, mul_assoc, mul_comm, mul_left_comm] using hh + +lemma halasz_band_index_mono {y Y : ℝ} (hyY : y ≤ Y) : + halaszBandIndex y ≤ halaszBandIndex Y := by + apply Nat.log_mono_right + apply Nat.floor_mono + exact div_le_div_of_nonneg_right hyY (le_of_lt (Real.log_pos (by norm_num : (1 : ℝ) < 2))) + +noncomputable def halaszPrimeBandPart (P : Finset ℕ) (X : ℝ) (j : ℕ) : Finset ℕ := + P.filter (fun p : ℕ => halaszBandIndex (Real.log (X / p)) = j) + +lemma halasz_prime_band_part_bounds (P : Finset ℕ) {X : ℝ} {j p : ℕ} + (hP : ∀ p ∈ P, Real.log 2 ≤ Real.log (X / p)) + (hp : p ∈ halaszPrimeBandPart P X j) : + halaszBandScale j ≤ Real.log (X / p) ∧ Real.log (X / p) < 2 * halaszBandScale j := by + obtain ⟨hpP, hpj⟩ := mem_filter.mp hp + simpa only [hpj] using halasz_band_scale_bounds (hP p hpP) + +theorem halasz_prime_band_partition (P : Finset ℕ) {X Y : ℝ} + (hP : ∀ p ∈ P, Real.log (X / p) ≤ Y) (a : ℕ → ℂ) : + (∑ p ∈ P, a p) = + ∑ j ∈ range (halaszBandIndex Y + 1), ∑ p ∈ halaszPrimeBandPart P X j, a p := by + symm + apply sum_fiberwise_of_maps_to + intro p hp + exact mem_range.mpr (Nat.lt_succ_of_le (halasz_band_index_mono (hP p hp))) + +lemma halasz_band_scale_ge_log_two (j : ℕ) : Real.log 2 ≤ halaszBandScale j := by + have hp : (1 : ℝ) ≤ 2 ^ j := one_le_pow₀ (by norm_num) + simpa only [mul_one, halaszBandScale] using + mul_le_mul_of_nonneg_left hp (le_of_lt (Real.log_pos (by norm_num : (1 : ℝ) < 2))) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandPowerCost.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandPowerCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..c01dd87fe6b81ec1eed5f9bf7c6d0ab1b2ec1aff --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandPowerCost.lean @@ -0,0 +1,55 @@ +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTBandParameters + +namespace OAI + +/-! The actual number of original bands costs only a small logarithmic +power in the inclusion-exclusion cofactor estimate. -/ +namespace TwoPointCorrelations + +open Filter + +theorem halasz_band_power_cost : + ∀ᶠ L : ℝ in atTop, ∀ (Q : ℝ) (J : ℕ), 1 ≤ Real.log Q → + Real.log (mrtBandUpper Q J) ≤ 2*Real.sqrt L → + (2:ℝ)^J ≤ L^(1/1000:ℝ) := by + filter_upwards [eventually_ge_atTop (4:ℝ), + Real.tendsto_log_atTop.eventually (eventually_ge_atTop (1000*Real.exp 1000))] + with L hL hlogL + intro Q J hQ hU + have hL0 : 0 < L := by linarith + have hsqrt : 2*Real.sqrt L ≤ L := by + have hh : Real.sqrt L ≤ L/2 := (Real.sqrt_le_iff).mpr ⟨by positivity,by nlinarith⟩ + linarith + have hlog2u : Real.log 2 ≤ 1 := by + linarith [Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ) < 2)] + have hJ : (J:ℝ)*Real.log 2 ≤ Real.log L/1000 := by + by_cases hj : (J:ℝ) ≤ Real.exp 1000 + · calc + _ ≤ (J:ℝ) := mul_le_of_le_one_right (Nat.cast_nonneg _) hlog2u + _ ≤ Real.exp 1000 := hj + _ ≤ _ := by linarith + · have hjbig : Real.exp 1000 ≤ (J:ℝ) := le_of_not_ge hj + have hj0 : (0:ℝ) < J := (Real.exp_pos _).trans_le hjbig + have hj1 : (1:ℝ) ≤ J := + (Real.one_le_exp (by norm_num : (0:ℝ) ≤ 1000)).trans hjbig + have hjlog : 1000 ≤ Real.log (J:ℝ) := by + simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1000) hjbig + have hjpow : (J:ℝ)^J ≤ Real.log (mrtBandUpper Q J) := by + rw [mrtBandUpper,Real.log_exp] + calc + _ ≤ (J:ℝ)^(4*J+2) := pow_le_pow_right₀ hj1 (by omega) + _ ≤ _ := le_mul_of_one_le_right (by positivity) (one_le_pow₀ hQ) + have hJlog : (J:ℝ)*Real.log (J:ℝ) ≤ Real.log L := by + have hh := Real.log_le_log (pow_pos hj0 J) + (hjpow.trans (hU.trans hsqrt)) + simpa only [Real.log_pow] using hh + have hh := mul_le_mul_of_nonneg_left hjlog (Nat.cast_nonneg J : (0:ℝ) ≤ J) + nlinarith + rw [← Real.rpow_natCast,Real.rpow_def_of_pos (by norm_num : (0:ℝ)<2), + Real.rpow_def_of_pos hL0] + apply Real.exp_le_exp.mpr + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandSummation.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandSummation.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ed1812c87d64ce0bfc16ff53efe87d8ad0e8dca --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandSummation.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszBandPartition + +namespace OAI + +/-! Summing the minimum of the trivial band estimate and the distance +estimate. This is the step that keeps the factor (M+1) exp(-M). -/ + +namespace TwoPointCorrelations + +open Finset + +lemma halasz_band_scale_sum (J : ℕ) : + (∑ j ∈ range J, halaszBandScale j) = Real.log 2 * ((2 : ℝ) ^ J - 1) := by + induction J with + | zero => simp + | succ J ih => + rw [sum_range_succ, ih] + simp only [halaszBandScale, pow_succ] + ring + +lemma halasz_band_scale_sum_le (J : ℕ) : + (∑ j ∈ range J, halaszBandScale j) ≤ halaszBandScale J := by + rw [halasz_band_scale_sum] + dsimp [halaszBandScale] + have htwo := (Real.log_pos (by norm_num : (1 : ℝ) < 2)).le + nlinarith + +lemma halasz_band_inverse_sum (J : ℕ) : + (∑ j ∈ range J, (halaszBandScale j)⁻¹) = + (2 / Real.log 2) * (1 - ((2 : ℝ)⁻¹) ^ J) := by + induction J with + | zero => simp + | succ J ih => + rw [sum_range_succ, ih] + simp only [halaszBandScale, mul_inv_rev, inv_pow, pow_succ] + ring + +lemma halasz_band_inverse_sum_le (J : ℕ) : + (∑ j ∈ range J, (halaszBandScale j)⁻¹) ≤ 2 / Real.log 2 := by + rw [halasz_band_inverse_sum] + have htwo : 0 ≤ 2 / Real.log 2 := by positivity + have hp : 0 ≤ ((2 : ℝ)⁻¹) ^ J := by positivity + nlinarith + +lemma halasz_band_min_split {A : ℝ} (_hA : 0 ≤ A) (J k : ℕ) (hk : k ≤ J) : + (∑ j ∈ range J, min A (halaszBandScale j)) ≤ + halaszBandScale k + (J - k : ℕ) * A := by + rw [← sum_range_add_sum_Ico _ hk] + have hfirst : (∑ j ∈ range k, min A (halaszBandScale j)) ≤ halaszBandScale k := + (sum_le_sum (fun j _ => min_le_right _ _)).trans (halasz_band_scale_sum_le k) + have hlast : (∑ j ∈ Ico k J, min A (halaszBandScale j)) ≤ (J - k : ℕ) * A := by + apply (sum_le_sum (fun j _ => min_le_left _ _)).trans_eq + simp + exact add_le_add hfirst hlast + +theorem halasz_band_saving_sum : ∃ C : ℝ, 0 < C ∧ + ∀ (J : ℕ) (V M : ℝ), 0 ≤ V → 0 ≤ M → halaszBandScale J ≤ 2 * V → + (∑ j ∈ range J, min (V * Real.exp (-M)) (halaszBandScale j)) ≤ + C * V * (M + 1) * Real.exp (-M) := by + let C := 1 / Real.log 2 + 3 + have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hC : 0 < C := by dsimp [C]; positivity + refine ⟨C, hC, ?_⟩ + intro J V M hV hM htop + let r : ℕ := ⌈M / Real.log 2⌉₊ + let A := V * Real.exp (-M) + have hA : 0 ≤ A := mul_nonneg hV (Real.exp_pos _).le + have hrlo : M / Real.log 2 ≤ (r : ℝ) := Nat.le_ceil _ + have hrhi : (r : ℝ) < M / Real.log 2 + 1 := Nat.ceil_lt_add_one (div_nonneg hM htwo.le) + have hpow : Real.exp M ≤ (2 : ℝ) ^ r := by + have h := Real.exp_le_exp.mpr ((div_le_iff₀ htwo).mp hrlo) + simpa only [Real.exp_nat_mul, Real.exp_log (by norm_num : (0 : ℝ) < 2)] using h + have hsum : (∑ j ∈ range J, min A (halaszBandScale j)) ≤ ((r : ℝ) + 2) * A := by + by_cases hrJ : r ≤ J + · have hscale : halaszBandScale (J - r) ≤ 2 * A := by + have hmul : halaszBandScale (J - r) * (2 : ℝ) ^ r = halaszBandScale J := by + dsimp [halaszBandScale] + rw [mul_assoc, ← pow_add, Nat.sub_add_cancel hrJ] + calc + _ = halaszBandScale J / (2 : ℝ) ^ r := by rw [← hmul]; field_simp + _ ≤ 2 * V / (2 : ℝ) ^ r := div_le_div_of_nonneg_right htop (by positivity) + _ ≤ 2 * V / Real.exp M := div_le_div_of_nonneg_left (by positivity) (Real.exp_pos _) hpow + _ = 2 * A := by dsimp [A]; rw [Real.exp_neg]; ring + have hs := halasz_band_min_split hA J (J - r) (Nat.sub_le _ _) + have hcard : J - (J - r) = r := Nat.sub_sub_self hrJ + rw [hcard] at hs + nlinarith + · have hcount : (J : ℝ) ≤ r := by exact_mod_cast (Nat.le_of_lt (Nat.lt_of_not_ge hrJ)) + have hs : (∑ j ∈ range J, min A (halaszBandScale j)) ≤ (J : ℝ) * A := by + apply (sum_le_sum (fun j _ => min_le_left _ _)).trans_eq + simp + nlinarith + have hlinear : (r : ℝ) + 2 ≤ C * (M + 1) := by + have hi : 0 ≤ 1 / Real.log 2 := by positivity + dsimp [C] + rw [div_eq_mul_inv] at hrhi + simp only [one_div] at hi ⊢ + nlinarith + calc + _ ≤ ((r : ℝ) + 2) * A := hsum + _ ≤ (C * (M + 1)) * A := mul_le_mul_of_nonneg_right hlinear hA + _ = _ := by dsimp [A]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandWeights.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..54c222f94ced766e15e498e39a02a776c177085a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBandWeights.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLogBands +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimePolynomial + +namespace OAI + +/-! On one logarithmic band the two prime mean-square masses cancel: +the adaptive denominator contributes v⁻² and the two prime masses O(v²). -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma halasz_prime_set_mass_le {Y : ℝ} (hY : 1 ≤ Y) (Q : Finset ℕ) + (hQ : ∀ q ∈ Q, q.Prime ∧ (q : ℝ) ≤ Y) : + (∑ q ∈ Q, Real.log (q : ℝ) / q) ≤ Real.log Y + halaszMertensConstant := by + have hsub : Q ⊆ sievePrimesUpTo Y := by + intro q hq + exact mem_filter.mpr ⟨mem_Iic.mpr ((Nat.le_floor_iff (by linarith)).mpr (hQ q hq).2), + (hQ q hq).1⟩ + exact (sum_le_sum_of_subset_of_nonneg (f := fun q : ℕ => Real.log (q : ℝ) / q) + hsub (fun q hq _ => div_nonneg + (Real.log_nonneg (by exact_mod_cast (sievePrimesUpTo_prime Y q hq).one_le)) + (Nat.cast_nonneg _))).trans (halasz_prime_prefix_mass_le hY) + +theorem halasz_band_mean_square_weights : ∃ K : ℝ, 0 < K ∧ + ∀ (f : ℕ → ℂ), OneBounded f → ∀ (X v : ℝ), 0 < X → Real.log 2 ≤ v → + ∀ (P Q : Finset ℕ), + (∀ p ∈ P, p.Prime ∧ v ≤ Real.log (X / p) ∧ Real.log (X / p) < 2 * v) → + (∀ q ∈ Q, q.Prime ∧ (q : ℝ) ≤ Real.exp (2 * v)) → + Real.sqrt (∑ p ∈ P, ‖f p / (Real.log (X / p) : ℂ)‖ ^ 2 * + (Real.log (p : ℝ) / p)) * + Real.sqrt (∑ q ∈ Q, ‖f q‖ ^ 2 * (Real.log (q : ℝ) / q)) ≤ K := by + let C₁ := 1 + 2 * halaszMertensConstant / Real.log 2 + let C₂ := 2 + halaszMertensConstant / Real.log 2 + have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hM := halaszMertensConstant_nonneg + have hC₁ : 0 < C₁ := by dsimp [C₁]; positivity + have hC₂ : 0 < C₂ := by dsimp [C₂]; positivity + refine ⟨Real.sqrt (C₁ * C₂), Real.sqrt_pos.mpr (mul_pos hC₁ hC₂), ?_⟩ + intro f hf X v hX hv P Q hP hQ + have hv0 : 0 < v := htwo.trans_le hv + have hPl : ∀ p ∈ P, p.Prime := fun p hp => (hP p hp).1 + have hQl : ∀ q ∈ Q, q.Prime := fun q hq => (hQ q hq).1 + have hpMass : (∑ p ∈ P, Real.log (p : ℝ) / p) ≤ C₁ * v := + halasz_log_band_mass_linear hX hv P hP + have hqMass : (∑ q ∈ Q, Real.log (q : ℝ) / q) ≤ C₂ * v := by + have hm := halasz_prime_set_mass_le (Y := Real.exp (2 * v)) + (Real.one_le_exp_iff.mpr (by linarith)) Q hQ + rw [Real.log_exp] at hm + have hh := mul_le_mul_of_nonneg_left hv + (show 0 ≤ halaszMertensConstant / Real.log 2 from div_nonneg hM htwo.le) + rw [div_mul_cancel₀ _ htwo.ne'] at hh + dsimp [C₂] + linarith + let A := ∑ p ∈ P, ‖f p / (Real.log (X / p) : ℂ)‖ ^ 2 * (Real.log (p : ℝ) / p) + let B := ∑ q ∈ Q, ‖f q‖ ^ 2 * (Real.log (q : ℝ) / q) + have hA0 : 0 ≤ A := sum_nonneg (fun p hp => mul_nonneg (sq_nonneg _) + (div_nonneg (Real.log_nonneg (by exact_mod_cast (hPl p hp).one_le)) (Nat.cast_nonneg _))) + have hB0 : 0 ≤ B := sum_nonneg (fun q hq => mul_nonneg (sq_nonneg _) + (div_nonneg (Real.log_nonneg (by exact_mod_cast (hQl q hq).one_le)) (Nat.cast_nonneg _))) + have hA : A ≤ C₁ / v := by + calc + _ ≤ (v⁻¹) ^ 2 * ∑ p ∈ P, Real.log (p : ℝ) / p := + halasz_prime_coefficient_square_mass P _ hPl + (fun p hp => halasz_adaptive_coefficient_bound f hf hv0 (hPl p hp).pos (hP p hp).2.1) + _ ≤ (v⁻¹) ^ 2 * (C₁ * v) := mul_le_mul_of_nonneg_left hpMass (sq_nonneg _) + _ = _ := by field_simp + have hB : B ≤ C₂ * v := by + have hb := halasz_prime_coefficient_square_mass Q f hQl (fun q hq => hf q (hQl q hq).pos) + simpa only [one_pow, one_mul] using hb.trans (by simpa only [one_pow, one_mul] using hqMass) + have hAB : A * B ≤ C₁ * C₂ := by + calc + _ ≤ (C₁ / v) * (C₂ * v) := mul_le_mul hA hB hB0 (by positivity) + _ = _ := by field_simp + have hs := Real.sqrt_le_sqrt hAB + rw [Real.sqrt_mul hA0] at hs + exact hs + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBoundedDegrees.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBoundedDegrees.lean new file mode 100644 index 0000000000000000000000000000000000000000..335f555d70f19d328db3dd8d38a90aaad50316f6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBoundedDegrees.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszSelectedWeights +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDegreeSaving + +namespace OAI + +/-! Fixed and rounded Taylor degrees cover the bounded height/length ratios. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma halasz_medium_degree_saving {lam k d : ℝ} + (hlo : 9/10≤lam) (hhi : lam≤48) (hk0 : 0≤k) (hk : k≤3*lam+6) + (hdlo : 3*lam/2≤d) (hdhi : d≤3*lam/2+1) : + (1:ℝ)/32+k^2/1024≤min (d/3) (min (d-lam) (lam-d/3)) := by + have hm := halasz_medium_degree_margin hlo hhi + have hk2 : k^2≤(3*lam+6)^2 := by nlinarith + apply le_min + · nlinarith + · apply le_min <;> nlinarith + +noncomputable def halaszMediumDegree (lam : ℝ) : ℕ := 3*⌈lam⌉₊+3 +noncomputable def halaszMediumActive (lam : ℝ) : ℕ := ⌈3*lam/2⌉₊ + +lemma halasz_medium_degree_bounds {lam : ℝ} (hlo : 9/10≤lam) : + 2≤halaszMediumDegree lam ∧ 1≤halaszMediumActive lam ∧ + halaszMediumActive lam≤halaszMediumDegree lam ∧ + 3*lam+3≤(halaszMediumDegree lam:ℝ) ∧ + (halaszMediumDegree lam:ℝ)≤3*lam+6 ∧ + 3*lam/2≤(halaszMediumActive lam:ℝ) ∧ + (halaszMediumActive lam:ℝ)≤3*lam/2+1 := by + have hc := Nat.le_ceil lam + have hc' := Nat.ceil_lt_add_one (by linarith : 0≤lam) + have hd := Nat.le_ceil (3*lam/2) + have hd' := Nat.ceil_lt_add_one (by linarith : 0≤3*lam/2) + have hklo : 3*lam+3≤(halaszMediumDegree lam:ℝ) := by + dsimp only [halaszMediumDegree] + push_cast + linarith + have hkhi : (halaszMediumDegree lam:ℝ)≤3*lam+6 := by + dsimp only [halaszMediumDegree] + push_cast + linarith + have hdlo : 3*lam/2≤(halaszMediumActive lam:ℝ) := hd + have hdhi : (halaszMediumActive lam:ℝ)≤3*lam/2+1 := hd'.le + refine ⟨?_,?_,?_,hklo,hkhi,hdlo,hdhi⟩ + · unfold halaszMediumDegree + omega + · exact_mod_cast (show (1:ℝ)≤halaszMediumActive lam by linarith) + · exact_mod_cast (show (halaszMediumActive lam:ℝ)≤halaszMediumDegree lam by linarith) + +lemma halasz_single_degree_weight_product {k r M d : ℕ} (hr : 1≤r) (hM : 1≤M) + (hd0 : 1≤d) (hdk : d≤k) {t z N lam η : ℝ} (hN : 1≤N) + (hz : N≤z) (hzhi : z≤2*N) (ht : |t|=N^lam) + (hscale : N^(1/3:ℝ)≤2*(M:ℝ)) + (h₁ : η≤(d:ℝ)/3) (h₂ : η≤(d:ℝ)-lam) (h₃ : η≤lam-(d:ℝ)/3) : + (∏ j : Fin k,halaszNormalizedWeight r M (halaszLogCoefficient t z) j)≤ + (halaszLogWeightCost k r)^k*N^(-η) := by + let j : Fin k := ⟨d-1,by omega⟩ + have hj : (j.val:ℝ)+1=d := by + dsimp only [j] + rw [Nat.cast_sub hd0,Nat.cast_one] + ring + have hh := halasz_log_selected_weight_product hr hM hN hz hzhi ht hscale {j} + (η := η) + (fun i hi => by have hi' := mem_singleton.mp hi; subst i; rw [hj]; linarith) + (fun i hi => by have hi' := mem_singleton.mp hi; subst i; rw [hj]; exact h₂) + (fun i hi => by have hi' := mem_singleton.mp hi; subst i; rw [hj]; linarith) + simpa using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBoundedLogPolynomial.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBoundedLogPolynomial.lean new file mode 100644 index 0000000000000000000000000000000000000000..0dead1becd62b2c6cf17bb19a62957e8fa1b054b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBoundedLogPolynomial.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszBoundedSaving + +namespace OAI + +/-! Uniform bounded-degree polynomial estimate and Taylor margin. -/ +namespace TwoPointCorrelations + +open Finset + +theorem halasz_bounded_log_polynomial : ∃ R₀ : ℕ, ∀ lam : ℝ, + 49/100≤lam → lam≤48 → ∃ k : ℕ, 2≤k ∧ k≤150 ∧ + lam-((k:ℝ)+1)/3≤-(1/2:ℝ) ∧ + ∀ M : ℕ, 1≤M → ∀ t z N : ℝ, (M:ℝ)≤N → N≤z → z≤2*N → + |t|=N^lam → N^(1/3:ℝ)≤2*(M:ℝ) → + ‖∑ b : Fin M,halaszVinogradovPolynomial k M + (halaszScaledFrequency (halaszLogCoefficient t z) + (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)))‖/(M:ℝ)^2 ≤ + (R₀+182:ℝ)^6*N^(-1/((10^15:ℝ)*lam^2)) := by + obtain ⟨R₀,hR⟩ := halasz_single_log_polynomial_saving + refine ⟨R₀,?_⟩ + intro lam hlo hhi + have hfinish (k d : ℕ) (hk : 2≤k) (hkhi : k≤150) (hd : 1≤d) (hdk : d≤k) + (hdeg : (1:ℝ)/32+(k:ℝ)^2/1024≤ + min ((d:ℝ)/3) (min ((d:ℝ)-lam) (lam-(d:ℝ)/3))) : + ∀ M : ℕ,1≤M → ∀ t z N : ℝ,(M:ℝ)≤N → N≤z → z≤2*N → + |t|=N^lam → N^(1/3:ℝ)≤2*(M:ℝ) → + ‖∑ b : Fin M,halaszVinogradovPolynomial k M + (halaszScaledFrequency (halaszLogCoefficient t z) + (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)))‖/(M:ℝ)^2 ≤ + (R₀+182:ℝ)^6*N^(-1/((10^15:ℝ)*lam^2)) := by + intro M hM t z N hMN hz hzhi ht hscale + have hp := hR k hk M hM d hd hdk t z N lam (1/32) hMN hz hzhi ht hscale hdeg + have hN : 1≤N := (show (1:ℝ)≤M by exact_mod_cast hM).trans hMN + have he := neg_le_neg (halasz_bounded_root_saving hk hkhi hlo) + have he' : -(1/32:ℝ)/((2*halaszSelectedMoment k*halaszSelectedMoment k:ℕ):ℝ)≤ + -1/((10^15:ℝ)*lam^2) := by simpa only [neg_div] using he + apply hp.trans + apply mul_le_mul + · apply pow_le_pow_left₀ (by positivity) + exact_mod_cast (show R₀+k+32≤R₀+182 by omega) + · exact Real.rpow_le_rpow_of_exponent_le hN he' + · exact Real.rpow_nonneg (by linarith) _ + · positivity + by_cases hlow : lam≤9/10 + · refine ⟨6,by norm_num,by norm_num,by norm_num; linarith,?_⟩ + apply hfinish 6 1 (by norm_num) (by norm_num) (by norm_num) (by norm_num) + simpa only [Nat.cast_ofNat,Nat.cast_one] using halasz_low_degree_saving hlo hlow + · have hmed : 9/10≤lam := by linarith + obtain ⟨hk,hd,hdk,hkl,hkh,hdl,hdh⟩ := halasz_medium_degree_bounds hmed + have hk150 : halaszMediumDegree lam≤150 := by + exact_mod_cast (show (halaszMediumDegree lam:ℝ)≤150 by linarith) + refine ⟨halaszMediumDegree lam,hk,hk150,?_,?_⟩ + · have ht := halasz_small_taylor_exponent hkl + linarith + · apply hfinish (halaszMediumDegree lam) (halaszMediumActive lam) hk hk150 hd hdk + exact halasz_medium_degree_saving hmed hhi (by positivity) hkh hdl hdh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBoundedSaving.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBoundedSaving.lean new file mode 100644 index 0000000000000000000000000000000000000000..1cff1e067acdb56a10b033ecdd981b429ceb5b81 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBoundedSaving.lean @@ -0,0 +1,38 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLogPolynomialSaving + +namespace OAI + +/-! A single absolute saving exponent covers the bounded-degree cases. -/ +namespace TwoPointCorrelations + +lemma halasz_bounded_root_saving {k : ℕ} (hk : 2≤k) (hkhi : k≤150) + {lam : ℝ} (hlam : 49/100≤lam) : + 1/((10^15:ℝ)*lam^2) ≤ + (1/32:ℝ)/((2*halaszSelectedMoment k*halaszSelectedMoment k:ℕ):ℝ) := by + have hk0 : 0≤(k:ℝ) := Nat.cast_nonneg _ + have hkR : (k:ℝ)≤150 := by exact_mod_cast hkhi + have hk2 : (k:ℝ)^2≤150^2 := pow_le_pow_left₀ hk0 hkR 2 + have hr : (halaszSelectedMoment k:ℝ)≤225150 := by + simp only [halaszSelectedMoment,Nat.cast_mul,Nat.cast_add,Nat.cast_one,Nat.cast_ofNat] + nlinarith + have hr0 : 0<(halaszSelectedMoment k:ℝ) := by + exact_mod_cast (show 0 (1:ℂ)) rfl + (by intros; simp) (by intro n hn; simp) N t + apply hs.norm.of_norm_bounded + intro n + by_cases hn : n = 0 + · subst n + simp [LSeries.term] + by_cases hsm : n ∈ Nat.smoothNumbers (N+1) + · simp only [LSeries.term, hn, ite_false, halaszSmoothFunction, hsm, ite_true, + norm_div, norm_one] + exact div_le_div_of_nonneg_right (hf n (Nat.pos_of_ne_zero hn)) (norm_nonneg _) + · simp [LSeries.term, hn, halaszSmoothFunction, hsm] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBoundedTriple.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBoundedTriple.lean new file mode 100644 index 0000000000000000000000000000000000000000..23774a7e35dcbcd0cbf6b0d839c52a9c8e3682a0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszBoundedTriple.lean @@ -0,0 +1,112 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszWindowPerron +import OAI.NumberTheory.TwoPoint.Halasz.HalaszWindowTail +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimePolynomial +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCoefficientBound +import OAI.NumberTheory.TwoPoint.Halasz.HalaszBoundedSmooth +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTripleEstimate + +namespace OAI + +/-! The triple-convolution estimate for the typical coefficient. Only +one-boundedness is needed by Perron inversion; multiplicativity belongs +to the separate finite convolution identity. -/ + +namespace TwoPointCorrelations + +open Finset Complex MeasureTheory +open _root_.Erdos970 (VerticalIntegral VerticalIntegral') +open scoped Classical LSeries.notation + +theorem halasz_bounded_prime_triple_estimate : ∃ C B : ℝ, 0 < C ∧ 2 ≤ B ∧ + ∀ (f : ℕ → ℂ), OneBounded f → + ∀ (N : ℕ) (x T A W R : ℝ) (m : ℕ), 0 < x → 0 < m → (m : ℝ) ≤ x → + (∀ n : ℕ, x ≠ (n : ℝ)) → B ≤ T → 0 ≤ A → 0 ≤ W → 0 ≤ R → + ∀ (P Q : Finset ℕ), (∀ p ∈ P, p.Prime ∧ T ^ 2 ≤ (p : ℝ)) → + (∀ q ∈ Q, q.Prime) → ∀ a b : ℕ → ℂ, + (∀ p ∈ P, ‖a p‖ ≤ R) → (∀ q ∈ Q, ‖b q‖ ≤ 1) → + (∀ t ∈ Set.Icc (-T) T, ‖LSeries (halaszSmoothFunction f N) (1 + (t : ℂ) * I)‖ ≤ A) → + (∀ t : ℝ, ‖LSeries (halaszSmoothFunction f N) (1 + (t : ℂ) * I)‖ ≤ W) → + ‖∑ n ∈ Icc 1 ⌊x⌋₊, + (halaszFiniteCoefficient P (fun p => (Real.log (p : ℝ) : ℂ) * a p) ⍟ + (halaszFiniteCoefficient Q (fun q => (Real.log (q : ℝ) : ℂ) * b q) ⍟ + halaszSmoothFunction f N)) n‖ ≤ + (C * x * A) * + (Real.sqrt (∑ p ∈ P, ‖a p‖ ^ 2 * (Real.log (p : ℝ) / p)) * + Real.sqrt (∑ q ∈ Q, ‖b q‖ ^ 2 * (Real.log (q : ℝ) / q))) + + 40 * x * (R * ∑ p ∈ P, Real.log (p : ℝ) / p) * + (∑ q ∈ Q, Real.log (q : ℝ) / q) * W / ((m / x) * T) + + R * Real.log (x + m) ^ 2 * m := by + obtain ⟨C, B, hC, hB, hmid⟩ := halasz_prime_window_middle + refine ⟨C, B, hC, hB, ?_⟩ + intro f hbound N x T A W R m hx hm hmx hxnat hBT hA hW hR P Q hP hQ a b ha hb hFA hFW + let c : ℕ → ℂ := halaszFiniteCoefficient P (fun p => (Real.log (p : ℝ) : ℂ) * a p) ⍟ + (halaszFiniteCoefficient Q (fun q => (Real.log (q : ℝ) : ℂ) * b q) ⍟ halaszSmoothFunction f N) + let D := halaszPrimePolynomial P a + let E := halaszPrimePolynomial Q b + let F := fun t : ℝ => LSeries (halaszSmoothFunction f N) (1 + (t : ℂ) * I) + have hPl : ∀ p ∈ P, p.Prime := fun p hp => (hP p hp).1 + have hsum (t : ℝ) : LSeriesSummable c (1 + (t : ℂ) * I) := + (halasz_finite_LSeries_summable P _ _).convolution + ((halasz_finite_LSeries_summable Q _ _).convolution + (halasz_bounded_smooth_summable f hbound N t)) + have hc : LSeriesSummable c 1 := by simpa using hsum 0 + have hline (t : ℝ) : LSeries c (1 + (t : ℂ) * I) = D t * E t * F t := by + dsimp only [c] + rw [LSeries_convolution' (halasz_finite_LSeries_summable P _ _) + ((halasz_finite_LSeries_summable Q _ _).convolution + (halasz_bounded_smooth_summable f hbound N t)), + LSeries_convolution' (halasz_finite_LSeries_summable Q _ _) + (halasz_bounded_smooth_summable f hbound N t), + halasz_finite_LSeries, halasz_finite_LSeries, + halasz_prime_polynomial_series P a hPl t, halasz_prime_polynomial_series Q b hQ t] + dsimp [D, E, F] + ring + have hmR : (0 : ℝ) < m := by exact_mod_cast hm + have hδ : 0 < (m : ℝ) / x := div_pos hmR hx + have hδ1 : (m : ℝ) / x ≤ 1 := (div_le_one hx).mpr hmx + have hT : 0 < T := lt_of_lt_of_le (by linarith : (0 : ℝ) < B) hBT + have hpMass : 0 ≤ ∑ p ∈ P, Real.log (p : ℝ) / p := sum_nonneg (fun p hp => + div_nonneg (Real.log_nonneg (by exact_mod_cast (hPl p hp).one_le)) (Nat.cast_nonneg _)) + have hqMass : 0 ≤ ∑ q ∈ Q, Real.log (q : ℝ) / q := sum_nonneg (fun q hq => + div_nonneg (Real.log_nonneg (by exact_mod_cast (hQ q hq).one_le)) (Nat.cast_nonneg _)) + have hint : Integrable (fun t : ℝ => D t * E t * F t * + halaszPerronWindowKernel x (m / x) (1 + (t : ℂ) * I)) := by + simpa only [hline] using halasz_LSeries_window_integrable c hc hx hδ + have htail := halasz_window_integral_truncate D E F hx hδ hδ1 hT + (mul_nonneg hR hpMass) hqMass hW + (halasz_prime_polynomial_bounded P a hPl ha) + (fun t => by simpa only [one_mul] using halasz_prime_polynomial_bounded Q b hQ hb t) + hFW hint + have hmiddle := hmid x (m / x) T A hx hδ hδ1 hBT hA P Q hP hQ a b F hFA + have hcoeff (n : ℕ) : ‖c n‖ ≤ R * Real.log (n : ℝ) ^ 2 := + halasz_triple_coefficient_bound _ _ _ hR + (halasz_finite_prime_mangoldt_bound P a hPl hR ha) + (fun n : ℕ => by simpa only [one_mul] using + halasz_finite_prime_mangoldt_bound Q b hQ (R := 1) (by norm_num) hb n) + (halasz_smooth_oneBounded f hbound N) n + have hboundary (n : ℕ) (hn : n ∈ Icc (⌊x⌋₊ + 1) (⌊x⌋₊ + m)) : + ‖c n‖ ≤ R * Real.log (x + m) ^ 2 := by + have hn0 : 0 < n := by have := (mem_Icc.mp hn).1; omega + have hn1 : (1 : ℝ) ≤ n := by exact_mod_cast hn0 + have hnle : (n : ℝ) ≤ x + m := by + have hh : (n : ℝ) ≤ (⌊x⌋₊ : ℝ) + m := by exact_mod_cast (mem_Icc.mp hn).2 + linarith [Nat.floor_le hx.le] + exact (hcoeff n).trans (mul_le_mul_of_nonneg_left + (pow_le_pow_left₀ (Real.log_nonneg hn1) + (Real.log_le_log (by positivity) hnle) 2) hR) + have hunsmooth := halasz_window_unsmoothing c hc hx m hm hxnat hboundary + have hnorm := halasz_vertical_integral_norm + (fun s => LSeries c s * halaszPerronWindowKernel x (m / x) s) + simp_rw [hline] at hnorm + have hcompare := norm_add_le + (VerticalIntegral' (fun s => LSeries c s * halaszPerronWindowKernel x (m / x) s) 1) + ((∑ n ∈ Icc 1 ⌊x⌋₊, c n) - + VerticalIntegral' (fun s => LSeries c s * halaszPerronWindowKernel x (m / x) s) 1) + rw [add_sub_cancel, norm_sub_rev] at hcompare + change ‖∑ n ∈ Icc 1 ⌊x⌋₊, c n‖ ≤ _ + dsimp only [D, E, halaszPrimePolynomial] at htail hnorm + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCauchyMeanSquare.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCauchyMeanSquare.lean new file mode 100644 index 0000000000000000000000000000000000000000..9da3523fb980ddaadcdd7f4dc47f2358a4af71b5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCauchyMeanSquare.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszUnitPrimeWindows +import Mathlib.Analysis.PSeries + +namespace OAI + +/-! Summing the translated unit-window estimates against the Cauchy +weight gives the global weighted mean square used in the Perron argument. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +lemma halasz_polynomial_norm_le {ι : Type*} (S : Finset ι) + (a : ι → ℂ) (freq : ι → ℝ) (t : ℝ) : + ‖mrtExponentialPolynomial S a freq t‖ ≤ ∑ i ∈ S, ‖a i‖ := by + unfold mrtExponentialPolynomial + exact (norm_sum_le _ _).trans (by + simp only [norm_mul, Complex.norm_exp_ofReal_mul_I, mul_one, le_refl]) + +lemma halasz_cauchy_polynomial_integrable {ι : Type*} (S : Finset ι) + (a : ι → ℂ) (freq : ι → ℝ) : + Integrable (fun t : ℝ => ‖mrtExponentialPolynomial S a freq t‖ ^ 2 * (1 + t ^ 2)⁻¹) := by + have hc : Continuous (fun t : ℝ => + ‖mrtExponentialPolynomial S a freq t‖ ^ 2 * (1 + t ^ 2)⁻¹) := by + apply ((halasz_polynomial_continuous S a freq).norm.pow 2).mul + exact (continuous_const.add (continuous_id.pow 2)).inv₀ + (fun t => ne_of_gt (by positivity : (0 : ℝ) < 1 + t ^ 2)) + apply (integrable_inv_one_add_sq.const_mul ((∑ i ∈ S, ‖a i‖) ^ 2)).mono' + hc.aestronglyMeasurable + apply Filter.Eventually.of_forall + intro t + rw [Real.norm_eq_abs, abs_of_nonneg (by positivity)] + exact mul_le_mul_of_nonneg_right + (pow_le_pow_left₀ (norm_nonneg _) (halasz_polynomial_norm_le S a freq t) 2) + (by positivity) + +lemma halasz_cauchy_integer_summable : Summable (fun k : ℤ => (1 + (k : ℝ) ^ 2)⁻¹) := by + have hsingle : Summable (fun k : ℤ => if k = 0 then (1 : ℝ) else 0) := by + apply summable_of_ne_finset_zero (s := {0}) + intro k hk + simp only [mem_singleton] at hk + simp [hk] + have hp := (Real.summable_one_div_int_pow.mpr (by norm_num : 1 < 2)).add hsingle + apply Summable.of_nonneg_of_le (fun k => by positivity) _ hp + intro k + by_cases hk : k = 0 + · simp [hk] + · rw [ite_eq_right hk, add_zero] + have hk0 : (k : ℝ) ≠ 0 := by exact_mod_cast hk + simpa only [one_div] using one_div_le_one_div_of_le (sq_pos_of_ne_zero hk0) + (show (k : ℝ) ^ 2 ≤ 1 + (k : ℝ) ^ 2 by linarith) + +lemma halasz_cauchy_weight_window {k t : ℝ} (ht : t ∈ Set.Icc (k - 1 / 2) (k + 1 / 2)) : + (1 + t ^ 2)⁻¹ ≤ 2 * (1 + k ^ 2)⁻¹ := by + have hgap : (k - t) ^ 2 ≤ 1 / 4 := by + have hp := mul_nonneg (sub_nonneg.mpr ht.1) (sub_nonneg.mpr ht.2) + nlinarith + have hden : 1 + k ^ 2 ≤ 2 * (1 + t ^ 2) := by nlinarith [sq_nonneg (2 * t - k)] + have hpos : 0 < 1 + t ^ 2 := by positivity + have hkpos : 0 < 1 + k ^ 2 := by positivity + simpa only [div_eq_mul_inv, one_mul] using + (div_le_div_iff₀ hpos hkpos).mpr (show (1 : ℝ) * (1 + k ^ 2) ≤ 2 * (1 + t ^ 2) by nlinarith) + +theorem halasz_prime_mean_square_cauchy : ∃ C : ℝ, 0 < C ∧ + ∀ (P : Finset ℕ), (∀ p ∈ P, p.Prime) → ∀ a : ℕ → ℂ, + (∫ t : ℝ, ‖mrtExponentialPolynomial P + (fun p => a p * ((Real.log (p : ℝ) / p : ℝ) : ℂ)) + (fun p => -Real.log (p : ℝ)) t‖ ^ 2 * (1 + t ^ 2)⁻¹) ≤ + C * ∑ p ∈ P, ‖a p‖ ^ 2 * (Real.log (p : ℝ) / p) := by + obtain ⟨C, hC, hm⟩ := halasz_prime_mean_square_unit + let W := ∑' k : ℤ, (1 + (k : ℝ) ^ 2)⁻¹ + have hW : 0 ≤ W := tsum_nonneg (fun _ => by positivity) + refine ⟨C * (1 + 2 * W), by positivity, ?_⟩ + intro P hP a + let D := mrtExponentialPolynomial P + (fun p => a p * ((Real.log (p : ℝ) / p : ℝ) : ℂ)) (fun p => -Real.log (p : ℝ)) + let M := ∑ p ∈ P, ‖a p‖ ^ 2 * (Real.log (p : ℝ) / p) + have hM : 0 ≤ M := sum_nonneg (fun p hp => mul_nonneg (sq_nonneg _) + (div_nonneg (Real.log_nonneg (by exact_mod_cast (hP p hp).one_le)) (Nat.cast_nonneg _))) + have hi : Integrable (fun t : ℝ => ‖D t‖ ^ 2 * (1 + t ^ 2)⁻¹) := + halasz_cauchy_polynomial_integrable P _ _ + have hs := hi.hasSum_intervalIntegral (-(1 / 2 : ℝ)) + have hb (k : ℤ) : (∫ t in (-(1 / 2 : ℝ) + k)..(-(1 / 2 : ℝ) + k + 1), + ‖D t‖ ^ 2 * (1 + t ^ 2)⁻¹) ≤ (2 * C * M) * (1 + (k : ℝ) ^ 2)⁻¹ := by + have he1 : -(1 / 2 : ℝ) + k = (k : ℝ) - 1 / 2 := by ring + have he2 : -(1 / 2 : ℝ) + k + 1 = (k : ℝ) + 1 / 2 := by ring + rw [he2, he1] + have hc := (halasz_polynomial_continuous P + (fun p => a p * ((Real.log (p : ℝ) / p : ℝ) : ℂ)) + (fun p => -Real.log (p : ℝ))).norm.pow 2 + calc + _ ≤ ∫ t in ((k : ℝ) - 1 / 2)..((k : ℝ) + 1 / 2), + (2 * (1 + (k : ℝ) ^ 2)⁻¹) * ‖D t‖ ^ 2 := by + apply intervalIntegral.integral_mono_on (by linarith) hi.intervalIntegrable + ((hc.const_mul _).intervalIntegrable _ _) + intro t ht + simpa only [D, Pi.pow_apply, mul_comm] using mul_le_mul_of_nonneg_left + (halasz_cauchy_weight_window ht) (sq_nonneg ‖D t‖) + _ = (2 * (1 + (k : ℝ) ^ 2)⁻¹) * + ∫ t in ((k : ℝ) - 1 / 2)..((k : ℝ) + 1 / 2), ‖D t‖ ^ 2 := + intervalIntegral.integral_const_mul _ _ + _ ≤ (2 * (1 + (k : ℝ) ^ 2)⁻¹) * (C * M) := + mul_le_mul_of_nonneg_left (hm P hP a k) (by positivity) + _ = _ := by ring + have hsum := hs.summable.tsum_le_tsum hb (halasz_cauchy_integer_summable.mul_left (2 * C * M)) + rw [hs.tsum_eq, tsum_mul_left] at hsum + change _ ≤ _ + change _ ≤ C * (1 + 2 * W) * M + change _ ≤ 2 * C * M * W at hsum + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCauchySchwarz.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCauchySchwarz.lean new file mode 100644 index 0000000000000000000000000000000000000000..776b1b872eeaf67f7053237888281e0fbc4e3243 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCauchySchwarz.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCauchyMeanSquare +import Mathlib.MeasureTheory.Function.L2Space + +namespace OAI + +/-! The finite-interval Cauchy--Schwarz step of the triple convolution. +One factor keeps its unweighted prime mean square; the second uses the +Cauchy weight from Perron's kernel. -/ + +namespace TwoPointCorrelations + +open MeasureTheory + +lemma halasz_integral_cauchy_schwarz {a b : ℝ} (hab : a ≤ b) (f g : ℝ → ℝ) + (hf : Continuous f) (hg : Continuous g) (hf0 : ∀ t, 0 ≤ f t) (hg0 : ∀ t, 0 ≤ g t) : + (∫ t in a..b, f t * g t) ≤ + Real.sqrt (∫ t in a..b, f t ^ 2) * Real.sqrt (∫ t in a..b, g t ^ 2) := by + let μ := volume.restrict (Set.Ioc a b) + have hfm : AEStronglyMeasurable f μ := hf.aestronglyMeasurable + have hgm : AEStronglyMeasurable g μ := hg.aestronglyMeasurable + have hfs : Integrable (fun t => f t ^ 2) μ := + ((hf.pow 2).continuousOn.integrableOn_Icc).mono_set Set.Ioc_subset_Icc_self + have hgs : Integrable (fun t => g t ^ 2) μ := + ((hg.pow 2).continuousOn.integrableOn_Icc).mono_set Set.Ioc_subset_Icc_self + have hfl : MemLp f 2 μ := (memLp_two_iff_integrable_sq hfm).mpr hfs + have hgl : MemLp g 2 μ := (memLp_two_iff_integrable_sq hgm).mpr hgs + have h := integral_mul_le_Lp_mul_Lq_of_nonneg Real.HolderConjugate.two_two + (Filter.Eventually.of_forall hf0) (Filter.Eventually.of_forall hg0) + (by simpa using hfl) (by simpa using hgl) + simp only [Real.rpow_two, ← Real.sqrt_eq_rpow] at h + simpa only [intervalIntegral.integral_of_le hab, μ] using h + +lemma halasz_weighted_integral_cauchy_schwarz {a b : ℝ} (hab : a ≤ b) + (P Q : ℝ → ℂ) (hP : Continuous P) (hQ : Continuous Q) : + (∫ t in a..b, ‖P t‖ * ‖Q t‖ / Real.sqrt (1 + t ^ 2)) ≤ + Real.sqrt (∫ t in a..b, ‖P t‖ ^ 2) * + Real.sqrt (∫ t in a..b, ‖Q t‖ ^ 2 * (1 + t ^ 2)⁻¹) := by + have hg : Continuous (fun t => ‖Q t‖ / Real.sqrt (1 + t ^ 2)) := by + exact hQ.norm.div ((continuous_const.add (continuous_id.pow 2)).sqrt) + (fun t => ne_of_gt (Real.sqrt_pos.mpr (by positivity))) + have h := halasz_integral_cauchy_schwarz hab (fun t => ‖P t‖) + (fun t => ‖Q t‖ / Real.sqrt (1 + t ^ 2)) hP.norm hg (fun _ => norm_nonneg _) + (fun _ => div_nonneg (norm_nonneg _) (Real.sqrt_nonneg _)) + have he (t : ℝ) : (‖Q t‖ / Real.sqrt (1 + t ^ 2)) ^ 2 = + ‖Q t‖ ^ 2 * (1 + t ^ 2)⁻¹ := by + rw [div_pow, Real.sq_sqrt (by positivity)] + rfl + simp_rw [he] at h + simpa only [mul_div_assoc] using h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCenteredEnergy.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCenteredEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..add1e3b45591a1c6bf1a9140c515b1267523e1e4 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCenteredEnergy.lean @@ -0,0 +1,128 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszNearScales +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTypicalNearEnergy + +namespace OAI + +/-! The near-frequency energy estimate, with the distance +hypotheses at the original cutoff and the actual typical-set error. -/ + +namespace TwoPointCorrelations + +open Finset Filter MeasureTheory +open scoped Classical + +lemma halasz_log_error_square (L : ℝ) (hL : 1 ≤ L) : + (Real.log L / L) ^ 2 ≤ 2 * L ^ (-1 / (16 : ℝ)) := by + have hL0 : 0 < L := by linarith + have hh := log_sq_le_two_mul L hL + have hr : 1 / L ≤ L ^ (-1 / (16 : ℝ)) := by + simpa only [Real.rpow_neg_one, one_div] using + Real.rpow_le_rpow_of_exponent_le hL (by norm_num : (-1 : ℝ) ≤ -1 / 16) + calc + _ = Real.log L ^ 2 / L ^ 2 := div_pow _ _ _ + _ ≤ (2 * L) / L ^ 2 := div_le_div_of_nonneg_right hh (sq_nonneg L) + _ = 2 * (1 / L) := by field_simp + _ ≤ _ := mul_le_mul_of_nonneg_left hr (by norm_num) + +theorem halasz_centered_typical_energy : ∃ C : ℝ, 0 < C ∧ + ∀ᶠ N : ℕ in atTop, ∀ X : ℕ, N ≤ 2 * X → X ≤ N ^ 3 → + ∀ (F : ℕ → ℂ), F 1 = 1 → Multiplicative F → OneBounded F → + ∀ (t T M : ℝ), 0 ≤ M → |t| + Real.log (2 * N : ℕ) ^ 8 ≤ T → + (∀ v : ℝ, |v| ≤ T → M ≤ squaredDistance F (mrtArchimedeanTwist v) X) → + squaredDistance F (mrtArchimedeanTwist t) X ≤ Real.log (Real.log X) / 10 → + ∀ {ι : Type} (J : Finset ι) (P : ι → Finset ℕ), + (∫ u in -((Real.log N) ^ (1 / (16 : ℝ)))..((Real.log N) ^ (1 / (16 : ℝ))), + ‖mrtDyadicPolynomial (mrtTypicalCoefficient J P F) N (t + u)‖ ^ 2) ≤ + 48 * Real.exp 1 * + (((Ioc N (2 * N)).filter (fun n => ¬mrtTypical J P n)).card : ℝ) / N + + C * (Real.exp (-M) + (Real.log N) ^ (-1 / (16 : ℝ))) := by + obtain ⟨C₀, hC₀, hcenter⟩ := halasz_centered_prefix + let D : ℝ := 36 * (halaszPrimePowerLogConstant + 1) * Real.exp 8 + let C : ℝ := 400 * Real.pi * C₀ ^ 2 + 200 * D ^ 2 + have hD : 0 < D := by dsimp [D, halaszPrimePowerLogConstant]; positivity + have hC : 0 < C := by dsimp [C]; positivity + refine ⟨C, hC, ?_⟩ + have hL : ∀ᶠ N : ℕ in atTop, 1 ≤ Real.log (N : ℝ) := + (Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop).eventually (eventually_ge_atTop 1) + filter_upwards [hcenter, halasz_near_prefix_uniform, hL, eventually_ge_atTop 2] + with N hcenter hnear hLN hN2 + intro X hNX hXN F hF1 hFm hFb t T M hM hT hd hsmall ι J P + let G := halaszTwistedFunction F t + let L := Real.log (N : ℝ) + let R := Real.log L / L + let U := L ^ (1 / (16 : ℝ)) + let A := C₀ * (Real.exp (-M / 2) + R) + let E := D * L ^ (-1 / (16 : ℝ)) + have hL0 : 0 < L := by dsimp [L]; linarith + have hR : 0 ≤ R := div_nonneg (Real.log_nonneg hLN) hL0.le + have hA : 0 ≤ A := by dsimp [A]; positivity + have hE : 0 ≤ E := by dsimp [E]; positivity + have hU : 0 < U := Real.rpow_pos_of_pos hL0 _ + have hUN : U ≤ (N : ℝ) := by + calc + U ≤ L := Real.rpow_le_self_of_one_le hLN (by norm_num) + _ ≤ (N : ℝ) := by + have hh := Real.log_le_sub_one_of_pos (show 0 < (N : ℝ) by exact_mod_cast (show 0 < N by omega)) + dsimp [L] + linarith + have hc : ∀ k ∈ Icc N (2 * N), ‖halaszPhaseMean G 0 k‖ ≤ A * k := + hcenter X hNX hXN F hF1 hFm hFb t T M hM hT hd + have hn : ∀ u ∈ Set.Icc (-U) U, ∀ k ∈ Icc N (2 * N), + ‖halaszPhaseMean G u k - + (halaszPowerPhase u k / (1 + (-u : ℂ) * Complex.I)) * halaszPhaseMean G 0 k‖ ≤ E * k := by + intro u hu k hk + exact hnear X hNX hXN F hF1 hFm hFb t hsmall u (abs_le.mpr hu) k hk + have hh := halasz_typical_near_energy J P G (halasz_twisted_oneBounded F hFb t) + (by omega : 0 < N) A E U hA hE hU hc hn + have hpoly (u : ℝ) : mrtDyadicPolynomial (mrtTypicalCoefficient J P G) N u = + mrtDyadicPolynomial (mrtTypicalCoefficient J P F) N (t + u) := by + dsimp [G] + rw [halasz_typical_twist, halasz_twisted_dyadic] + simp_rw [hpoly] at hh + have hmain : 100 * Real.pi * A ^ 2 + 200 * U * E ^ 2 ≤ + C * (Real.exp (-M) + L ^ (-1 / (16 : ℝ))) := by + have hexp : Real.exp (-M / 2) ^ 2 = Real.exp (-M) := by + rw [pow_two, ← Real.exp_add] + congr 1 + ring + have hs := halasz_log_error_square L hLN + have hsum : (Real.exp (-M / 2) + R) ^ 2 ≤ + 2 * (Real.exp (-M) + 2 * L ^ (-1 / (16 : ℝ))) := by + change (Real.exp (-M / 2) + Real.log L / L) ^ 2 ≤ _ + nlinarith [sq_nonneg (Real.exp (-M / 2) - Real.log L / L)] + have he : U * E ^ 2 = D ^ 2 * L ^ (-1 / (16 : ℝ)) := by + have hp : L ^ (1 / (16 : ℝ)) * L ^ (-1 / (16 : ℝ)) = 1 := by + rw [← Real.rpow_add hL0] + norm_num + dsimp [U, E] + calc + _ = D ^ 2 * (L ^ (1 / (16 : ℝ)) * L ^ (-1 / (16 : ℝ))) * L ^ (-1 / (16 : ℝ)) := by ring + _ = _ := by rw [hp]; ring + rw [mul_assoc (200 : ℝ) U (E ^ 2), he] + have hm := mul_le_mul_of_nonneg_left hsum + (show 0 ≤ 100 * Real.pi * C₀ ^ 2 by positivity) + dsimp [A, C] + nlinarith [mul_nonneg (sq_nonneg D) (Real.exp_pos (-M)).le, + mul_nonneg (mul_nonneg Real.pi_pos.le (sq_nonneg C₀)) (Real.exp_pos (-M)).le] + apply hh.trans + have hNr : 0 < (N : ℝ) := by exact_mod_cast (show 0 < N by omega) + have hratio : U / (N : ℝ) ≤ 1 := (div_le_one hNr).mpr hUN + have hbad : 0 ≤ (((Ioc N (2 * N)).filter (fun n => ¬mrtTypical J P n)).card : ℝ) := by positivity + have hexc : 16 * Real.exp 1 * (U / N + 2) * + (((Ioc N (2 * N)).filter (fun n => ¬mrtTypical J P n)).card : ℝ) / N ≤ + 48 * Real.exp 1 * (((Ioc N (2 * N)).filter (fun n => ¬mrtTypical J P n)).card : ℝ) / N := by + calc + _ ≤ 16 * Real.exp 1 * 3 * + (((Ioc N (2 * N)).filter (fun n => ¬mrtTypical J P n)).card : ℝ) / N := by + gcongr + linarith + _ = _ := by ring + calc + _ = 16 * Real.exp 1 * (U / N + 2) * + (((Ioc N (2 * N)).filter (fun n => ¬mrtTypical J P n)).card : ℝ) / N + + (100 * Real.pi * A ^ 2 + 200 * U * E ^ 2) := by ring + _ ≤ _ := add_le_add hexc hmain + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCenteredPrefix.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCenteredPrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..b37cdc4fb493ecec67784d3d4841715c1aeb9971 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCenteredPrefix.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPhaseTranslation +import Mathlib.Analysis.SpecialFunctions.Log.Monotone + +namespace OAI + +/-! Centered prefix cancellation from the proved general Halasz theorem. +The lower bound on distance stays at the original large cutoff. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped ComplexConjugate + +lemma halasz_distance_monotone (F : ℕ → ℂ) (hF : OneBounded F) (t : ℝ) : + Monotone (fun N => squaredDistance F (mrtArchimedeanTwist t) N) := by + intro n N hnN + unfold squaredDistance + apply sum_le_sum_of_subset_of_nonneg (halasz_prime_cutoff_subset hnN) + intro p hp _ + have hp0 := (mem_filter.mp hp).2.pos + have hn : ‖F p * conj (mrtArchimedeanTwist t p)‖ ≤ 1 := by + simpa only [norm_mul, Complex.norm_conj, mrtArchimedeanTwist_norm, mul_one] using hF p hp0 + exact div_nonneg (sub_nonneg.mpr ((Complex.re_le_norm _).trans hn)) (Nat.cast_nonneg p) + +lemma halasz_decay_half (M : ℝ) : + (M + 1) * Real.exp (-M) ≤ 2 * Real.exp (-M / 2) := by + have hh := Real.add_one_le_exp (M / 2) + have hm := mul_le_mul_of_nonneg_right hh (Real.exp_pos (-M)).le + have he : Real.exp (M / 2) * Real.exp (-M) = Real.exp (-M / 2) := by + rw [← Real.exp_add] + congr 1 + ring + rw [he] at hm + nlinarith [Real.exp_pos (-M)] + +/-- Uniform centered prefixes on a dyadic interval. The pretentious +lower bound is imposed only at the original cutoff X, not at smaller +scales or on a modified multiplicative function. -/ +theorem halasz_centered_prefix : ∃ C : ℝ, 0 < C ∧ + ∀ᶠ N : ℕ in atTop, ∀ X : ℕ, N ≤ 2 * X → X ≤ N ^ 3 → + ∀ (F : ℕ → ℂ), F 1 = 1 → Multiplicative F → OneBounded F → + ∀ (t T M : ℝ), 0 ≤ M → |t| + Real.log (2 * N : ℕ) ^ 8 ≤ T → + (∀ v : ℝ, |v| ≤ T → M ≤ squaredDistance F (mrtArchimedeanTwist v) X) → + ∀ k ∈ Icc N (2 * N), + ‖halaszPhaseMean (halaszTwistedFunction F t) 0 k‖ ≤ + C * (Real.exp (-M / 2) + Real.log (Real.log N) / Real.log N) * k := by + obtain ⟨C, X₀, hC, hmean⟩ := halasz_general_twisted_mean + obtain ⟨K, hK, hcut⟩ := halasz_distance_cutoff_loss + let D := 2 * C * Real.exp K + C + refine ⟨D, by dsimp [D]; positivity, ?_⟩ + have hNX : ∀ᶠ N : ℕ in atTop, X₀ ≤ (N : ℝ) := + tendsto_natCast_atTop_atTop.eventually (eventually_ge_atTop X₀) + have hNL : ∀ᶠ N : ℕ in atTop, Real.exp 1 ≤ Real.log (N : ℝ) := + (Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop).eventually + (eventually_ge_atTop (Real.exp 1)) + filter_upwards [hNX, hNL, eventually_ge_atTop 2] with N hNX hNL hN2 + intro X _hNX₂ hXN F hF1 hFm hFb t T M hM hT hdist k hk + have hNk : N ≤ k := (mem_Icc.mp hk).1 + have hk₂ : k ≤ 2 * N := (mem_Icc.mp hk).2 + have hk2 : 2 ≤ k := hN2.trans hNk + have hXk : X ≤ k ^ 3 := hXN.trans (by gcongr) + have hlogk : Real.log (N : ℝ) ≤ Real.log k := Real.log_le_log + (by exact_mod_cast (show 0 < N by omega)) (by exact_mod_cast hNk) + have hlog2k : Real.log (k : ℝ) ≤ Real.log (2 * N : ℕ) := Real.log_le_log + (by exact_mod_cast (show 0 < k by omega)) (by exact_mod_cast hk₂) + have hl0 : 0 ≤ Real.log (k : ℝ) := (Real.exp_pos 1).le.trans (hNL.trans hlogk) + have hheight : |t| + Real.log (k : ℝ) ^ 8 ≤ T := by + have hp := pow_le_pow_left₀ hl0 hlog2k 8 + linarith + let M' := max 0 (M - K) + have hd : ∀ v : ℝ, |v| ≤ T → M' ≤ squaredDistance F (mrtArchimedeanTwist v) k := by + intro v hv + apply max_le + · exact halasz_distance_nonneg F hFb k v + · have hd := hdist v hv + by_cases hkX : k ≤ X + · have hh := hcut F hFb k X hk2 hkX hXk v + linarith + · have hh := halasz_distance_monotone F hFb v (by omega : X ≤ k) + linarith + have hm := hmean k (hNX.trans (by exact_mod_cast hNk)) F hF1 hFm hFb + t T M' (le_max_left _ _) hheight hd + have he := (halasz_decay_shift hM hK).trans + (mul_le_mul_of_nonneg_left (halasz_decay_half M) (Real.exp_pos K).le) + have hR := Real.log_div_self_antitoneOn hNL (hNL.trans hlogk) hlogk + have hRN : 0 ≤ Real.log (Real.log (N : ℝ)) / Real.log N := by + apply div_nonneg + · apply Real.log_nonneg + exact (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hNL + · exact (Real.exp_pos 1).le.trans hNL + have hk0 : 0 ≤ (k : ℝ) := Nat.cast_nonneg k + have hbound : ((M' + 1) * Real.exp (-M') + Real.log (Real.log k) / Real.log k) ≤ + 2 * Real.exp K * Real.exp (-M / 2) + Real.log (Real.log N) / Real.log N := by + dsimp [M'] + nlinarith + have hp := mul_le_mul_of_nonneg_left hbound (mul_nonneg hC.le hk0) + have hf : ‖halaszPhaseMean (halaszTwistedFunction F t) 0 k‖ = + ‖∑ n ∈ Icc 1 k, F n * star (mrtArchimedeanTwist t n)‖ := by + simp [halaszPhaseMean, halaszPowerPhase, halaszTwistedFunction] + rw [hf] + apply hm.trans + apply hp.trans + have hfinal : C * (2 * Real.exp K * Real.exp (-M / 2) + + Real.log (Real.log N) / Real.log N) ≤ + D * (Real.exp (-M / 2) + Real.log (Real.log N) / Real.log N) := by + dsimp [D] + nlinarith [mul_nonneg hC.le (Real.exp_pos (-M / 2)).le, + mul_nonneg (mul_nonneg hC.le (Real.exp_pos K).le) hRN] + calc + _ = (C * (2 * Real.exp K * Real.exp (-M / 2) + + Real.log (Real.log N) / Real.log N)) * k := by ring + _ ≤ _ := mul_le_mul_of_nonneg_right hfinal hk0 + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCircleWindow.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCircleWindow.lean new file mode 100644 index 0000000000000000000000000000000000000000..be050d69144ac6a52b066a651268c07e4bc96571 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCircleWindow.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTorusBessel +import Mathlib.MeasureTheory.Group.AddCircle + +namespace OAI + +/-! A compact circle window with a lower bound for its small Fourier +coefficients. This supplies the localizer for the double moment estimate. -/ +namespace TwoPointCorrelations + +open MeasureTheory Metric Set +open scoped ComplexConjugate + +local instance : Fact (0<(1:ℝ)) := ⟨by norm_num⟩ + +noncomputable def halaszCircleWindow (δ : ℝ) (x : AddCircle (1:ℝ)) : ℂ := + (closedBall 0 δ).indicator (fun _ => 1) x + +lemma halasz_circle_window_memLp (δ : ℝ) : + MemLp (halaszCircleWindow δ) 2 AddCircle.haarAddCircle := + (memLp_const (1:ℂ)).indicator measurableSet_closedBall + +lemma halasz_circle_window_volume {δ : ℝ} (hδ : 0≤δ) (hδhalf : δ≤1/2) : + AddCircle.haarAddCircle.real (closedBall (0:AddCircle (1:ℝ)) δ)=2*δ := by + have hμ : (volume : Measure (AddCircle (1:ℝ)))=AddCircle.haarAddCircle := by + simpa using (AddCircle.volume_eq_smul_haarAddCircle (T := (1:ℝ))) + rw [← hμ,measureReal_def,AddCircle.volume_closedBall, + min_eq_right (by linarith : 2*δ≤1),ENNReal.toReal_ofReal (by positivity)] + +lemma halasz_circle_character_re {δ : ℝ} {n : ℤ} + (hphase : 2*Real.pi*|(n:ℝ)| * δ≤1) (x : AddCircle (1:ℝ)) (hx : x∈closedBall 0 δ) : + (1/2:ℝ)≤(fourier n x).re := by + let y := AddCircle.equivIoc (1:ℝ) (-(1/2:ℝ)) x + have hy : -(1/2:ℝ)<(y:ℝ) ∧ (y:ℝ)≤1/2 := by + have hh := y.property + change -(1/2:ℝ)<(y:ℝ) ∧ (y:ℝ)≤-(1/2:ℝ)+1 at hh + constructor <;> linarith [hh.1,hh.2] + have hyx : ((y:ℝ):AddCircle (1:ℝ))=x := AddCircle.coe_equivIoc + have hn : ‖x‖=|(y:ℝ)| := by + rw [← hyx] + exact (AddCircle.norm_coe_eq_abs_iff (1:ℝ) (by norm_num)).mpr + (by simpa using abs_le.mpr ⟨hy.1.le,hy.2⟩) + have hyδ : |(y:ℝ)|≤δ := by + simpa only [mem_closedBall,dist_zero_right,hn] using hx + have ha : |2*Real.pi*(n:ℝ)*(y:ℝ)|≤1 := by + rw [abs_mul,abs_mul,abs_of_pos (by positivity : 0<2*Real.pi)] + exact (mul_le_mul_of_nonneg_left hyδ (by positivity)).trans hphase + have hs : (2*Real.pi*(n:ℝ)*(y:ℝ))^2≤1 := by + nlinarith [(abs_le.mp ha).1,(abs_le.mp ha).2] + have hc := Real.one_sub_sq_div_two_le_cos (x := 2*Real.pi*(n:ℝ)*(y:ℝ)) + rw [← hyx,fourier_coe_apply] + have he : (Complex.exp (2*↑Real.pi*Complex.I*(n:ℂ)*(y:ℂ)/(1:ℂ))).re = + Real.cos (2*Real.pi*(n:ℝ)*(y:ℝ)) := by + rw [show 2*↑Real.pi*Complex.I*(n:ℂ)*(y:ℂ)/(1:ℂ)= + ((2*Real.pi*(n:ℝ)*(y:ℝ):ℝ):ℂ)*Complex.I by push_cast; ring] + exact Complex.exp_ofReal_mul_I_re _ + norm_num only [Complex.ofReal_one] at * + rw [he] + linarith + +/-- The small Fourier coefficients of the indicator window cannot cancel. -/ +theorem halasz_circle_window_coefficient {δ : ℝ} {n : ℤ} + (hδ : 0≤δ) (hδhalf : δ≤1/2) (hphase : 2*Real.pi*|(n:ℝ)| * δ≤1) : + δ≤‖∫ x : AddCircle (1:ℝ), conj (fourier n x)*halaszCircleWindow δ x + ∂AddCircle.haarAddCircle‖ := by + have hi : IntegrableOn (fun x : AddCircle (1:ℝ) => conj (fourier n x)) + (closedBall 0 δ) AddCircle.haarAddCircle := by + exact ((Complex.continuous_conj.comp (fourier n).continuous).integrable_of_hasCompactSupport + (HasCompactSupport.of_compactSpace _)).integrableOn + have heq : (∫ x : AddCircle (1:ℝ), conj (fourier n x)*halaszCircleWindow δ x + ∂AddCircle.haarAddCircle) = + ∫ x in closedBall (0:AddCircle (1:ℝ)) δ, conj (fourier n x) + ∂AddCircle.haarAddCircle := by + rw [← integral_indicator measurableSet_closedBall] + apply integral_congr_ae + filter_upwards [] with x + by_cases hx : x∈closedBall (0:AddCircle (1:ℝ)) δ <;> + simp [halaszCircleWindow,hx] + rw [heq] + apply le_trans _ (Complex.re_le_norm _) + change δ≤RCLike.re (∫ x in closedBall (0:AddCircle (1:ℝ)) δ, + conj (fourier n x) ∂AddCircle.haarAddCircle) + rw [← integral_re hi] + have hh := setIntegral_mono_on (integrableOn_const (C := (1/2:ℝ))) hi.re + measurableSet_closedBall (fun x hx => by + change (1/2:ℝ)≤(conj (fourier n x)).re + simpa only [Complex.conj_re] using halasz_circle_character_re hphase x hx) + rw [setIntegral_const,smul_eq_mul,halasz_circle_window_volume hδ hδhalf] at hh + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszClassicalDefect.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszClassicalDefect.lean new file mode 100644 index 0000000000000000000000000000000000000000..48b2b982f6670ba02767460c03d61e746ab8f5f7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszClassicalDefect.lean @@ -0,0 +1,104 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszNormalizedStep + +namespace OAI + +/-! The geometric defect in the classical Vinogradov iteration. -/ +namespace TwoPointCorrelations + +def halaszTriangularDegree (k : ℕ) : ℕ := k*(k-1)/2 + +def halaszTotalDegree (k : ℕ) : ℕ := k+halaszTriangularDegree k + +noncomputable def halaszClassicalDefect (k n : ℕ) : ℝ := + (halaszTriangularDegree k:ℝ)*(1-1/(k:ℝ))^n + +noncomputable def halaszClassicalExponent (k n : ℕ) : ℝ := + 2*(((n+1)*k:ℕ):ℝ)-(halaszTotalDegree k:ℝ)+halaszClassicalDefect k n + +lemma halasz_triangular_degree_cast {k : ℕ} (hk : 0 linarith [one_div_pos.mpr hk0] + +lemma halasz_classical_defect_bounds {k : ℕ} (hk : 0 exact (halasz_classical_exponent_zero k).ge + | succ n ih => + rw [halasz_classical_exponent_successor] + linarith [hd n] + · have hh := (halasz_classical_defect_bounds hk n).2 + simp only [halaszClassicalExponent,halaszTotalDegree,Nat.cast_add, + halaszStepExponent,Nat.cast_mul,Nat.cast_ofNat,Nat.cast_one] + change 2*(((n:ℝ)+1)*k)-((k:ℝ)+(halaszTriangularDegree k:ℝ))+ + halaszClassicalDefect k n ≤ 2*(((n:ℝ)+1)*k)+(halaszTriangularDegree k:ℝ) + linarith [show (0:ℝ)≤(halaszTriangularDegree k:ℝ) from Nat.cast_nonneg _] + +lemma halasz_classical_exponent_normalization {k : ℕ} (hk : 0 + intro N hN + simp only [Nat.zero_add,one_mul,halasz_classical_exponent_zero, + Real.rpow_natCast,halasz_iteration_constant_zero] + have hf := (halasz_iteration_base_bounds R₀ k).2.1 + have hnat : halaszVinogradovCount k k N≤halaszIterationBase R₀ k*N^k := by + calc + _ ≤ N^k*k.factorial := halasz_vinogradov_diagonal_bound (N := N) (le_refl k) + _ ≤ N^k*halaszIterationBase R₀ k := Nat.mul_le_mul_left _ hf + _ = _ := Nat.mul_comm _ _ + exact_mod_cast hnat + | succ n ih => + intro N hN + by_cases hsmall : N≤halaszIterationThreshold R₀ k + · have hd := (halasz_classical_defect_bounds hk0 (n+1)).1 + have he : ((2*((n+1+1)*k):ℕ):ℝ)≤ + halaszClassicalExponent k (n+1)+(halaszTotalDegree k:ℝ) := by + unfold halaszClassicalExponent + push_cast + linarith + have hh := halasz_small_moment (s := (n+1+1)*k) (k := k) + (K := halaszTotalDegree k) hN hsmall he + have hB : (halaszIterationThreshold R₀ k)^(halaszTotalDegree k)≤ + halaszIterationConstant R₀ k (n+1) := + (halasz_iteration_base_bounds R₀ k).2.2.1.trans + (halasz_iteration_constant_ge_base R₀ k (n+1)) + exact hh.trans (mul_le_mul_of_nonneg_right (by exact_mod_cast hB) + (Real.rpow_nonneg (Nat.cast_nonneg _) _)) + · have hlarge : halaszIterationThreshold R₀ k c * ArithmeticFunction.vonMangoldt a), + ← mul_sum, ArithmeticFunction.vonMangoldt_sum] + +lemma halasz_triple_coefficient_bound (a b f : ℕ → ℂ) {c : ℝ} (hc : 0 ≤ c) + (ha : ∀ n, ‖a n‖ ≤ c * ArithmeticFunction.vonMangoldt n) + (hb : ∀ n, ‖b n‖ ≤ ArithmeticFunction.vonMangoldt n) (hf : OneBounded f) (n : ℕ) : + ‖(a ⍟ (b ⍟ f)) n‖ ≤ c * (Real.log (n : ℝ)) ^ 2 := by + by_cases hn : n = 0 + · subst n + simp + have hnpos : 0 < n := Nat.pos_of_ne_zero hn + have hlogn : 0 ≤ Real.log (n : ℝ) := Real.log_nonneg (by exact_mod_cast hnpos) + have hinner (m : ℕ) : ‖(b ⍟ f) m‖ ≤ Real.log (m : ℝ) := by + simpa only [one_mul] using halasz_mangoldt_convolution_bound b f (c := 1) + (by norm_num) (fun n => by simpa using hb n) hf m + rw [LSeries.convolution_def] + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ p ∈ n.divisorsAntidiagonal, + c * ArithmeticFunction.vonMangoldt p.1 * Real.log (n : ℝ) := by + apply sum_le_sum + intro p hp + have hpmul := (Nat.mem_divisorsAntidiagonal.mp hp).1 + have hp0 := Nat.ne_zero_of_mem_divisorsAntidiagonal hp + have hp2pos := Nat.pos_of_ne_zero hp0.2 + have hp2le : p.2 ≤ n := by + rw [← hpmul] + exact Nat.le_mul_of_pos_left _ (Nat.pos_of_ne_zero hp0.1) + have hlog : Real.log (p.2 : ℝ) ≤ Real.log (n : ℝ) := + Real.log_le_log (by exact_mod_cast hp2pos) (by exact_mod_cast hp2le) + rw [norm_mul] + exact (mul_le_mul (ha p.1) (hinner p.2) (norm_nonneg _) + (mul_nonneg hc ArithmeticFunction.vonMangoldt_nonneg)).trans + (mul_le_mul_of_nonneg_left hlog (mul_nonneg hc ArithmeticFunction.vonMangoldt_nonneg)) + _ = c * Real.log (n : ℝ) ^ 2 := by + rw [Nat.sum_divisorsAntidiagonal + (fun a _ => c * ArithmeticFunction.vonMangoldt a * Real.log (n : ℝ)), + ← sum_mul, ← mul_sum, ArithmeticFunction.vonMangoldt_sum] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCofactorBandCount.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCofactorBandCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..da5e8e6f2a2cb8754c22c23d7e7002607c63f142 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCofactorBandCount.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszModerateCofactor + +namespace OAI + +/-! The actual original prime bands fit the cofactor inclusion-exclusion +budget even when their cutoff is specified at the original scale. -/ +namespace TwoPointCorrelations + +open Filter Finset + +theorem halasz_cofactor_band_count : + ∀ᶠ n : ℕ in atTop, ∀ X : ℕ, n ≤ X → X ≤ n^3 → + ∀ (Q : ℝ) (J : ℕ), 1 ≤ Real.log Q → + mrtBandUpper Q J ≤ Real.exp (Real.sqrt (Real.log X)) → + (2:ℝ)^(Icc 1 J).card ≤ (Real.log n)^(1/1000:ℝ) := by + have hlog : Tendsto (fun n:ℕ => Real.log n) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + filter_upwards [hlog.eventually halasz_band_power_cost,eventually_ge_atTop 2] + with n hcost hn + intro X hnX hX Q J hQ hband + have hn0 : 0 < (n:ℝ) := by exact_mod_cast (show 0 mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) N a t‖ ≤ + (Real.log n)^(-1/40:ℝ) := by + obtain ⟨X₀,hcofactor⟩ := halasz_moderate_cofactor + refine ⟨X₀,?_⟩ + filter_upwards [hcofactor,halasz_cofactor_band_count] with n hcofactor hcount + intro N a ha hbase hn X hnX hX F hF1 hFm hFb P Q J hQ hband A hA t τ hmin ht hmod haway + exact hcofactor N a ha hbase hn X hnX hX F hF1 hFm hFb ℕ (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) A + (fun _ _ _ hp => mrtPrimeBand_prime hp) hA (hcount X hnX hX Q J hQ hband) + t τ hmin ht hmod haway + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCofactorScale.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCofactorScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..c9680b7e365cc1ff681ec4ea7aae87a19ff519bc --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCofactorScale.lean @@ -0,0 +1,118 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszOffCenterCofactor +import OAI.NumberTheory.TwoPoint.Halasz.HalaszSparseCost + +namespace OAI + +/-! The cutoffs of extra-prime cofactors stay at the original logarithmic +scale. These bounds include the floors used in the actual polynomials. -/ +namespace TwoPointCorrelations + +open Filter + +theorem halasz_cofactor_floor_scale (X₀ : ℝ) (n₀ : ℕ) : + ∀ᶠ N : ℕ in atTop, ∀ a : ℝ, 1 ≤ a → + a ≤ Real.exp (Real.log N/Real.log (Real.log N)) → + let m := ⌊(N:ℝ)/a⌋₊ + let n := ⌊(2*N:ℝ)/a⌋₊ + X₀ ≤ (m:ℝ) ∧ n₀ ≤ n ∧ n ≤ 2*N ∧ 2*N ≤ n^3 ∧ + Real.log N/2 ≤ Real.log (n:ℝ) ∧ Real.log (n:ℝ) ≤ 2*Real.log N ∧ + Real.log (n:ℝ)^8 ≤ N := by + have hlog : Tendsto (fun N:ℕ => Real.log N) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + have hb := (isLittleO_pow_exp_pos_mul_atTop 8 (b := 1) (by norm_num)).bound + (show (0:ℝ)<1/256 by norm_num) + filter_upwards [hlog.eventually hb, + hlog.eventually (eventually_ge_atTop (10+2*|X₀|+2*(n₀:ℝ))), + (Real.tendsto_log_atTop.comp hlog).eventually (eventually_ge_atTop (1000:ℝ)), + eventually_ge_atTop 2] with N hb hL hLL hN + intro a ha haU + let L := Real.log (N:ℝ) + let m := ⌊(N:ℝ)/a⌋₊ + let n := ⌊(2*N:ℝ)/a⌋₊ + have hL0 : 0 < L := by dsimp [L]; nlinarith [abs_nonneg X₀,Nat.cast_nonneg (α:=ℝ) n₀] + have hN0 : 0 < (N:ℝ) := by exact_mod_cast (show 0 nlinarith [abs_nonneg X₀,Nat.cast_nonneg (α:=ℝ) n₀] + have hx : 2 ≤ (N:ℝ)/a := hbig.2.2.trans hlen + have hmX : X₀ ≤ (m:ℝ) := by + have hf := Nat.lt_floor_add_one ((N:ℝ)/a) + change (N:ℝ)/a < (m:ℝ)+1 at hf + linarith [hbig.1.trans hlen] + have hnlow : (N:ℝ)/a ≤ (n:ℝ) := by + have hf := Nat.lt_floor_add_one ((2*N:ℝ)/a) + change (2*N:ℝ)/a < (n:ℝ)+1 at hf + have he : (2*N:ℝ)/a=2*((N:ℝ)/a) := by ring + rw [he] at hf + linarith [abs_nonneg X₀,Nat.cast_nonneg (α:=ℝ) n₀] + have hnscale := hlen.trans hnlow + have hnlarge : n₀ ≤ n := by exact_mod_cast hbig.2.1.trans hnscale + have hnupper : n ≤ 2*N := by + apply Nat.floor_le_of_le + simpa only [Nat.cast_mul,Nat.cast_ofNat] using + div_le_self (show (0:ℝ) ≤ 2*N by positivity) ha + have hn0 : 0 < (n:ℝ) := (Real.exp_pos _).trans_le hnscale + have hloglow : (999/1000:ℝ)*L ≤ Real.log (n:ℝ) := by + simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos _) hnscale + have hlogupper : Real.log (n:ℝ) ≤ 2*L := by + have hh := Real.log_le_log hn0 + (show (n:ℝ) ≤ 2*(N:ℝ) by exact_mod_cast hnupper) + rw [Real.log_mul (by norm_num : (2:ℝ)≠0) hN0.ne'] at hh + have htwo := Real.log_le_sub_one_of_pos (show (0:ℝ)<2 by norm_num) + dsimp [L] + linarith [abs_nonneg X₀,Nat.cast_nonneg (α:=ℝ) n₀] + have hncube : 2*N ≤ n^3 := by + have hN2 : (2:ℝ) ≤ N := by exact_mod_cast hN + have hpow := pow_le_pow_left₀ (Real.exp_pos ((999/1000:ℝ)*L)).le hnscale 3 + have hNexp : (N:ℝ)^2=Real.exp (2*L) := by + rw [show 2*L=L+L by ring,Real.exp_add,Real.exp_log hN0] + ring + have hexp : Real.exp (2*L) ≤ (Real.exp ((999/1000:ℝ)*L))^3 := by + rw [← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + norm_num + nlinarith + have hh : 2*(N:ℝ) ≤ (n:ℝ)^3 := by nlinarith + exact_mod_cast hh + have hwidth : Real.log (n:ℝ)^8 ≤ N := by + have hnlog0 : 0 ≤ Real.log (n:ℝ) := by nlinarith + have hp := pow_le_pow_left₀ hnlog0 hlogupper 8 + change ‖L^8‖ ≤ (1/256:ℝ)*‖Real.exp (1*L)‖ at hb + rw [one_mul,Real.norm_eq_abs,abs_of_nonneg (by positivity : 0 ≤ L^8), + Real.norm_eq_abs,abs_of_pos (Real.exp_pos L),Real.exp_log hN0] at hb + norm_num [mul_pow] at hp + nlinarith + exact ⟨hmX,hnlarge,hnupper,hncube,by nlinarith,hlogupper,hwidth⟩ + +lemma halasz_cofactor_scale_decay {L l : ℝ} (hL : 0 < L) + (hlow : L/2 ≤ l) (hupp : l ≤ 2*L) : + l^(1/16:ℝ)/2 ≤ L^(1/16:ℝ) ∧ l^(-1/40:ℝ) ≤ 2*L^(-1/40:ℝ) := by + have hl : 0 < l := by linarith + have hp1 : (2:ℝ)^(1/16:ℝ) ≤ 2 := by + simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le + (show (1:ℝ)≤2 by norm_num) (show (1/16:ℝ)≤1 by norm_num) + have hp2 : (2:ℝ)^(1/40:ℝ) ≤ 2 := by + simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le + (show (1:ℝ)≤2 by norm_num) (show (1/40:ℝ)≤1 by norm_num) + constructor + · have hh := Real.rpow_le_rpow hl.le hupp (show (0:ℝ)≤1/16 by norm_num) + rw [Real.mul_rpow (by norm_num : (0:ℝ)≤2) hL.le] at hh + nlinarith [mul_le_mul_of_nonneg_right hp1 (Real.rpow_nonneg hL.le (1/16))] + · have hh := Real.rpow_le_rpow_of_nonpos (by positivity : 0 (F x)^2) (fun x => (G x)^2) + (hF.pow 2) (hG.pow 2) (fun x => sq_nonneg _) (fun x => sq_nonneg _) + have hs (x : ℝ) (hx : 0≤x) : (x^2)^(1/(2:ℝ))=x := by + rw [← Real.rpow_natCast,← Real.rpow_mul hx] + norm_num + norm_num only [Nat.cast_ofNat,show (1:ℝ)-1/2=1/2 by norm_num, + hs _ (hF0 _),hs _ (hG0 _),Nat.reduceSub,pow_one] at h + exact h + +lemma halasz_collision_interpoland {s k : ℕ} (hk : 2≤k) + {f g : ℝ} (hf : 0≤f) (hg : 0≤g) : + (f^(2*(s+k)))^(1-1/(k:ℝ)) * + (f^(2*s)*g^k)^(1/(k:ℝ)) = f^(2*(s+k)-2)*g := by + have hk0 : (k:ℝ)≠0 := by exact_mod_cast (by omega : k≠0) + have he : ((2*(s+k):ℕ):ℝ)*(1-1/(k:ℝ)) + ((2*s:ℕ):ℝ)*(1/(k:ℝ)) = + ((2*(s+k)-2:ℕ):ℝ) := by + rw [Nat.cast_sub (by omega : 2≤2*(s+k))] + push_cast + field_simp + ring + rw [Real.mul_rpow (pow_nonneg hf _) (pow_nonneg hg _)] + simp only [← Real.rpow_natCast,← Real.rpow_mul hf,← Real.rpow_mul hg] + rw [← mul_assoc,← Real.rpow_add' hf] + · rw [he,mul_one_div_cancel hk0,Real.rpow_one,Real.rpow_natCast] + · rw [he] + exact_mod_cast (by omega : 2*(s+k)-2≠0) + +noncomputable def halaszCollisionMoment (s k N : ℕ) : ℝ := + ∫ α, ‖halaszVinogradovPolynomial k N α‖^(2*(s+k)-2) * + ‖halaszScaledPolynomial k N 2 α‖ ∂halaszVinogradovHaar k + +theorem halasz_collision_moment_bound {s k : ℕ} (hs : 0 ‖halaszVinogradovPolynomial k N α‖ + let G := fun α => ‖halaszScaledPolynomial k N 2 α‖ + have hF : Continuous F := (halasz_finite_phase_continuous _ _).norm + have hG : Continuous G := (halasz_scaled_polynomial_continuous k N 2).norm + have hF0 : ∀ α, 0≤F α := fun _ => norm_nonneg _ + have hG0 : ∀ α, 0≤G α := fun _ => norm_nonneg _ + let B := fun α => (F α)^(2*s)*(G α)^k + have hB : Continuous B := (hF.pow _).mul (hG.pow _) + have hB0 : ∀ α, 0≤B α := fun α => mul_nonneg (pow_nonneg (hF0 α) _) + (pow_nonneg (hG0 α) _) + have hI := halasz_holder_integer_power hk (fun α => (F α)^(2*(s+k))) B + (hF.pow _) hB (fun α => pow_nonneg (hF0 α) _) hB0 + have heq (α : Fin k → AddCircle (1:ℝ)) : + ((F α)^(2*(s+k)))^(1-1/(k:ℝ))*(B α)^(1/(k:ℝ)) = + (F α)^(2*(s+k)-2)*G α := + halasz_collision_interpoland hk (hF0 α) (hG0 α) + simp_rw [heq] at hI + change (halaszCollisionMoment s k N)^k ≤ _ at hI + rw [halasz_vinogradov_real_moment] at hI + have hC := halasz_torus_cauchy (fun α => (F α)^s*(G α)^k) + (fun α => (F α)^s) ((hF.pow _).mul (hG.pow _)) (hF.pow _) + (fun α => mul_nonneg (pow_nonneg (hF0 α) _) (pow_nonneg (hG0 α) _)) + (fun α => pow_nonneg (hF0 α) _) + have hprod (α : Fin k → AddCircle (1:ℝ)) : + ((F α)^s*(G α)^k)*(F α)^s=B α := by dsimp [B]; ring + simp_rw [hprod,mul_pow,← pow_mul,Nat.mul_comm s 2,Nat.mul_comm k 2] at hC + rw [halasz_vinogradov_real_moment] at hC + have hM := halasz_scaled_mixed_moment hs (by omega : 0 mul_nonneg (pow_nonneg (hF0 α) _) (hG0 α))) _) hI 2 + rw [mul_pow] at hpow + have h := hpow.trans (mul_le_mul_of_nonneg_left hC' + (pow_nonneg (pow_nonneg (Nat.cast_nonneg _) _) _)) + rw [← pow_mul,← pow_mul,← mul_assoc,← pow_succ, + show k*2=2*k by omega,show (k-1)*2+1=2*k-1 by omega] at h + exact h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCollisionPartition.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCollisionPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fbb760753f996defd1195df9f5e7092eb6feb32 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCollisionPartition.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszRepeatedCoordinates +import OAI.NumberTheory.TwoPoint.Halasz.HalaszEnergyRestriction +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCollisionAbsorption + +namespace OAI + +/-! The complete-system moment is controlled by the tuples whose +chosen long coordinates are pairwise distinct. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def halaszGoodLongTuples {n N ℓ : ℕ} (L : Fin ℓ → Fin n) : + Finset (Fin n → Fin N) := univ.filter (fun x => Function.Injective (x ∘ L)) + +noncomputable def halaszBadLongCount {n k N ℓ : ℕ} (L : Fin ℓ → Fin (n+2)) : ℕ := + (univ.filter (fun xy : (Fin (n+2) → Fin N) × (Fin (n+2) → Fin N) => + ¬Function.Injective (xy.1 ∘ L) ∧ + halaszVinogradovFrequency k xy.1=halaszVinogradovFrequency k xy.2)).card + +theorem halasz_bad_long_count_bound {n k N ℓ : ℕ} (L : Fin ℓ → Fin (n+2)) + (hL : Function.Injective L) : + halaszBadLongCount (k := k) (N := N) L ≤ ℓ^2*halaszRepeatedCount n k N := by + let P := (univ : Finset (Fin ℓ × Fin ℓ)).filter (fun ij => ij.1≠ij.2) + let S := fun ij : Fin ℓ × Fin ℓ => halaszPairCollision n k N (L ij.1) (L ij.2) + have hsub : (univ.filter (fun xy : (Fin (n+2) → Fin N) × (Fin (n+2) → Fin N) => + ¬Function.Injective (xy.1 ∘ L) ∧ + halaszVinogradovFrequency k xy.1=halaszVinogradovFrequency k xy.2)) ⊆ + P.biUnion S := by + intro xy hxy + obtain ⟨hbad,hfreq⟩ := (mem_filter.mp hxy).2 + obtain ⟨i,j,hij,hne⟩ := Function.not_injective_iff.mp hbad + apply mem_biUnion.mpr + refine ⟨(i,j),mem_filter.mpr ⟨mem_univ _,hne⟩,?_⟩ + exact mem_filter.mpr ⟨mem_univ _,hij,hfreq⟩ + have hP : P.card≤ℓ^2 := by + calc + P.card ≤ (univ : Finset (Fin ℓ × Fin ℓ)).card := card_filter_le _ _ + _ = ℓ^2 := by simp [pow_two] + calc + halaszBadLongCount (k := k) (N := N) L ≤ (P.biUnion S).card := card_le_card hsub + _ ≤ ∑ ij∈P, (S ij).card := card_biUnion_le + _ ≤ ∑ _ij∈P, halaszRepeatedCount n k N := by + apply sum_le_sum + intro ij hij + exact halasz_pair_collision_bound _ _ (fun h => (mem_filter.mp hij).2 (hL h)) + _ = P.card*halaszRepeatedCount n k N := by simp + _ ≤ ℓ^2*halaszRepeatedCount n k N := Nat.mul_le_mul_right _ hP + +lemma halasz_frequency_energy (n k N : ℕ) : + halaszFiberEnergy (univ : Finset (Fin n → Fin N)) (halaszVinogradovFrequency k) = + halaszVinogradovCount n k N := by + rw [← halasz_nat_power_energy n k N] + apply halasz_fiber_energy_congr + intro x _ y _ + constructor + · intro h + funext j + have hj := congrFun h j + simp only [halaszVinogradovFrequency,← Nat.cast_sum] at hj + exact_mod_cast hj + · intro h + funext j + simp only [halaszVinogradovFrequency,← Nat.cast_sum] + exact_mod_cast congrFun h j + +theorem halasz_long_collision_partition {n k N ℓ : ℕ} (L : Fin ℓ → Fin (n+2)) + (hL : Function.Injective L) : + halaszVinogradovCount (n+2) k N ≤ 2*(ℓ^2*halaszRepeatedCount n k N) + + halaszFiberEnergy (halaszGoodLongTuples (N := N) L) (halaszVinogradovFrequency k) := by + have h := halasz_energy_restriction (univ : Finset (Fin (n+2) → Fin N)) + (halaszGoodLongTuples (N := N) L) (halaszVinogradovFrequency k) + rw [halasz_frequency_energy] at h + apply h.trans + apply Nat.add_le_add_right + apply Nat.mul_le_mul_left 2 + convert halasz_bad_long_count_bound (k := k) (N := N) L hL using 1 + unfold halaszCrossCount halaszBadLongCount + congr 1 + ext xy + simp only [mem_filter,mem_product,mem_sdiff,mem_univ,true_and, + halaszGoodLongTuples,and_true] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCongruenceEnergy.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCongruenceEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a936391f5e195af33e812b5b012310fa55ed322 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCongruenceEnergy.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszFiberEnergy +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCongruenceExponent + +namespace OAI + +/-! The mixed congruence count inserted into the finite energy inequality. +The trace `f` may contain further variables, provided those variables +vanish modulo the indicated prime powers. -/ +namespace TwoPointCorrelations + +open Finset Polynomial +open scoped Classical + +theorem halasz_mixed_congruence_energy {ι : Type*} {p r k : ℕ} [Fact p.Prime] + (hkp : k halaszPrimePowerReduction p r (z x j))) + (hmod : ∀ x∈F, ∀ j, + (∑ i, (P j).eval (z x i)).val % p^(min (j.val+1) (r+1)) = + f x j % p^(min (j.val+1) (r+1))) : + halaszFiberEnergy F f ≤ + (k^k * ∏ j : Fin k, p^(r+1-min (j.val+1) (r+1))) * + halaszFiberEnergy F (fun x => (f x,z x)) := by + apply halasz_fiber_energy_refine + intro t _ + convert halasz_mixed_congruence_count hkp P hdeg hunit + ((F.filter (fun x => f x=t)).image z) + (fun j => t j % p^(min (j.val+1) (r+1))) ?_ ?_ using 1 + · congr 1 + ext y + simp + · intro y hy + obtain ⟨x,hx,rfl⟩ := mem_image.mp hy + exact hnonsing x (mem_filter.mp hx).1 + · intro y hy j + obtain ⟨x,hx,rfl⟩ := mem_image.mp hy + rw [hmod x (mem_filter.mp hx).1 j,(mem_filter.mp hx).2] + +theorem halasz_mixed_congruence_energy_triangular {ι : Type*} {p r k : ℕ} + [Fact p.Prime] (hkp : k halaszPrimePowerReduction p r (z x j))) + (hmod : ∀ x∈F, ∀ j, + (∑ i, (P j).eval (z x i)).val % p^(min (j.val+1) (r+1)) = + f x j % p^(min (j.val+1) (r+1))) : + halaszFiberEnergy F f ≤ + (k^k * p^((r+1)*r/2)) * halaszFiberEnergy F (fun x => (f x,z x)) := by + have h := halasz_mixed_congruence_energy hkp P hdeg hunit F z f hnonsing hmod + rw [halasz_congruence_digit_product hrk] at h + simpa only [Nat.add_sub_cancel] using h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCongruenceExponent.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCongruenceExponent.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd3b97c631b8241d0074667b934461d02f21535e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCongruenceExponent.lean @@ -0,0 +1,38 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMixedCongruenceCount +import Mathlib.Algebra.BigOperators.Intervals + +namespace OAI + +/-! The free residue digits in the mixed congruence count total the +triangular exponent r(r-1)/2. -/ +namespace TwoPointCorrelations + +open Finset + +lemma halasz_congruence_exponent_sum {r k : ℕ} (hrk : r≤k) : + (∑ j∈range k, (r-min (j+1) r)) = r*(r-1)/2 := by + have hcut : (∑ j∈range r, (r-min (j+1) r)) = + ∑ j∈range k, (r-min (j+1) r) := by + apply sum_subset (range_mono hrk) + intro j _ hj + have hh : r≤j := Nat.le_of_not_gt (fun h => hj (mem_range.mpr h)) + rw [Nat.min_eq_right (by omega),Nat.sub_self] + rw [← hcut] + calc + _ = ∑ j∈range r, (r-1-j) := by + apply sum_congr rfl + intro j hj + have hjr := mem_range.mp hj + omega + _ = ∑ j∈range r, j := sum_range_reflect (fun j => j) r + _ = _ := sum_range_id r + +theorem halasz_congruence_digit_product {p r k : ℕ} (hrk : r≤k) : + (∏ j : Fin k, p^(r-min (j.val+1) r)) = p^(r*(r-1)/2) := by + rw [prod_pow_eq_pow_sum] + congr 1 + simpa only [← Fin.sum_univ_eq_sum_range] using halasz_congruence_exponent_sum hrk + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszConstantGrowth.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszConstantGrowth.lean new file mode 100644 index 0000000000000000000000000000000000000000..08f897919acc7efe4a386173cc9ce89db6e588fa --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszConstantGrowth.lean @@ -0,0 +1,121 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszIterationConstants + +namespace OAI + +/-! Polynomial-in-the-degree control of the logarithm of the explicit +iteration constant. The absolute prime-supply threshold is retained. -/ +namespace TwoPointCorrelations + +private lemma four_terms {b e a c d f : ℕ} (hb : 4≤b) + (ha : a≤b^e) (hc : c≤b^e) (hd : d≤b^e) (hf : f≤b^e) : + a+c+d+f≤b^(e+1) := by + rw [pow_succ] + have hh := Nat.mul_le_mul_left (b^e) hb + omega + +lemma halasz_iteration_threshold_growth {R₀ k : ℕ} (hk : 2≤k) : + halaszIterationThreshold R₀ k≤(R₀+k+32)^(10*k) := by + let b := R₀+k+32 + have hb : 32≤b := by omega + have hb1 : 1≤b := by omega + have hkb : k≤b := by omega + have hRb : R₀≤b := by omega + have h3 : 1≤b^3 := Nat.one_le_pow _ _ hb1 + have hm : 2*(k^2*k)+1≤b^4 := by + have hk3 : k^2*k≤b^3 := by simpa [pow_succ] using Nat.pow_le_pow_left hkb 3 + have hfour : b^3*3≤b^3*b := Nat.mul_le_mul_left _ (by omega) + rw [← pow_succ] at hfour + change b^3*3≤b^4 at hfour + omega + have hm2 : (2*(k^2*k)+1)^2≤b^8 := by + simpa [← pow_mul] using Nat.pow_le_pow_left hm 2 + have hbe : b≤b^8 := by simpa using pow_le_pow_right₀ hb1 (by decide : 1≤8) + have hT : halaszIterationRootThreshold R₀ k≤b^9 := by + exact four_terms (by omega) (hRb.trans hbe) hm2 (hkb.trans hbe) + ((show 2≤b by omega).trans hbe) + have hp : (halaszIterationRootThreshold R₀ k)^k≤b^(9*k) := by + simpa [← pow_mul] using Nat.pow_le_pow_left hT k + have hs : (4*k^2)^2≤b^8 := by + have hkk := Nat.pow_le_pow_left hkb 2 + have hb2 : 4≤b^2 := by nlinarith + have hmul := Nat.mul_le_mul hb2 hkk + have ht : 4*k^2≤b^4 := by simpa [← pow_add] using hmul + simpa [← pow_mul] using Nat.pow_le_pow_left ht 2 + have hs' : (4*k^2)^2≤b^(9*k) := hs.trans (pow_le_pow_right₀ hb1 (by omega)) + have htwo : 2^k≤b^(9*k) := (Nat.pow_le_pow_left (by omega : 2≤b) k).trans + (pow_le_pow_right₀ hb1 (by omega)) + have hone : 1≤b^(9*k) := Nat.one_le_pow _ _ hb1 + exact (four_terms (by omega) hp hs' htwo hone).trans + (pow_le_pow_right₀ hb1 (by omega)) + +lemma halasz_iteration_base_growth {R₀ k : ℕ} (hk : 2≤k) : + halaszIterationBase R₀ k≤(R₀+k+32)^(11*k^3) := by + let b := R₀+k+32 + have hb : 32≤b := by omega + have hb1 : 1≤b := by omega + have hkb : k≤b := by omega + have hk1 : 1≤k := by omega + have hk3 : k≤k^3 := by simpa using pow_le_pow_right₀ hk1 (by decide : 1≤3) + have htri : k*(k-1)/2≤k^2 := (Nat.div_le_self _ _).trans (by + simpa [pow_two] using Nat.mul_le_mul_left k (Nat.sub_le k 1)) + have hK : k+k*(k-1)/2≤k^2 := by + have he := Nat.mul_div_cancel' (Nat.two_dvd_mul_sub_one k) + have hsub : k*(k-1)=k^2-k := by + rw [Nat.mul_sub_left_distrib,pow_two,mul_one] + rw [hsub] at he ⊢ + have hkk : k≤k^2 := by simpa using pow_le_pow_right₀ hk1 (by decide : 1≤2) + omega + have hH : (halaszIterationThreshold R₀ k)^(k+k*(k-1)/2)≤b^(10*k^3) := by + have hh := Nat.pow_le_pow_left (halasz_iteration_threshold_growth (R₀ := R₀) hk) (k+k*(k-1)/2) + rw [← pow_mul] at hh + apply hh.trans (pow_le_pow_right₀ hb1 _) + nlinarith + have hfact : k.factorial≤b^(10*k^3) := (Nat.factorial_le_pow k).trans + ((Nat.pow_le_pow_left hkb k).trans (pow_le_pow_right₀ hb1 (by omega))) + have h3 : 1≤b^3 := Nat.one_le_pow _ _ hb1 + have hm : 2*(k^2*k)+1≤b^4 := by + have hk3b : k^2*k≤b^3 := by simpa [pow_succ] using Nat.pow_le_pow_left hkb 3 + have hfour : b^3*3≤b^3*b := Nat.mul_le_mul_left _ (by omega) + rw [← pow_succ] at hfour + change b^3*3≤b^4 at hfour + omega + have hstep : 2*(2*(k^2*k)+1)*k^k*32^(k*(k-1)/2)≤b^(10*k^3) := by + have hh := Nat.mul_le_mul (Nat.mul_le_mul + (Nat.mul_le_mul (show 2≤b by omega) hm) (Nat.pow_le_pow_left hkb k)) + (Nat.pow_le_pow_left hb (k*(k-1)/2)) + have hh' : 2*(2*(k^2*k)+1)*k^k*32^(k*(k-1)/2)≤b^(5+k+k*(k-1)/2) := by + convert hh using 1 + simp only [pow_add,pow_succ] + ring + apply hh'.trans (pow_le_pow_right₀ hb1 _) + have hk2 : k^2≤k^3 := pow_le_pow_right₀ hk1 (by decide : 2≤3) + have hk32 : 2≤k^3 := (show 2≤k from hk).trans hk3 + omega + have hone : 1≤b^(10*k^3) := Nat.one_le_pow _ _ hb1 + exact (four_terms (by omega) hfact hH hstep hone).trans + (pow_le_pow_right₀ hb1 (by nlinarith)) + +/-- The constant at the selected moment has logarithm `O(k^4 log k)`. +No endpoint-dependent constant is hidden. -/ +theorem halasz_selected_constant_growth {R₀ k : ℕ} (hk : 2≤k) : + halaszIterationConstant R₀ k (10*k)≤(R₀+k+32)^(256*k^4) := by + let b := R₀+k+32 + have hb : 32≤b := by omega + have hb1 : 1≤b := by omega + have hk1 : 1≤k := by omega + have h1 := Nat.pow_le_pow_left (halasz_iteration_base_growth (R₀ := R₀) hk) (10*k+1) + have h2 := Nat.pow_le_pow_left hb (k*(10*k)*(10*k+1)) + have hmul := Nat.mul_le_mul h1 h2 + unfold halaszIterationConstant + apply hmul.trans + rw [← pow_mul,← pow_add] + apply pow_le_pow_right₀ hb1 + have h34 : k^3≤k^4 := pow_le_pow_right₀ hk1 (by decide : 3≤4) + have h24 : k^2≤k^4 := pow_le_pow_right₀ hk1 (by decide : 2≤4) + have he : 11*k^3*(10*k+1)+k*(10*k)*(10*k+1)=110*k^4+111*k^3+10*k^2 := by ring + rw [he] + omega + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCorrectionScale.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCorrectionScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..c634cf8ad7f01c4efb643a63bc6b0864523d016d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCorrectionScale.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszParameters + +namespace OAI + +/-! A logarithmic cutoff for the general multiplicative correction. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma halasz_eventually_correction_scale (X₀ : ℝ) : + ∀ᶠ x : ℝ in atTop, + let W := ⌈Real.log x ^ 4⌉₊ + 2 ≤ W ∧ X₀ ≤ (W : ℝ) ∧ (W : ℝ) ^ 2 ≤ x ∧ + (W : ℝ) ^ (-(1 / 4 : ℝ)) ≤ 1 / Real.log x ∧ + 2 ≤ Real.log x ∧ 1 ≤ Real.log (Real.log x) := by + have hsmall := (Real.isLittleO_pow_log_id_atTop (n := 8)).bound + (by norm_num : (0 : ℝ) < 1 / 4) + have hlog := Real.tendsto_log_atTop.eventually (eventually_ge_atTop (max 2 X₀)) + have hll := (Real.tendsto_log_atTop.comp Real.tendsto_log_atTop).eventually + (eventually_ge_atTop (1 : ℝ)) + filter_upwards [eventually_gt_atTop (0 : ℝ), hsmall, hlog, hll] with x hx hs hl hll + let ℓ := Real.log x + let W := ⌈ℓ ^ 4⌉₊ + have hℓ2 : 2 ≤ ℓ := (le_max_left _ _).trans hl + have hℓ1 : 1 ≤ ℓ := by linarith + have hℓ0 : 0 < ℓ := by linarith + have hp : 1 ≤ ℓ ^ 4 := one_le_pow₀ hℓ1 + have hlow : ℓ ^ 4 ≤ (W : ℝ) := Nat.le_ceil _ + have hhigh : (W : ℝ) ≤ 2 * ℓ ^ 4 := by + have hh : (W : ℝ) < ℓ ^ 4 + 1 := Nat.ceil_lt_add_one (by positivity) + linarith + have hℓle : ℓ ≤ ℓ ^ 4 := le_self_pow₀ hℓ1 (by norm_num : (4 : ℕ) ≠ 0) + have hW2 : 2 ≤ W := by exact_mod_cast hℓ2.trans (hℓle.trans hlow) + have hWX : X₀ ≤ (W : ℝ) := ((le_max_right _ _).trans hl).trans (hℓle.trans hlow) + dsimp only [id] at hs + rw [Real.norm_eq_abs, abs_of_nonneg (pow_nonneg hℓ0.le 8), + Real.norm_eq_abs, abs_of_pos hx] at hs + have hWs : (W : ℝ) ^ 2 ≤ x := by + calc + _ ≤ (2 * ℓ ^ 4) ^ 2 := pow_le_pow_left₀ (Nat.cast_nonneg W) hhigh 2 + _ = 4 * ℓ ^ 8 := by ring + _ ≤ x := by linarith + have htail : (W : ℝ) ^ (-(1 / 4 : ℝ)) ≤ 1 / ℓ := by + calc + _ ≤ (ℓ ^ 4) ^ (-(1 / 4 : ℝ)) := + Real.rpow_le_rpow_of_nonpos (pow_pos hℓ0 4) hlow (by norm_num) + _ = 1 / ℓ := by + rw [← Real.rpow_natCast, ← Real.rpow_mul hℓ0.le] + norm_num + rw [Real.rpow_neg_one] + exact ⟨hW2, hWX, hWs, htail, hℓ2, hll⟩ + +lemma halasz_correction_quotient {N W d : ℕ} (hW : 2 ≤ W) (hd : 0 < d) + (hdW : d ≤ W) (hWN : W ^ 2 ≤ N) : + W ≤ N / d ∧ N / d ≤ N ∧ N ≤ (N / d) ^ 3 := by + have hWpos : 0 < W := by omega + have hWd : W * d ≤ N := (Nat.mul_le_mul_left W hdW).trans (by simpa [pow_two] using hWN) + have hWq : W ≤ N / d := (Nat.le_div_iff_mul_le hd).mpr hWd + have hq : 2 ≤ N / d := hW.trans hWq + have hdq : d ≤ N / d := hdW.trans hWq + have hn := Nat.lt_mul_div_succ N hd + refine ⟨hWq, Nat.div_le_self N d, ?_⟩ + have htwo : N / d + 1 ≤ (N / d) ^ 2 := by nlinarith + calc + N ≤ d * (N / d + 1) := hn.le + _ ≤ (N / d) * ((N / d) ^ 2) := Nat.mul_le_mul hdq htwo + _ = (N / d) ^ 3 := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCorrectionTransfer.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCorrectionTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b397e1b6e2ece2c6f127105e1cf876a5f442b71 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCorrectionTransfer.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszHyperbolaRows +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimePowers +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTCorrectionSummability + +namespace OAI + +/-! Transfer an ordinary mean estimate through the exact prime-power +correction, retaining its uniform summable tail. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma halasz_correction_prefix (f : ℕ → ℂ) (hf : Multiplicative f) (hf1 : f 1 = 1) + (N : ℕ) : + (∑ n ∈ Icc 1 N, f n) = + ∑ d ∈ Icc 1 N, mrtCorrection f d * ∑ n ∈ Icc 1 (N / d), mrtCompletePart f n := by + calc + _ = ∑ n ∈ Icc 1 N, ∑ p ∈ n.divisorsAntidiagonal, + mrtCorrection f p.1 * mrtCompletePart f p.2 := by + apply sum_congr rfl + intro n hn + rw [Nat.sum_divisorsAntidiagonal (fun d m => mrtCorrection f d * mrtCompletePart f m)] + exact mrt_multiplicative_divisor_sum f hf hf1 (mem_Icc.mp hn).1 + _ = _ := by + rw [halasz_sum_divisorsAntidiagonal (fun d n => mrtCorrection f d * mrtCompletePart f n), + halasz_hyperbola_rows (fun d n => mrtCorrection f d * mrtCompletePart f n)] + exact sum_congr rfl (fun d _ => (mul_sum _ _ _).symm) + +theorem halasz_correction_mean_bound (f : ℕ → ℂ) (hf : Multiplicative f) + (hbound : OneBounded f) (hf1 : f 1 = 1) (N W : ℕ) (hW : 0 < W) + (A : ℝ) (hA : 0 ≤ A) + (hmean : ∀ d ∈ Icc 1 N, d ≤ W → + ‖∑ n ∈ Icc 1 (N / d), mrtCompletePart f n‖ ≤ A * ((N / d : ℕ) : ℝ)) : + ‖∑ n ∈ Icc 1 N, f n‖ ≤ + mrtCorrectionBound * N * (A + (W : ℝ) ^ (-(1 / 4 : ℝ))) := by + let S := (Icc 1 N).filter (fun d => d ≤ W) + let U := (Icc 1 N).filter (fun d => ¬d ≤ W) + let a := fun d : ℕ => mrtCorrection f d * ∑ n ∈ Icc 1 (N / d), mrtCompletePart f n + have hsplit : (∑ n ∈ Icc 1 N, f n) = (∑ d ∈ S, a d) + ∑ d ∈ U, a d := by + rw [halasz_correction_prefix f hf hf1] + exact (sum_filter_add_sum_filter_not (Icc 1 N) (fun d => d ≤ W) a).symm + have hs : ‖∑ d ∈ S, a d‖ ≤ (A * N) * ∑ d ∈ S, ‖mrtCorrection f d‖ / (d : ℝ) := by + apply (norm_sum_le _ _).trans + rw [mul_sum] + apply sum_le_sum + intro d hd + obtain ⟨hdN, hdW⟩ := mem_filter.mp hd + rw [show a d = mrtCorrection f d * ∑ n ∈ Icc 1 (N / d), mrtCompletePart f n from rfl, norm_mul] + calc + _ ≤ ‖mrtCorrection f d‖ * (A * ((N / d : ℕ) : ℝ)) := + mul_le_mul_of_nonneg_left (hmean d hdN hdW) (norm_nonneg _) + _ ≤ ‖mrtCorrection f d‖ * (A * ((N : ℝ) / d)) := by + gcongr + exact Nat.cast_div_le + _ = _ := by ring + have hu : ‖∑ d ∈ U, a d‖ ≤ (N : ℝ) * ∑ d ∈ U, ‖mrtCorrection f d‖ / (d : ℝ) := by + apply (norm_sum_le _ _).trans + rw [mul_sum] + apply sum_le_sum + intro d hd + rw [show a d = mrtCorrection f d * ∑ n ∈ Icc 1 (N / d), mrtCompletePart f n from rfl, norm_mul] + calc + _ ≤ ‖mrtCorrection f d‖ * ((N / d : ℕ) : ℝ) := + mul_le_mul_of_nonneg_left + (halasz_bounded_prefix_norm _ (mrtCompletePart_oneBounded f hbound) _) (norm_nonneg _) + _ ≤ ‖mrtCorrection f d‖ * ((N : ℝ) / d) := + mul_le_mul_of_nonneg_left Nat.cast_div_le (norm_nonneg _) + _ = _ := by ring + have hsmass : (∑ d ∈ S, ‖mrtCorrection f d‖ / (d : ℝ)) ≤ mrtCorrectionBound := by + simpa using mrt_correction_tail_bound f hbound hf1 (W := 1) (by norm_num) S + (fun d hd => (mem_Icc.mp (mem_filter.mp hd).1).1) + have humass := mrt_correction_tail_bound f hbound hf1 hW U + (fun d hd => Nat.le_of_lt (Nat.lt_of_not_ge (mem_filter.mp hd).2)) + calc + _ ≤ ‖∑ d ∈ S, a d‖ + ‖∑ d ∈ U, a d‖ := by rw [hsplit]; exact norm_add_le _ _ + _ ≤ (A * N) * (∑ d ∈ S, ‖mrtCorrection f d‖ / (d : ℝ)) + + (N : ℝ) * (∑ d ∈ U, ‖mrtCorrection f d‖ / (d : ℝ)) := add_le_add hs hu + _ ≤ (A * N) * mrtCorrectionBound + + (N : ℝ) * (mrtCorrectionBound * (W : ℝ) ^ (-(1 / 4 : ℝ))) := by gcongr + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCosineMinorant.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCosineMinorant.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b00a633221b5604d077bd86a986b58505fa2df8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCosineMinorant.lean @@ -0,0 +1,66 @@ +import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Tactic + +namespace OAI + +/-! A three-harmonic minorant for the prime-phase defect in corrected +MRT Lemma A.4(ii). Its mean is 81/256, enough to retain the needed 1/10 +after restricting primes above exp((log X)^(27/40)). -/ +namespace TwoPointCorrelations + +open Finset + +lemma halasz_sqrt_polynomial_minorant (a : ℝ) (ha : 0 ≤ a) : + (1-a^2)/2+(1-a^2)^2/8+(1-a^2)^3/16 ≤ 1-a := by + have h : 0 ≤ (a-1)^4*(a^2+4*a+5)/16 := by positivity + nlinarith only [h] + +lemma halasz_cosine_three_harmonics (x : ℝ) : + (81/256:ℝ)-(175/512)*Real.cos (2*x)+(7/256)*Real.cos (4*x)- + (1/512)*Real.cos (6*x) ≤ 1-|Real.cos x| := by + have h := halasz_sqrt_polynomial_minorant |Real.cos x| (abs_nonneg _) + have hsq : |Real.cos x|^2 = Real.cos x^2 := sq_abs _ + rw [hsq] at h + have hfour : Real.cos (4*x) = 2*(2*Real.cos x^2-1)^2-1 := by + rw [show 4*x=2*(2*x) by ring,Real.cos_two_mul,Real.cos_two_mul] + have hsix : Real.cos (6*x) = 4*(2*Real.cos x^2-1)^3-3*(2*Real.cos x^2-1) := by + rw [show 6*x=3*(2*x) by ring,Real.cos_three_mul,Real.cos_two_mul] + rw [hfour,hsix,Real.cos_two_mul] + convert h using 1; ring + +/-- Three bounded prime-phase sums suffice; no Fourier approximation or +limit interchange is needed for this part of the repulsion argument. -/ +theorem halasz_weighted_cosine_repulsion {ι : Type*} (P : Finset ι) + (w θ : ι → ℝ) (hw : ∀ p ∈ P, 0 ≤ w p) (E : ℝ) + (h₁ : |∑ p ∈ P, w p*Real.cos (θ p)| ≤ E) + (h₂ : |∑ p ∈ P, w p*Real.cos (2*θ p)| ≤ E) + (h₃ : |∑ p ∈ P, w p*Real.cos (3*θ p)| ≤ E) : + (81/256:ℝ)*(∑ p ∈ P, w p)-(95/256)*E ≤ + ∑ p ∈ P, w p*(1-|Real.cos (θ p/2)|) := by + have hpoint (p : ι) (hp : p ∈ P) := + mul_le_mul_of_nonneg_left (halasz_cosine_three_harmonics (θ p/2)) (hw p hp) + have hsum := sum_le_sum hpoint + have hphase (p : ι) : + 2*(θ p/2)=θ p ∧ 4*(θ p/2)=2*θ p ∧ 6*(θ p/2)=3*θ p := by + constructor + · ring + constructor <;> ring + simp only [(hphase _).1,(hphase _).2.1,(hphase _).2.2, + mul_sub,mul_add,sum_sub_distrib,sum_add_distrib] at hsum + have hm (c : ℝ) (f : ι → ℝ) : + (∑ p ∈ P, w p*(c*f p)) = c*(∑ p ∈ P, w p*f p) := by + rw [mul_sum] + apply sum_congr rfl + intro p _ + ring + rw [hm,hm,hm,← sum_mul] at hsum + have ha := (abs_le.mp h₁).2 + have hb := (abs_le.mp h₂).1 + have hc := (abs_le.mp h₃).2 + simp only [mul_sub,sum_sub_distrib] + linarith only [hsum,ha,hb,hc] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCountException.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCountException.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e7c3ac18519b01b1f10a3863c5a25c2c6f2c32a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCountException.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTCountMean +import OAI.NumberTheory.TwoPoint.Halasz.HalaszGeneralException + +namespace OAI + +/-! Localize the Halasz distance hypothesis to the frequency window +actually used by a reciprocal-count cofactor. This allows a distant +frequency to be treated even when the minimizing twist is close to zero. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical ComplexConjugate + +theorem halasz_local_count_exception : ∃ C X₀ : ℝ, 0 < C ∧ + ∀ N : ℕ, X₀ ≤ N → + ∀ F : ℕ → ℂ, F 1 = 1 → Multiplicative F → OneBounded F → + ∀ Q P : Finset ℕ, (∀ p ∈ Q, p.Prime) → (∀ p ∈ P, p.Prime) → + ∀ t τ M : ℝ, 0 ≤ M → + (∀ v : ℝ, |v-t| ≤ Real.log (N:ℝ)^8 → + 1/2 ≤ |v-τ| → 2*M ≤ squaredDistance F (mrtArchimedeanTwist v) N) → + ‖∑ n ∈ Icc 1 N, (mrtMissingCoefficient F Q n * conj (mrtArchimedeanTwist t n)) / + ((finitePrimeDivisorCount P n : ℂ)+1)‖ ≤ + C*N*((min M (Real.log (1+|τ-t|))+1)*Real.exp (-min M (Real.log (1+|τ-t|)))+ + Real.log (Real.log N)/Real.log N) := by + obtain ⟨C, X₀, hC, hmean⟩ := halasz_general_exceptional_mean + refine ⟨C, X₀, hC, ?_⟩ + intro N hN F hF1 hFm hFb Q P hQ hP t τ M hM hd + apply mrt_reciprocal_count_polynomial_bound (Icc 1 N) P + (fun n => mrtMissingCoefficient F Q n * conj (mrtArchimedeanTwist t n)) + intro u hu hu1 + let G := mrtCountMaskedCoefficient (mrtMissingCoefficient F Q) P u + have hG1 : G 1 = 1 := mrt_missing_count_one F hF1 Q P hQ hP u + have hGm : Multiplicative G := + (mrtMissingCoefficient_multiplicative F hFm Q hQ).mrtCountMaskedCoefficient P hP u + have hGb : OneBounded G := + (mrtMissingCoefficient_oneBounded F hFb Q).mrtCountMaskedCoefficient P hu hu1 + have hh := hmean N hN (halaszTwistedFunction G t) + (halasz_twisted_one G hG1 t) (halasz_twisted_multiplicative G hGm t) + (halasz_twisted_oneBounded G hGb t) M (τ-t) hM (by + intro v hv hvout + rw [halasz_twisted_distance] + have hv' : |(t+v)-t| ≤ Real.log (N:ℝ)^8 := by + simpa only [add_sub_cancel_left] using abs_le.mpr ⟨hv.1.le,hv.2⟩ + have haway : 1/2 ≤ |(t+v)-τ| := by + by_contra! hh + have he : |v-(τ-t)| = |(t+v)-τ| := by congr 1; ring + rw [← he] at hh + have hb := abs_lt.mp hh + exact hvout ⟨by linarith [hb.1],by linarith [hb.2]⟩ + have hl := hd (t+v) hv' haway + have hm := mrt_missing_count_mask_distance F (mrtArchimedeanTwist (t+v)) Q P hu hu1 N + (fun p hp => hFb p ((mem_filter.mp hp).2.pos)) + (fun p _ => by rw [mrtArchimedeanTwist_norm]) + change squaredDistance F (mrtArchimedeanTwist (t+v)) N ≤ + 2*squaredDistance G (mrtArchimedeanTwist (t+v)) N at hm + linarith) + convert hh using 1 + congr 1 + apply sum_congr rfl + intro n _ + simp only [halaszTwistedFunction, G, mrtCountMaskedCoefficient] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCountMonotone.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCountMonotone.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c41051d0bfc55fed77dd81affa48e67abac0455 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCountMonotone.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimeRecurrence + +namespace OAI + +/-! Monotonicity in the summation endpoint, needed to give the short +moment one common endpoint after summing over the selected primes. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem halasz_vinogradov_count_mono (s k : ℕ) {N M : ℕ} (hNM : N≤M) : + halaszVinogradovCount s k N≤halaszVinogradovCount s k M := by + let e : (Fin s → Fin N) → (Fin s → Fin M) := fun x i => (x i).castLE hNM + have he : Function.Injective e := by + intro x y h + funext i + exact Fin.castLE_injective hNM (congrFun h i) + have hf (x : Fin s → Fin N) : + halaszNatPowerFrequency k (e x)=halaszNatPowerFrequency k x := rfl + have hm := halasz_fiber_energy_mono + (subset_univ ((univ : Finset (Fin s → Fin N)).image e)) (halaszNatPowerFrequency k) + rw [halasz_nat_power_energy] at hm + have ht := halasz_fiber_energy_transfer (univ : Finset (Fin s → Fin N)) e he.injOn + (halaszNatPowerFrequency k) (halaszNatPowerFrequency k) (fun x _ => hf x) + rw [halasz_nat_power_energy] at ht + apply ht.trans_le + convert hm using 1 + congr 1 + ext x + simp only [mem_image] + +theorem halasz_vinogradov_prime_recurrence {s k N R B : ℕ} (hs : 0 ⟨(hP p hp).1,(hP p hp).2.1⟩) hcard + have hb : ∀ p∈P, p^(2*s)*((k^k*p^(k*(k-1)/2))* + (N^k*halaszVinogradovCount s k (N/p+1))) ≤ + B^(2*s)*((k^k*B^(k*(k-1)/2))*(N^k*halaszVinogradovCount s k (N/R+1))) := by + intro p hp + have hpB := (hP p hp).2.2 + have hdiv : N/p+1≤N/R+1 := Nat.add_le_add_right + (Nat.div_le_div_left (hP p hp).2.1 (by omega : 0 f x.1=g x.2)).card + +theorem halasz_cross_integral {ι κ : Type*} {k : ℕ} + (F : Finset ι) (G : Finset κ) (f : ι → Fin k → ℤ) (g : κ → Fin k → ℤ) : + (∫ α, halaszFinitePhase F f α * conj (halaszFinitePhase G g α) + ∂halaszVinogradovHaar k) = (halaszCrossCount F G f g:ℂ) := by + have hi (x : ι) (y : κ) : Integrable (fun α => + halaszVinogradovCharacter (f x) α * conj (halaszVinogradovCharacter (g y) α)) + (halaszVinogradovHaar k) := by + simp_rw [← halasz_vinogradov_character_neg,← halasz_vinogradov_character_add] + exact halasz_vinogradov_character_integrable _ + unfold halaszFinitePhase + simp_rw [map_sum,sum_mul,mul_sum] + rw [integral_finsetSum F (fun x _ => integrable_finsetSum G (fun y _ => hi x y))] + simp_rw [integral_finsetSum G (fun y _ => hi _ y),halasz_vinogradov_character_inner] + simp only [halaszCrossCount,card_eq_sum_ones,sum_filter,sum_product,Nat.cast_sum, + Nat.cast_ite,Nat.cast_one,Nat.cast_zero] + +theorem halasz_cross_count_bound {ι κ : Type*} {k : ℕ} + (F : Finset ι) (G : Finset κ) (f : ι → Fin k → ℤ) (g : κ → Fin k → ℤ) : + (halaszCrossCount F G f g:ℝ) ≤ + ∫ α, ‖halaszFinitePhase F f α‖ * ‖halaszFinitePhase G g α‖ + ∂halaszVinogradovHaar k := by + have h := norm_integral_le_integral_norm + (fun α => halaszFinitePhase F f α * conj (halaszFinitePhase G g α)) + (μ := halaszVinogradovHaar k) + rw [halasz_cross_integral,Complex.norm_natCast] at h + simpa only [norm_mul,Complex.norm_conj] using h + +def halaszRepeatedFrequency (n k N : ℕ) (x : Fin N × (Fin n → Fin N)) : Fin k → ℤ := + fun j => 2*((x.1.val+1)^(j.val+1):ℕ)+halaszVinogradovFrequency k x.2 j + +noncomputable def halaszRepeatedCount (n k N : ℕ) : ℕ := + halaszCrossCount univ univ (halaszRepeatedFrequency n k N) + (halaszVinogradovFrequency (s := n+2) (N := N) k) + +lemma halasz_repeated_phase (n k N : ℕ) (α : Fin k → AddCircle (1:ℝ)) : + halaszFinitePhase univ (halaszRepeatedFrequency n k N) α = + halaszScaledPolynomial k N 2 α * (halaszVinogradovPolynomial k N α)^n := by + let f (x : Fin N) : Fin k → ℤ := fun j => 2*((x.val+1)^(j.val+1):ℕ) + let g (x : Fin N) : Fin k → ℤ := fun j => ((x.val+1)^(j.val+1):ℕ) + have h := halasz_finite_phase_product (univ : Finset (Fin N)) + (Fintype.piFinset (fun _ : Fin n => (univ : Finset (Fin N)))) f + (fun x => ∑ i, g (x i)) α + rw [halasz_finite_phase_power] at h + have hf : (fun x : Fin N × (Fin n → Fin N) => f x.1+∑ i, g (x.2 i)) = + halaszRepeatedFrequency n k N := by + funext x j + simp only [Pi.add_apply,Finset.sum_apply,halaszRepeatedFrequency, + halaszVinogradovFrequency,f,g] + rw [hf] at h + simpa only [Fintype.piFinset_univ,univ_product_univ,halaszScaledPolynomial, + halaszVinogradovPolynomial,halaszFinitePhase,f,g] using h + +theorem halasz_repeated_count_bound {s k : ℕ} (hk : 2≤k) (N : ℕ) : + (halaszRepeatedCount (s+k-2) k N:ℝ) ≤ halaszCollisionMoment s k N := by + have hn : s+k-2+2=s+k := by omega + have h := halasz_cross_count_bound (univ : Finset (Fin N × (Fin (s+k-2) → Fin N))) + (univ : Finset (Fin (s+k-2+2) → Fin N)) (halaszRepeatedFrequency (s+k-2) k N) + (halaszVinogradovFrequency k) + simp_rw [halasz_repeated_phase,show ∀ α, halaszFinitePhase univ + (halaszVinogradovFrequency (s := s+k-2+2) (N := N) k) α = + (halaszVinogradovPolynomial k N α)^(s+k-2+2) by + intro α + exact (halasz_vinogradov_power_expand _ _ _ α).symm, + norm_mul,norm_pow] at h + change (halaszRepeatedCount (s+k-2) k N:ℝ) ≤ _ at h + convert h using 1 + unfold halaszCollisionMoment + apply integral_congr_ae + filter_upwards [] with α + rw [mul_comm,mul_assoc,← pow_add] + congr 2 + omega + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCubicLaplace.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCubicLaplace.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b651d9b85ab5aaa49d53e87c862ab10f299f2e6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCubicLaplace.lean @@ -0,0 +1,99 @@ +import Mathlib.Analysis.SpecialFunctions.Gaussian.GaussianIntegral +import Mathlib.MeasureTheory.Integral.Gamma +import Mathlib.Tactic + +namespace OAI + +/-! The cubic Laplace estimate used to pass from the logarithmic +exponential-sum bound to the Vinogradov--Korobov zeta bound (Ford, +Proc. LMS 85 (2002), Section 7). Absolute constants are deliberately +weakened; only the exponents 3/2 and 2/3 matter for the application. -/ +namespace TwoPointCorrelations + +open MeasureTheory Set + +lemma halasz_cubic_balance {δ x L : ℝ} (hδ : 0 ≤ δ) (hx : 0 ≤ x) (hL : 0 < L) : + δ*x-x^3/(1000*L^2) ≤ + 1000*δ^(3/2:ℝ)*L-x^3/(2000*L^2) := by + have hr : δ^(3/2:ℝ) = δ*Real.sqrt δ := by + by_cases hz : δ=0 + · simp [hz] + have hδ0 : 0 < δ := lt_of_le_of_ne hδ (Ne.symm hz) + rw [show (3/2:ℝ)=1+1/2 by norm_num,Real.rpow_add hδ0,Real.rpow_one, + Real.sqrt_eq_rpow] + have hd : Real.sqrt δ^2 = δ := Real.sq_sqrt hδ + have hl2 : 0 < L^2 := sq_pos_of_pos hL + have hx3 : 0 ≤ x^3 := pow_nonneg hx _ + have he : x^3/(1000*L^2) = 2*(x^3/(2000*L^2)) := by + field_simp + ring + rw [he,hr] + by_cases hsmall : x ≤ 1000*Real.sqrt δ*L + · have hh := mul_le_mul_of_nonneg_left hsmall hδ + have hn : 0 ≤ x^3/(2000*L^2) := by positivity + nlinarith only [hh,hn] + · have hbig : 1000*Real.sqrt δ*L ≤ x := (lt_of_not_ge hsmall).le + have hs := mul_self_le_mul_self (by positivity : 0 ≤ 1000*Real.sqrt δ*L) hbig + have hs' : 2000*δ*L^2 ≤ x^2 := by + have hn : 0 ≤ δ*L^2 := by positivity + nlinarith only [hs,hd,hn] + have hc : δ*x ≤ x^3/(2000*L^2) := by + apply (le_div_iff₀ (by positivity : 0 < 2000*L^2)).mpr + have hh := mul_le_mul_of_nonneg_right hs' hx + nlinarith only [hh] + have hn : 0 ≤ 1000*(δ*Real.sqrt δ)*L := by positivity + linarith only [hc,hn] + +lemma halasz_cubic_kernel_integrable {L : ℝ} (hL : 0 < L) : + IntegrableOn (fun x : ℝ => Real.exp (-x^3/(2000*L^2))) (Ioi 0) := by + have h := integrableOn_rpow_mul_exp_neg_mul_rpow + (s := 0) (p := 3) (b := 1/(2000*L^2)) (by norm_num) (by norm_num) (by positivity) + refine h.congr_fun (fun x _ => ?_) measurableSet_Ioi + norm_num only [Real.rpow_zero,one_mul,Real.rpow_ofNat] + congr 1 + ring + +lemma halasz_cubic_kernel_integral {L : ℝ} (hL : 0 < L) : + (∫ x : ℝ in Ioi 0, Real.exp (-x^3/(2000*L^2))) = + (2000:ℝ)^(1/3:ℝ)*Real.Gamma (4/3)*L^(2/3:ℝ) := by + have h := integral_exp_neg_mul_rpow (p := 3) (b := 1/(2000*L^2)) + (by norm_num) (by positivity) + have he : (1/(2000*L^2):ℝ)^(-1/3:ℝ) = (2000:ℝ)^(1/3:ℝ)*L^(2/3:ℝ) := by + rw [one_div,Real.inv_rpow (by positivity),← Real.rpow_neg (by positivity)] + norm_num only [neg_div,neg_neg] + rw [Real.mul_rpow (by norm_num) (by positivity),← Real.rpow_natCast_mul hL.le] + norm_num + rw [he] at h + norm_num only [one_div,div_self,show (3:ℝ)≠0 by norm_num] at h + calc + _ = ∫ x : ℝ in Ioi 0, Real.exp (-(2000*L^2)⁻¹*x^(3:ℝ)) := by + apply setIntegral_congr_fun measurableSet_Ioi + intro x _ + norm_num only [Real.rpow_ofNat] + congr 1 + ring + _ = _ := by rw [h]; ring + +theorem halasz_cubic_laplace_bound {δ L : ℝ} (hδ : 0 ≤ δ) (hL : 0 < L) : + (∫ x : ℝ in Ioi 0, Real.exp (δ*x-x^3/(1000*L^2))) ≤ + ((2000:ℝ)^(1/3:ℝ)*Real.Gamma (4/3))*L^(2/3:ℝ)* + Real.exp (1000*δ^(3/2:ℝ)*L) := by + let A := Real.exp (1000*δ^(3/2:ℝ)*L) + have hi := (halasz_cubic_kernel_integrable hL).const_mul A + have hpoint (x : ℝ) (hx : x ∈ Ioi 0) : + Real.exp (δ*x-x^3/(1000*L^2)) ≤ A*Real.exp (-x^3/(2000*L^2)) := by + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + simpa only [sub_eq_add_neg,neg_div] using halasz_cubic_balance hδ hx.le hL + have hf : IntegrableOn (fun x : ℝ => Real.exp (δ*x-x^3/(1000*L^2))) (Ioi 0) := by + apply hi.mono' (by fun_prop) + filter_upwards [ae_restrict_mem measurableSet_Ioi] with x hx + simpa only [Real.norm_eq_abs,abs_of_pos (Real.exp_pos _)] using hpoint x hx + calc + _ ≤ ∫ x : ℝ in Ioi 0, A*Real.exp (-x^3/(2000*L^2)) := + setIntegral_mono_on hf hi measurableSet_Ioi hpoint + _ = _ := by rw [integral_const_mul,halasz_cubic_kernel_integral hL]; dsimp only [A]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCubicMaximum.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCubicMaximum.lean new file mode 100644 index 0000000000000000000000000000000000000000..edabcfcfefe958ac435a3728264f7efce1174104 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszCubicMaximum.lean @@ -0,0 +1,26 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCubicLaplace + +namespace OAI + +/-! Cubic logarithmic cancellation absorbs a strip displacement. -/ +namespace TwoPointCorrelations + +lemma halasz_cubic_maximum {δ y L : ℝ} (hδ : 0≤δ) (hy : 0≤y) (hL : 0 linarith + +lemma halasz_medium_degree_margin {lam : ℝ} (hlo : 9/10≤lam) (hhi : lam≤48) : + (1:ℝ)/32≤lam/2-1/3-(3*lam+6)^2/1024 := by + have hprod : 0≤(lam-9/10)*(48-lam) := mul_nonneg (by linarith) (by linarith) + nlinarith + +lemma halasz_small_degree_margin {lam : ℝ} (hlo : 19/20≤lam) (hhi : lam≤48) : + (1:ℝ)/16≤lam/2-1/3-(3*lam+6)^2/1024 := by + have hprod : 0≤(lam-19/20)*(48-lam) := mul_nonneg (by linarith) (by linarith) + nlinarith + +lemma halasz_small_degree_saving {lam k j : ℝ} + (hlo : 19/20≤lam) (hhi : lam≤48) (hk0 : 0≤k) (hk : k≤3*lam+6) + (hjlo : 3*lam/2≤j) (hjhi : j≤3*lam/2+1) : + (1:ℝ)/16+k^2/1024≤min (j/3) (min (j-lam) (lam-j/3)) := by + have hm := halasz_small_degree_margin hlo hhi + have hk2 : k^2≤(3*lam+6)^2 := by nlinarith + apply le_min + · nlinarith + · apply le_min <;> nlinarith + +lemma halasz_large_degree_margin {m : ℝ} (hm : 8≤m) : + m^2/4≤(2*m+1)*(m-6)-(12*m)^2/1024 := by + have hh : 0≤m*(m-8) := mul_nonneg (by linarith) (by linarith) + nlinarith + +lemma halasz_large_degree_saving {m lam j : ℝ} (hm : 8≤m) + (hlamlo : 6*m-6≤lam) (hlamhi : lam≤6*m) + (hjlo : 8*m≤j) (hjhi : j≤10*m) : + m-6≤min (j/4) (min (j-lam) (lam-j/2)) := by + apply le_min + · linarith + · apply le_min <;> linarith + +lemma halasz_small_taylor_exponent {lam k : ℝ} (hk : 3*lam+3≤k) : + lam-(k+1)/3≤-(4/3:ℝ) := by linarith + +lemma halasz_large_taylor_exponent {lam m : ℝ} (hlam : lam≤6*m) : + lam-(12*m+1)/2≤-(1/2:ℝ) := by linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDegreeSelection.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDegreeSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..cee12aae3bb98235f6f0f59cff9458cca97ff8b0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDegreeSelection.lean @@ -0,0 +1,49 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszBoundedDegrees +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLargeDegrees +import OAI.NumberTheory.TwoPoint.Halasz.HalaszSelectedDoubleMoment + +namespace OAI + +/-! Quantitative degree choices as a function of log|t|/log N. -/ +namespace TwoPointCorrelations + +lemma halasz_large_degree_selection {lam : ℝ} (hlam : 48≤lam) : + 8≤⌈lam/6⌉₊ ∧ 6*(⌈lam/6⌉₊:ℝ)-6≤lam ∧ lam≤6*(⌈lam/6⌉₊:ℝ) ∧ + (12*⌈lam/6⌉₊:ℝ)≤2*lam+12 := by + have hlo := Nat.le_ceil (lam/6) + have hhi := Nat.ceil_lt_add_one (by linarith : 0≤lam/6) + refine ⟨?_,by linarith,by linarith,?_⟩ + · exact_mod_cast (show (8:ℝ)≤⌈lam/6⌉₊ by linarith) + · linarith + +lemma halasz_large_root_saving {m : ℕ} (hm : 8≤m) {lam : ℝ} + (hlo : 6*(m:ℝ)-6≤lam) : + 1/((10^8:ℝ)*lam^2)≤ + (m:ℝ)^2/(4*((2*halaszSelectedMoment (12*m)*halaszSelectedMoment (12*m):ℕ):ℝ)) := by + have hmR : (8:ℝ)≤m := by exact_mod_cast hm + have hm0 : 0<(m:ℝ) := by linarith + have hlam : 5*(m:ℝ)≤lam := by linarith + have hlam0 : 0 -Real.log (Real.log X - Real.log y)) + (halaszDenominatorWeight X x / x) x := by + have hg := (hasDerivAt_const x (Real.log X)).sub (Real.hasDerivAt_log hx.ne') + have hd := ((Real.hasDerivAt_log (ne_of_gt (halasz_log_gap_pos hx hxX))).comp x hg).neg + convert hd using 1 + · rfl + · simp only [zero_sub, halaszDenominatorWeight] + ring + +lemma halasz_denominator_deriv_continuous {X a b : ℝ} (ha : 0 < a) + (hbX : b < X) : ContinuousOn (deriv (halaszDenominatorWeight X)) (Set.Icc a b) := by + have hxn (x : ℝ) (hx : x ∈ Set.Icc a b) : x ≠ 0 := (ha.trans_le hx.1).ne' + have hgap (x : ℝ) (hx : x ∈ Set.Icc a b) : Real.log X - Real.log x ≠ 0 := + (halasz_log_gap_pos (ha.trans_le hx.1) (hx.2.trans_lt hbX)).ne' + have hlog : ContinuousOn Real.log (Set.Icc a b) := + fun x hx => (Real.continuousAt_log (hxn x hx)).continuousWithinAt + apply ContinuousOn.congr (f := fun x => x⁻¹ / (Real.log X - Real.log x) ^ 2) + · exact (continuousOn_id.inv₀ hxn).div + ((continuousOn_const.sub hlog).pow 2) (fun x hx => pow_ne_zero 2 (hgap x hx)) + · intro x hx + exact (halasz_denominator_hasDerivAt (ha.trans_le hx.1) (hx.2.trans_lt hbX)).deriv + +lemma halasz_denominator_integral {X a b : ℝ} (ha : 0 < a) (hab : a ≤ b) + (hbX : b < X) : + (∫ t in a..b, halaszDenominatorWeight X t / t) = + Real.log (Real.log X - Real.log a) - Real.log (Real.log X - Real.log b) := by + have hf : ContinuousOn (fun t => halaszDenominatorWeight X t / t) (Set.Icc a b) := by + have hxn (x : ℝ) (hx : x ∈ Set.Icc a b) : x ≠ 0 := (ha.trans_le hx.1).ne' + have hgap (x : ℝ) (hx : x ∈ Set.Icc a b) : Real.log X - Real.log x ≠ 0 := + (halasz_log_gap_pos (ha.trans_le hx.1) (hx.2.trans_lt hbX)).ne' + have hlog : ContinuousOn Real.log (Set.Icc a b) := + fun x hx => (Real.continuousAt_log (hxn x hx)).continuousWithinAt + exact ((continuousOn_const.sub hlog).inv₀ hgap).div continuousOn_id hxn + have he := intervalIntegral.integral_eq_sub_of_hasDerivAt + (fun x hx => halasz_denominator_primitive + (ha.trans_le (show x ∈ Set.Icc a b from by simpa [Set.uIcc_of_le hab] using hx).1) + ((show x ∈ Set.Icc a b from by simpa [Set.uIcc_of_le hab] using hx).2.trans_lt hbX)) + (hf.intervalIntegrable_of_Icc hab) + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDenominatorMass.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDenominatorMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3992d48ab694ec65f96f6318f50cb7a4ff61fb8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDenominatorMass.lean @@ -0,0 +1,96 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDenominatorCalculus + +namespace OAI + +/-! The weighted prime mass left by the second logarithmic convolution is +only of order log log X, with an absolute constant. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +lemma halasz_denominator_prime_error {X a b : ℝ} (ha : 1 ≤ a) (hab : a ≤ b) + (hbX : b < X) : + (∑ p ∈ mrtPrimeBand a b, + halaszDenominatorWeight X p * (Real.log (p : ℝ) / p)) ≤ + Real.log (Real.log X - Real.log a) - Real.log (Real.log X - Real.log b) + + 2 * halaszMertensConstant * halaszDenominatorWeight X b := by + let w := halaszDenominatorWeight X + let E := fun x => partialCoefficientSum halaszPrimeWeight x - Real.log x + have ha0 : 0 < a := lt_of_lt_of_le zero_lt_one ha + have hxpos (x : ℝ) (hx : x ∈ Set.Icc a b) : 0 < x := ha0.trans_le hx.1 + have hxX (x : ℝ) (hx : x ∈ Set.Icc a b) : x < X := hx.2.trans_lt hbX + have hwpos (x : ℝ) (hx : x ∈ Set.Icc a b) : 0 ≤ w x := + inv_nonneg.mpr (halasz_log_gap_pos (hxpos x hx) (hxX x hx)).le + have hE (x : ℝ) (hx : x ∈ Set.Icc a b) : |E x| ≤ halaszMertensConstant := by + dsimp [E] + rw [halasz_prime_weight_prefix] + exact halasz_prime_prefix_mass (ha.trans hx.1) + have hd (x : ℝ) (hx : x ∈ Set.Icc a b) : HasDerivAt w (deriv w x) x := + (halasz_denominator_hasDerivAt (hxpos x hx) (hxX x hx)).differentiableAt.hasDerivAt + have hdc : ContinuousOn (deriv w) (Set.Icc a b) := + halasz_denominator_deriv_continuous ha0 hbX + have hdi : IntervalIntegrable (deriv w) volume a b := hdc.intervalIntegrable_of_Icc hab + have hint : (∫ x in a..b, deriv w x) = w b - w a := + intervalIntegral.integral_eq_sub_of_hasDerivAt + (fun x hx => hd x (by simpa [Set.uIcc_of_le hab] using hx)) hdi + have hi : |∫ x in a..b, deriv w x * E x| ≤ halaszMertensConstant * (w b - w a) := by + have hb := intervalIntegral.norm_integral_le_of_norm_le + (f := fun x => deriv w x * E x) (g := fun x => halaszMertensConstant * deriv w x) hab + (Filter.Eventually.of_forall (fun x hx => by + have hxi : x ∈ Set.Icc a b := ⟨hx.1.le, hx.2⟩ + have hd0 : 0 ≤ deriv w x := by + rw [(halasz_denominator_hasDerivAt (hxpos x hxi) (hxX x hxi)).deriv] + exact div_nonneg (inv_nonneg.mpr (hxpos x hxi).le) (sq_nonneg _) + rw [Real.norm_eq_abs, abs_mul, abs_of_nonneg hd0] + simpa only [mul_comm] using mul_le_mul_of_nonneg_left (hE x hxi) hd0)) + (hdi.const_mul halaszMertensConstant) + rw [Real.norm_eq_abs, intervalIntegral.integral_const_mul, hint] at hb + exact hb + have hAbel := halasz_prime_partial_summation a b ha0 hab w + (fun x hx => (hd x hx).differentiableAt) hdc + rw [halasz_denominator_integral ha0 hab hbX] at hAbel + change _ = w b * E b - w a * E a - _ at hAbel + have heb := mul_le_mul_of_nonneg_left (abs_le.mp (hE b ⟨hab, le_rfl⟩)).2 + (hwpos b ⟨hab, le_rfl⟩) + have hea := mul_le_mul_of_nonneg_left (abs_le.mp (hE a ⟨le_rfl, hab⟩)).1 + (hwpos a ⟨le_rfl, hab⟩) + have hilow := (abs_le.mp hi).1 + dsimp [w] at * + linarith + +theorem halasz_denominator_prime_mass {X L : ℝ} (hL : 1 ≤ L) (hLX : L ≤ X / 2) : + (∑ p ∈ mrtPrimeBand L (X / 2), + Real.log (p : ℝ) / ((p : ℝ) * Real.log (X / p))) ≤ + Real.log (Real.log X) - Real.log (Real.log 2) + + 2 * halaszMertensConstant / Real.log 2 := by + have hX : 2 ≤ X := by linarith + have hX0 : 0 < X := by linarith + have hL0 : 0 < L := lt_of_lt_of_le zero_lt_one hL + have hhX : X / 2 < X := by linarith + have he : Real.log X - Real.log (X / 2) = Real.log 2 := by + rw [Real.log_div hX0.ne' (by norm_num)] + ring + have hgap := halasz_log_gap_pos hL0 (lt_of_le_of_lt hLX hhX) + have hlogL : 0 ≤ Real.log L := Real.log_nonneg hL + have hmain := Real.log_le_log hgap (show Real.log X - Real.log L ≤ Real.log X by linarith) + have hb := halasz_denominator_prime_error hL hLX hhX + have hsum : (∑ p ∈ mrtPrimeBand L (X / 2), + Real.log (p : ℝ) / ((p : ℝ) * Real.log (X / p))) = + ∑ p ∈ mrtPrimeBand L (X / 2), + halaszDenominatorWeight X p * (Real.log (p : ℝ) / p) := by + apply sum_congr rfl + intro p hp + have hp0 : (0 : ℝ) < p := by exact_mod_cast (mrtPrimeBand_prime hp).pos + rw [Real.log_div hX0.ne' hp0.ne', halaszDenominatorWeight] + simp only [div_eq_mul_inv, mul_inv_rev] + ring + rw [hsum] + dsimp [halaszDenominatorWeight] + simp only [halaszDenominatorWeight, he, ← div_eq_mul_inv] at hb + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDifferenceCount.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDifferenceCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..4184f3c0ca2e86eb34be034bb228d851055f0271 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDifferenceCount.lean @@ -0,0 +1,39 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCollisionPartition +import OAI.NumberTheory.TwoPoint.Halasz.HalaszZeroRepresentation + +namespace OAI + +/-! Counting allowed differences by the zero-representation inequality. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma halasz_difference_set_count {ι : Type*} [Fintype ι] {k : ℕ} + (f : ι → Fin k → ℤ) (W : Finset (Fin k → ℤ)) : + (univ.filter (fun xy : ι×ι => f xy.1-f xy.2∈W)).card≤ + W.card*halaszRepresentationCount f 0 := by + have hsub : univ.filter (fun xy : ι×ι => f xy.1-f xy.2∈W) ⊆ + W.biUnion (fun w => univ.filter (fun xy : ι×ι => f xy.1-f xy.2=w)) := by + intro xy hxy + exact mem_biUnion.mpr ⟨f xy.1-f xy.2,(mem_filter.mp hxy).2, + mem_filter.mpr ⟨mem_univ _,rfl⟩⟩ + calc + _ ≤ _ := card_le_card hsub + _ ≤ ∑ w∈W,(univ.filter (fun xy : ι×ι => f xy.1-f xy.2=w)).card := card_biUnion_le + _ = ∑ w∈W,halaszRepresentationCount f w := rfl + _ ≤ ∑ _w∈W,halaszRepresentationCount f 0 := + sum_le_sum (fun w _ => halasz_zero_representation_dominates f w) + _ = _ := by simp + +lemma halasz_vinogradov_difference_count (s k M : ℕ) (W : Finset (Fin k → ℤ)) : + (univ.filter (fun xy : (Fin s → Fin M)×(Fin s → Fin M) => + halaszVinogradovFrequency k xy.1-halaszVinogradovFrequency k xy.2∈W)).card≤ + W.card*halaszVinogradovCount s k M := by + have h := halasz_difference_set_count (halaszVinogradovFrequency (s := s) (N := M) k) W + rw [← halasz_fiber_energy_representation,halasz_frequency_energy] at h + exact h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDistanceCutoff.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDistanceCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..026d5f20f1eda6644bc20115e457d7ebc6499915 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDistanceCutoff.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszSmoothBounds + +namespace OAI + +/-! A fixed-power change of the prime cutoff changes the squared +pretentious distance by an absolute constant. -/ + +namespace TwoPointCorrelations + +open Finset Complex +open scoped ComplexConjugate + +lemma halasz_prime_cutoff_subset {n N : ℕ} (hn : n ≤ N) : primesUpTo n ⊆ primesUpTo N := by + intro p hp + obtain ⟨hp, hprime⟩ := mem_filter.mp hp + exact mem_filter.mpr ⟨mem_range.mpr (by have := mem_range.mp hp; omega), hprime⟩ + +theorem halasz_distance_cutoff_loss : ∃ K : ℝ, 0 ≤ K ∧ + ∀ (f : ℕ → ℂ), OneBounded f → ∀ (n N : ℕ), 2 ≤ n → n ≤ N → N ≤ n ^ 3 → + ∀ t : ℝ, squaredDistance f (mrtArchimedeanTwist t) N ≤ + squaredDistance f (mrtArchimedeanTwist t) n + K := by + obtain ⟨C, hC⟩ := primeReciprocalInput + let K := 2 * (Real.log 3 + 2 * |C|) + have hK : 0 ≤ K := by dsimp [K]; positivity + refine ⟨K, hK, ?_⟩ + intro f hf n N hn hnN hNcube t + have hn0 : (0 : ℝ) < n := by exact_mod_cast (by omega : 0 < n) + have hN0 : (0 : ℝ) < N := by exact_mod_cast (by omega : 0 < N) + have hln : 0 < Real.log (n : ℝ) := Real.log_pos (by exact_mod_cast (by omega : 1 < n)) + have hlN : 0 < Real.log (N : ℝ) := Real.log_pos (by exact_mod_cast (by omega : 1 < N)) + have hlNn : Real.log (N : ℝ) ≤ 3 * Real.log (n : ℝ) := by + have h := Real.log_le_log hN0 (show (N : ℝ) ≤ (n : ℝ) ^ 3 by exact_mod_cast hNcube) + simpa only [Real.log_pow, Nat.cast_ofNat] using h + have hll : Real.log (Real.log (N : ℝ)) - Real.log (Real.log (n : ℝ)) ≤ Real.log 3 := by + have h := Real.log_le_log hlN hlNn + rw [Real.log_mul (by norm_num) hln.ne'] at h + linarith + have hmN := hC (N : ℝ) (by exact_mod_cast (show 2 ≤ N by omega)) + have hmn := hC (n : ℝ) (by exact_mod_cast hn) + rw [mrt_sievePrimesUpTo_nat] at hmN hmn + have hmass : (∑ p ∈ primesUpTo N, (1 : ℝ) / p) - + (∑ p ∈ primesUpTo n, (1 : ℝ) / p) ≤ Real.log 3 + 2 * |C| := by + have ha := (abs_le.mp hmN).2 + have hb := (abs_le.mp hmn).1 + linarith [le_abs_self C] + let P := primesUpTo N \ primesUpTo n + have hsub := halasz_prime_cutoff_subset hnN + have hterm (p : ℕ) (hp : p ∈ P) : + (1 - (f p * conj (mrtArchimedeanTwist t p)).re) / (p : ℝ) ≤ 2 * (1 / (p : ℝ)) := by + have hprime : p.Prime := (mem_filter.mp (mem_sdiff.mp hp).1).2 + have hnrm : ‖f p * conj (mrtArchimedeanTwist t p)‖ ≤ 1 := by + simpa only [norm_mul, norm_conj, mrtArchimedeanTwist_norm, mul_one] using hf p hprime.pos + have hre := (neg_le_abs _).trans ((Complex.abs_re_le_norm _).trans hnrm) + have hnum : 1 - (f p * conj (mrtArchimedeanTwist t p)).re ≤ 2 := by linarith + simpa only [mul_one_div] using div_le_div_of_nonneg_right hnum (Nat.cast_nonneg p) + have hs := sum_le_sum (fun p hp => hterm p hp) + rw [← mul_sum] at hs + have heDist := sum_sdiff hsub (f := fun p : ℕ => + (1 - (f p * conj (mrtArchimedeanTwist t p)).re) / (p : ℝ)) + have heMass := sum_sdiff hsub (f := fun p : ℕ => (1 : ℝ) / p) + change (∑ p ∈ P, (1 - (f p * conj (mrtArchimedeanTwist t p)).re) / (p : ℝ)) + + squaredDistance f (mrtArchimedeanTwist t) n = squaredDistance f (mrtArchimedeanTwist t) N at heDist + change (∑ p ∈ P, (1 : ℝ) / p) + (∑ p ∈ primesUpTo n, (1 : ℝ) / p) = + (∑ p ∈ primesUpTo N, (1 : ℝ) / p) at heMass + dsimp [K] + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDistanceDecay.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDistanceDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..5558235f2c1835d9941b5f5e881005b1a6907d5c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDistanceDecay.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDistanceCutoff + +namespace OAI + +/-! The elementary losses when changing the prime cutoff by a fixed power. -/ + +namespace TwoPointCorrelations + +lemma halasz_decay_shift {M K : ℝ} (hM : 0 ≤ M) (hK : 0 ≤ K) : + (max 0 (M - K) + 1) * Real.exp (-max 0 (M - K)) ≤ + Real.exp K * ((M + 1) * Real.exp (-M)) := by + by_cases hMK : M ≤ K + · rw [max_eq_left (by linarith : M - K ≤ 0)] + simp only [zero_add, neg_zero, Real.exp_zero, mul_one] + have he : 1 ≤ Real.exp K * Real.exp (-M) := by + rw [← Real.exp_add] + exact Real.one_le_exp_iff.mpr (by linarith) + have hmul := mul_le_mul_of_nonneg_right (show 1 ≤ M + 1 by linarith) + (mul_nonneg (Real.exp_nonneg K) (Real.exp_nonneg (-M))) + nlinarith + · rw [max_eq_right (by linarith : 0 ≤ M - K)] + have he : Real.exp (-(M - K)) = Real.exp K * Real.exp (-M) := by + rw [← Real.exp_add] + congr 1 + ring + rw [he] + have hh := mul_le_mul_of_nonneg_right (show M - K + 1 ≤ M + 1 by linarith) + (mul_nonneg (Real.exp_nonneg K) (Real.exp_nonneg (-M))) + nlinarith + +lemma halasz_log_error_cutoff {n N : ℕ} (hn : 2 ≤ n) (hnN : n ≤ N) + (hNc : N ≤ n ^ 3) (hllN : 0 ≤ Real.log (Real.log (N : ℝ))) : + Real.log (Real.log (n : ℝ)) / Real.log n ≤ + 3 * (Real.log (Real.log (N : ℝ)) / Real.log N) := by + have hn0 : (0 : ℝ) < n := by exact_mod_cast (by omega : 0 < n) + have hN0 : (0 : ℝ) < N := by exact_mod_cast (by omega : 0 < N) + have hln : 0 < Real.log (n : ℝ) := Real.log_pos (by exact_mod_cast (by omega : 1 < n)) + have hlN : 0 < Real.log (N : ℝ) := Real.log_pos (by exact_mod_cast (by omega : 1 < N)) + have hlnN : Real.log (n : ℝ) ≤ Real.log (N : ℝ) := + Real.log_le_log hn0 (by exact_mod_cast hnN) + have hln3 : Real.log (N : ℝ) ≤ 3 * Real.log (n : ℝ) := by + have h := Real.log_le_log hN0 (show (N : ℝ) ≤ (n : ℝ) ^ 3 by exact_mod_cast hNc) + simpa only [Real.log_pow, Nat.cast_ofNat] using h + calc + _ ≤ Real.log (Real.log (N : ℝ)) / Real.log n := + div_le_div_of_nonneg_right (Real.log_le_log hln hlnN) hln.le + _ ≤ 3 * (Real.log (Real.log (N : ℝ)) / Real.log N) := by + rw [← mul_div_assoc] + apply (div_le_div_iff₀ hln hlN).mpr + nlinarith [mul_le_mul_of_nonneg_left hln3 hllN] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDistinctMoment.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDistinctMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..a566becfaaac1f5a790754036a87695b9a7620a7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDistinctMoment.lean @@ -0,0 +1,35 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCollisionPartition + +namespace OAI + +/-! At least half the complete-system solutions have distinct chosen +long coordinates on both sides, once the elementary size threshold holds. -/ +namespace TwoPointCorrelations + +theorem halasz_distinct_moment {s k n N ℓ : ℕ} (hs : 0 (hpbounds p hp).2) _ + have hpiece (j : ℕ) : ‖halaszGroupedDouble f N (halaszPrimeBandPart P N j)‖ ≤ + D * N * min A (halaszBandScale j) + + D * N * halaszBandScale j * W / (δ * T) + + (m : ℝ) / halaszBandScale j * Real.log (3 * N) ^ 2 := by + let v := halaszBandScale j + have hv : Real.log 2 ≤ v := halasz_band_scale_ge_log_two j + have hv0 : 0 < v := htwo.trans_le hv + have hPb : ∀ p ∈ halaszPrimeBandPart P N j, p.Prime ∧ + v ≤ Real.log ((N : ℝ) / p) ∧ Real.log ((N : ℝ) / p) < 2 * v := by + intro p hp + exact ⟨hPl p (mem_filter.mp hp).1, + halasz_prime_band_part_bounds P (fun p hp => (hpbounds p hp).1) hp⟩ + have hPbig : ∀ p ∈ halaszPrimeBandPart P N j, p.Prime ∧ T ^ 2 ≤ (p : ℝ) ∧ + v ≤ Real.log ((N : ℝ) / p) ∧ Real.log ((N : ℝ) / p) < 2 * v := by + intro p hp + have hpp := (mem_filter.mp hp).1 + have hb := mrtPrimeBand_bounds (show 0 ≤ L by linarith) (by positivity) hpp + exact ⟨(hPb p hp).1, hTL.trans hb.1.le, (hPb p hp).2⟩ + have ht := htrivial f hbound N v (by omega) hv _ hPb + have ha := hanalytic f hf1 hf hbound N m v T A W hN hm hmN hv hBT hA hW _ hPbig hFA hFW + have htD : ‖halaszGroupedDouble f N (halaszPrimeBandPart P N j)‖ ≤ D * N * v := + ht.trans (by gcongr) + have haD : ‖halaszGroupedDouble f N (halaszPrimeBandPart P N j)‖ ≤ + D * N * A + D * N * v * W / (δ * T) + (m : ℝ) / v * Real.log (3 * N) ^ 2 := + ha.trans (by gcongr) + change ‖halaszGroupedDouble f N (halaszPrimeBandPart P N j)‖ ≤ + D * N * min A v + D * N * v * W / (δ * T) + (m : ℝ) / v * Real.log (3 * N) ^ 2 + by_cases hvA : v ≤ A + · rw [min_eq_right hvA] + have herr : 0 ≤ D * N * v * W / (δ * T) + (m : ℝ) / v * Real.log (3 * N) ^ 2 := by positivity + linarith + · rw [min_eq_left (le_of_not_ge hvA)] + exact haD + have htop : halaszBandScale J ≤ 2 * Real.log (N : ℝ) := by + have hb := (halasz_band_scale_bounds hNlog).1 + have he : halaszBandScale J = 2 * halaszBandScale (halaszBandIndex (Real.log (N : ℝ))) := by + dsimp [J, halaszBandScale] + rw [pow_succ] + ring + rw [he] + linarith + have hmin := hgeometric J V M hV hM (htop.trans (by linarith)) + have hscales := (halasz_band_scale_sum_le J).trans htop + have hinverses := halasz_band_inverse_sum_le J + have hsum : ‖halaszDoubleConvolution f N L‖ ≤ + (D * N) * (∑ j ∈ range J, min A (halaszBandScale j)) + + (D * N * W / (δ * T)) * (∑ j ∈ range J, halaszBandScale j) + + ((m : ℝ) * Real.log (3 * N) ^ 2) * (∑ j ∈ range J, (halaszBandScale j)⁻¹) := by + rw [hpart] + apply (norm_sum_le _ _).trans + apply (sum_le_sum (fun j _ => hpiece j)).trans_eq + simp only [mul_sum, ← sum_add_distrib] + apply sum_congr rfl + intro j _ + ring + have hc1 : D * G ≤ C := by + dsimp [C] + linarith [show 0 ≤ 2 / Real.log 2 by positivity] + have hc2 : 2 * D ≤ C := by + dsimp [C] + linarith [show 0 ≤ D * G by positivity, show 0 ≤ 2 / Real.log 2 by positivity] + have hc3 : 2 / Real.log 2 ≤ C := by + dsimp [C] + linarith [show 0 ≤ D * G by positivity] + calc + _ ≤ _ := hsum + _ ≤ (D * N) * (G * V * (M + 1) * Real.exp (-M)) + + (D * N * W / (δ * T)) * (2 * Real.log (N : ℝ)) + + ((m : ℝ) * Real.log (3 * N) ^ 2) * (2 / Real.log 2) := by + gcongr + _ = (D * G) * N * V * (M + 1) * Real.exp (-M) + + (2 * D) * N * W * Real.log N / (δ * T) + + (2 / Real.log 2) * m * Real.log (3 * N) ^ 2 := by ring + _ ≤ _ := by gcongr + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleException.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleException.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e2e9a19bfefec0732c6fba333a9855420ea9975 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleException.lean @@ -0,0 +1,157 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszGroupedException +import OAI.NumberTheory.TwoPoint.Halasz.HalaszBandSummation + +namespace OAI + +/-! Sum the actual geometric prime bands. The central terms retain the +Halász saving, and both kinds of error have summable band weights. -/ + +namespace TwoPointCorrelations + +open Finset Complex +open scoped Classical + +theorem halasz_double_convolution_exception : ∃ C B : ℝ, 0 < C ∧ 2 ≤ B ∧ + ∀ (f : ℕ → ℂ), f 1 = 1 → + (∀ a b, 0 < a → 0 < b → f (a * b) = f a * f b) → OneBounded f → + ∀ (N m : ℕ) (L T V W M₀ τ : ℝ), 2 ≤ N → 0 < m → m ≤ N → + 1 ≤ L → T ^ 2 ≤ L → B ≤ T → Real.log N ≤ V → 0 ≤ W → 0 ≤ M₀ → + (∀ t ∈ Set.Ioc (-T) T, t ∉ Set.Ioc (τ-1/2) (τ+1/2) → + ‖LSeries (halaszSmoothFunction f N) (1 + (t : ℂ) * I)‖ ≤ V * Real.exp (-M₀)) → + (∀ t : ℝ, ‖LSeries (halaszSmoothFunction f N) (1 + (t : ℂ) * I)‖ ≤ W) → + ‖halaszDoubleConvolution f N L‖ ≤ + C * N * (V+W) * (min M₀ (Real.log (1+|τ|)) + 1) * + Real.exp (-min M₀ (Real.log (1+|τ|))) + + C * N * W * Real.log N / (((m : ℝ) / ((N : ℝ) + 1 / 2)) * T) + + C * m * Real.log (3 * N) ^ 2 := by + obtain ⟨C₁, B, hC₁, hB, hanalytic⟩ := halasz_grouped_double_exception + obtain ⟨C₂, hC₂, htrivial⟩ := halasz_grouped_double_trivial + obtain ⟨G, hG, hgeometric⟩ := halasz_band_saving_sum + let D := C₁ + C₂ + let C := 1 + D * G + 2 * D + 2 / Real.log 2 + have hD : 0 < D := add_pos hC₁ hC₂ + have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hC : 0 < C := by dsimp [C]; positivity + refine ⟨C, B, hC, hB, ?_⟩ + intro f hf1 hf hbound N m L T V W M₀ τ hN hm hmN hL hTL hBT hNV hW hM₀ hFA hFW + let P := mrtPrimeBand L ((N : ℝ) / 2) + let J := halaszBandIndex (Real.log (N : ℝ)) + 1 + let M := min M₀ (Real.log (1+|τ|)) + let A₀ := V * Real.exp (-M₀) + let A := (V+W) * Real.exp (-M) + let δ := (m : ℝ) / ((N : ℝ) + 1 / 2) + have hN0 : (0 : ℝ) < N := by exact_mod_cast (by omega : 0 < N) + have hNlog : Real.log 2 ≤ Real.log (N : ℝ) := + Real.log_le_log (by norm_num) (by exact_mod_cast hN) + have hlog0 : 0 < Real.log (N : ℝ) := htwo.trans_le hNlog + have hV : 0 ≤ V := hlog0.le.trans hNV + have hM : 0 ≤ M := le_min hM₀ (Real.log_nonneg (by linarith [abs_nonneg τ])) + have hA₀ : 0 ≤ A₀ := by dsimp [A₀]; positivity + have hA : 0 ≤ A := by dsimp [A]; positivity + have heffective : A₀+W/(1+|τ|) ≤ A := by + have h1 : Real.exp (-M₀) ≤ Real.exp (-M) := + Real.exp_le_exp.mpr (neg_le_neg (min_le_left _ _)) + have h2 : 1/(1+|τ|) ≤ Real.exp (-M) := by + have hh := Real.exp_le_exp.mpr (neg_le_neg (min_le_right M₀ (Real.log (1+|τ|)))) + rw [Real.exp_neg,Real.exp_log (by positivity : 0 < 1+|τ|)] at hh + simpa only [one_div,M] using hh + dsimp [A₀,A] + have hv := mul_le_mul_of_nonneg_left h1 hV + have hw := mul_le_mul_of_nonneg_left h2 hW + calc + _ ≤ V*Real.exp (-M)+W*Real.exp (-M) := + add_le_add hv (by simpa only [mul_one_div] using hw) + _ = _ := by ring + have hT : 0 < T := lt_of_lt_of_le (by linarith : (0 : ℝ) < B) hBT + have hδ : 0 < δ := by dsimp [δ]; positivity + have hC₁D : C₁ ≤ D := by dsimp [D]; linarith + have hC₂D : C₂ ≤ D := by dsimp [D]; linarith + have hPl (p : ℕ) (hp : p ∈ P) : p.Prime := mrtPrimeBand_prime hp + have hpbounds (p : ℕ) (hp : p ∈ P) : Real.log 2 ≤ Real.log ((N : ℝ) / p) ∧ + Real.log ((N : ℝ) / p) ≤ Real.log (N : ℝ) := by + have hp0 : (0 : ℝ) < p := by exact_mod_cast (hPl p hp).pos + have hb := mrtPrimeBand_bounds (show 0 ≤ L by linarith) (by positivity) hp + have hquot : (2 : ℝ) ≤ (N : ℝ) / p := (le_div_iff₀ hp0).mpr (by linarith) + exact ⟨Real.log_le_log (by norm_num) hquot, + Real.log_le_log (div_pos hN0 hp0) (div_le_self hN0.le (by exact_mod_cast (hPl p hp).one_le))⟩ + have hpart : halaszDoubleConvolution f N L = + ∑ j ∈ range J, halaszGroupedDouble f N (halaszPrimeBandPart P N j) := by + exact halasz_prime_band_partition P (fun p hp => (hpbounds p hp).2) _ + have hpiece (j : ℕ) : ‖halaszGroupedDouble f N (halaszPrimeBandPart P N j)‖ ≤ + D * N * min A (halaszBandScale j) + + D * N * halaszBandScale j * W / (δ * T) + + (m : ℝ) / halaszBandScale j * Real.log (3 * N) ^ 2 := by + let v := halaszBandScale j + have hv : Real.log 2 ≤ v := halasz_band_scale_ge_log_two j + have hv0 : 0 < v := htwo.trans_le hv + have hPb : ∀ p ∈ halaszPrimeBandPart P N j, p.Prime ∧ + v ≤ Real.log ((N : ℝ) / p) ∧ Real.log ((N : ℝ) / p) < 2 * v := by + intro p hp + exact ⟨hPl p (mem_filter.mp hp).1, + halasz_prime_band_part_bounds P (fun p hp => (hpbounds p hp).1) hp⟩ + have hPbig : ∀ p ∈ halaszPrimeBandPart P N j, p.Prime ∧ T ^ 2 ≤ (p : ℝ) ∧ + v ≤ Real.log ((N : ℝ) / p) ∧ Real.log ((N : ℝ) / p) < 2 * v := by + intro p hp + have hpp := (mem_filter.mp hp).1 + have hb := mrtPrimeBand_bounds (show 0 ≤ L by linarith) (by positivity) hpp + exact ⟨(hPb p hp).1, hTL.trans hb.1.le, (hPb p hp).2⟩ + have ht := htrivial f hbound N v (by omega) hv _ hPb + have ha := hanalytic f hf1 hf hbound N m v T A₀ W τ hN hm hmN hv hBT hA₀ hW _ hPbig hFA hFW + have htD : ‖halaszGroupedDouble f N (halaszPrimeBandPart P N j)‖ ≤ D * N * v := + ht.trans (by gcongr) + have haD : ‖halaszGroupedDouble f N (halaszPrimeBandPart P N j)‖ ≤ + D * N * A + D * N * v * W / (δ * T) + (m : ℝ) / v * Real.log (3 * N) ^ 2 := + ha.trans (by gcongr) + change ‖halaszGroupedDouble f N (halaszPrimeBandPart P N j)‖ ≤ + D * N * min A v + D * N * v * W / (δ * T) + (m : ℝ) / v * Real.log (3 * N) ^ 2 + by_cases hvA : v ≤ A + · rw [min_eq_right hvA] + have herr : 0 ≤ D * N * v * W / (δ * T) + (m : ℝ) / v * Real.log (3 * N) ^ 2 := by positivity + linarith + · rw [min_eq_left (le_of_not_ge hvA)] + exact haD + have htop : halaszBandScale J ≤ 2 * Real.log (N : ℝ) := by + have hb := (halasz_band_scale_bounds hNlog).1 + have he : halaszBandScale J = 2 * halaszBandScale (halaszBandIndex (Real.log (N : ℝ))) := by + dsimp [J, halaszBandScale] + rw [pow_succ] + ring + rw [he] + linarith + have hmin := hgeometric J (V+W) M (add_nonneg hV hW) hM (htop.trans (by linarith)) + have hscales := (halasz_band_scale_sum_le J).trans htop + have hinverses := halasz_band_inverse_sum_le J + have hsum : ‖halaszDoubleConvolution f N L‖ ≤ + (D * N) * (∑ j ∈ range J, min A (halaszBandScale j)) + + (D * N * W / (δ * T)) * (∑ j ∈ range J, halaszBandScale j) + + ((m : ℝ) * Real.log (3 * N) ^ 2) * (∑ j ∈ range J, (halaszBandScale j)⁻¹) := by + rw [hpart] + apply (norm_sum_le _ _).trans + apply (sum_le_sum (fun j _ => hpiece j)).trans_eq + simp only [mul_sum, ← sum_add_distrib] + apply sum_congr rfl + intro j _ + ring + have hc1 : D * G ≤ C := by + dsimp [C] + linarith [show 0 ≤ 2 / Real.log 2 by positivity] + have hc2 : 2 * D ≤ C := by + dsimp [C] + linarith [show 0 ≤ D * G by positivity, show 0 ≤ 2 / Real.log 2 by positivity] + have hc3 : 2 / Real.log 2 ≤ C := by + dsimp [C] + linarith [show 0 ≤ D * G by positivity] + calc + _ ≤ _ := hsum + _ ≤ (D * N) * (G * (V+W) * (M + 1) * Real.exp (-M)) + + (D * N * W / (δ * T)) * (2 * Real.log (N : ℝ)) + + ((m : ℝ) * Real.log (3 * N) ^ 2) * (2 / Real.log 2) := by + gcongr + _ = (D * G) * N * (V+W) * (M + 1) * Real.exp (-M) + + (2 * D) * N * W * Real.log N / (δ * T) + + (2 / Real.log 2) * m * Real.log (3 * N) ^ 2 := by ring + _ ≤ _ := by gcongr + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleHolder.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleHolder.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd2e71ab0846a80d7c56648d6b944f0305a67106 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleHolder.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszFiberHolder +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCollisionPartition + +namespace OAI + +/-! The two Hölder steps in Ford's double mean-value argument (Lemma 5.1), +with the full complete-system frequency on both sides. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem halasz_double_holder {ι : Type*} (B : Finset ι) (k M r s : ℕ) + (hr : 1≤r) (hs : 1≤s) (α : ι → Fin k → AddCircle (1:ℝ)) : + ∃ ε : ι → ℂ, (∀ b, ‖ε b‖=1) ∧ + ‖∑ b∈B,halaszVinogradovPolynomial k M (α b)‖^(2*r*s) ≤ + (B.card:ℝ)^((r-1)*(2*s))*(M:ℝ)^(r*(2*s-2))* + (halaszVinogradovCount r k M:ℝ)* + ∑ c∈(univ : Finset (Fin r → Fin M)).image (halaszVinogradovFrequency k), + ‖∑ b∈B,ε b*halaszVinogradovCharacter c (α b)‖^(2*s) := by + let P := fun b => halaszVinogradovPolynomial k M (α b) + choose ε hεnorm hεeq using (fun b : ι => Complex.exists_norm_eq_mul_self ((P b)^r)) + refine ⟨ε,hεnorm,?_⟩ + let V := fun c : Fin k → ℤ => ∑ b∈B,ε b*halaszVinogradovCharacter c (α b) + have hnonneg : 0≤∑ b∈B,‖P b‖^r := sum_nonneg (fun _ _ => by positivity) + have hexpand : ((∑ b∈B,‖P b‖^r:ℝ):ℂ)=∑ x : Fin r → Fin M, + V (halaszVinogradovFrequency k x) := by + push_cast + simp_rw [show ∀ b, ((‖P b‖:ℝ):ℂ)^r=ε b*(P b)^r from fun b => by + simpa only [norm_pow,Complex.ofReal_pow] using hεeq b] + dsimp only [P] + simp_rw [halasz_vinogradov_power_expand,mul_sum] + exact sum_comm + have hnorm : (∑ b∈B,‖P b‖^r:ℝ)= + ‖∑ x : Fin r → Fin M,V (halaszVinogradovFrequency k x)‖ := by + have hh := congrArg norm hexpand + simpa only [Complex.norm_real,Real.norm_eq_abs,abs_of_nonneg hnonneg] using hh + have h1 := halasz_complex_sum_power B P hr + have hp := pow_le_pow_left₀ (pow_nonneg (norm_nonneg _) r) h1 (2*s) + rw [mul_pow,← pow_mul,← pow_mul,hnorm] at hp + have h2 := halasz_fiber_holder (univ : Finset (Fin r → Fin M)) + (halaszVinogradovFrequency k) V hs + rw [halasz_frequency_energy] at h2 + simp only [card_univ,Fintype.card_fun,Fintype.card_fin,Nat.cast_pow,← pow_mul] at h2 + have hh := mul_le_mul_of_nonneg_left h2 + (pow_nonneg (Nat.cast_nonneg B.card) ((r-1)*(2*s))) + have he : r*(2*s)=2*r*s := by ring + rw [he] at hp + have himage (d : DecidableEq (Fin k → ℤ)) : + @Finset.image (Fin r → Fin M) (Fin k → ℤ) d (halaszVinogradovFrequency k) univ = + @Finset.image (Fin r → Fin M) (Fin k → ℤ) + (fun a b => Fintype.decidablePiFintype a b) (halaszVinogradovFrequency k) univ := by + ext c + simp only [mem_image] + rw [himage] at hh + exact hp.trans (by simpa only [V,mul_assoc] using hh) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleMean.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e5049ac1b05422698b3ea7511e00e840d4d9523 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleMean.lean @@ -0,0 +1,124 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDoubleConvolution +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDenominatorMass + +namespace OAI + +/-! The ordinary mean reduces to the adaptive double prime convolution, +with an explicit N log log N error. -/ + +namespace TwoPointCorrelations + +open Finset + +noncomputable def halaszDenominatorConstant : ℝ := + -Real.log (Real.log 2) + 2 * halaszMertensConstant / Real.log 2 + +theorem halasz_double_mean_bound (f : ℕ → ℂ) (hf : OneBounded f) + (hmul : ∀ m n : ℕ, 0 < m → 0 < n → f (m * n) = f m * f n) + (N : ℕ) {L : ℝ} (hL : 1 ≤ L) (hLN : L ≤ (N : ℝ) / 2) : + Real.log (N : ℝ) * ‖∑ n ∈ Icc 1 N, f n‖ ≤ + ‖halaszDoubleConvolution f N L‖ + (N : ℝ) * + (Real.log L + Real.log 2 + 3 * halaszMertensConstant + + halaszPrimePowerConstant + 1 + halaszInnerErrorConstant * + (Real.log (Real.log N) + halaszDenominatorConstant)) := by + have hmass := halasz_denominator_prime_mass hL hLN + have hm := halasz_double_convolution_error f hf hmul N hL + have hC : 0 ≤ halaszInnerErrorConstant * (N : ℝ) := + mul_nonneg halaszInnerErrorConstant_nonneg (Nat.cast_nonneg _) + have herr : ‖halaszPrimeBandConvolution f N L ((N : ℝ) / 2) - + halaszDoubleConvolution f N L‖ ≤ + halaszInnerErrorConstant * (N : ℝ) * + (Real.log (Real.log N) + halaszDenominatorConstant) := by + apply hm.trans + apply mul_le_mul_of_nonneg_left _ hC + simpa only [halaszDenominatorConstant, sub_eq_add_neg, add_assoc] using hmass + have hn := norm_add_le (halaszDoubleConvolution f N L) + (halaszPrimeBandConvolution f N L ((N : ℝ) / 2) - halaszDoubleConvolution f N L) + rw [add_sub_cancel] at hn + have ht := halasz_truncated_convolution_mean_bound f hf hmul N hL hLN + nlinarith + +noncomputable def halaszDoubleErrorConstant : ℝ := + 4 + (Real.log 2 + 3 * halaszMertensConstant + halaszPrimePowerConstant + 1) + + halaszInnerErrorConstant * (1 + |halaszDenominatorConstant|) + +lemma halaszDoubleErrorConstant_nonneg : 0 ≤ halaszDoubleErrorConstant := by + have hm := halaszMertensConstant_nonneg + have hp := halaszPrimePowerConstant_nonneg + have hi := halaszInnerErrorConstant_nonneg + have h2 : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) + unfold halaszDoubleErrorConstant + positivity + +/-- The logarithmic-fourth-power prime cutoff used in the mean-value proof. -/ +theorem halasz_double_mean_log_fourth (f : ℕ → ℂ) (hf : OneBounded f) + (hmul : ∀ m n : ℕ, 0 < m → 0 < n → f (m * n) = f m * f n) + (N : ℕ) (hlog : 1 ≤ Real.log (Real.log (N : ℝ))) + (hL : 1 ≤ Real.log (N : ℝ) ^ 4) + (hLN : Real.log (N : ℝ) ^ 4 ≤ (N : ℝ) / 2) : + Real.log (N : ℝ) * ‖∑ n ∈ Icc 1 N, f n‖ ≤ + ‖halaszDoubleConvolution f N (Real.log (N : ℝ) ^ 4)‖ + + halaszDoubleErrorConstant * (N : ℝ) * Real.log (Real.log N) := by + have hb := halasz_double_mean_bound f hf hmul N hL hLN + have hpow : Real.log (Real.log (N : ℝ) ^ 4) = 4 * Real.log (Real.log (N : ℝ)) := by + rw [Real.log_pow] + norm_num + rw [hpow] at hb + have hA : 0 ≤ Real.log 2 + 3 * halaszMertensConstant + halaszPrimePowerConstant + 1 := by + have hm := halaszMertensConstant_nonneg + have hp := halaszPrimePowerConstant_nonneg + have h2 : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) + positivity + have hi := halaszInnerErrorConstant_nonneg + have hsmall := mul_le_mul_of_nonneg_left hlog hA + have hD : halaszDenominatorConstant ≤ |halaszDenominatorConstant| * + Real.log (Real.log (N : ℝ)) := + (le_abs_self _).trans (le_mul_of_one_le_right (abs_nonneg _) hlog) + have hprod := mul_le_mul_of_nonneg_left hD hi + have hscalar : 4 * Real.log (Real.log (N : ℝ)) + Real.log 2 + + 3 * halaszMertensConstant + halaszPrimePowerConstant + 1 + + halaszInnerErrorConstant * (Real.log (Real.log N) + halaszDenominatorConstant) ≤ + halaszDoubleErrorConstant * Real.log (Real.log N) := by + unfold halaszDoubleErrorConstant + nlinarith + have hmulN := mul_le_mul_of_nonneg_left hscalar (Nat.cast_nonneg N : (0 : ℝ) ≤ N) + nlinarith + +/-- The larger fixed logarithmic cutoff needed by the narrow-window +truncation. The deletion error still has order N log log N. -/ +theorem halasz_double_mean_log_sixteenth (f : ℕ → ℂ) (hf : OneBounded f) + (hmul : ∀ m n : ℕ, 0 < m → 0 < n → f (m * n) = f m * f n) + (N : ℕ) (hlog : 1 ≤ Real.log (Real.log (N : ℝ))) + (hL : 1 ≤ Real.log (N : ℝ) ^ 16) + (hLN : Real.log (N : ℝ) ^ 16 ≤ (N : ℝ) / 2) : + Real.log (N : ℝ) * ‖∑ n ∈ Icc 1 N, f n‖ ≤ + ‖halaszDoubleConvolution f N (Real.log (N : ℝ) ^ 16)‖ + + (halaszDoubleErrorConstant + 12) * (N : ℝ) * Real.log (Real.log N) := by + have hb := halasz_double_mean_bound f hf hmul N hL hLN + have hpow : Real.log (Real.log (N : ℝ) ^ 16) = 16 * Real.log (Real.log (N : ℝ)) := by + rw [Real.log_pow] + norm_num + rw [hpow] at hb + have hA : 0 ≤ Real.log 2 + 3 * halaszMertensConstant + halaszPrimePowerConstant + 1 := by + have hm := halaszMertensConstant_nonneg + have hp := halaszPrimePowerConstant_nonneg + have h2 : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) + positivity + have hi := halaszInnerErrorConstant_nonneg + have hsmall := mul_le_mul_of_nonneg_left hlog hA + have hD : halaszDenominatorConstant ≤ |halaszDenominatorConstant| * + Real.log (Real.log (N : ℝ)) := + (le_abs_self _).trans (le_mul_of_one_le_right (abs_nonneg _) hlog) + have hprod := mul_le_mul_of_nonneg_left hD hi + have hscalar : 16 * Real.log (Real.log (N : ℝ)) + Real.log 2 + + 3 * halaszMertensConstant + halaszPrimePowerConstant + 1 + + halaszInnerErrorConstant * (Real.log (Real.log N) + halaszDenominatorConstant) ≤ + (halaszDoubleErrorConstant + 12) * Real.log (Real.log N) := by + unfold halaszDoubleErrorConstant + nlinarith + have hmulN := mul_le_mul_of_nonneg_left hscalar (Nat.cast_nonneg N : (0 : ℝ) ≤ N) + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleMeanValue.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleMeanValue.lean new file mode 100644 index 0000000000000000000000000000000000000000..5664b3b054a706d7fb1df24f73ca2986a2bc9def --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleMeanValue.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMomentSampling +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDoubleHolder + +namespace OAI + +/-! The double mean-value bound with two complete Vinogradov systems. +The explicit coordinate minimum is retained for logarithmic Taylor phases. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem halasz_double_mean_value (k M₁ M₂ r s : ℕ) (hr : 1≤r) (hs : 1≤s) + (γ δ : Fin k → ℝ) (hγ : ∀ j,γ j≠0) (hδ : ∀ j,0≤δ j) + (hδquarter : ∀ j,δ j≤1/4) + (hphase : ∀ j,2*Real.pi*((r*M₁^(j.val+1):ℕ):ℝ)*δ j≤1) : + (∏ j,δ j)^2* + ‖∑ b : Fin M₂,halaszVinogradovPolynomial k M₁ + (halaszScaledFrequency γ (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)))‖^(2*r*s) ≤ + (M₂:ℝ)^((r-1)*(2*s))*(M₁:ℝ)^(r*(2*s-2))* + (halaszVinogradovCount r k M₁:ℝ)*(∏ j,2*δ j)* + (halaszVinogradovCount s k M₂:ℝ)* + ∏ j,min (2*((s*M₂^(j.val+1):ℕ):ℝ)+1) + (8*((s*M₂^(j.val+1):ℕ):ℝ)*δ j+ + 2*((s*M₂^(j.val+1):ℕ):ℝ)* |γ j| +8*δ j/ |γ j| +2) := by + let α : Fin M₂ → Fin k → AddCircle (1:ℝ) := fun b => + halaszScaledFrequency γ (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)) + let S := (univ : Finset (Fin r → Fin M₁)).image (halaszVinogradovFrequency k) + obtain ⟨ε,hε,hd⟩ := halasz_double_holder (univ : Finset (Fin M₂)) k M₁ r s hr hs α + have hm := halasz_moment_sampling s S ε γ δ (fun b => (hε b).le) hγ hδ hδquarter (by + intro m hm j + obtain ⟨x,_,rfl⟩ := mem_image.mp hm + have hx : |(halaszVinogradovFrequency k x j:ℝ)|≤((r*M₁^(j.val+1):ℕ):ℝ) := by + rw [abs_of_nonneg (by exact_mod_cast halasz_vinogradov_frequency_nonneg x j)] + exact_mod_cast halasz_vinogradov_frequency_le x j + have hpi : 0≤2*Real.pi*δ j := mul_nonneg (by positivity) (hδ j) + nlinarith [mul_le_mul_of_nonneg_left hx hpi,hphase j]) + let C := (M₂:ℝ)^((r-1)*(2*s))*(M₁:ℝ)^(r*(2*s-2))* + (halaszVinogradovCount r k M₁:ℝ) + have hC : 0≤C := by dsimp only [C]; positivity + have hd' : + ‖∑ b : Fin M₂,halaszVinogradovPolynomial k M₁ (α b)‖^(2*r*s)≤ + C*∑ m∈S,‖∑ b : Fin M₂,ε b*halaszVinogradovCharacter m (α b)‖^(2*s) := by + simpa only [card_univ,Fintype.card_fin,C,S] using hd + calc + _ ≤ (∏ j,δ j)^2*(C*∑ m∈S, + ‖∑ b : Fin M₂,ε b*halaszVinogradovCharacter m (α b)‖^(2*s)) := + mul_le_mul_of_nonneg_left hd' (sq_nonneg _) + _ = C*((∏ j,δ j)^2*∑ m∈S, + ‖∑ b : Fin M₂,ε b*halaszVinogradovCharacter m (α b)‖^(2*s)) := by ring + _ ≤ C*((∏ j,2*δ j)*(halaszVinogradovCount s k M₂:ℝ)* + ∏ j,min (2*((s*M₂^(j.val+1):ℕ):ℝ)+1) + (8*((s*M₂^(j.val+1):ℕ):ℝ)*δ j+ + 2*((s*M₂^(j.val+1):ℕ):ℝ)* |γ j| +8*δ j/ |γ j| +2)) := + mul_le_mul_of_nonneg_left hm hC + _ = _ := by dsimp only [C]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleOscillation.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleOscillation.lean new file mode 100644 index 0000000000000000000000000000000000000000..18091be1ebc7f8b3b239cccf73cce17ddf18f676 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleOscillation.lean @@ -0,0 +1,120 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszAffineAmplitude + +namespace OAI + +/-! Two integrations by parts for an affine-weighted logarithmic phase. +The exact boundary formula is used on the two sides of a triangular weight. -/ +namespace TwoPointCorrelations + +open MeasureTheory + +noncomputable def halaszLogAmplitude0 (u v m c x : ℝ) : ℝ := + (m*x+c) / halaszLogSlope u v x + +noncomputable def halaszLogAmplitude2 (u v m c x : ℝ) : ℝ := + m/(halaszLogSlope u v x)^2 + + (m*x+c)*u/(x^2*(halaszLogSlope u v x)^3) + +noncomputable def halaszLogAmplitude2Deriv (u v m c x : ℝ) : ℝ := + 3*m*u/(x^2*(halaszLogSlope u v x)^3) - + 2*(m*x+c)*u/(x^3*(halaszLogSlope u v x)^3) + + 3*(m*x+c)*u^2/(x^4*(halaszLogSlope u v x)^4) + +lemma halasz_log_amplitude0_deriv (u v m c x : ℝ) (hx : x ≠ 0) + (hd : halaszLogSlope u v x ≠ 0) : + HasDerivAt (halaszLogAmplitude0 u v m c) + (m/(halaszLogSlope u v x) + + (m*x+c)*halaszLogReciprocalDeriv u v x) x := by + have hh := (((hasDerivAt_id x).const_mul m).add_const c).mul + (halasz_log_reciprocal_deriv u v x hx hd) + convert hh using 1 + · funext y + simp only [halaszLogAmplitude0, div_eq_mul_inv, Pi.mul_apply, id_eq] + · dsimp only [id_eq] + ring + +lemma halasz_log_amplitude2_deriv (u v m c x : ℝ) (hx : x ≠ 0) + (hd : halaszLogSlope u v x ≠ 0) : + HasDerivAt (halaszLogAmplitude2 u v m c) + (halaszLogAmplitude2Deriv u v m c x) x := by + have hD : HasDerivAt (halaszLogSlope u v) (-u/x^2) x := by + convert ((hasDerivAt_const x u).div (hasDerivAt_id x) hx).sub_const v using 1 + · rfl + · simp only [id_eq, zero_mul, mul_one, zero_sub, neg_div] + have hw := ((hasDerivAt_id x).const_mul m).add_const c + have h1 := (hasDerivAt_const x m).div (hD.pow 2) (pow_ne_zero 2 hd) + have h2 := (hw.mul_const u).div + (((hasDerivAt_id x).pow 2).mul (hD.pow 3)) + (mul_ne_zero (pow_ne_zero 2 hx) (pow_ne_zero 3 hd)) + convert h1.add h2 using 1 + · rfl + · dsimp only [halaszLogAmplitude2Deriv, id_eq, Pi.pow_apply, Pi.mul_apply] + norm_num only [Nat.cast_ofNat, Nat.reduceSub] + field_simp [hx, hd] + ring + +noncomputable def halaszLogDoublePrimitive (u v m c x : ℝ) : ℂ := + halaszLogPhase u v x * ((halaszLogAmplitude2 u v m c x:ℂ) - + Complex.I*(halaszLogAmplitude0 u v m c x:ℂ)) + +lemma halasz_log_double_primitive_deriv (u v m c x : ℝ) (hx : x ≠ 0) + (hd : halaszLogSlope u v x ≠ 0) : + HasDerivAt (halaszLogDoublePrimitive u v m c) + (((m*x+c:ℝ):ℂ)*halaszLogPhase u v x + + (halaszLogAmplitude2Deriv u v m c x:ℂ)*halaszLogPhase u v x) x := by + have hh := (halasz_log_phase_deriv u v x hx).mul + ((halasz_log_amplitude2_deriv u v m c x hx hd).ofReal_comp.sub + ((halasz_log_amplitude0_deriv u v m c x hx hd).ofReal_comp.const_mul Complex.I)) + convert hh using 1 + · rfl + · dsimp only [halaszLogAmplitude0, halaszLogAmplitude2, halaszLogReciprocalDeriv, Pi.sub_apply] + push_cast + have hx' : (x:ℂ) ≠ 0 := by exact_mod_cast hx + have hd' : (halaszLogSlope u v x:ℂ) ≠ 0 := by exact_mod_cast hd + field_simp [hx', hd'] + ring_nf + simp only [Complex.I_sq] + ring + +lemma halasz_log_amplitude2_deriv_continuousOn (u v m c a b : ℝ) (ha : 0 < a) + (hd : ∀ x ∈ Set.Icc a b, halaszLogSlope u v x ≠ 0) : + ContinuousOn (halaszLogAmplitude2Deriv u v m c) (Set.Icc a b) := by + have hx (x : ℝ) (h : x ∈ Set.Icc a b) : x ≠ 0 := (ha.trans_le h.1).ne' + have hD : ContinuousOn (halaszLogSlope u v) (Set.Icc a b) := + (continuousOn_const.div continuousOn_id hx).sub continuousOn_const + have hw : ContinuousOn (fun x : ℝ => m*x+c) (Set.Icc a b) := + (continuousOn_const.mul continuousOn_id).add continuousOn_const + apply ContinuousOn.add + · apply ContinuousOn.sub + · exact continuousOn_const.div ((continuousOn_id.pow 2).mul (hD.pow 3)) + (fun x h => mul_ne_zero (pow_ne_zero 2 (hx x h)) (pow_ne_zero 3 (hd x h))) + · exact ((continuousOn_const.mul hw).mul continuousOn_const).div + ((continuousOn_id.pow 3).mul (hD.pow 3)) + (fun x h => mul_ne_zero (pow_ne_zero 3 (hx x h)) (pow_ne_zero 3 (hd x h))) + · exact ((continuousOn_const.mul hw).mul continuousOn_const).div + ((continuousOn_id.pow 4).mul (hD.pow 4)) + (fun x h => mul_ne_zero (pow_ne_zero 4 (hx x h)) (pow_ne_zero 4 (hd x h))) + +theorem halasz_log_double_integral (u v m c a b : ℝ) (ha : 0 < a) (hab : a ≤ b) + (hd : ∀ x ∈ Set.Icc a b, halaszLogSlope u v x ≠ 0) : + (∫ x in a..b, ((m*x+c:ℝ):ℂ)*halaszLogPhase u v x) = + halaszLogDoublePrimitive u v m c b - halaszLogDoublePrimitive u v m c a - + ∫ x in a..b, (halaszLogAmplitude2Deriv u v m c x:ℂ)*halaszLogPhase u v x := by + have hphase := halasz_log_phase_continuousOn u v a b ha + have hwi : IntervalIntegrable (fun x => ((m*x+c:ℝ):ℂ)*halaszLogPhase u v x) volume a b := + ((Complex.continuous_ofReal.comp_continuousOn + ((continuousOn_const.mul continuousOn_id).add continuousOn_const)).mul hphase).intervalIntegrable_of_Icc hab + have hdi : IntervalIntegrable (fun x => (halaszLogAmplitude2Deriv u v m c x:ℂ)* + halaszLogPhase u v x) volume a b := + ((Complex.continuous_ofReal.comp_continuousOn + (halasz_log_amplitude2_deriv_continuousOn u v m c a b ha hd)).mul hphase).intervalIntegrable_of_Icc hab + have he := intervalIntegral.integral_eq_sub_of_hasDerivAt + (fun x hx => halasz_log_double_primitive_deriv u v m c x + (ha.trans_le (show x ∈ Set.Icc a b from by simpa only [Set.uIcc_of_le hab] using hx).1).ne' + (hd x (by simpa only [Set.uIcc_of_le hab] using hx))) (hwi.add hdi) + rw [intervalIntegral.integral_add hwi hdi] at he + exact eq_sub_of_add_eq he + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleSpecialization.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleSpecialization.lean new file mode 100644 index 0000000000000000000000000000000000000000..83e29e5bbe69851fceae5cf4c02883bc2db713d0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleSpecialization.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDoubleWindow + +namespace OAI + +/-! Removing the localization volume from the double mean-value estimate. -/ +namespace TwoPointCorrelations + +open Finset + +noncomputable def halaszDoubleWeight {k : ℕ} (r s M₁ M₂ : ℕ) + (γ : Fin k → ℝ) (j : Fin k) : ℝ := + min (2*((s*M₂^(j.val+1):ℕ):ℝ)+1) + (8*((s*M₂^(j.val+1):ℕ):ℝ)*halaszDoubleWindow r M₁ j+ + 2*((s*M₂^(j.val+1):ℕ):ℝ)* |γ j| +8*halaszDoubleWindow r M₁ j/ |γ j| +2) + +theorem halasz_double_specialized (k M₁ M₂ r s : ℕ) (hr : 1≤r) (hs : 1≤s) + (hM₁ : 1≤M₁) (γ : Fin k → ℝ) (hγ : ∀ j,γ j≠0) : + ‖∑ b : Fin M₂,halaszVinogradovPolynomial k M₁ + (halaszScaledFrequency γ (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)))‖^(2*r*s) ≤ + (32*(r:ℝ))^k*(M₁:ℝ)^(∑ j : Fin k, (j.val+1))* + (M₂:ℝ)^((r-1)*(2*s))*(M₁:ℝ)^(r*(2*s-2))* + (halaszVinogradovCount r k M₁:ℝ)*(halaszVinogradovCount s k M₂:ℝ)* + ∏ j,halaszDoubleWeight r s M₁ M₂ γ j := by + let δ : Fin k → ℝ := halaszDoubleWindow r M₁ + let P := ∏ j,δ j + let Q := (16*(r:ℝ))^k*(M₁:ℝ)^(∑ j : Fin k, (j.val+1)) + let C := (M₂:ℝ)^((r-1)*(2*s))*(M₁:ℝ)^(r*(2*s-2))* + (halaszVinogradovCount r k M₁:ℝ) + let U := (halaszVinogradovCount s k M₂:ℝ)*∏ j,halaszDoubleWeight r s M₁ M₂ γ j + have hP : 0

halasz_double_window_pos hr hM₁ j) + have hPQ : P*Q=1 := halasz_double_window_product hr hM₁ + have hQ : 0≤Q := by + dsimp only [Q] + positivity + have htwo : (∏ j : Fin k,2*δ j)=(2:ℝ)^k*P := by + rw [prod_mul_distrib,prod_const,card_univ,Fintype.card_fin] + have hd := halasz_double_mean_value k M₁ M₂ r s hr hs γ δ hγ + (fun j => (halasz_double_window_pos hr hM₁ j).le) + (fun j => halasz_double_window_small hr hM₁ j) + (fun j => halasz_double_window_phase hr hM₁ j) + have hscaled : P^2* + ‖∑ b : Fin M₂,halaszVinogradovPolynomial k M₁ + (halaszScaledFrequency γ (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)))‖^(2*r*s) ≤ + C*((2:ℝ)^k*P)*U := by + convert hd using 1 + dsimp only [C,U,halaszDoubleWeight] + rw [htwo] + ring + have hcancel : P* + ‖∑ b : Fin M₂,halaszVinogradovPolynomial k M₁ + (halaszScaledFrequency γ (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)))‖^(2*r*s) ≤ + C*(2:ℝ)^k*U := by + apply (mul_le_mul_iff_right₀ hP).mp + convert hscaled using 1 <;> ring + have hmul := mul_le_mul_of_nonneg_left hcancel hQ + have hpw : (16*(r:ℝ))^k*(2:ℝ)^k=(32*(r:ℝ))^k := by + rw [← mul_pow] + congr 1 + ring + calc + _ = Q*(P*‖∑ b : Fin M₂,halaszVinogradovPolynomial k M₁ + (halaszScaledFrequency γ (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)))‖^(2*r*s)) := by + rw [← mul_assoc,mul_comm Q P,hPQ,one_mul] + _ ≤ Q*(C*(2:ℝ)^k*U) := hmul + _ = ((16*(r:ℝ))^k*(2:ℝ)^k)*(M₁:ℝ)^(∑ j : Fin k, (j.val+1))*C*U := by + dsimp only [Q] + ring + _ = _ := by rw [hpw]; dsimp only [C,U]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleWindow.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleWindow.lean new file mode 100644 index 0000000000000000000000000000000000000000..2adda6c93a0cb03f6753bc2ceb064960ba722878 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDoubleWindow.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDoubleMeanValue +import Mathlib.Analysis.Real.Pi.Bounds + +namespace OAI + +/-! The coefficient window used in the double mean-value specialization. -/ +namespace TwoPointCorrelations + +open Finset + +noncomputable def halaszDoubleWindow {k : ℕ} (r M : ℕ) (j : Fin k) : ℝ := + 1/(16*(r:ℝ)*(M:ℝ)^(j.val+1)) + +lemma halasz_double_window_pos {k r M : ℕ} (hr : 1≤r) (hM : 1≤M) (j : Fin k) : + 0 if n=0 then 0 else (((n:ℝ)+a:ℝ):ℂ)^(-s) + have hf0 : ‖f 0‖≤C*(L+1)^6 := by simpa [f] using hB0 + have hblocks : ∀ k norm_num at hH ⊢ <;> omega + have hs : ‖∑ i∈range H,((((2^k:ℕ):ℝ)+a+i:ℝ):ℂ)^(-s)‖≤H := by + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ _i∈range H,(1:ℝ) := by + apply sum_le_sum + intro i _ + have hx : (1:ℝ)≤((2^k:ℕ):ℝ)+a+i := by + have hNR : (1:ℝ)≤(2^k:ℕ) := by exact_mod_cast hNk + have hi : (0:ℝ)≤ i := Nat.cast_nonneg _ + linarith [ha.1] + rw [Complex.norm_cpow_eq_rpow_re_of_pos (by linarith : + (0:ℝ)<((2^k:ℕ):ℝ)+a+i)] + simp only [Complex.neg_re] + exact Real.rpow_le_one_of_one_le_of_nonpos hx (by linarith) + _ = _ := by simp + have hHR : (H:ℝ)≤4 := by exact_mod_cast hNH + have hCB : 8≤C*(L+1)^6 := by + have hC8 : 8≤C := by dsimp only [C]; linarith + nlinarith + linarith + · have hk3 : 3≤k := by omega + obtain ⟨hlog,hhalf⟩ := halasz_dyadic_size hk3 + have hy : 0 + intro M hM + have hM1 : M≤1 := by simpa only [pow_zero] using hM + interval_cases M + · simpa using hB + · simpa using hzero + | succ K ih => + have hprev : ∀ k hblock k (by omega) H hH + intro M hM + by_cases hsmall : M≤2^K + · have hh := ih hprev M hsmall + push_cast + linarith + · have hsplit : M=2^K+(M-2^K) := by omega + have htail : M-2^K≤2^K := by rw [pow_succ] at hM; omega + conv_lhs => rw [hsplit, sum_range_add] + apply (norm_add_le _ _).trans + have hleft := ih hprev (2^K) le_rfl + have hright := hblock K (by omega) (M-2^K) htail + push_cast + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDyadicScale.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDyadicScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b494ca6fecf914872ec78863cdc01e1b0018eaf --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszDyadicScale.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszFirstOriginalMean + +namespace OAI + +/-! The dyadic blocks above the square-root cutoff stay inside the +original pretentious scale, with uniform logarithmic errors. -/ + +namespace TwoPointCorrelations + +lemma halasz_dyadic_original_scale {X N : ℕ} (hX : 2 ≤ X) + (hN : Real.sqrt (X:ℝ) ≤ N) : + X ≤ N^3 ∧ Real.log (X:ℝ)/2 ≤ Real.log N := by + have hX0 : 0 < (X:ℝ) := by exact_mod_cast (show 0 ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszEnergyDiagonal.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszEnergyDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..20f57b18b69489acce47df2f585ea48f6e733ef9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszEnergyDiagonal.lean @@ -0,0 +1,42 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszFinitePhase + +namespace OAI + +/-! Diagonal pairs in the long variables retain a full copy of the +short-variable energy for each long tuple. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem halasz_energy_diagonal_lower {α β γ : Type*} [Add γ] + (F : Finset α) (G : Finset β) (f : α → γ) (g : β → γ) : + F.card * halaszFiberEnergy G g ≤ + halaszFiberEnergy (F×ˢG) (fun x => f x.1+g x.2) := by + rw [halasz_fiber_energy_rows,halasz_fiber_energy_rows,sum_product,mul_sum] + have hl (a : α) (ha : a∈F) (b : β) : + (G.filter (fun y => g y=g b)).card ≤ + ((F×ˢG).filter (fun y => f y.1+g y.2=f a+g b)).card := by + calc + _ = ({a}×ˢ(G.filter (fun y => g y=g b))).card := by simp + _ ≤ _ := by + apply card_le_card + intro y hy + obtain ⟨hy1,hy2⟩ := mem_product.mp hy + have hy1' : y.1=a := mem_singleton.mp hy1 + obtain ⟨hyG,hyg⟩ := mem_filter.mp hy2 + exact mem_filter.mpr ⟨mem_product.mpr ⟨hy1' ▸ ha,hyG⟩,by rw [hy1',hyg]⟩ + calc + _ = ∑ _a∈F, ∑ b∈G, (G.filter (fun y => g y=g b)).card := by + rw [← mul_sum] + simp + _ ≤ _ := by + apply sum_le_sum + intro a ha + apply sum_le_sum + intro b _ + exact hl a ha b + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszEnergyImage.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszEnergyImage.lean new file mode 100644 index 0000000000000000000000000000000000000000..a101f391701158599c417c5c53a1ad0ab20e26a0 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszEnergyImage.lean @@ -0,0 +1,43 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszFiberEnergy + +namespace OAI + +/-! Reindexing finite energies by the residue-class quotient map. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma halasz_fiber_energy_image {α β γ : Type*} (F : Finset α) + (g : α → β) (hg : Set.InjOn g F) (f : β → γ) : + halaszFiberEnergy (F.image g) f = halaszFiberEnergy F (fun x => f (g x)) := by + rw [halasz_fiber_energy_rows,halasz_fiber_energy_rows,sum_image hg] + apply sum_congr rfl + intro x _ + rw [filter_image] + exact card_image_of_injOn (hg.mono (filter_subset _ _)) + +lemma halasz_fiber_energy_natCast {α : Type*} {k : ℕ} (F : Finset α) + (f : α → Fin k → ℕ) : + halaszFiberEnergy F (fun x j => (f x j : ℤ)) = halaszFiberEnergy F f := by + apply halasz_fiber_energy_congr + intro x _ y _ + constructor + · intro h + funext j + exact_mod_cast congrFun h j + · intro h + exact congrArg (fun v j => (v j : ℤ)) h + +lemma halasz_fiber_energy_transfer {α β γ : Type*} (F : Finset α) + (g : α → β) (hg : Set.InjOn g F) (u : α → γ) (v : β → γ) + (hv : ∀ x∈F, v (g x)=u x) : + halaszFiberEnergy F u = halaszFiberEnergy (F.image g) v := by + rw [halasz_fiber_energy_image F g hg v] + apply halasz_fiber_energy_congr + intro x hx y hy + rw [hv x hx,hv y hy] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszEnergyRestriction.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszEnergyRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..df47424e0b5c1389e114b6d6008a12414c46abd8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszEnergyRestriction.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCrossMoment + +namespace OAI + +/-! Removing a bad collection of tuples costs at most twice its +cross-count with all tuples. This keeps both sides of the system good. -/ +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical ComplexConjugate + +lemma halasz_cross_count_self {α : Type*} {k : ℕ} + (F : Finset α) (f : α → Fin k → ℤ) : + halaszCrossCount F F f f=halaszFiberEnergy F f := by + have h := halasz_cross_integral F F f f + simp_rw [Complex.mul_conj'] at h + simp_rw [← Complex.ofReal_pow] at h + rw [integral_complex_ofReal,halasz_finite_phase_energy] at h + exact_mod_cast h.symm + +lemma halasz_cross_count_symm {α β : Type*} {k : ℕ} + (F : Finset α) (G : Finset β) (f : α → Fin k → ℤ) (g : β → Fin k → ℤ) : + halaszCrossCount F G f g=halaszCrossCount G F g f := by + unfold halaszCrossCount + simp only [card_eq_sum_ones,sum_filter,sum_product] + rw [sum_comm] + apply sum_congr rfl + intro y _ + apply sum_congr rfl + intro x _ + simp only [eq_comm] + +lemma halasz_cross_count_mono {α β : Type*} {k : ℕ} + {F F' : Finset α} {G G' : Finset β} (hF : F⊆F') (hG : G⊆G') + (f : α → Fin k → ℤ) (g : β → Fin k → ℤ) : + halaszCrossCount F G f g≤halaszCrossCount F' G' f g := by + apply card_le_card + exact filter_subset_filter _ (product_subset_product hF hG) + +theorem halasz_energy_restriction {α : Type*} {k : ℕ} + (F G : Finset α) (f : α → Fin k → ℤ) : + halaszFiberEnergy F f ≤ 2*halaszCrossCount (F\G) F f f + halaszFiberEnergy G f := by + let A := (((F\G)×ˢF).filter (fun x => f x.1=f x.2)) + let B := ((F×ˢ(F\G)).filter (fun x => f x.1=f x.2)) + let C := ((G×ˢG).filter (fun x => f x.1=f x.2)) + have hc : ((F×ˢF).filter (fun x => f x.1=f x.2)) ⊆ A∪B∪C := by + intro x hx + have hx' := mem_filter.mp hx + have hxF := mem_product.mp hx'.1 + by_cases h1 : x.1∈G + · by_cases h2 : x.2∈G + · exact mem_union_right _ (mem_filter.mpr ⟨mem_product.mpr ⟨h1,h2⟩,hx'.2⟩) + · exact mem_union_left _ (mem_union_right _ (mem_filter.mpr + ⟨mem_product.mpr ⟨hxF.1,mem_sdiff.mpr ⟨hxF.2,h2⟩⟩,hx'.2⟩)) + · exact mem_union_left _ (mem_union_left _ (mem_filter.mpr + ⟨mem_product.mpr ⟨mem_sdiff.mpr ⟨hxF.1,h1⟩,hxF.2⟩,hx'.2⟩)) + have hcard : halaszCrossCount F F f f ≤ A.card+B.card+C.card := by + exact (card_le_card hc).trans ((card_union_le _ _).trans + (Nat.add_le_add_right (card_union_le A B) _)) + have hb : B.card=A.card := halasz_cross_count_symm F (F\G) f f + have hC : C.card=halaszFiberEnergy G f := halasz_cross_count_self G f + rw [halasz_cross_count_self,hb,hC] at hcard + change _ ≤ 2*A.card+_ + omega + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalCofactor.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalCofactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..6fdd418c7690b980e84766154acb84c050325157 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalCofactor.lean @@ -0,0 +1,134 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCountException +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTTypicalWindow + +namespace OAI + +/-! Actual cofactor bounds with a local frequency hypothesis. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical ComplexConjugate + +theorem halasz_exceptional_count_window : + ∃ C K X₀ : ℝ, 0 < C ∧ 0 ≤ K ∧ + ∀ (N : ℕ) (a : ℝ), 1 ≤ a → X₀ ≤ (⌊(N : ℝ) / a⌋₊ : ℝ) → + ∀ (F : ℕ → ℂ), F 1 = 1 → Multiplicative F → OneBounded F → + ∀ (Q P : Finset ℕ), (∀ p ∈ Q, p.Prime) → (∀ p ∈ P, p.Prime) → + ∀ (t τ M : ℝ), 0 ≤ M → + (∀ v : ℝ, |v-t| ≤ Real.log (⌊(2 * N : ℝ) / a⌋₊ : ℝ) ^ 8 → + 1/2 ≤ |v-τ| → 2 * M + K ≤ squaredDistance F (mrtArchimedeanTwist v) ⌊(2 * N : ℝ) / a⌋₊) → + ‖mrtCofactorPolynomial P (mrtMissingCoefficient F Q) N a t‖ ≤ C * + ((min M (Real.log (1+|τ-t|)) + 1) * Real.exp (-min M (Real.log (1+|τ-t|))) + + Real.log (Real.log (⌊(2 * N : ℝ) / a⌋₊ : ℝ)) / + Real.log (⌊(2 * N : ℝ) / a⌋₊ : ℝ)) := by + obtain ⟨C, X₁, hC, hmean⟩ := halasz_local_count_exception + obtain ⟨K, hK, hcut⟩ := halasz_distance_cutoff_loss + refine ⟨15 * C, K, max X₁ (Real.exp 2), by positivity, hK, ?_⟩ + intro N a ha hX F hF1 hFm hFb Q P hQ hP t τ M hM hd + let m := ⌊(N : ℝ) / a⌋₊ + let n := ⌊(2 * N : ℝ) / a⌋₊ + have hmX : X₁ ≤ (m : ℝ) := (le_max_left _ _).trans hX + have hme : Real.exp 2 ≤ (m : ℝ) := (le_max_right _ _).trans hX + have he2 : (2 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + have hm2 : 2 ≤ m := by exact_mod_cast (he2.trans hme) + have ha0 : 0 < a := by linarith + have hx : 2 ≤ (N : ℝ) / a := + (he2.trans hme).trans (Nat.floor_le (div_nonneg (Nat.cast_nonneg N) ha0.le)) + obtain ⟨hm0, hmn, hn3⟩ := mrt_cofactor_window_ratio N ha0 hx + change 0 < m at hm0 + change m ≤ n at hmn + change n ≤ 3 * m at hn3 + have hn0 : (0 : ℝ) < n := by exact_mod_cast hm0.trans_le hmn + have hln : 2 ≤ Real.log (n : ℝ) := by + apply (Real.le_log_iff_exp_le hn0).mpr + exact hme.trans (by exact_mod_cast hmn) + have hlln : 0 ≤ Real.log (Real.log (n : ℝ)) := Real.log_nonneg (by linarith) + let D := (min M (Real.log (1+|τ-t|)) + 1) * Real.exp (-min M (Real.log (1+|τ-t|))) + let E := Real.log (Real.log (n : ℝ)) / Real.log (n : ℝ) + have hmin : 0 ≤ min M (Real.log (1+|τ-t|)) := + le_min hM (Real.log_nonneg (by linarith [abs_nonneg (τ-t)])) + have hD : 0 ≤ D := by dsimp [D]; positivity + have hE : 0 ≤ E := div_nonneg hlln (by linarith) + have hbound := mrt_cofactor_bound_of_prefix P (mrtMissingCoefficient F Q) N ha hx t + (A := 3 * C * (D + E)) (by positivity) ?_ + · change ‖mrtCofactorPolynomial P (mrtMissingCoefficient F Q) N a t‖ ≤ + (15 * C) * (D + E) + exact hbound.trans_eq (by ring) + · intro k hk + change k ∈ Icc m n at hk + obtain ⟨hmk, hkn⟩ := mem_Icc.mp hk + have hk2 : 2 ≤ k := hm2.trans hmk + have hk0 : (0 : ℝ) < k := by exact_mod_cast (by omega : 0 < k) + have hkn3 : n ≤ k ^ 3 := by + have hkSq : 3 ≤ k ^ 2 := by nlinarith + calc + n ≤ 3 * m := hn3 + _ ≤ 3 * k := Nat.mul_le_mul_left 3 hmk + _ ≤ k * k ^ 2 := by nlinarith + _ = k ^ 3 := by ring + have hlog : Real.log (k : ℝ) ≤ Real.log (n : ℝ) := + Real.log_le_log hk0 (by exact_mod_cast hkn) + have hlog0 : 0 ≤ Real.log (k : ℝ) := Real.log_nonneg (by exact_mod_cast (by omega : 1 ≤ k)) + have hdk : ∀ v : ℝ, |v-t| ≤ Real.log (k:ℝ)^8 → + 1/2 ≤ |v-τ| → 2*M ≤ squaredDistance F (mrtArchimedeanTwist v) k := by + intro v hv haway + have hdist := hcut F hFb k n hk2 hkn hkn3 v + have hlow := hd v (hv.trans (pow_le_pow_left₀ hlog0 hlog 8)) haway + change 2*M+K ≤ squaredDistance F (mrtArchimedeanTwist v) n at hlow + linarith + have hpref := hmean k (hmX.trans (by exact_mod_cast hmk)) F hF1 hFm hFb Q P hQ hP + t τ M hM hdk + have herror := halasz_log_error_cutoff hk2 hkn hkn3 hlln + change Real.log (Real.log (k : ℝ)) / Real.log (k : ℝ) ≤ 3 * E at herror + calc + _ ≤ C * k * (D + Real.log (Real.log (k : ℝ)) / Real.log (k : ℝ)) := hpref + _ ≤ C * k * (D + 3 * E) := + mul_le_mul_of_nonneg_left (add_le_add le_rfl herror) (by positivity) + _ ≤ C * k * (3 * (D + E)) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + linarith + _ = (3 * C * (D + E)) * k := by ring + +/-- Remaining-band inclusion--exclusion preserves the local frequency window. -/ +theorem halasz_exceptional_typical_window : + ∃ C K X₀ : ℝ, 0 < C ∧ 0 ≤ K ∧ + ∀ (N : ℕ) (a : ℝ), 1 ≤ a → X₀ ≤ (⌊(N : ℝ) / a⌋₊ : ℝ) → + ∀ (F : ℕ → ℂ), F 1 = 1 → Multiplicative F → OneBounded F → + ∀ (ι : Type*) (J : Finset ι) (P : ι → Finset ℕ) (Q : Finset ℕ), + (∀ j ∈ J, ∀ p ∈ P j, p.Prime) → (∀ p ∈ Q, p.Prime) → + ∀ (t τ M : ℝ), 0 ≤ M → + (∀ v : ℝ, |v-t| ≤ Real.log (⌊(2 * N : ℝ) / a⌋₊ : ℝ) ^ 8 → + 1/2 ≤ |v-τ| → 2 * M + K ≤ squaredDistance F (mrtArchimedeanTwist v) ⌊(2 * N : ℝ) / a⌋₊) → + ‖mrtCofactorPolynomial Q (mrtTypicalCoefficient J P F) N a t‖ ≤ + (2 : ℝ) ^ J.card * C * ((min M (Real.log (1+|τ-t|)) + 1) * Real.exp (-min M (Real.log (1+|τ-t|))) + + Real.log (Real.log (⌊(2 * N : ℝ) / a⌋₊ : ℝ)) / + Real.log (⌊(2 * N : ℝ) / a⌋₊ : ℝ)) := by + obtain ⟨C, K, X₀, hC, hK, hb⟩ := halasz_exceptional_count_window + refine ⟨C, K, X₀, hC, hK, ?_⟩ + intro N a ha hN F hF1 hFm hFb ι J P Q hP hQ t τ M hM hd + rw [mrt_typical_cofactor_expansion] + calc + _ ≤ ∑ I ∈ J.powerset, + ‖(-1 : ℂ) ^ I.card * + mrtCofactorPolynomial Q (mrtMissingCoefficient F (I.biUnion P)) N a t‖ := + norm_sum_le _ _ + _ ≤ ∑ I ∈ J.powerset, C * ((min M (Real.log (1+|τ-t|)) + 1) * Real.exp (-min M (Real.log (1+|τ-t|))) + + Real.log (Real.log (⌊(2 * N : ℝ) / a⌋₊ : ℝ)) / + Real.log (⌊(2 * N : ℝ) / a⌋₊ : ℝ)) := by + apply sum_le_sum + intro I hI + rw [norm_mul, norm_pow] + simp only [norm_neg, norm_one, one_pow, one_mul] + apply hb N a ha hN F hF1 hFm hFb (I.biUnion P) Q _ hQ t τ M hM hd + intro p hp + obtain ⟨j, hj, hpj⟩ := mem_biUnion.mp hp + exact hP j ((mem_powerset.mp hI) hj) p hpj + _ = _ := by + rw [sum_const, nsmul_eq_mul, card_powerset, Nat.cast_pow, Nat.cast_ofNat] + ring + + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalDecay.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..f66b29913e69a542ea2bedee8b81df4facc6449e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalDecay.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszBandPowerCost +import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics + +namespace OAI + +/-! The fixed logarithmic saving retained after the actual band count. -/ +namespace TwoPointCorrelations + +open Filter + +theorem halasz_exceptional_decay (C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ B u : ℝ, 0 ≤ B → B ≤ L^(1/1000:ℝ) → + L^(1/16:ℝ)/2 ≤ |u| → + C*B*((min ((3/100:ℝ)*Real.log L) (Real.log (1+|u|))+1)* + Real.exp (-min ((3/100:ℝ)*Real.log L) (Real.log (1+|u|)))+Real.log L/L) ≤ + L^(-1/40:ℝ) := by + have hK : 0 < C+1 := by linarith + have hb := (isLittleO_log_rpow_atTop (show (0:ℝ)<1/250 by norm_num)).bound + (show (0:ℝ)<1/(4*(C+1)) by positivity) + have hp := (tendsto_rpow_atTop (show (0:ℝ)<1/250 by norm_num)).eventually + (eventually_ge_atTop (4*(C+1))) + filter_upwards [hb,hp,eventually_ge_atTop (1:ℝ), + Real.tendsto_log_atTop.eventually (eventually_ge_atTop (100:ℝ))] + with L hb hp hL hlog + have hL0 : 0 < L := by linarith + have hlog0 : 0 ≤ Real.log L := by linarith + rw [Real.norm_eq_abs,abs_of_nonneg hlog0,Real.norm_eq_abs, + abs_of_nonneg (Real.rpow_nonneg hL0.le _)] at hb + have hlogbound : (C+1)*Real.log L ≤ (1/4:ℝ)*L^(1/250:ℝ) := by + have hh := mul_le_mul_of_nonneg_left hb hK.le + field_simp at hh + nlinarith + have hconst : C+1 ≤ (1/4:ℝ)*L^(1/250:ℝ) := by linarith + have hcommon : C*((3/100:ℝ)*Real.log L+1) ≤ (1/2:ℝ)*L^(1/250:ℝ) := by + have hh : C*((3/100:ℝ)*Real.log L+1) ≤ (C+1)*(Real.log L+1) := by nlinarith + nlinarith + have hlogC : C*Real.log L ≤ (1/2:ℝ)*L^(1/250:ℝ) := by nlinarith + intro B u hB hBL hu + have hbase : 0 < L^(1/16:ℝ)/2 := by positivity + have hlogu := Real.log_le_log hbase (hu.trans (by linarith : |u| ≤ 1+|u|)) + rw [Real.log_div (by positivity : L^(1/16:ℝ) ≠ 0) (by norm_num : (2:ℝ) ≠ 0), + Real.log_rpow hL0] at hlogu + have hlog2 : Real.log 2 ≤ 1 := by + linarith [Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2)] + have hmin : min ((3/100:ℝ)*Real.log L) (Real.log (1+|u|)) = + (3/100:ℝ)*Real.log L := min_eq_left (by linarith) + rw [hmin] + have he : Real.exp (-((3/100:ℝ)*Real.log L)) = L^(-3/100:ℝ) := by + rw [Real.rpow_def_of_pos hL0] + congr 1 + ring + rw [he] + have hprod : L^(1/1000:ℝ)*L^(-3/100:ℝ) = L^(-29/1000:ℝ) := by + rw [← Real.rpow_add hL0] + norm_num + have hquot : L^(1/1000:ℝ)/L = L^(-999/1000:ℝ) := by + rw [div_eq_mul_inv,← Real.rpow_neg_one,← Real.rpow_add hL0] + norm_num + calc + _ ≤ C*L^(1/1000:ℝ)*(((3/100:ℝ)*Real.log L+1)*L^(-3/100:ℝ)+Real.log L/L) := + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hBL hC) (by positivity) + _ = C*((3/100:ℝ)*Real.log L+1)*(L^(1/1000:ℝ)*L^(-3/100:ℝ))+ + (C*Real.log L)*(L^(1/1000:ℝ)/L) := by ring + _ = C*((3/100:ℝ)*Real.log L+1)*L^(-29/1000:ℝ)+ + (C*Real.log L)*L^(-999/1000:ℝ) := by rw [hprod,hquot] + _ ≤ ((1/2:ℝ)*L^(1/250:ℝ))*L^(-29/1000:ℝ)+ + ((1/2:ℝ)*L^(1/250:ℝ))*L^(-999/1000:ℝ) := by gcongr + _ = (1/2:ℝ)*L^(-1/40:ℝ)+(1/2:ℝ)*L^(-199/200:ℝ) := by + simp only [mul_assoc,← Real.rpow_add hL0] + norm_num + _ ≤ L^(-1/40:ℝ) := by + have hh := Real.rpow_le_rpow_of_exponent_le hL (show (-199/200:ℝ) ≤ -1/40 by norm_num) + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalEnergy.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ef3ce83d3e34567d6694fd67c1d43e0d7db01be --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalEnergy.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszNearEnergy +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTTypicalCoarse + +namespace OAI + +/-! The near-frequency exceptional set can be controlled in mean square +without paying for the width of that frequency interval. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +lemma halasz_dyadic_sub (F G : ℕ → ℂ) (N : ℕ) (t : ℝ) : + mrtDyadicPolynomial (fun n => F n - G n) N t = + mrtDyadicPolynomial F N t - mrtDyadicPolynomial G N t := by + unfold mrtDyadicPolynomial mrtExponentialPolynomial + simp only [sub_div, sub_mul, sum_sub_distrib] + +lemma halasz_exceptional_coefficient_mass {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (F : ℕ → ℂ) (hF : OneBounded F) + {N : ℕ} (hN : 0 < N) : + (∑ n ∈ Ioc N (2 * N), + ‖(F n - mrtTypicalCoefficient J P F n) / (n : ℂ)‖ ^ 2) ≤ + (((Ioc N (2 * N)).filter (fun n => ¬mrtTypical J P n)).card : ℝ) / N ^ 2 := by + have hNr : 0 < (N : ℝ) := by exact_mod_cast hN + calc + _ ≤ ∑ n ∈ Ioc N (2 * N), if ¬mrtTypical J P n then (1 / (N : ℝ)) ^ 2 else 0 := by + apply sum_le_sum + intro n hn + have hn0 : 0 < n := hN.trans (mem_Ioc.mp hn).1 + have hnR : (N : ℝ) ≤ n := by exact_mod_cast (mem_Ioc.mp hn).1.le + by_cases ht : mrtTypical J P n + · simp [mrtTypicalCoefficient, ht] + · simp only [mrtTypicalCoefficient, ht, ite_false, sub_zero, not_false_eq_true, ite_true] + apply pow_le_pow_left₀ (norm_nonneg _) _ 2 + rw [norm_div, Complex.norm_natCast] + exact (div_le_div_of_nonneg_right (hF n hn0) (by positivity)).trans + (one_div_le_one_div_of_le hNr hnR) + _ = _ := by rw [← sum_filter]; simp [div_eq_mul_inv] + +/-- The error from excluding atypical integers costs their density, even +when the near-frequency interval grows. -/ +theorem halasz_exceptional_dyadic_energy {ι : Type*} (J : Finset ι) + (P : ι → Finset ℕ) (F : ℕ → ℂ) (hF : OneBounded F) + {N : ℕ} (hN : 0 < N) {T : ℝ} (hT : 0 < T) : + (∫ t in -T..T, ‖mrtDyadicPolynomial F N t - + mrtDyadicPolynomial (mrtTypicalCoefficient J P F) N t‖ ^ 2) ≤ + 8 * Real.exp 1 * (T / N + 2) * + (((Ioc N (2 * N)).filter (fun n => ¬mrtTypical J P n)).card : ℝ) / N := by + have hNr : (N : ℝ) ≠ 0 := by exact_mod_cast hN.ne' + have hm := mrt_dirichlet_mean_square_subset (Ioc N (2 * N)) + (N := 2 * N) (by + intro n hn + exact mem_Ioc.mpr ⟨lt_trans hN (mem_Ioc.mp hn).1, (mem_Ioc.mp hn).2⟩) + (fun n => (F n - mrtTypicalCoefficient J P F n) / (n : ℂ)) hT + change (∫ t in -T..T, ‖mrtDyadicPolynomial + (fun n => F n - mrtTypicalCoefficient J P F n) N t‖ ^ 2) ≤ _ at hm + simp_rw [halasz_dyadic_sub] at hm + apply hm.trans + calc + _ ≤ 8 * Real.exp 1 * (T + ((2 * N : ℕ) : ℝ)) * + ((((Ioc N (2 * N)).filter (fun n => ¬mrtTypical J P n)).card : ℝ) / N ^ 2) := + mul_le_mul_of_nonneg_left (halasz_exceptional_coefficient_mass J P F hF hN) (by positivity) + _ = _ := by push_cast; field_simp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalMean.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..8bfa3886f370baaf2a8b2f6fea0a2b2b5b57a458 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalMean.lean @@ -0,0 +1,113 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDoubleException +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDoubleMean +import OAI.NumberTheory.TwoPoint.Halasz.HalaszNumericalErrors +import OAI.NumberTheory.TwoPoint.Halasz.HalaszSmoothBounds + +namespace OAI + +/-! The ordinary mean estimate retaining the location of one exceptional +unit interval in the logarithmic-height Perron window. -/ + +namespace TwoPointCorrelations + +open Finset Filter + +/-- Completely multiplicative means with one unit interval excluded from +the distance hypothesis. Its location supplies an additional decay term. -/ +theorem halasz_exceptional_mean_value : ∃ C X₀ : ℝ, 0 < C ∧ + ∀ (N : ℕ), X₀ ≤ N → + ∀ (f : ℕ → ℂ), f 1 = 1 → + (∀ a b, 0 < a → 0 < b → f (a * b) = f a * f b) → OneBounded f → + ∀ (M τ : ℝ), 0 ≤ M → + (∀ t ∈ Set.Ioc (-(Real.log (N : ℝ) ^ 8)) (Real.log (N : ℝ) ^ 8), + t ∉ Set.Ioc (τ-1/2) (τ+1/2) → M ≤ squaredDistance f (mrtArchimedeanTwist t) N) → + ‖∑ n ∈ Icc 1 N, f n‖ ≤ C * N * + ((min M (Real.log (1+|τ|)) + 1) * Real.exp (-min M (Real.log (1+|τ|))) + + Real.log (Real.log N) / Real.log N) := by + obtain ⟨C₁, B, hC₁, hB, hdouble⟩ := halasz_double_convolution_exception + obtain ⟨H₀, hH₀, hEuler⟩ := mrt_smooth_distance_bound + let H := max 1 H₀ + let D := 2 * C₁ * H + 8 * C₁ + (halaszDoubleErrorConstant + 12) + let C := 1 + 2 * C₁ * H + D + have hH : 1 ≤ H := le_max_left _ _ + have hH₀H : H₀ ≤ H := le_max_right _ _ + have hD : 0 ≤ D := by + dsimp [D] + have := halaszDoubleErrorConstant_nonneg + positivity + have hC : 0 < C := by dsimp [C]; positivity + obtain ⟨X₀, hX₀⟩ := eventually_atTop.mp (halasz_eventually_numeric_scale B) + obtain ⟨X₁, hX₁⟩ := eventually_atTop.mp + (Real.tendsto_log_atTop.eventually (eventually_ge_atTop (2 : ℝ))) + refine ⟨C, max X₀ X₁, hC, ?_⟩ + intro N hXN f hf1 hf hbound M τ hM hdist + obtain ⟨hNr, hll, hl4, hl16, hBT⟩ := hX₀ N ((le_max_left _ _).trans hXN) + have hN : 3 ≤ N := by exact_mod_cast hNr + have hN2 : 2 ≤ N := by omega + have hℓ2 : 2 ≤ Real.log (N : ℝ) := hX₁ N ((le_max_right _ _).trans hXN) + have hℓ : 1 ≤ Real.log (N : ℝ) := by linarith + have hℓ0 : 0 < Real.log (N : ℝ) := by linarith + have hl4N : Real.log (N : ℝ) ^ 4 ≤ N := + (pow_le_pow_right₀ hℓ (by norm_num : (4 : ℕ) ≤ 16)).trans (by linarith) + let m := ⌈(N : ℝ) / Real.log (N : ℝ) ^ 4⌉₊ + obtain ⟨hm, hmN, _, hml, hmu⟩ := halasz_smoothing_integer hN2 hl4 hl4N + have hglobal (t : ℝ) : + ‖LSeries (halaszSmoothFunction f N) (1 + (t : ℂ) * Complex.I)‖ ≤ + H * Real.log N := by + rw [halasz_smooth_LSeries] + have he := hEuler f hf1 hf hbound N hN2 t + have hd := halasz_distance_nonneg f hbound N t + have hx : Real.exp (-squaredDistance f (mrtArchimedeanTwist t) N) ≤ 1 := + Real.exp_le_one_iff.mpr (by linarith) + calc + _ ≤ H₀ * Real.log N * Real.exp (-squaredDistance f (mrtArchimedeanTwist t) N) := he + _ ≤ H₀ * Real.log N := by simpa only [mul_one] using + mul_le_mul_of_nonneg_left hx (by positivity : 0 ≤ H₀ * Real.log (N : ℝ)) + _ ≤ H * Real.log N := mul_le_mul_of_nonneg_right hH₀H hℓ0.le + have hcentral (t : ℝ) + (ht : t ∈ Set.Ioc (-(Real.log (N : ℝ) ^ 8)) (Real.log (N : ℝ) ^ 8)) + (hout : t ∉ Set.Ioc (τ-1/2) (τ+1/2)) : + ‖LSeries (halaszSmoothFunction f N) (1 + (t : ℂ) * Complex.I)‖ ≤ + (H * Real.log N) * Real.exp (-M) := by + rw [halasz_smooth_LSeries] + apply (hEuler f hf1 hf hbound N hN2 t).trans + apply mul_le_mul + · exact mul_le_mul_of_nonneg_right hH₀H hℓ0.le + · exact Real.exp_le_exp.mpr (neg_le_neg (hdist t ht hout)) + · positivity + · positivity + have hb := hdouble f hf1 hf hbound N m (Real.log N ^ 16) (Real.log N ^ 8) + (H * Real.log N) (H * Real.log N) M τ hN2 hm hmN + (one_le_pow₀ hℓ) (by rw [← pow_mul]) hBT + (le_mul_of_one_le_left hℓ0.le hH) (by positivity) hM hcentral hglobal + let M₁ := min M (Real.log (1+|τ|)) + have hM₁ : 0 ≤ M₁ := le_min hM (Real.log_nonneg (by linarith [abs_nonneg τ])) + have herr := halasz_numerical_errors hN hC₁.le (by linarith : 0 ≤ H) hℓ hm hml hmu + have hreduce := halasz_double_mean_log_sixteenth f hbound hf N hll (one_le_pow₀ hℓ) hl16 + have hsmall : (2 * C₁ * H + 8 * C₁) * N ≤ + (2 * C₁ * H + 8 * C₁) * N * Real.log (Real.log N) := + le_mul_of_one_le_right (by positivity) hll + have hmain : Real.log (N : ℝ) * ‖∑ n ∈ Icc 1 N, f n‖ ≤ + 2 * C₁ * N * (H * Real.log N) * (M₁ + 1) * Real.exp (-M₁) + + D * N * Real.log (Real.log N) := by + dsimp [D] + linarith + have hdiv := div_le_div_of_nonneg_right hmain hℓ0.le + have heq : (2 * C₁ * N * (H * Real.log N) * (M₁ + 1) * Real.exp (-M₁) + + D * N * Real.log (Real.log N)) / Real.log N = + 2 * C₁ * H * N * ((M₁ + 1) * Real.exp (-M₁)) + + D * N * (Real.log (Real.log N) / Real.log N) := by + field_simp + rw [mul_div_cancel_left₀ _ hℓ0.ne', heq] at hdiv + have hC₁H : 2 * C₁ * H ≤ C := by dsimp [C]; linarith + have hDC : D ≤ C := by dsimp [C]; linarith [show 0 ≤ C₁ * H by positivity] + calc + _ ≤ 2 * C₁ * H * N * ((M₁ + 1) * Real.exp (-M₁)) + + D * N * (Real.log (Real.log N) / Real.log N) := hdiv + _ ≤ C * N * ((M₁ + 1) * Real.exp (-M₁)) + + C * N * (Real.log (Real.log N) / Real.log N) := by gcongr + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalWindow.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalWindow.lean new file mode 100644 index 0000000000000000000000000000000000000000..5659bef9c510795012b5fda75c2ae200954afa9c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExceptionalWindow.lean @@ -0,0 +1,122 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszWindowIntegral + +namespace OAI + +/-! A localized exceptional interval in the Halasz Perron integral. +This retains decay in the distance from the minimizing frequency instead +of requiring a uniform bound throughout a large central window. -/ +namespace TwoPointCorrelations + +open MeasureTheory + +lemma halasz_exceptional_cauchy_weight (c t : ℝ) + (ht : t ∈ Set.Ioc (c-1/2) (c+1/2)) : + 1/Real.sqrt (1+t^2) ≤ 3/(1+|c|) := by + have hs : 0 < Real.sqrt (1+t^2) := Real.sqrt_pos.mpr (by positivity) + have hs1 : 1 ≤ Real.sqrt (1+t^2) := by + apply (Real.le_sqrt (by norm_num) (by positivity)).mpr + nlinarith + have hst : |t| ≤ Real.sqrt (1+t^2) := by + apply (Real.le_sqrt (abs_nonneg _) (by positivity)).mpr + rw [sq_abs] + linarith + have hdiff : |c-t| ≤ 1/2 := abs_le.mpr ⟨by linarith [ht.2],by linarith [ht.1]⟩ + have hc : |c| ≤ 1/2+|t| := by + have hh := abs_add_le (c-t) t + rw [sub_add_cancel] at hh + linarith + apply (div_le_div_iff₀ hs (by positivity : 0 < 1+|c|)).mpr + nlinarith + +theorem halasz_window_middle_exception {x δ T A W c : ℝ} + (hx : 0 < x) (hδ : 0 < δ) (hδ1 : δ ≤ 1) (hT : 0 ≤ T) + (hA : 0 ≤ A) (hW : 0 ≤ W) + (P Q F : ℝ → ℂ) (hP : Continuous P) (hQ : Continuous Q) + (hi : IntegrableOn (fun t => P t*Q t*F t* + halaszPerronWindowKernel x δ (1+(t:ℂ)*Complex.I)) (Set.Ioc (-T) T)) + (hF : ∀ t ∈ Set.Ioc (-T) T, t ∉ Set.Ioc (c-1/2) (c+1/2) → ‖F t‖ ≤ A) + (hFW : ∀ t ∈ Set.Ioc (-T) T, ‖F t‖ ≤ W) : + ‖∫ t in -T..T, P t*Q t*F t* + halaszPerronWindowKernel x δ (1+(t:ℂ)*Complex.I)‖ ≤ + (4*x*A)*(Real.sqrt (∫ t in -T..T, ‖P t‖^2)* + Real.sqrt (∫ t in -T..T, ‖Q t‖^2*(1+t^2)⁻¹)) + + (12*x*W/(1+|c|))*(Real.sqrt (∫ t in (c-1/2)..(c+1/2), ‖P t‖^2)* + Real.sqrt (∫ t in (c-1/2)..(c+1/2), ‖Q t‖^2)) := by + let D := Set.Ioc (-T) T + let E := Set.Ioc (c-1/2) (c+1/2) + let I := fun t => P t*Q t*F t*halaszPerronWindowKernel x δ (1+(t:ℂ)*Complex.I) + let G := fun t => ‖P t‖*‖Q t‖/Real.sqrt (1+t^2) + let J := fun t => ‖P t‖*‖Q t‖ + have hG : Continuous G := (hP.norm.mul hQ.norm).div + ((continuous_const.add (continuous_id.pow 2)).sqrt) + (fun t => ne_of_gt (Real.sqrt_pos.mpr (by positivity))) + have hJ : Continuous J := hP.norm.mul hQ.norm + have hGD : IntegrableOn G D := + (intervalIntegrable_iff_integrableOn_Ioc_of_le (by linarith : -T ≤ T)).mp + (hG.intervalIntegrable _ _) + have hJE : IntegrableOn J E := + (intervalIntegrable_iff_integrableOn_Ioc_of_le (by linarith : c-1/2 ≤ c+1/2)).mp + (hJ.intervalIntegrable _ _) + have hsmall : ‖∫ t in D \ E, I t‖ ≤ (4*x*A)*∫ t in D, G t := by + calc + _ ≤ ∫ t in D \ E, (4*x*A)*G t := by + apply norm_integral_le_of_norm_le ((hGD.mono_set Set.sdiff_subset).const_mul _) + apply (ae_restrict_mem (measurableSet_Ioc.diff measurableSet_Ioc)).mono + intro t ht + have hk := halasz_perron_window_bound hx hδ hδ1 t + rw [halasz_vertical_norm] at hk + dsimp [I,G] + simp only [norm_mul] + calc + _ ≤ (‖P t‖*‖Q t‖*A)*(4*x/Real.sqrt (1+t^2)) := + mul_le_mul (mul_le_mul_of_nonneg_left (hF t ht.1 ht.2) (by positivity)) + hk (norm_nonneg _) (by positivity) + _ = _ := by ring + _ ≤ ∫ t in D, (4*x*A)*G t := setIntegral_mono_set + (hGD.const_mul _) (Filter.Eventually.of_forall (fun t => by dsimp [G]; positivity)) + (Filter.Eventually.of_forall Set.sdiff_subset) + _ = _ := integral_const_mul _ _ + have hlarge : ‖∫ t in D ∩ E, I t‖ ≤ (12*x*W/(1+|c|))*∫ t in E, J t := by + calc + _ ≤ ∫ t in D ∩ E, (12*x*W/(1+|c|))*J t := by + apply norm_integral_le_of_norm_le ((hJE.mono_set Set.inter_subset_right).const_mul _) + apply (ae_restrict_mem (measurableSet_Ioc.inter measurableSet_Ioc)).mono + intro t ht + have hk := halasz_perron_window_bound hx hδ hδ1 t + rw [halasz_vertical_norm] at hk + have hw := halasz_exceptional_cauchy_weight c t ht.2 + have hkernel : ‖halaszPerronWindowKernel x δ (1+(t:ℂ)*Complex.I)‖ ≤ + 12*x/(1+|c|) := by + apply hk.trans + have hh := mul_le_mul_of_nonneg_left hw (show 0 ≤ 4*x by positivity) + convert hh using 1 <;> ring + dsimp [I,J] + simp only [norm_mul] + calc + _ ≤ (‖P t‖*‖Q t‖*W)*(12*x/(1+|c|)) := + mul_le_mul (mul_le_mul_of_nonneg_left (hFW t ht.1) (by positivity)) + hkernel (norm_nonneg _) (by positivity) + _ = _ := by ring + _ ≤ ∫ t in E, (12*x*W/(1+|c|))*J t := setIntegral_mono_set + (hJE.const_mul _) (Filter.Eventually.of_forall (fun t => by dsimp [J]; positivity)) + (Filter.Eventually.of_forall Set.inter_subset_right) + _ = _ := integral_const_mul _ _ + have hsplit := integral_inter_add_sdiff (f := I) (s := D) (t := E) measurableSet_Ioc hi + have hnorm := norm_add_le (∫ t in D ∩ E, I t) (∫ t in D \ E, I t) + rw [hsplit] at hnorm + rw [intervalIntegral.integral_of_le (by linarith : -T ≤ T)] + apply (hnorm.trans (add_le_add hlarge hsmall)).trans + have hcs := halasz_weighted_integral_cauchy_schwarz (by linarith : -T ≤ T) P Q hP hQ + have hce := halasz_integral_cauchy_schwarz (by linarith : c-1/2 ≤ c+1/2) + (fun t => ‖P t‖) (fun t => ‖Q t‖) hP.norm hQ.norm + (fun _ => norm_nonneg _) (fun _ => norm_nonneg _) + rw [intervalIntegral.integral_of_le (by linarith : -T ≤ T)] at hcs + rw [intervalIntegral.integral_of_le (by linarith : c-1/2 ≤ c+1/2)] at hce + change (∫ t in D, G t) ≤ _ at hcs + change (∫ t in E, J t) ≤ _ at hce + nlinarith [mul_le_mul_of_nonneg_left hcs (show 0 ≤ 4*x*A by positivity), + mul_le_mul_of_nonneg_left hce (show 0 ≤ 12*x*W/(1+|c|) by positivity)] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExtraCofactor.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExtraCofactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..a533b1689c374f5b73e805f4e8d004ed5beb1e23 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszExtraCofactor.lean @@ -0,0 +1,55 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCofactorScale + +namespace OAI + +/-! The actual extra-prime cofactor has uniform decay off the original +minimizing twist. All floor and band-count losses have been absorbed. -/ +namespace TwoPointCorrelations + +open Filter Finset + +theorem HalaszHighPrimeInput.extra_cofactor (hhigh : HalaszHighPrimeInput) : + ∀ᶠ N : ℕ in atTop, ∀ (F : ℕ → ℂ), F 1 = 1 → Multiplicative F → OneBounded F → + ∀ (P Q : ℝ) (J : ℕ), 1 ≤ Real.log Q → + mrtBandUpper Q J ≤ Real.exp (Real.sqrt (Real.log N)) → + ∀ (A : Finset ℕ), (∀ p ∈ A, p.Prime) → + ∀ a : ℝ, 1 ≤ a → a ≤ Real.exp (Real.log N/Real.log (Real.log N)) → + ∀ t τ : ℝ, |t| ≤ N → |τ| ≤ 2*N → + (∀ v : ℝ, |v| ≤ 2*N → squaredDistance F (mrtArchimedeanTwist τ) (2*N) ≤ + squaredDistance F (mrtArchimedeanTwist v) (2*N)) → + (Real.log N)^(1/16:ℝ) ≤ |t-τ| → + ‖mrtCofactorPolynomial A (mrtTypicalCoefficient (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) N a t‖ ≤ + 2*(Real.log N)^(-1/40:ℝ) := by + obtain ⟨X₀,hcofactor⟩ := hhigh.actual_cofactor + obtain ⟨n₀,hn₀⟩ := eventually_atTop.mp hcofactor + filter_upwards [halasz_cofactor_floor_scale X₀ n₀,eventually_ge_atTop 2] + with N hscale hN + intro F hF1 hFm hFb P Q J hQ hband A hA a ha haU t τ ht hτ hmin haway + let n := ⌊(2*N:ℝ)/a⌋₊ + obtain ⟨hbase,hnlarge,hnupper,hncube,hloglow,hlogupper,hwidth⟩ := hscale a ha haU + have hN0 : 0 < (N:ℝ) := by exact_mod_cast (show 0 f x=t)).card^2 + +lemma halasz_fiber_energy_rows {α β : Type*} (F : Finset α) (f : α → β) : + halaszFiberEnergy F f = ∑ x ∈ F, (F.filter (fun y => f y=f x)).card := by + unfold halaszFiberEnergy + calc + _ = ∑ t ∈ F.image f, ∑ x ∈ F.filter (fun x => f x=t), + (F.filter (fun y => f y=f x)).card := by + apply sum_congr rfl + intro t _ + rw [show (∑ x ∈ F.filter (fun x => f x=t), + (F.filter (fun y => f y=f x)).card) = + ∑ _x ∈ F.filter (fun x => f x=t), (F.filter (fun y => f y=t)).card from + sum_congr rfl (fun x hx => by rw [(mem_filter.mp hx).2])] + simp [pow_two] + _ = _ := sum_fiberwise_of_maps_to (fun x hx => mem_image_of_mem f hx) _ + +lemma halasz_fiber_energy_partition {α β γ : Type*} (F : Finset α) + (f : α → β) (g : α → γ) : + halaszFiberEnergy F (fun x => (f x,g x)) = + ∑ t ∈ F.image f, halaszFiberEnergy (F.filter (fun x => f x=t)) g := by + rw [halasz_fiber_energy_rows] + calc + _ = ∑ t ∈ F.image f, ∑ x ∈ F.filter (fun x => f x=t), + (F.filter (fun y => (f y,g y)=(f x,g x))).card := by + convert (sum_fiberwise_of_maps_to (s := F) (t := F.image f) (g := f) + (fun x hx => mem_image_of_mem f hx) + (fun x => (F.filter (fun y => (f y,g y)=(f x,g x))).card)).symm using 1 + apply sum_congr rfl + intro x _ + congr 1 + ext y + simp only [mem_filter] + _ = _ := by + apply sum_congr rfl + intro t _ + rw [halasz_fiber_energy_rows] + apply sum_congr rfl + intro x hx + have hxt := (mem_filter.mp hx).2 + congr 1 + ext y + simp only [mem_filter,Prod.mk.injEq] + rw [hxt] + tauto + +lemma halasz_card_sq_le_fiber_energy {α β : Type*} (F : Finset α) (f : α → β) : + F.card^2 ≤ (F.image f).card * halaszFiberEnergy F f := by + have h := sq_sum_le_card_mul_sum_sq (s := F.image f) + (f := fun t => (F.filter (fun x => f x=t)).card) + rw [← card_eq_sum_card_image f F] at h + exact h + +theorem halasz_fiber_energy_refine {α β γ : Type*} (F : Finset α) + (f : α → β) (g : α → γ) (B : ℕ) + (hB : ∀ t ∈ F.image f, ((F.filter (fun x => f x=t)).image g).card ≤ B) : + halaszFiberEnergy F f ≤ B * halaszFiberEnergy F (fun x => (f x,g x)) := by + rw [halasz_fiber_energy_partition,mul_sum] + change (∑ t ∈ F.image f, (F.filter (fun x => f x=t)).card^2) ≤ _ + apply sum_le_sum + intro t ht + exact (halasz_card_sq_le_fiber_energy _ g).trans + (Nat.mul_le_mul_right _ (hB t ht)) + +lemma halasz_fiber_energy_congr {α β γ : Type*} (F : Finset α) + (f : α → β) (g : α → γ) + (h : ∀ x∈F, ∀ y∈F, f y=f x ↔ g y=g x) : + halaszFiberEnergy F f = halaszFiberEnergy F g := by + rw [halasz_fiber_energy_rows,halasz_fiber_energy_rows] + apply sum_congr rfl + intro x hx + congr 1 + ext y + simpa only [mem_filter] using and_congr_right (fun hy => h x hx y hy) + +lemma halasz_fiber_energy_mono {α β : Type*} {F G : Finset α} (hFG : F⊆G) + (f : α → β) : halaszFiberEnergy F f ≤ halaszFiberEnergy G f := by + rw [halasz_fiber_energy_rows,halasz_fiber_energy_rows] + calc + _ ≤ ∑ x∈F, (G.filter (fun y => f y=f x)).card := by + apply sum_le_sum + intro x _ + exact card_le_card (filter_subset_filter _ hFG) + _ ≤ _ := sum_le_sum_of_subset_of_nonneg hFG (fun _ _ _ => Nat.zero_le _) + +lemma halasz_fiber_energy_product {α β γ : Type*} (F : Finset α) (G : Finset β) + (g : β → γ) : + halaszFiberEnergy (F×ˢG) (fun x => (x.1,g x.2)) = F.card * halaszFiberEnergy G g := by + rw [halasz_fiber_energy_rows,halasz_fiber_energy_rows,sum_product] + have hf (a : α) (ha : a∈F) (b : β) : + ((F×ˢG).filter (fun y => (y.1,g y.2)=(a,g b))).card = + (G.filter (fun y => g y=g b)).card := by + have he : (F×ˢG).filter (fun y => (y.1,g y.2)=(a,g b)) = + {a}×ˢ(G.filter (fun y => g y=g b)) := by + ext y + simp only [mem_filter,mem_product,mem_singleton,Prod.mk.injEq] + constructor + · rintro ⟨⟨_,hG⟩,he,hg⟩ + exact ⟨he,hG,hg⟩ + · rintro ⟨he,hG,hg⟩ + exact ⟨⟨he ▸ ha,hG⟩,he,hg⟩ + rw [he,card_product,card_singleton,one_mul] + calc + _ = ∑ _a∈F, ∑ b∈G, (G.filter (fun y => g y=g b)).card := by + apply sum_congr rfl + intro a ha + apply sum_congr rfl + intro b _ + simpa only [filter_congr_decidable] using hf a ha b + _ = _ := by simp + +lemma halasz_fiber_energy_representation {ι : Type*} [Fintype ι] {k : ℕ} + (f : ι → Fin k → ℤ) : + halaszFiberEnergy univ f = halaszRepresentationCount f 0 := by + rw [halasz_fiber_energy_rows] + unfold halaszRepresentationCount + rw [show (univ.filter (fun xy : ι × ι => f xy.1-f xy.2=0)) = + univ.filter (fun xy : ι × ι => f xy.2=f xy.1) by + ext xy + simp only [mem_filter,mem_univ,true_and,sub_eq_zero] + exact eq_comm] + simp_rw [card_eq_sum_ones,sum_filter] + rw [← Fintype.sum_prod_type'] + congr 1 + funext x + by_cases h : f x.2=f x.1 <;> simp [h] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFiberHolder.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFiberHolder.lean new file mode 100644 index 0000000000000000000000000000000000000000..615463fc29ad87bc8f740496f8461164d7bef157 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFiberHolder.lean @@ -0,0 +1,44 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszFiniteHolder +import OAI.NumberTheory.TwoPoint.Halasz.HalaszFiberEnergy + +namespace OAI + +/-! Weighted Hölder after grouping tuples by their complete-system +frequency. The square multiplicity sum is exactly the Vinogradov energy. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma halasz_fiber_norm_sum {α β : Type*} (F : Finset α) (f : α → β) (z : β → ℂ) : + ‖∑ a∈F,z (f a)‖≤∑ c∈F.image f,((F.filter (fun a => f a=c)).card:ℝ)*‖z c‖ := by + apply (norm_sum_le _ _).trans_eq + rw [← sum_fiberwise_of_maps_to (s := F) (t := F.image f) (g := f) + (fun a ha => mem_image_of_mem f ha)] + apply sum_congr rfl + intro c _ + calc + _ = ∑ _a∈F.filter (fun a => f a=c), ‖z c‖ := by + apply sum_congr rfl + intro a ha + rw [(mem_filter.mp ha).2] + _ = _ := by simp + +theorem halasz_fiber_holder {α β : Type*} (F : Finset α) (f : α → β) + (z : β → ℂ) {s : ℕ} (hs : 1≤s) : + ‖∑ a∈F,z (f a)‖^(2*s) ≤ (F.card:ℝ)^(2*s-2)* + (halaszFiberEnergy F f:ℝ)*(∑ c∈F.image f,‖z c‖^(2*s)) := by + have h := halasz_finite_weighted_holder (F.image f) + (fun c => ((F.filter (fun a => f a=c)).card:ℝ)) (fun c => ‖z c‖) + (fun _ => Nat.cast_nonneg _) (fun _ => norm_nonneg _) hs + have hcard : (∑ c∈F.image f,((F.filter (fun a => f a=c)).card:ℝ))=(F.card:ℝ) := by + exact_mod_cast (card_eq_sum_card_image f F).symm + have henergy : (∑ c∈F.image f,((F.filter (fun a => f a=c)).card:ℝ)^2)= + (halaszFiberEnergy F f:ℝ) := by + simp only [halaszFiberEnergy,Nat.cast_sum,Nat.cast_pow] + rw [hcard,henergy] at h + exact (pow_le_pow_left₀ (norm_nonneg _) (halasz_fiber_norm_sum F f z) _).trans h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFiniteHolder.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFiniteHolder.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3c1710fe8f30ce66a8939afe58f2f5a574cd12a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFiniteHolder.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTorusBessel +import Mathlib.Analysis.MeanInequalities + +namespace OAI + +/-! The two finite Hölder steps used in the double mean-value argument. -/ +namespace TwoPointCorrelations + +open Finset + +lemma halasz_finite_weighted_power {ι : Type*} (S : Finset ι) + (w f : ι → ℝ) (hw : ∀ i, 0≤w i) (hf : ∀ i, 0≤f i) + {s : ℕ} (hs : 1≤s) : + (∑ i∈S, w i*f i)^s ≤ (∑ i∈S,w i)^(s-1)*(∑ i∈S,w i*(f i)^s) := by + have hsR : (1:ℝ)≤s := by exact_mod_cast hs + have hs0 : (s:ℝ)≠0 := by exact_mod_cast (by omega : s≠0) + have h := Real.inner_le_weight_mul_Lp_of_nonneg S hsR w f hw hf + have hp := pow_le_pow_left₀ (sum_nonneg (fun i _ => mul_nonneg (hw i) (hf i))) h s + have hW : 0≤∑ i∈S,w i := sum_nonneg (fun i _ => hw i) + have hF : 0≤∑ i∈S,w i*(f i)^(s:ℝ) := sum_nonneg (fun i _ => + mul_nonneg (hw i) (Real.rpow_nonneg (hf i) _)) + have he : (1-(s:ℝ)⁻¹)*(s:ℝ)=((s-1:ℕ):ℝ) := by + rw [Nat.cast_sub hs,Nat.cast_one] + field_simp + rw [mul_pow,← Real.rpow_mul_natCast hW,← Real.rpow_mul_natCast hF, + he,inv_mul_cancel₀ hs0,Real.rpow_one,Real.rpow_natCast] at hp + simpa only [Real.rpow_natCast] using hp + +theorem halasz_finite_weighted_holder {ι : Type*} (S : Finset ι) + (w f : ι → ℝ) (hw : ∀ i, 0≤w i) (hf : ∀ i, 0≤f i) + {s : ℕ} (hs : 1≤s) : + (∑ i∈S,w i*f i)^(2*s) ≤ + (∑ i∈S,w i)^(2*s-2)*(∑ i∈S,(w i)^2)*(∑ i∈S,(f i)^(2*s)) := by + have h := halasz_finite_weighted_power S w f hw hf hs + have hp := pow_le_pow_left₀ (pow_nonneg + (sum_nonneg (fun i _ => mul_nonneg (hw i) (hf i))) s) h 2 + have hc := sum_mul_sq_le_sq_mul_sq S w (fun i => (f i)^s) + rw [mul_pow,← pow_mul,← pow_mul] at hp + rw [show s*2=2*s by omega,show (s-1)*2=2*s-2 by omega] at hp + simp only [← pow_mul,show s*2=2*s by omega] at hc + exact hp.trans (by + have hh := mul_le_mul_of_nonneg_left hc (pow_nonneg + (sum_nonneg (s := S) (fun i _ => hw i)) (2*s-2)) + simpa only [mul_assoc] using hh) + +lemma halasz_complex_sum_power {ι : Type*} (S : Finset ι) (z : ι → ℂ) + {r : ℕ} (hr : 1≤r) : + ‖∑ i∈S,z i‖^r≤(S.card:ℝ)^(r-1)*(∑ i∈S,‖z i‖^r) := by + have hh := halasz_finite_weighted_power S (fun _ => (1:ℝ)) (fun i => ‖z i‖) + (fun _ => zero_le_one) (fun _ => norm_nonneg _) hr + have hn := pow_le_pow_left₀ (norm_nonneg _) (norm_sum_le S z) r + exact hn.trans (by simpa using hh) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFinitePhase.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFinitePhase.lean new file mode 100644 index 0000000000000000000000000000000000000000..20d420c2c29f65ed60c0d26771849b87fe18d102 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFinitePhase.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszFiberEnergy + +namespace OAI + +/-! Exact Fourier formulas for the finite energies used when the short +variables are restricted to one residue class. -/ +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical ComplexConjugate + +noncomputable def halaszFinitePhase {ι : Type*} {k : ℕ} (F : Finset ι) + (f : ι → Fin k → ℤ) (α : Fin k → AddCircle (1:ℝ)) : ℂ := + ∑ x∈F, halaszVinogradovCharacter (f x) α + +lemma halasz_finite_phase_continuous {ι : Type*} {k : ℕ} + (F : Finset ι) (f : ι → Fin k → ℤ) : Continuous (halaszFinitePhase F f) := by + exact continuous_finsetSum F (fun x _ => halasz_vinogradov_character_continuous (f x)) + +lemma halasz_torus_integrable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + {k : ℕ} (f : (Fin k → AddCircle (1:ℝ)) → E) (hf : Continuous f) : + Integrable f (halaszVinogradovHaar k) := + hf.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) + +theorem halasz_finite_phase_energy {ι : Type*} {k : ℕ} (F : Finset ι) + (f : ι → Fin k → ℤ) : + (∫ α, ‖halaszFinitePhase F f α‖^2 ∂halaszVinogradovHaar k) = + (halaszFiberEnergy F f : ℝ) := by + have hi (x y : ι) : Integrable (fun α => + halaszVinogradovCharacter (f x) α * conj (halaszVinogradovCharacter (f y) α)) + (halaszVinogradovHaar k) := by + simp_rw [← halasz_vinogradov_character_neg,← halasz_vinogradov_character_add] + exact halasz_vinogradov_character_integrable _ + have hc : (∫ α, halaszFinitePhase F f α * conj (halaszFinitePhase F f α) + ∂halaszVinogradovHaar k) = (halaszFiberEnergy F f : ℂ) := by + unfold halaszFinitePhase + simp_rw [map_sum,sum_mul,mul_sum] + rw [integral_finsetSum F (fun x _ => integrable_finsetSum F (fun y _ => hi x y))] + simp_rw [integral_finsetSum F (fun y _ => hi _ y),halasz_vinogradov_character_inner] + rw [halasz_fiber_energy_rows,Nat.cast_sum] + apply sum_congr rfl + intro x _ + simp only [sum_boole] + congr 2 + ext y + simp only [mem_filter] + exact and_congr_right (fun _ => eq_comm) + apply Complex.ofReal_injective + rw [← integral_complex_ofReal] + simpa only [Complex.mul_conj',Complex.ofReal_pow,Complex.ofReal_natCast] using hc + +lemma halasz_finite_phase_product {ι κ : Type*} {k : ℕ} (F : Finset ι) (G : Finset κ) + (f : ι → Fin k → ℤ) (g : κ → Fin k → ℤ) (α : Fin k → AddCircle (1:ℝ)) : + halaszFinitePhase (F×ˢG) (fun x => f x.1+g x.2) α = + halaszFinitePhase F f α * halaszFinitePhase G g α := by + simp only [halaszFinitePhase,sum_product,halasz_vinogradov_character_add,sum_mul,mul_sum] + rw [sum_comm] + +lemma halasz_finite_phase_power {ι : Type*} {k : ℕ} (F : Finset ι) + (f : ι → Fin k → ℤ) (s : ℕ) (α : Fin k → AddCircle (1:ℝ)) : + halaszFinitePhase (Fintype.piFinset (fun _ : Fin s => F)) + (fun x => ∑ i, f (x i)) α = (halaszFinitePhase F f α)^s := by + rw [halaszFinitePhase,halaszFinitePhase,sum_pow'] + apply sum_congr rfl + intro x _ + exact halasz_vinogradov_character_sum univ (fun i => f (x i)) α + +theorem halasz_finite_mixed_moment {ι κ : Type*} {k : ℕ} + (F : Finset ι) (G : Finset κ) (f : ι → Fin k → ℤ) (g : κ → Fin k → ℤ) (s : ℕ) : + (∫ α, ‖halaszFinitePhase F f α‖^2 * ‖halaszFinitePhase G g α‖^(2*s) + ∂halaszVinogradovHaar k) = + (halaszFiberEnergy (F×ˢFintype.piFinset (fun _ : Fin s => G)) + (fun x => f x.1+∑ i, g (x.2 i)) : ℝ) := by + rw [← halasz_finite_phase_energy] + apply integral_congr_ae + filter_upwards [] with α + rw [halasz_finite_phase_product F (Fintype.piFinset (fun _ : Fin s => G)) f + (fun x => ∑ i, g (x i)),halasz_finite_phase_power,norm_mul,mul_pow,norm_pow] + congr 1 + rw [← pow_mul,Nat.mul_comm s 2] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFirstDerivative.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFirstDerivative.lean new file mode 100644 index 0000000000000000000000000000000000000000..93fcaa5b31045ea852c105e78eb9b2943cc961bf --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFirstDerivative.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLogOscillation + +namespace OAI + +/-! A first-derivative oscillatory-integral estimate for the logarithmic +phase, to be used on the nonstationary pieces of the Poisson kernel. -/ + +namespace TwoPointCorrelations + +open MeasureTheory + +lemma halasz_log_phase_continuousOn (u v a b : ℝ) (ha : 0 < a) : + ContinuousOn (halaszLogPhase u v) (Set.Icc a b) := by + intro x hx + exact (halasz_log_phase_deriv u v x (ha.trans_le hx.1).ne').continuousAt.continuousWithinAt + +lemma halasz_log_reciprocal_deriv_continuousOn (u v a b : ℝ) (ha : 0 < a) + (hd : ∀ x ∈ Set.Icc a b, halaszLogSlope u v x ≠ 0) : + ContinuousOn (halaszLogReciprocalDeriv u v) (Set.Icc a b) := by + have hx (x : ℝ) (h : x ∈ Set.Icc a b) : x ≠ 0 := (ha.trans_le h.1).ne' + apply continuousOn_const.div + ((continuousOn_id.pow 2).mul (((continuousOn_const.div continuousOn_id hx).sub + continuousOn_const).pow 2)) + intro x h + exact mul_ne_zero (pow_ne_zero 2 (hx x h)) (pow_ne_zero 2 (hd x h)) + +theorem halasz_log_first_derivative (u v a b lam : ℝ) (hu : 0 ≤ u) + (ha : 0 < a) (hab : a ≤ b) (hlam : 0 < lam) + (hslope : ∀ x ∈ Set.Icc a b, lam ≤ |halaszLogSlope u v x|) : + ‖∫ x in a..b, halaszLogPhase u v x‖ ≤ 4/lam := by + have hd (x : ℝ) (hx : x ∈ Set.Icc a b) : halaszLogSlope u v x ≠ 0 := by + have hh := hslope x hx + exact abs_pos.mp (hlam.trans_le hh) + have hiF : IntervalIntegrable (halaszLogPhase u v) volume a b := (halasz_log_phase_continuousOn u v a b ha).intervalIntegrable_of_Icc hab + let K : ℝ → ℂ := fun x => Complex.I*halaszLogPhase u v x* + (halaszLogReciprocalDeriv u v x:ℂ) + have hiK : IntervalIntegrable K volume a b := + ((continuousOn_const.mul (halasz_log_phase_continuousOn u v a b ha)).mul + (Complex.continuous_ofReal.comp_continuousOn + (halasz_log_reciprocal_deriv_continuousOn u v a b ha hd))).intervalIntegrable_of_Icc hab + have hFTC := intervalIntegral.integral_eq_sub_of_hasDerivAt + (fun x hx => halasz_log_phase_primitive_deriv u v x + (ha.trans_le (show x ∈ Set.Icc a b from by simpa only [Set.uIcc_of_le hab] using hx).1).ne' + (hd x (by simpa only [Set.uIcc_of_le hab] using hx))) (hiF.sub hiK) + have hKn (x : ℝ) : ‖K x‖ = halaszLogReciprocalDeriv u v x := by + simp only [K, norm_mul, Complex.norm_I, one_mul, halasz_log_phase_norm, + Complex.norm_real, Real.norm_eq_abs] + exact abs_of_nonneg (by unfold halaszLogReciprocalDeriv; positivity) + have hKI : ‖∫ x in a..b, K x‖ ≤ + (halaszLogSlope u v b)⁻¹-(halaszLogSlope u v a)⁻¹ := by + have hh := intervalIntegral.norm_integral_le_integral_norm (μ := volume) (f := K) hab + simp_rw [hKn] at hh + rwa [halasz_log_reciprocal_integral u v a b ha hab hd] at hh + have hbound (x : ℝ) (hx : x ∈ Set.Icc a b) : + |(halaszLogSlope u v x)⁻¹| ≤ 1/lam := by + rw [abs_inv] + simpa only [one_div] using one_div_le_one_div_of_le hlam (hslope x hx) + have hBa := hbound a ⟨le_rfl, hab⟩ + have hBb := hbound b ⟨hab, le_rfl⟩ + have hR : (halaszLogSlope u v b)⁻¹-(halaszLogSlope u v a)⁻¹ ≤ 2/lam := by + have haa := le_abs_self (-(halaszLogSlope u v a)⁻¹) + rw [abs_neg] at haa + have hbb := le_abs_self ((halaszLogSlope u v b)⁻¹) + simp only [div_eq_mul_inv] at hBa hBb ⊢ + linarith + have hHnorm (x : ℝ) : + ‖-Complex.I*halaszLogPhase u v x*((halaszLogSlope u v x)⁻¹:ℝ)‖ = + |(halaszLogSlope u v x)⁻¹| := by + simp only [norm_mul, norm_neg, Complex.norm_I, halasz_log_phase_norm, + one_mul, Complex.norm_real, Real.norm_eq_abs] + have hidentity : (∫ x in a..b, halaszLogPhase u v x) = + -Complex.I*halaszLogPhase u v b*((halaszLogSlope u v b)⁻¹:ℝ) - + (-Complex.I*halaszLogPhase u v a*((halaszLogSlope u v a)⁻¹:ℝ)) + + ∫ x in a..b, K x := by + rw [intervalIntegral.integral_sub hiF hiK] at hFTC + exact sub_eq_iff_eq_add.mp hFTC + rw [hidentity] + apply (norm_add_le _ _).trans + have hh := norm_sub_le + (-Complex.I*halaszLogPhase u v b*((halaszLogSlope u v b)⁻¹:ℝ)) + (-Complex.I*halaszLogPhase u v a*((halaszLogSlope u v a)⁻¹:ℝ)) + simp only [hHnorm] at hh + simp only [div_eq_mul_inv] at hBa hBb hR ⊢ + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFirstOriginalMean.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFirstOriginalMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e2b714a5484553e298603f20bb9ce7117012775 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFirstOriginalMean.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszOriginalShortMean +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTFinalBandBudget +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTCommonDistance +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTShortMeanQuarterRate + +namespace OAI + +/-! The published short-mean rate with the exact original pretentious +cutoff and frequency range, for dyadic windows inside that cutoff. -/ + +namespace TwoPointCorrelations + +open Filter Finset MeasureTheory +open scoped Classical + +theorem halasz_first_original_short_mean + (hprime : HalaszPrimeSparseInput) (hhigh : HalaszHighPrimeInput) + (A : ℕ) (hA : 500000 ≤ A) : + ∃ C H₀ : ℝ, 0 < C ∧ 1 ≤ H₀ ∧ ∀ᶠ N : ℕ in atTop, + ∀ X : ℕ, N ≤ X → X ≤ N^3 → + ∀ H : ℕ, H₀ ≤ H → (H:ℝ) ≤ Real.exp (Real.sqrt (Real.log N)) → + ∀ F : ℕ → ℂ, F 1=1 → Multiplicative F → OneBounded F → + ∀ M : ℝ, 0 ≤ M → + (∀ u:ℝ, |u| ≤ X → M ≤ squaredDistance F (mrtArchimedeanTwist u) X) → + (∫ x in (N:ℝ)..(2*N), ‖shortExponentialSum F H 0 x‖)/((N:ℝ)*H) ≤ + C*(Real.log (Real.log H)/Real.log H + Real.exp (-M/2)+(Real.log N)^(-1/700:ℝ)) := by + obtain ⟨C₁,C₂,hC₁,hC₂,hmean⟩ := halasz_original_short_mean hprime hhigh + obtain ⟨C₀,L₀,H₀,hC₀,hL₀,hH₀,hrate⟩ := mrt_short_mean_quarter_rate A hA C₁ C₂ hC₁.le hC₂.le + obtain ⟨H₁,hscale⟩ := eventually_atTop.mp + ((minor_arc_first_band_scale A 0 (by omega)).and (minor_arc_first_band_budget_eventually A hA)) + refine ⟨C₀,max H₀ H₁,hC₀, + hH₀.trans (le_max_left _ _),?_⟩ + have hlog : Tendsto (fun N:ℕ => Real.log N) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + filter_upwards [hmean,mrt_common_final_band_from_budget, + hlog.eventually (eventually_ge_atTop L₀),eventually_ge_atTop 2] + with N hmean hband hLN hN2 + intro X hNX hXN H hH₀' hHN F hF1 hFm hFb M hM hd + obtain ⟨hs,hbudget⟩ := hscale H ((le_max_right _ _).trans hH₀') + obtain ⟨hH4,hLH,hLL,hP4,_,_,hPQ,hQU,_,hlQ⟩ := hs + let P := minorArcFirstLower A H + let Q := minorArcFirstUpper H + have hL : 1 ≤ Real.log (N:ℝ) := hL₀.trans hLN + have hHr : 0 < (H:ℝ) := by linarith + have hH : 0 < H := by exact_mod_cast hHr + have hN0 : 0 < (N:ℝ) := by exact_mod_cast (show 0 Int.natCast_nonneg _) + +lemma halasz_vinogradov_frequency_le {s k M : ℕ} (x : Fin s → Fin M) (j : Fin k) : + halaszVinogradovFrequency k x j≤(s*M^(j.val+1):ℕ) := by + unfold halaszVinogradovFrequency + have hh : (∑ i, ((x i).val+1)^(j.val+1))≤s*M^(j.val+1) := by + calc + _ ≤ ∑ _i : Fin s,M^(j.val+1) := sum_le_sum (fun i _ => + Nat.pow_le_pow_left (by omega : (x i).val+1≤M) _) + _ = _ := by simp + exact_mod_cast hh + +lemma halasz_vinogradov_difference_abs {s k M : ℕ} + (x y : Fin s → Fin M) (j : Fin k) : + |halaszVinogradovFrequency k x j-halaszVinogradovFrequency k y j|≤ + (s*M^(j.val+1):ℕ) := by + apply abs_le.mpr + constructor <;> linarith [halasz_vinogradov_frequency_nonneg x j, + halasz_vinogradov_frequency_nonneg y j,halasz_vinogradov_frequency_le x j, + halasz_vinogradov_frequency_le y j] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFrequencyRows.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFrequencyRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..9bf47c4c51cebfbb22aae70a589617d3a39c0321 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszFrequencyRows.lean @@ -0,0 +1,178 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszWeightedMeanSquare + +namespace OAI + +/-! A local frequency-mass estimate controls the entire quadratic-decay row. +This keeps the prime-counting input separate from the finite harmonic-analysis +argument, and applies to the actual finite Dirichlet polynomial. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped BigOperators Classical + +noncomputable def halaszFrequencyShell {ι : Type*} (S : Finset ι) + (freq : ι → ℝ) (T u : ℝ) (k : ℕ) : Finset ι := + S.filter (fun i => Nat.floor (T * |freq i - u|) = k) + +lemma halasz_quadratic_kernel_sum (M : ℕ) : + (∑ k ∈ range (M + 1), (1 + (k : ℝ) ^ 2)⁻¹) ≤ 4 := by + have he : range (M + 1) = insert 0 (Ioc 0 M) := by + ext k + simp only [mem_range, mem_insert, mem_Ioc] + omega + rw [he, sum_insert (by simp)] + have hh := mrt_quadratic_gap_sum (R := 1) (by norm_num) M + norm_num only [div_one] at hh + norm_num only [Nat.cast_zero, zero_pow (by decide : 2 ≠ 0), add_zero, inv_one] + linarith + +/-- Shell mass at frequency resolution `1/T` controls the whole Fourier +kernel row, uniformly in the number and placement of the frequencies. -/ +theorem halasz_frequency_row_of_shells {ι : Type*} (S : Finset ι) + (freq w : ι → ℝ) (u : ℝ) {T B : ℝ} (hT : 0 < T) (hB : 0 ≤ B) + (hw : ∀ i ∈ S, 0 ≤ w i) + (hshell : ∀ k : ℕ, ∑ i ∈ halaszFrequencyShell S freq T u k, w i ≤ B / T) : + (∑ i ∈ S, w i * (2 * T / (1 + T ^ 2 * (freq i - u) ^ 2))) ≤ 8 * B := by + classical + let bin : ι → ℕ := fun i => Nat.floor (T * |freq i - u|) + let M := S.sup bin + have hmaps : ∀ i ∈ S, bin i ∈ range (M + 1) := by + intro i hi + exact mem_range.mpr (Nat.lt_succ_of_le (le_sup (f := bin) hi)) + have hpoint (i : ι) : + 2 * T / (1 + T ^ 2 * (freq i - u) ^ 2) ≤ + 2 * T * (1 + (bin i : ℝ) ^ 2)⁻¹ := by + have hfloor : (bin i : ℝ) ≤ T * |freq i - u| := + Nat.floor_le (mul_nonneg hT.le (abs_nonneg _)) + have hsq := pow_le_pow_left₀ (Nat.cast_nonneg (bin i)) hfloor 2 + rw [mul_pow, sq_abs] at hsq + rw [div_eq_mul_inv] + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact inv_anti₀ (by positivity) (add_le_add le_rfl hsq) + have hgroup : (∑ i ∈ S, w i * (2 * T * (1 + (bin i : ℝ) ^ 2)⁻¹)) = + ∑ k ∈ range (M + 1), (2 * T * (1 + (k : ℝ) ^ 2)⁻¹) * + ∑ i ∈ halaszFrequencyShell S freq T u k, w i := by + rw [← sum_fiberwise_of_maps_to hmaps] + apply sum_congr rfl + intro k _ + rw [mul_sum] + apply sum_congr rfl + intro i hi + have he := (mem_filter.mp hi).2 + change bin i = k at he + rw [he] + ring + calc + _ ≤ ∑ i ∈ S, w i * (2 * T * (1 + (bin i : ℝ) ^ 2)⁻¹) := by + exact sum_le_sum (fun i hi => mul_le_mul_of_nonneg_left (hpoint i) (hw i hi)) + _ = _ := hgroup + _ ≤ ∑ k ∈ range (M + 1), (2 * T * (1 + (k : ℝ) ^ 2)⁻¹) * (B / T) := by + exact sum_le_sum (fun k _ => mul_le_mul_of_nonneg_left (hshell k) (by positivity)) + _ = 2 * B * ∑ k ∈ range (M + 1), (1 + (k : ℝ) ^ 2)⁻¹ := by + rw [mul_sum] + apply sum_congr rfl + intro k _ + field_simp + _ ≤ 2 * B * 4 := + mul_le_mul_of_nonneg_left (halasz_quadratic_kernel_sum M) (by positivity) + _ = _ := by ring + +/-- The corresponding mean-square estimate for a finite polynomial whose +weighted frequency shells all have controlled mass. -/ +theorem halasz_mean_square_of_frequency_shells {ι : Type*} (S : Finset ι) + (a : ι → ℂ) (w freq : ι → ℝ) {T B : ℝ} (hT : 0 < T) (hB : 0 ≤ B) + (hw : ∀ i ∈ S, 0 ≤ w i) + (hshell : ∀ i ∈ S, ∀ k : ℕ, + ∑ j ∈ halaszFrequencyShell S freq T (freq i) k, w j ≤ B / T) : + (∫ t in -T..T, + ‖mrtExponentialPolynomial S (fun i => a i * (w i : ℂ)) freq t‖ ^ 2) ≤ + 8 * Real.exp 1 * B * ∑ i ∈ S, ‖a i‖ ^ 2 * w i := by + have hrow : ∀ i ∈ S, + ∑ j ∈ S, w j * (2 * T / (1 + T ^ 2 * (freq i - freq j) ^ 2)) ≤ 8 * B := by + intro i hi + convert halasz_frequency_row_of_shells S freq w (freq i) hT hB hw (hshell i hi) using 1 + apply sum_congr rfl + intro j _ + rw [show (freq i - freq j) ^ 2 = (freq j - freq i) ^ 2 by ring] + apply (halasz_mean_square_of_weighted_rows S a w freq hT hw hrow).trans_eq + ring + + +/-- A shell is the union of its two one-sided frequency intervals. -/ +lemma halasz_shell_mass_of_windows {ι : Type*} (S : Finset ι) + (freq w : ι → ℝ) (u : ℝ) {T A : ℝ} (hT : 0 < T) + (hw : ∀ i ∈ S, 0 ≤ w i) + (hwindow : ∀ v : ℝ, + (∑ i ∈ S.filter (fun i => v ≤ freq i ∧ freq i ≤ v + 1 / T), w i) ≤ A / T) + (k : ℕ) : + (∑ i ∈ halaszFrequencyShell S freq T u k, w i) ≤ 2 * A / T := by + classical + let Q := halaszFrequencyShell S freq T u k + let R := Q.filter (fun i => u ≤ freq i) + let L := Q.filter (fun i => ¬u ≤ freq i) + have he : Q = R ∪ L := by + ext i + simp only [R, L, mem_union, mem_filter] + tauto + have hd : Disjoint R L := by + rw [disjoint_left] + intro i hi hj + exact (mem_filter.mp hj).2 (mem_filter.mp hi).2 + have hgap (i : ι) (hi : i ∈ Q) : + (k : ℝ) / T ≤ |freq i - u| ∧ |freq i - u| ≤ ((k : ℝ) + 1) / T := by + have heq := (mem_filter.mp hi).2 + change Nat.floor (T * |freq i - u|) = k at heq + have hlo := Nat.floor_le (mul_nonneg hT.le (abs_nonneg (freq i - u))) + have hhi := Nat.lt_floor_add_one (T * |freq i - u|) + rw [heq] at hlo hhi + constructor + · exact (div_le_iff₀ hT).mpr (by linarith) + · exact (le_div_iff₀ hT).mpr (by linarith) + have hR : R ⊆ S.filter (fun i => + u + (k : ℝ) / T ≤ freq i ∧ freq i ≤ u + (k : ℝ) / T + 1 / T) := by + intro i hi + obtain ⟨hiQ, hiu⟩ := mem_filter.mp hi + have hg := hgap i hiQ + rw [abs_of_nonneg (sub_nonneg.mpr hiu)] at hg + refine mem_filter.mpr ⟨(mem_filter.mp hiQ).1, ?_⟩ + simp only [add_div] at hg ⊢ + constructor <;> linarith + have hL : L ⊆ S.filter (fun i => + u - ((k : ℝ) + 1) / T ≤ freq i ∧ + freq i ≤ u - ((k : ℝ) + 1) / T + 1 / T) := by + intro i hi + obtain ⟨hiQ, hiu⟩ := mem_filter.mp hi + have hg := hgap i hiQ + rw [abs_of_nonpos (sub_nonpos.mpr (le_of_not_ge hiu))] at hg + refine mem_filter.mpr ⟨(mem_filter.mp hiQ).1, ?_⟩ + simp only [add_div] at hg ⊢ + constructor <;> linarith + have hbR : (∑ i ∈ R, w i) ≤ A / T := by + apply (sum_le_sum_of_subset_of_nonneg hR ?_).trans (hwindow _) + intro i hi _ + exact hw i (mem_filter.mp hi).1 + have hbL : (∑ i ∈ L, w i) ≤ A / T := by + apply (sum_le_sum_of_subset_of_nonneg hL ?_).trans (hwindow _) + intro i hi _ + exact hw i (mem_filter.mp hi).1 + change (∑ i ∈ Q, w i) ≤ _ + rw [he, sum_union hd] + calc + _ ≤ A / T + A / T := add_le_add hbR hbL + _ = _ := by ring + +/-- A uniform local frequency-mass bound gives a uniform kernel-row bound. -/ +theorem halasz_frequency_row_of_windows {ι : Type*} (S : Finset ι) + (freq w : ι → ℝ) (u : ℝ) {T A : ℝ} (hT : 0 < T) (hA : 0 ≤ A) + (hw : ∀ i ∈ S, 0 ≤ w i) + (hwindow : ∀ v : ℝ, + (∑ i ∈ S.filter (fun i => v ≤ freq i ∧ freq i ≤ v + 1 / T), w i) ≤ A / T) : + (∑ i ∈ S, w i * (2 * T / (1 + T ^ 2 * (freq i - u) ^ 2))) ≤ 16 * A := by + have hh := halasz_frequency_row_of_shells S freq w u hT (mul_nonneg (by norm_num) hA) + hw (halasz_shell_mass_of_windows S freq w u hT hw hwindow) + convert hh using 1; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGeneralException.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGeneralException.lean new file mode 100644 index 0000000000000000000000000000000000000000..c392e9d0c2cb3ab8e2a21d6c63caacfcb55755ab --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGeneralException.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszGeneralMean +import OAI.NumberTheory.TwoPoint.Halasz.HalaszExceptionalMean + +namespace OAI + +/-! The localized exceptional-window mean for ordinary multiplicative functions. -/ +namespace TwoPointCorrelations + +open Finset Filter + +theorem halasz_general_exceptional_mean : ∃ C X₀ : ℝ, 0 < C ∧ + ∀ (N : ℕ), X₀ ≤ N → + ∀ (f : ℕ → ℂ), f 1 = 1 → Multiplicative f → OneBounded f → + ∀ (M₀ τ : ℝ), 0 ≤ M₀ → + (∀ t ∈ Set.Ioc (-(Real.log (N : ℝ) ^ 8)) (Real.log (N : ℝ) ^ 8), + t ∉ Set.Ioc (τ-1/2) (τ+1/2) → M₀ ≤ squaredDistance f (mrtArchimedeanTwist t) N) → + ‖∑ n ∈ Icc 1 N, f n‖ ≤ C * N * + ((min M₀ (Real.log (1+|τ|)) + 1) * Real.exp (-min M₀ (Real.log (1+|τ|))) + + Real.log (Real.log N) / Real.log N) := by + obtain ⟨C₀, Y₀, hC₀, hmean⟩ := halasz_exceptional_mean_value + obtain ⟨K, hK, hcut⟩ := halasz_distance_cutoff_loss + let D := C₀ * Real.exp K + 3 * C₀ + 1 + let C := mrtCorrectionBound * D + have hCorr : 0 < mrtCorrectionBound := Real.exp_pos _ + have hD : 0 < D := by dsimp [D]; positivity + have hC : 0 < C := mul_pos hCorr hD + obtain ⟨X₀, hX₀⟩ := eventually_atTop.mp (halasz_eventually_correction_scale Y₀) + refine ⟨C, X₀, hC, ?_⟩ + intro N hXN f hf1 hf hb M₀ τ hM₀ hd + obtain ⟨hW, hWY, hWN, htail, hlog, hll⟩ := hX₀ N hXN + let W := ⌈Real.log (N : ℝ) ^ 4⌉₊ + let M := min M₀ (Real.log (1+|τ|)) + have hM : 0 ≤ M := le_min hM₀ (Real.log_nonneg (by linarith [abs_nonneg τ])) + have hMM₀ : M ≤ M₀ := min_le_left _ _ + let M' := max 0 (M - K) + let E := (M + 1) * Real.exp (-M) + let R := Real.log (Real.log (N : ℝ)) / Real.log N + let A := C₀ * (Real.exp K * E + 3 * R) + have hE : 0 ≤ E := by dsimp [E]; positivity + have hR : 0 ≤ R := by dsimp [R]; positivity + have hA : 0 ≤ A := by dsimp [A]; positivity + have hNlog : 0 < Real.log (N : ℝ) := by linarith + have hprefix (d : ℕ) (hdN : d ∈ Icc 1 N) (hdW : d ≤ W) : + ‖∑ n ∈ Icc 1 (N / d), mrtCompletePart f n‖ ≤ A * ((N / d : ℕ) : ℝ) := by + have hd0 : 0 < d := (mem_Icc.mp hdN).1 + have hWNnat : W ^ 2 ≤ N := by exact_mod_cast hWN + obtain ⟨hWq, hqN, hNq⟩ := halasz_correction_quotient hW hd0 hdW hWNnat + have hq2 : 2 ≤ N / d := hW.trans hWq + have hqY : Y₀ ≤ ((N / d : ℕ) : ℝ) := + hWY.trans (by exact_mod_cast hWq) + have hlnq : 0 < Real.log ((N / d : ℕ) : ℝ) := + Real.log_pos (by exact_mod_cast (show 1 < N / d by omega)) + have hlogqN : Real.log ((N / d : ℕ) : ℝ) ≤ Real.log (N : ℝ) := + Real.log_le_log (by exact_mod_cast (show 0 < N / d by omega)) (by exact_mod_cast hqN) + have hheight : Real.log ((N / d : ℕ) : ℝ) ^ 8 ≤ Real.log (N : ℝ) ^ 8 := + pow_le_pow_left₀ hlnq.le hlogqN 8 + have hdist (t : ℝ) (ht : t ∈ Set.Ioc + (-(Real.log ((N / d : ℕ) : ℝ) ^ 8)) (Real.log ((N / d : ℕ) : ℝ) ^ 8)) + (hout : t ∉ Set.Ioc (τ-1/2) (τ+1/2)) : + M' ≤ squaredDistance (mrtCompletePart f) (mrtArchimedeanTwist t) (N / d) := by + rw [halasz_complete_distance] + apply max_le + · exact halasz_distance_nonneg f hb _ t + · have hl := hcut f hb (N / d) N hq2 hqN hNq t + have hu := hd t ⟨by linarith [ht.1], ht.2.trans hheight⟩ hout + linarith + have hm := hmean (N / d) hqY (mrtCompletePart f) (fromPrimePowers_one _) + (fun a b ha hb => mrtCompletePart_mul f ha hb) (mrtCompletePart_oneBounded f hb) + M' τ (le_max_left _ _) hdist + have hMlog : M' ≤ Real.log (1+|τ|) := by + have hm : M ≤ Real.log (1+|τ|) := min_le_right _ _ + exact max_le (Real.log_nonneg (by linarith [abs_nonneg τ])) (by linarith) + rw [min_eq_left hMlog] at hm + have hdec := halasz_decay_shift hM hK + have herr := halasz_log_error_cutoff hq2 hqN hNq (by linarith) + calc + _ ≤ C₀ * ((N / d : ℕ) : ℝ) * + ((M' + 1) * Real.exp (-M') + + Real.log (Real.log ((N / d : ℕ) : ℝ)) / Real.log ((N / d : ℕ) : ℝ)) := hm + _ ≤ C₀ * ((N / d : ℕ) : ℝ) * (Real.exp K * E + 3 * R) := by gcongr + _ = _ := by ring + have hc := halasz_correction_mean_bound f hf hb hf1 N W (by omega) A hA hprefix + have hRtail : (W : ℝ) ^ (-(1 / 4 : ℝ)) ≤ R := by + apply htail.trans + exact div_le_div_of_nonneg_right hll hNlog.le + have hsmall : A + (W : ℝ) ^ (-(1 / 4 : ℝ)) ≤ D * (E + R) := by + dsimp [A, D] + have hCE : 0 ≤ C₀ * Real.exp K * R := by positivity + have h3E : 0 ≤ 3 * C₀ * E := by positivity + nlinarith + calc + _ ≤ mrtCorrectionBound * N * (A + (W : ℝ) ^ (-(1 / 4 : ℝ))) := hc + _ ≤ mrtCorrectionBound * N * (D * (E + R)) := + mul_le_mul_of_nonneg_left hsmall (by positivity) + _ = _ := by dsimp [C, E, R]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGeneralMean.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGeneralMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..c19b3c154865f49241ab1d4c352474512fba4b52 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGeneralMean.lean @@ -0,0 +1,104 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMeanValue +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCorrectionTransfer +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCorrectionScale +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDistanceDecay + +namespace OAI + +/-! The ordinary Halász estimate for general normalized multiplicative +functions. Only the values at primes enter the pretentious hypothesis. -/ + +namespace TwoPointCorrelations + +open Finset Filter + +lemma halasz_complete_distance (f : ℕ → ℂ) (g : ℕ → ℂ) (N : ℕ) : + squaredDistance (mrtCompletePart f) g N = squaredDistance f g N := by + unfold squaredDistance + apply sum_congr rfl + intro p hp + have hprime : p.Prime := (mem_filter.mp hp).2 + have he : mrtCompletePart f p = f p := by + simpa using mrtCompletePart_prime_pow f hprime 1 + rw [he] + +theorem halasz_general_mean_value : ∃ C X₀ : ℝ, 0 < C ∧ + ∀ (N : ℕ), X₀ ≤ N → + ∀ (f : ℕ → ℂ), f 1 = 1 → Multiplicative f → OneBounded f → + ∀ (M : ℝ), 0 ≤ M → + (∀ t ∈ Set.Icc (-(Real.log (N : ℝ) ^ 8)) (Real.log (N : ℝ) ^ 8), + M ≤ squaredDistance f (mrtArchimedeanTwist t) N) → + ‖∑ n ∈ Icc 1 N, f n‖ ≤ C * N * + ((M + 1) * Real.exp (-M) + Real.log (Real.log N) / Real.log N) := by + obtain ⟨C₀, Y₀, hC₀, hmean⟩ := halasz_mean_value + obtain ⟨K, hK, hcut⟩ := halasz_distance_cutoff_loss + let D := C₀ * Real.exp K + 3 * C₀ + 1 + let C := mrtCorrectionBound * D + have hCorr : 0 < mrtCorrectionBound := Real.exp_pos _ + have hD : 0 < D := by dsimp [D]; positivity + have hC : 0 < C := mul_pos hCorr hD + obtain ⟨X₀, hX₀⟩ := eventually_atTop.mp (halasz_eventually_correction_scale Y₀) + refine ⟨C, X₀, hC, ?_⟩ + intro N hXN f hf1 hf hb M hM hd + obtain ⟨hW, hWY, hWN, htail, hlog, hll⟩ := hX₀ N hXN + let W := ⌈Real.log (N : ℝ) ^ 4⌉₊ + let M' := max 0 (M - K) + let E := (M + 1) * Real.exp (-M) + let R := Real.log (Real.log (N : ℝ)) / Real.log N + let A := C₀ * (Real.exp K * E + 3 * R) + have hE : 0 ≤ E := by dsimp [E]; positivity + have hR : 0 ≤ R := by dsimp [R]; positivity + have hA : 0 ≤ A := by dsimp [A]; positivity + have hNlog : 0 < Real.log (N : ℝ) := by linarith + have hprefix (d : ℕ) (hdN : d ∈ Icc 1 N) (hdW : d ≤ W) : + ‖∑ n ∈ Icc 1 (N / d), mrtCompletePart f n‖ ≤ A * ((N / d : ℕ) : ℝ) := by + have hd0 : 0 < d := (mem_Icc.mp hdN).1 + have hWNnat : W ^ 2 ≤ N := by exact_mod_cast hWN + obtain ⟨hWq, hqN, hNq⟩ := halasz_correction_quotient hW hd0 hdW hWNnat + have hq2 : 2 ≤ N / d := hW.trans hWq + have hqY : Y₀ ≤ ((N / d : ℕ) : ℝ) := + hWY.trans (by exact_mod_cast hWq) + have hlnq : 0 < Real.log ((N / d : ℕ) : ℝ) := + Real.log_pos (by exact_mod_cast (show 1 < N / d by omega)) + have hlogqN : Real.log ((N / d : ℕ) : ℝ) ≤ Real.log (N : ℝ) := + Real.log_le_log (by exact_mod_cast (show 0 < N / d by omega)) (by exact_mod_cast hqN) + have hheight : Real.log ((N / d : ℕ) : ℝ) ^ 8 ≤ Real.log (N : ℝ) ^ 8 := + pow_le_pow_left₀ hlnq.le hlogqN 8 + have hdist (t : ℝ) (ht : t ∈ Set.Icc + (-(Real.log ((N / d : ℕ) : ℝ) ^ 8)) (Real.log ((N / d : ℕ) : ℝ) ^ 8)) : + M' ≤ squaredDistance (mrtCompletePart f) (mrtArchimedeanTwist t) (N / d) := by + rw [halasz_complete_distance] + apply max_le + · exact halasz_distance_nonneg f hb _ t + · have hl := hcut f hb (N / d) N hq2 hqN hNq t + have hu := hd t ⟨by linarith [ht.1], ht.2.trans hheight⟩ + linarith + have hm := hmean (N / d) hqY (mrtCompletePart f) (fromPrimePowers_one _) + (fun a b ha hb => mrtCompletePart_mul f ha hb) (mrtCompletePart_oneBounded f hb) + M' (le_max_left _ _) hdist + have hdec := halasz_decay_shift hM hK + have herr := halasz_log_error_cutoff hq2 hqN hNq (by linarith) + calc + _ ≤ C₀ * ((N / d : ℕ) : ℝ) * + ((M' + 1) * Real.exp (-M') + + Real.log (Real.log ((N / d : ℕ) : ℝ)) / Real.log ((N / d : ℕ) : ℝ)) := hm + _ ≤ C₀ * ((N / d : ℕ) : ℝ) * (Real.exp K * E + 3 * R) := by gcongr + _ = _ := by ring + have hc := halasz_correction_mean_bound f hf hb hf1 N W (by omega) A hA hprefix + have hRtail : (W : ℝ) ^ (-(1 / 4 : ℝ)) ≤ R := by + apply htail.trans + exact div_le_div_of_nonneg_right hll hNlog.le + have hsmall : A + (W : ℝ) ^ (-(1 / 4 : ℝ)) ≤ D * (E + R) := by + dsimp [A, D] + have hCE : 0 ≤ C₀ * Real.exp K * R := by positivity + have h3E : 0 ≤ 3 * C₀ * E := by positivity + nlinarith + calc + _ ≤ mrtCorrectionBound * N * (A + (W : ℝ) ^ (-(1 / 4 : ℝ))) := hc + _ ≤ mrtCorrectionBound * N * (D * (E + R)) := + mul_le_mul_of_nonneg_left hsmall (by positivity) + _ = _ := by dsimp [C, E, R]; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGeneralTwist.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGeneralTwist.lean new file mode 100644 index 0000000000000000000000000000000000000000..372ab2b5b8b0fd6bd186bead29aed2b5bd80900e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGeneralTwist.lean @@ -0,0 +1,38 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszGeneralMean +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTwistedMean + +namespace OAI + +/-! General multiplicative ordinary means after a height translation. -/ + +namespace TwoPointCorrelations + +open Complex Finset +open scoped ComplexConjugate + +lemma halasz_twisted_multiplicative (f : ℕ → ℂ) (hf : Multiplicative f) (t : ℝ) : + Multiplicative (halaszTwistedFunction f t) := by + intro a b ha hb hab + simp only [halaszTwistedFunction, hf a b ha hb hab, halasz_twist_mul t ha hb, map_mul] + ring + +theorem halasz_general_twisted_mean : ∃ C X₀ : ℝ, 0 < C ∧ + ∀ (N : ℕ), X₀ ≤ N → + ∀ (f : ℕ → ℂ), f 1 = 1 → Multiplicative f → OneBounded f → + ∀ (t T M : ℝ), 0 ≤ M → |t| + Real.log (N : ℝ) ^ 8 ≤ T → + (∀ v : ℝ, |v| ≤ T → M ≤ squaredDistance f (mrtArchimedeanTwist v) N) → + ‖∑ n ∈ Icc 1 N, f n * conj (mrtArchimedeanTwist t n)‖ ≤ C * N * + ((M + 1) * Real.exp (-M) + Real.log (Real.log N) / Real.log N) := by + obtain ⟨C, X₀, hC, hmean⟩ := halasz_general_mean_value + refine ⟨C, X₀, hC, ?_⟩ + intro N hXN f hf1 hf hbound t T M hM hT hd + apply hmean N hXN (halaszTwistedFunction f t) (halasz_twisted_one f hf1 t) + (halasz_twisted_multiplicative f hf t) (halasz_twisted_oneBounded f hbound t) M hM + intro u hu + rw [halasz_twisted_distance] + apply hd + exact (abs_add_le t u).trans ((add_le_add le_rfl (abs_le.mpr hu)).trans hT) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGroupedBounds.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGroupedBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..782fa644c438f04218a24c0f3a3bc23e9945157d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGroupedBounds.lean @@ -0,0 +1,104 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszBandWeights +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTripleEstimate + +namespace OAI + +/-! The complementary trivial estimate for a logarithmic prime band. +Together with the Perron estimate it produces the minimum summed later. -/ + +namespace TwoPointCorrelations + +open Finset Complex +open scoped Classical + +noncomputable def halaszGroupedDouble (f : ℕ → ℂ) (N : ℕ) (P : Finset ℕ) : ℂ := + ∑ p ∈ P, (Real.log (p : ℝ) : ℂ) * f p * + (halaszPrimeConvolution f (N / p) / (Real.log ((N : ℝ) / p) : ℂ)) + +lemma halasz_prime_convolution_trivial (f : ℕ → ℂ) (hf : OneBounded f) + {N : ℕ} (hN : 1 ≤ N) : + ‖halaszPrimeConvolution f N‖ ≤ (N : ℝ) * (Real.log N + halaszMertensConstant) := by + have hp := halasz_prime_set_bound f hf N ((Icc 1 N).filter Nat.Prime) + (fun p hp => (mem_filter.mp hp).2) + have hs : (Icc 1 N).filter Nat.Prime = sievePrimesUpTo (N : ℝ) := by + ext p + simp only [sievePrimesUpTo, Nat.floor_natCast, mem_filter, mem_Iic, mem_Icc] + exact ⟨fun h => ⟨h.1.2, h.2⟩, fun h => ⟨⟨h.2.pos, h.1⟩, h.2⟩⟩ + change ‖halaszPrimeConvolution f N‖ ≤ _ at hp + rw [hs] at hp + exact hp.trans (mul_le_mul_of_nonneg_left + (halasz_prime_prefix_mass_le (by exact_mod_cast hN)) (Nat.cast_nonneg _)) + +lemma halasz_prime_convolution_div_log (f : ℕ → ℂ) (hf : OneBounded f) + {M : ℕ} {y : ℝ} (hy : 2 ≤ y) (hMy : (M : ℝ) ≤ y) : + ‖halaszPrimeConvolution f M / (Real.log y : ℂ)‖ ≤ + (1 + halaszMertensConstant / Real.log 2) * y := by + have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hlog : Real.log 2 ≤ Real.log y := Real.log_le_log (by norm_num) hy + have hly : 0 < Real.log y := htwo.trans_le hlog + have hMertens := halaszMertensConstant_nonneg + rw [norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hly] + by_cases hM : M = 0 + · subst M + simp only [halaszPrimeConvolution, Icc_eq_empty_of_lt (by omega : 0 < 1), + filter_empty, sum_empty, norm_zero, zero_div] + positivity + · have hM1 : 1 ≤ M := Nat.one_le_iff_ne_zero.mpr hM + have hLM : Real.log (M : ℝ) ≤ Real.log y := + Real.log_le_log (by exact_mod_cast (Nat.pos_of_ne_zero hM)) hMy + calc + _ ≤ ((M : ℝ) * (Real.log M + halaszMertensConstant)) / Real.log y := + div_le_div_of_nonneg_right (halasz_prime_convolution_trivial f hf hM1) hly.le + _ ≤ (y * (Real.log y + halaszMertensConstant)) / Real.log y := by + apply div_le_div_of_nonneg_right _ hly.le + exact mul_le_mul hMy (add_le_add hLM le_rfl) + (add_nonneg (Real.log_nonneg (by exact_mod_cast hM1)) hMertens) (by linarith) + _ = (1 + halaszMertensConstant / Real.log y) * y := by field_simp + _ ≤ _ := by + apply mul_le_mul_of_nonneg_right _ (by linarith) + exact add_le_add le_rfl (div_le_div_of_nonneg_left hMertens htwo hlog) + +theorem halasz_grouped_double_trivial : ∃ C : ℝ, 0 < C ∧ + ∀ (f : ℕ → ℂ), OneBounded f → ∀ (N : ℕ) (v : ℝ), 0 < N → Real.log 2 ≤ v → + ∀ (P : Finset ℕ), (∀ p ∈ P, p.Prime ∧ + v ≤ Real.log ((N : ℝ) / p) ∧ Real.log ((N : ℝ) / p) < 2 * v) → + ‖halaszGroupedDouble f N P‖ ≤ C * N * v := by + let K := 1 + halaszMertensConstant / Real.log 2 + let L := 1 + 2 * halaszMertensConstant / Real.log 2 + have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hM := halaszMertensConstant_nonneg + have hK : 0 < K := by dsimp [K]; positivity + have hL : 0 < L := by dsimp [L]; positivity + refine ⟨K * L, mul_pos hK hL, ?_⟩ + intro f hf N v hN hv P hP + have hN0 : (0 : ℝ) < N := by exact_mod_cast hN + have hm := halasz_log_band_mass_linear hN0 hv P hP + have hp (p : ℕ) (hp : p ∈ P) : + ‖(Real.log (p : ℝ) : ℂ) * f p * + (halaszPrimeConvolution f (N / p) / (Real.log ((N : ℝ) / p) : ℂ))‖ ≤ + K * N * (Real.log (p : ℝ) / p) := by + have hprime := (hP p hp).1 + have hp0 : (0 : ℝ) < p := by exact_mod_cast hprime.pos + have hy0 : 0 < (N : ℝ) / p := div_pos hN0 hp0 + have hy : (2 : ℝ) ≤ (N : ℝ) / p := + (Real.log_le_log_iff (by norm_num) hy0).mp (hv.trans (hP p hp).2.1) + have hquot : ((N / p : ℕ) : ℝ) ≤ (N : ℝ) / p := by + apply (le_div_iff₀ hp0).mpr + exact_mod_cast Nat.div_mul_le_self N p + rw [norm_mul, norm_mul, Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (Real.log_nonneg (by exact_mod_cast hprime.one_le))] + calc + _ ≤ Real.log (p : ℝ) * 1 * (K * ((N : ℝ) / p)) := + mul_le_mul (mul_le_mul_of_nonneg_left (hf p hprime.pos) (by positivity)) + (halasz_prime_convolution_div_log f hf hy hquot) (norm_nonneg _) (by positivity) + _ = _ := by dsimp [K]; ring + calc + _ ≤ ∑ p ∈ P, ‖(Real.log (p : ℝ) : ℂ) * f p * + (halaszPrimeConvolution f (N / p) / (Real.log ((N : ℝ) / p) : ℂ))‖ := norm_sum_le _ _ + _ ≤ K * N * ∑ p ∈ P, Real.log (p : ℝ) / p := by rw [mul_sum]; exact sum_le_sum hp + _ ≤ K * N * (L * v) := mul_le_mul_of_nonneg_left hm (by positivity) + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGroupedEstimate.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGroupedEstimate.lean new file mode 100644 index 0000000000000000000000000000000000000000..aedbf89efbf85e5ebaa9cc6c5d4e27d0481f50b7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGroupedEstimate.lean @@ -0,0 +1,155 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszGroupedBounds +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePsiDecay + +namespace OAI + +/-! Apply the full triple-convolution estimate to one actual logarithmic +band, with its adaptive denominator and finite cofactor prime cutoff. -/ + +namespace TwoPointCorrelations + +open Finset Complex +open scoped Classical LSeries.notation + +theorem halasz_grouped_double_estimate : ∃ C B : ℝ, 0 < C ∧ 2 ≤ B ∧ + ∀ (f : ℕ → ℂ), f 1 = 1 → + (∀ m n, 0 < m → 0 < n → f (m * n) = f m * f n) → OneBounded f → + ∀ (N m : ℕ) (v T A W : ℝ), 2 ≤ N → 0 < m → m ≤ N → Real.log 2 ≤ v → + B ≤ T → 0 ≤ A → 0 ≤ W → + ∀ (P : Finset ℕ), (∀ p ∈ P, p.Prime ∧ T ^ 2 ≤ (p : ℝ) ∧ + v ≤ Real.log ((N : ℝ) / p) ∧ Real.log ((N : ℝ) / p) < 2 * v) → + (∀ t ∈ Set.Icc (-T) T, ‖LSeries (halaszSmoothFunction f N) (1 + (t : ℂ) * I)‖ ≤ A) → + (∀ t : ℝ, ‖LSeries (halaszSmoothFunction f N) (1 + (t : ℂ) * I)‖ ≤ W) → + ‖halaszGroupedDouble f N P‖ ≤ C * N * A + + C * N * v * W / (((m : ℝ) / ((N : ℝ) + 1 / 2)) * T) + + (m : ℝ) / v * Real.log (3 * N) ^ 2 := by + obtain ⟨C₀, B, hC₀, hB, htriple⟩ := halasz_prime_triple_estimate + obtain ⟨K, hK, hweights⟩ := halasz_band_mean_square_weights + let U := 1 + 2 * halaszMertensConstant / Real.log 2 + let V := 2 + halaszMertensConstant / Real.log 2 + let C := 2 * C₀ * K + 80 * U * V + have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hM := halaszMertensConstant_nonneg + have hU : 0 < U := by dsimp [U]; positivity + have hV : 0 < V := by dsimp [V]; positivity + have hC : 0 < C := by dsimp [C]; positivity + refine ⟨C, B, hC, hB, ?_⟩ + intro f hf1 hf hbound N m v T A W hN hm hmN hv hBT hA hW P hP hFA hFW + let x : ℝ := (N : ℝ) + 1 / 2 + let Q := sievePrimesUpTo (Real.exp (2 * v)) + let a := fun p : ℕ => f p / (Real.log ((N : ℝ) / p) : ℂ) + have hN0 : (0 : ℝ) < N := by exact_mod_cast (by omega : 0 < N) + have hx : 0 < x := by dsimp [x]; positivity + have hxle : x ≤ 2 * N := by + have hNr : (2 : ℝ) ≤ N := by exact_mod_cast hN + dsimp [x] + linarith + have hv0 : 0 < v := htwo.trans_le hv + have hT : 0 < T := lt_of_lt_of_le (by linarith : (0 : ℝ) < B) hBT + have hmR : (0 : ℝ) < m := by exact_mod_cast hm + have hmle : (m : ℝ) ≤ x := by + have hmr : (m : ℝ) ≤ N := by exact_mod_cast hmN + dsimp [x] + linarith + have hPl : ∀ p ∈ P, p.Prime := fun p hp => (hP p hp).1 + have hPb : ∀ p ∈ P, p.Prime ∧ v ≤ Real.log ((N : ℝ) / p) ∧ + Real.log ((N : ℝ) / p) < 2 * v := fun p hp => ⟨(hP p hp).1, (hP p hp).2.2⟩ + have hQl : ∀ q ∈ Q, q.Prime := fun q hq => sievePrimesUpTo_prime _ q hq + have hQb : ∀ q ∈ Q, q.Prime ∧ (q : ℝ) ≤ Real.exp (2 * v) := fun q hq => + ⟨hQl q hq, sievePrimesUpTo_le _ (Real.exp_pos _).le q hq⟩ + have hPsub : P ⊆ Icc 1 N := by + intro p hp + have he := (halasz_log_band_endpoints hN0 (hPl p hp) (hP p hp).2.2.1 (hP p hp).2.2.2).2 + have hdiv : (N : ℝ) / Real.exp v ≤ N := + div_le_self hN0.le (Real.one_le_exp_iff.mpr hv0.le) + exact mem_Icc.mpr ⟨(hPl p hp).pos, by exact_mod_cast he.trans hdiv⟩ + have hcover : ∀ p ∈ P, ∀ q, q.Prime → q ≤ N / p → q ∈ Q := by + intro p hp q hq hqN + have hp0 : (0 : ℝ) < p := by exact_mod_cast (hPl p hp).pos + have hcut : ((N / p : ℕ) : ℝ) ≤ (N : ℝ) / p := by + apply (le_div_iff₀ hp0).mpr + exact_mod_cast Nat.div_mul_le_self N p + have hy0 : 0 < (N : ℝ) / p := div_pos hN0 hp0 + have hupper := (Real.log_lt_iff_lt_exp hy0).mp (hP p hp).2.2.2 + have hqr : (q : ℝ) ≤ Real.exp (2 * v) := (by exact_mod_cast hqN : (q : ℝ) ≤ ((N / p : ℕ) : ℝ)).trans + (hcut.trans hupper.le) + exact mem_filter.mpr ⟨mem_Iic.mpr ((Nat.le_floor_iff (Real.exp_pos _).le).mpr hqr), hq⟩ + have ha : ∀ p ∈ P, ‖a p‖ ≤ v⁻¹ := fun p hp => + halasz_adaptive_coefficient_bound f hbound hv0 (hPl p hp).pos (hP p hp).2.2.1 + have hb : ∀ q ∈ Q, ‖f q‖ ≤ 1 := fun q hq => hbound q (hQl q hq).pos + have hestimate := htriple f hf1 hf hbound N x T A W (v⁻¹) m hx hm hmle + (modFive_half_cutoff_nonnat N) hBT hA hW (inv_nonneg.mpr hv0.le) P Q + (fun p hp => ⟨(hP p hp).1, (hP p hp).2.1⟩) hQl a f ha hb hFA hFW + have heqa : (fun p : ℕ => (Real.log (p : ℝ) : ℂ) * a p) = + fun p : ℕ => (Real.log (p : ℝ) : ℂ) * f p / (Real.log ((N : ℝ) / p) : ℂ) := by + funext p + dsimp [a] + ring + rw [show ⌊x⌋₊ = N from modFive_half_cutoff_floor N, heqa, + halasz_grouped_triple_prefix f N P Q hPsub hQl hcover] at hestimate + have hweight := hweights f hbound N v hN0 hv P Q hPb hQb + have hpMass : (∑ p ∈ P, Real.log (p : ℝ) / p) ≤ U * v := + halasz_log_band_mass_linear hN0 hv P hPb + have hqMass : (∑ q ∈ Q, Real.log (q : ℝ) / q) ≤ V * v := by + have hq := halasz_prime_set_mass_le (Y := Real.exp (2 * v)) + (Real.one_le_exp_iff.mpr (by linarith)) Q hQb + rw [Real.log_exp] at hq + have hscale := mul_le_mul_of_nonneg_left hv + (show 0 ≤ halaszMertensConstant / Real.log 2 from div_nonneg hM htwo.le) + rw [div_mul_cancel₀ _ htwo.ne'] at hscale + dsimp [V] + linarith + have hp0 : 0 ≤ ∑ p ∈ P, Real.log (p : ℝ) / p := sum_nonneg (fun p hp => + div_nonneg (Real.log_nonneg (by exact_mod_cast (hPl p hp).one_le)) (Nat.cast_nonneg _)) + have hq0 : 0 ≤ ∑ q ∈ Q, Real.log (q : ℝ) / q := sum_nonneg (fun q hq => + div_nonneg (Real.log_nonneg (by exact_mod_cast (hQl q hq).one_le)) (Nat.cast_nonneg _)) + have hsmall : v⁻¹ * (∑ p ∈ P, Real.log (p : ℝ) / p) ≤ U := by + apply (mul_le_mul_of_nonneg_left hpMass (inv_nonneg.mpr hv0.le)).trans_eq + field_simp + have hprod : (v⁻¹ * ∑ p ∈ P, Real.log (p : ℝ) / p) * + (∑ q ∈ Q, Real.log (q : ℝ) / q) ≤ U * (V * v) := + mul_le_mul hsmall hqMass hq0 hU.le + have hlog : Real.log (x + m) ^ 2 ≤ Real.log (3 * N) ^ 2 := by + have hmr : (m : ℝ) ≤ N := by exact_mod_cast hmN + have hNr : (2 : ℝ) ≤ N := by exact_mod_cast hN + apply pow_le_pow_left₀ (Real.log_nonneg (by dsimp [x]; linarith)) + exact Real.log_le_log (by positivity) (by dsimp [x]; linarith) + have hcmain : 2 * C₀ * K ≤ C := by + dsimp [C] + linarith [show 0 ≤ 80 * U * V by positivity] + have hctail : 80 * U * V ≤ C := by + dsimp [C] + linarith [show 0 ≤ 2 * C₀ * K by positivity] + change ‖halaszGroupedDouble f N P‖ ≤ _ at hestimate ⊢ + calc + _ ≤ _ := hestimate + _ ≤ (C₀ * (2 * N) * A) * K + + 40 * (2 * N) * (U * (V * v)) * W / ((m / x) * T) + + v⁻¹ * Real.log (3 * N) ^ 2 * m := by + apply add_le_add + · apply add_le_add + · calc + _ ≤ (C₀ * x * A) * K := mul_le_mul_of_nonneg_left hweight (by positivity) + _ ≤ _ := by gcongr + · calc + _ = (40 * x * W / ((m / x) * T)) * + ((v⁻¹ * ∑ p ∈ P, Real.log (p : ℝ) / p) * + (∑ q ∈ Q, Real.log (q : ℝ) / q)) := by ring + _ ≤ (40 * x * W / ((m / x) * T)) * (U * (V * v)) := + mul_le_mul_of_nonneg_left hprod (by positivity) + _ ≤ (40 * (2 * N) * W / ((m / x) * T)) * (U * (V * v)) := by + gcongr + _ = _ := by ring + · exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hlog (inv_nonneg.mpr hv0.le)) (Nat.cast_nonneg m) + _ ≤ C * N * A + C * N * v * W / ((m / x) * T) + + (m : ℝ) / v * Real.log (3 * N) ^ 2 := by + have hfirst := mul_le_mul_of_nonneg_right hcmain (show 0 ≤ (N : ℝ) * A by positivity) + have hlast := mul_le_mul_of_nonneg_right hctail + (show 0 ≤ (N : ℝ) * v * W / ((m / x) * T) by positivity) + ring_nf at hfirst hlast ⊢ + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGroupedException.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGroupedException.lean new file mode 100644 index 0000000000000000000000000000000000000000..a14319d79bdf17737e06bb39389db1d67505a7af --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszGroupedException.lean @@ -0,0 +1,157 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszGroupedBounds +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTripleException +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePsiDecay + +namespace OAI + +/-! Apply the full triple-convolution estimate to one actual logarithmic +band, with its adaptive denominator and finite cofactor prime cutoff. -/ + +namespace TwoPointCorrelations + +open Finset Complex +open scoped Classical LSeries.notation + +theorem halasz_grouped_double_exception : ∃ C B : ℝ, 0 < C ∧ 2 ≤ B ∧ + ∀ (f : ℕ → ℂ), f 1 = 1 → + (∀ m n, 0 < m → 0 < n → f (m * n) = f m * f n) → OneBounded f → + ∀ (N m : ℕ) (v T A W τ : ℝ), 2 ≤ N → 0 < m → m ≤ N → Real.log 2 ≤ v → + B ≤ T → 0 ≤ A → 0 ≤ W → + ∀ (P : Finset ℕ), (∀ p ∈ P, p.Prime ∧ T ^ 2 ≤ (p : ℝ) ∧ + v ≤ Real.log ((N : ℝ) / p) ∧ Real.log ((N : ℝ) / p) < 2 * v) → + (∀ t ∈ Set.Ioc (-T) T, t ∉ Set.Ioc (τ-1/2) (τ+1/2) → + ‖LSeries (halaszSmoothFunction f N) (1 + (t : ℂ) * I)‖ ≤ A) → + (∀ t : ℝ, ‖LSeries (halaszSmoothFunction f N) (1 + (t : ℂ) * I)‖ ≤ W) → + ‖halaszGroupedDouble f N P‖ ≤ C * N * (A+W/(1+|τ|)) + + C * N * v * W / (((m : ℝ) / ((N : ℝ) + 1 / 2)) * T) + + (m : ℝ) / v * Real.log (3 * N) ^ 2 := by + obtain ⟨C₀, B, hC₀, hB, htriple⟩ := halasz_prime_triple_exception + obtain ⟨K, hK, hweights⟩ := halasz_band_mean_square_weights + let U := 1 + 2 * halaszMertensConstant / Real.log 2 + let V := 2 + halaszMertensConstant / Real.log 2 + let C := 2 * C₀ * K + 80 * U * V + have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hM := halaszMertensConstant_nonneg + have hU : 0 < U := by dsimp [U]; positivity + have hV : 0 < V := by dsimp [V]; positivity + have hC : 0 < C := by dsimp [C]; positivity + refine ⟨C, B, hC, hB, ?_⟩ + intro f hf1 hf hbound N m v T A W τ hN hm hmN hv hBT hA hW P hP hFA hFW + let x : ℝ := (N : ℝ) + 1 / 2 + let Q := sievePrimesUpTo (Real.exp (2 * v)) + let a := fun p : ℕ => f p / (Real.log ((N : ℝ) / p) : ℂ) + have hN0 : (0 : ℝ) < N := by exact_mod_cast (by omega : 0 < N) + have hx : 0 < x := by dsimp [x]; positivity + have hxle : x ≤ 2 * N := by + have hNr : (2 : ℝ) ≤ N := by exact_mod_cast hN + dsimp [x] + linarith + have hv0 : 0 < v := htwo.trans_le hv + have hT : 0 < T := lt_of_lt_of_le (by linarith : (0 : ℝ) < B) hBT + have hmR : (0 : ℝ) < m := by exact_mod_cast hm + have hmle : (m : ℝ) ≤ x := by + have hmr : (m : ℝ) ≤ N := by exact_mod_cast hmN + dsimp [x] + linarith + have hPl : ∀ p ∈ P, p.Prime := fun p hp => (hP p hp).1 + have hPb : ∀ p ∈ P, p.Prime ∧ v ≤ Real.log ((N : ℝ) / p) ∧ + Real.log ((N : ℝ) / p) < 2 * v := fun p hp => ⟨(hP p hp).1, (hP p hp).2.2⟩ + have hQl : ∀ q ∈ Q, q.Prime := fun q hq => sievePrimesUpTo_prime _ q hq + have hQb : ∀ q ∈ Q, q.Prime ∧ (q : ℝ) ≤ Real.exp (2 * v) := fun q hq => + ⟨hQl q hq, sievePrimesUpTo_le _ (Real.exp_pos _).le q hq⟩ + have hPsub : P ⊆ Icc 1 N := by + intro p hp + have he := (halasz_log_band_endpoints hN0 (hPl p hp) (hP p hp).2.2.1 (hP p hp).2.2.2).2 + have hdiv : (N : ℝ) / Real.exp v ≤ N := + div_le_self hN0.le (Real.one_le_exp_iff.mpr hv0.le) + exact mem_Icc.mpr ⟨(hPl p hp).pos, by exact_mod_cast he.trans hdiv⟩ + have hcover : ∀ p ∈ P, ∀ q, q.Prime → q ≤ N / p → q ∈ Q := by + intro p hp q hq hqN + have hp0 : (0 : ℝ) < p := by exact_mod_cast (hPl p hp).pos + have hcut : ((N / p : ℕ) : ℝ) ≤ (N : ℝ) / p := by + apply (le_div_iff₀ hp0).mpr + exact_mod_cast Nat.div_mul_le_self N p + have hy0 : 0 < (N : ℝ) / p := div_pos hN0 hp0 + have hupper := (Real.log_lt_iff_lt_exp hy0).mp (hP p hp).2.2.2 + have hqr : (q : ℝ) ≤ Real.exp (2 * v) := (by exact_mod_cast hqN : (q : ℝ) ≤ ((N / p : ℕ) : ℝ)).trans + (hcut.trans hupper.le) + exact mem_filter.mpr ⟨mem_Iic.mpr ((Nat.le_floor_iff (Real.exp_pos _).le).mpr hqr), hq⟩ + have ha : ∀ p ∈ P, ‖a p‖ ≤ v⁻¹ := fun p hp => + halasz_adaptive_coefficient_bound f hbound hv0 (hPl p hp).pos (hP p hp).2.2.1 + have hb : ∀ q ∈ Q, ‖f q‖ ≤ 1 := fun q hq => hbound q (hQl q hq).pos + have hestimate := htriple f hf1 hf hbound N x T A W τ (v⁻¹) m hx hm hmle + (modFive_half_cutoff_nonnat N) hBT hA hW (inv_nonneg.mpr hv0.le) P Q + (fun p hp => ⟨(hP p hp).1, (hP p hp).2.1⟩) hQl a f ha hb hFA hFW + have heqa : (fun p : ℕ => (Real.log (p : ℝ) : ℂ) * a p) = + fun p : ℕ => (Real.log (p : ℝ) : ℂ) * f p / (Real.log ((N : ℝ) / p) : ℂ) := by + funext p + dsimp [a] + ring + rw [show ⌊x⌋₊ = N from modFive_half_cutoff_floor N, heqa, + halasz_grouped_triple_prefix f N P Q hPsub hQl hcover] at hestimate + have hweight := hweights f hbound N v hN0 hv P Q hPb hQb + have hpMass : (∑ p ∈ P, Real.log (p : ℝ) / p) ≤ U * v := + halasz_log_band_mass_linear hN0 hv P hPb + have hqMass : (∑ q ∈ Q, Real.log (q : ℝ) / q) ≤ V * v := by + have hq := halasz_prime_set_mass_le (Y := Real.exp (2 * v)) + (Real.one_le_exp_iff.mpr (by linarith)) Q hQb + rw [Real.log_exp] at hq + have hscale := mul_le_mul_of_nonneg_left hv + (show 0 ≤ halaszMertensConstant / Real.log 2 from div_nonneg hM htwo.le) + rw [div_mul_cancel₀ _ htwo.ne'] at hscale + dsimp [V] + linarith + have hp0 : 0 ≤ ∑ p ∈ P, Real.log (p : ℝ) / p := sum_nonneg (fun p hp => + div_nonneg (Real.log_nonneg (by exact_mod_cast (hPl p hp).one_le)) (Nat.cast_nonneg _)) + have hq0 : 0 ≤ ∑ q ∈ Q, Real.log (q : ℝ) / q := sum_nonneg (fun q hq => + div_nonneg (Real.log_nonneg (by exact_mod_cast (hQl q hq).one_le)) (Nat.cast_nonneg _)) + have hsmall : v⁻¹ * (∑ p ∈ P, Real.log (p : ℝ) / p) ≤ U := by + apply (mul_le_mul_of_nonneg_left hpMass (inv_nonneg.mpr hv0.le)).trans_eq + field_simp + have hprod : (v⁻¹ * ∑ p ∈ P, Real.log (p : ℝ) / p) * + (∑ q ∈ Q, Real.log (q : ℝ) / q) ≤ U * (V * v) := + mul_le_mul hsmall hqMass hq0 hU.le + have hlog : Real.log (x + m) ^ 2 ≤ Real.log (3 * N) ^ 2 := by + have hmr : (m : ℝ) ≤ N := by exact_mod_cast hmN + have hNr : (2 : ℝ) ≤ N := by exact_mod_cast hN + apply pow_le_pow_left₀ (Real.log_nonneg (by dsimp [x]; linarith)) + exact Real.log_le_log (by positivity) (by dsimp [x]; linarith) + have hcmain : 2 * C₀ * K ≤ C := by + dsimp [C] + linarith [show 0 ≤ 80 * U * V by positivity] + have hctail : 80 * U * V ≤ C := by + dsimp [C] + linarith [show 0 ≤ 2 * C₀ * K by positivity] + change ‖halaszGroupedDouble f N P‖ ≤ _ at hestimate ⊢ + calc + _ ≤ _ := hestimate + _ ≤ (C₀ * (2 * N) * (A+W/(1+|τ|))) * K + + 40 * (2 * N) * (U * (V * v)) * W / ((m / x) * T) + + v⁻¹ * Real.log (3 * N) ^ 2 * m := by + apply add_le_add + · apply add_le_add + · calc + _ ≤ (C₀ * x * (A+W/(1+|τ|))) * K := mul_le_mul_of_nonneg_left hweight (by positivity) + _ ≤ _ := by gcongr + · calc + _ = (40 * x * W / ((m / x) * T)) * + ((v⁻¹ * ∑ p ∈ P, Real.log (p : ℝ) / p) * + (∑ q ∈ Q, Real.log (q : ℝ) / q)) := by ring + _ ≤ (40 * x * W / ((m / x) * T)) * (U * (V * v)) := + mul_le_mul_of_nonneg_left hprod (by positivity) + _ ≤ (40 * (2 * N) * W / ((m / x) * T)) * (U * (V * v)) := by + gcongr + _ = _ := by ring + · exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hlog (inv_nonneg.mpr hv0.le)) (Nat.cast_nonneg m) + _ ≤ C * N * (A+W/(1+|τ|)) + C * N * v * W / ((m / x) * T) + + (m : ℝ) / v * Real.log (3 * N) ^ 2 := by + have hfirst := mul_le_mul_of_nonneg_right hcmain (show 0 ≤ (N : ℝ) * (A+W/(1+|τ|)) by positivity) + have hlast := mul_le_mul_of_nonneg_right hctail + (show 0 ≤ (N : ℝ) * v * W / ((m / x) * T) by positivity) + ring_nf at hfirst hlast ⊢ + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHighPrimeInput.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHighPrimeInput.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7cb73a7e747ccda70fdf92819cc641499f61f4a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHighPrimeInput.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszModerateCofactor + +namespace OAI + +/-! The high-frequency part of the published prime-repulsion argument. +The explicit input is the weaker constant 1/10 in (A.5)--(A.6) of +Matomäki--Radziwiłł--Tao, *An averaged form of Chowla's conjecture*, +arXiv:1503.05121v3, proof of Lemma A.4(ii), with the quantitative +Vinogradov--Korobov estimate supplying prime-phase cancellation. -/ +namespace TwoPointCorrelations + +open Filter Finset + +def HalaszHighPrimeInput : Prop := + ∀ᶠ X : ℕ in atTop, ∀ u : ℝ, (Real.log X)^20 ≤ |u| → |u| ≤ 2*X → + (1/10:ℝ)*Real.log (Real.log X) ≤ + ∑ p ∈ primesUpTo X, (1-|Real.cos (u*Real.log (p:ℝ)/2)|)/(p:ℝ) + +theorem HalaszHighPrimeInput.distance_off_unit (hhigh : HalaszHighPrimeInput) : + ∀ᶠ X : ℕ in atTop, ∀ (F : ℕ → ℂ), OneBounded F → + ∀ v τ : ℝ, |v| ≤ X → |τ| ≤ X → 1/2 ≤ |v-τ| → + squaredDistance F (mrtArchimedeanTwist τ) X ≤ + squaredDistance F (mrtArchimedeanTwist v) X → + (31/500:ℝ)*Real.log (Real.log X) ≤ + squaredDistance F (mrtArchimedeanTwist v) X := by + have hlog : Tendsto (fun X:ℕ => Real.log X) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + filter_upwards [hhigh,halasz_moderate_distance_unit, + hlog.eventually (eventually_ge_atTop (1:ℝ))] with X hhigh hmoderate hlogX + intro F hF v τ hv hτ hsep hmin + by_cases hu : |v-τ| ≤ (Real.log X)^20 + · have hh := hmoderate F hF ∅ v τ hsep hu hmin + have he : mrtMissingCoefficient F ∅ = F := by + funext n + simp [mrtMissingCoefficient,mrtPrimeMask,mrtPrimeAvoids] + simpa only [he] using hh + · have hupper : |v-τ| ≤ 2*X := by + have hh := abs_sub v τ + linarith + have hh := hhigh (v-τ) (le_of_not_ge hu) hupper + have hd := halasz_distance_from_minimizer F hF X v τ hmin + have hll : 0 ≤ Real.log (Real.log X) := Real.log_nonneg hlogX + linarith + +theorem HalaszHighPrimeInput.distance_cutoff (hhigh : HalaszHighPrimeInput) (K : ℝ) : + ∀ᶠ n : ℕ in atTop, ∀ X : ℕ, n ≤ X → X ≤ n^3 → + ∀ (F : ℕ → ℂ), OneBounded F → ∀ v τ : ℝ, + |v| ≤ X → |τ| ≤ X → 1/2 ≤ |v-τ| → + squaredDistance F (mrtArchimedeanTwist τ) X ≤ + squaredDistance F (mrtArchimedeanTwist v) X → + 2*((3/100:ℝ)*Real.log (Real.log n))+K ≤ + squaredDistance F (mrtArchimedeanTwist v) n := by + obtain ⟨K₀,hK₀,hcut⟩ := halasz_distance_cutoff_loss + obtain ⟨n₀,hn₀⟩ := eventually_atTop.mp hhigh.distance_off_unit + have hll := (Real.tendsto_log_atTop.comp + (Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop)).eventually + (eventually_ge_atTop (500*(K+K₀))) + filter_upwards [eventually_ge_atTop n₀,eventually_ge_atTop 2,hll] + with n hn hn2 hlln + intro X hnX hX F hF v τ hv hτ hsep hmin + have hrep := hn₀ X (hn.trans hnX) F hF v τ hv hτ hsep hmin + have hlogn : 0 < Real.log (n:ℝ) := + Real.log_pos (by exact_mod_cast (show 1 Real.log X) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + have hll := (Real.tendsto_log_atTop.comp hlog).eventually + (eventually_ge_atTop (10240*((81/256)*C+(95/256)*K))) + filter_upwards [hphase,hll,hlog.eventually (eventually_ge_atTop (1:ℝ))] + with X hp hlarge hL + intro u hu hux + let P := mrtPrimePowerTail (27/40) X + have hs : (13/40:ℝ)*Real.log (Real.log X)-C ≤ ∑ p ∈ P, 1/(p:ℝ) := by + simpa only [show (1:ℝ)-27/40=13/40 by norm_num] using + hmass (27/40) (by norm_num) (by norm_num) X hL + have hsum (k : ℕ) (hk : 1 ≤ k) (hk3 : k ≤ 3) : + |∑ p ∈ P, (1/(p:ℝ))*Real.cos ((k:ℝ)*(u*Real.log (p:ℝ)))| ≤ K := by + simpa only [P,div_eq_mul_inv,one_mul,mul_assoc,mul_comm,mul_left_comm] using + hp u hu hux k hk hk3 + have h₁ := hsum 1 (by omega) (by omega) + simp only [Nat.cast_one,one_mul] at h₁ + have h₂ := hsum 2 (by omega) (by omega) + have h₃ := hsum 3 (by omega) (by omega) + norm_num only [Nat.cast_ofNat] at h₂ h₃ + have hrep := halasz_weighted_cosine_repulsion P (fun p => 1/(p:ℝ)) + (fun p => u*Real.log (p:ℝ)) (fun p _ => by positivity) K h₁ h₂ h₃ + have hsub : P ⊆ primesUpTo X := by + intro p hp + have hh : p ∈ sievePrimesUpTo (X:ℝ) := (mem_sdiff.mp hp).1 + rwa [mrt_sievePrimesUpTo_nat] at hh + have hfull : (∑ p ∈ P, (1/(p:ℝ))*(1-|Real.cos (u*Real.log (p:ℝ)/2)|)) ≤ + ∑ p ∈ primesUpTo X, (1-|Real.cos (u*Real.log (p:ℝ)/2)|)/(p:ℝ) := by + have hh := sum_le_sum_of_subset_of_nonneg + (f := fun p : ℕ => (1/(p:ℝ))*(1-|Real.cos (u*Real.log (p:ℝ)/2)|)) + hsub (fun p _ _ => mul_nonneg (by positivity) + (sub_nonneg.mpr (Real.abs_cos_le_one _))) + simpa only [div_eq_mul_inv,one_mul,mul_one,mul_comm] using hh + apply le_trans _ hfull + dsimp only [Function.comp_def] at hlarge + have hll0 : 0 ≤ Real.log (Real.log (X:ℝ)) := Real.log_nonneg hL + linarith only [hs,hrep,hlarge,hll0] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHolderPowers.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHolderPowers.lean new file mode 100644 index 0000000000000000000000000000000000000000..2abfd79da90462957e430bf0f2c5cb5fb2947e50 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHolderPowers.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMomentInterpolation + +namespace OAI + +/-! Integer-power forms of the moment interpolation inequalities. +They avoid fractional powers in the final collision-absorption step. -/ +namespace TwoPointCorrelations + +open MeasureTheory + +theorem halasz_holder_integer_power {d k : ℕ} (hk : 2≤k) + (A B : (Fin d → AddCircle (1:ℝ)) → ℝ) + (hA : Continuous A) (hB : Continuous B) + (hA0 : ∀ x, 0≤A x) (hB0 : ∀ x, 0≤B x) : + (∫ x, (A x)^(1-1/(k:ℝ))*(B x)^(1/(k:ℝ)) ∂halaszVinogradovHaar d)^k ≤ + (∫ x, A x ∂halaszVinogradovHaar d)^(k-1) * + (∫ x, B x ∂halaszVinogradovHaar d) := by + have hk0 : (0:ℝ) + mul_nonneg (Real.rpow_nonneg (hA0 x) _) (Real.rpow_nonneg (hB0 x) _)) + have hAI : 0≤∫ x, A x ∂halaszVinogradovHaar d := integral_nonneg hA0 + have hBI : 0≤∫ x, B x ∂halaszVinogradovHaar d := integral_nonneg hB0 + have hexp : (1-1/(k:ℝ))*(k:ℝ)=((k-1:ℕ):ℝ) := by + rw [Nat.cast_sub (by omega : 1≤k)] + push_cast + field_simp + have hpow := pow_le_pow_left₀ hI h k + rw [mul_pow,← Real.rpow_mul_natCast hAI,← Real.rpow_mul_natCast hBI, + hexp,one_div_mul_cancel hk0.ne',Real.rpow_natCast,Real.rpow_one] at hpow + exact hpow + +lemma halasz_collision_power_absorb {k : ℕ} (hk : 1≤k) + {A B C : ℝ} (hA : 0 if a=0 then 0 else (a:ℂ)^(-z)) s + by_cases ha : a=0 + · simp only [ite_eq_left ha] + exact differentiableAt_const (c := (0:ℂ)) + · simp only [ite_eq_right ha] + exact differentiableAt_id.neg.const_cpow (Or.inl (Complex.ofReal_ne_zero.mpr ha)) + +lemma halasz_hurwitz_difference_series_convergent {a : ℝ} + (ha : a∈Set.Icc (0:ℝ) 1) {s : ℂ} (hs : 1 1/((n:ℝ)+a:ℂ)^s + have hf := hasSum_hurwitzZeta_of_one_lt_re ha hs + have hf' : Summable f := hf.summable + have hshift : Summable (fun n => f (n+1)) := hf'.comp_injective Nat.succ_injective + have hzero : f 0=mrtHurwitzFirstTerm a s := by + by_cases ha0 : a=0 + · simp [f,mrtHurwitzFirstTerm,ha0,zero_cpow (ne_zero_of_one_lt_re hs)] + · simp [f,mrtHurwitzFirstTerm,ha0,cpow_neg] + have htail : (∑' n,f (n+1))=hurwitzZeta (a:UnitAddCircle) s-mrtHurwitzFirstTerm a s := by + have hEq := hf'.tsum_eq_zero_add + have ht := hf.tsum_eq + change (∑' n,f n)=_ at ht + rw [ht,hzero] at hEq + linear_combination -hEq + have hg : Summable (fun n : ℕ => 1/((n+1:ℕ):ℂ)^s) := + (Complex.summable_one_div_nat_cpow.mpr hs).comp_injective Nat.succ_injective + have hzt : (∑' n : ℕ,1/((n+1:ℕ):ℂ)^s)=riemannZeta s := by + simpa only [Nat.cast_add,Nat.cast_one] using + (zeta_eq_tsum_one_div_nat_add_one_cpow hs).symm + calc + _ = (∑' n,f (n+1))-(∑' n : ℕ,1/((n+1:ℕ):ℂ)^s) := by + rw [← Summable.tsum_sub hshift hg] + apply tsum_congr + intro n + simp only [halaszHurwitzDifference,f,one_div,cpow_neg] + _ = _ := by rw [htail,hzt]; ring + +theorem halasz_hurwitz_difference_series {a : ℝ} + (ha : a∈Set.Icc (0:ℝ) 1) {s : ℂ} (hs : 0 + hurwitzZeta (a:UnitAddCircle) z-riemannZeta z-mrtHurwitzFirstTerm a z + let G : ℂ → ℂ := fun z => ∑' n,halaszHurwitzDifference a n z + have ho : IsOpen U := isOpen_lt continuous_const Complex.continuous_re + have hc : Convex ℝ U := (convex_Ioi (0:ℝ)).linear_preimage Complex.reLm + have hd : Differentiable ℂ F := by + intro z + dsimp only [F] + rw [← hurwitzZeta_zero] + exact ((differentiable_hurwitzZeta_sub_hurwitzZeta (a:UnitAddCircle) 0) z).sub + (halasz_hurwitz_first_term_differentiable a z) + have hF : AnalyticOnNhd ℂ F U := hd.differentiableOn.analyticOnNhd ho + have hG : AnalyticOnNhd ℂ G U := by + apply DifferentiableOn.analyticOnNhd _ ho + intro z hz + exact (halasz_hurwitz_difference_tsum_differentiableAt ha hz).differentiableWithinAt + have heq : F=ᶠ[𝓝 (2:ℂ)] G := by + filter_upwards [(isOpen_lt continuous_const Complex.continuous_re).mem_nhds + (show 1<(2:ℂ).re by norm_num)] with z hz + exact (halasz_hurwitz_difference_series_convergent ha hz).symm + exact (hF.eqOn_of_preconnected_of_eventuallyEq hG hc.isPreconnected + (show (2:ℂ)∈U by change 0<(2:ℂ).re; norm_num) heq hs).symm + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHurwitzCutoff.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHurwitzCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..8fea73c9291ecd96af1b1cc37385e0766354d7d9 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHurwitzCutoff.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszHurwitzTail +import PrimeNumberTheoremAnd.Erdos970.ZetaBounds + +namespace OAI + +/-! First-order Euler truncation for the actual Hurwitz function, uniform +in the shift after its first term is removed. -/ +namespace TwoPointCorrelations + +open Complex HurwitzZeta MeasureTheory Finset Erdos970 + +lemma halasz_zeta_cutoff {s : ℂ} (hs : 0 by subst s; simp at hs + have hsum : (∑ n∈range (N+1),1/(n:ℂ)^s)= + ∑ n∈range N,((n+1:ℕ):ℂ)^(-s) := by + rw [sum_range_succ'] + simp only [Nat.cast_zero,zero_cpow hs0,div_zero,add_zero,one_div,cpow_neg] + have hint : ‖s*∫ x in Set.Ioi (N:ℝ),(⌊x⌋+1/2-x)/(x:ℂ)^(s+1)‖≤ + ‖s‖*(N:ℝ)^(-s.re)/s.re := by + have hi := ZetaBnd_aux1b N hN hs (t := s.im) + rw [s.re_add_im] at hi + rw [norm_mul] + simpa only [mul_div_assoc] using mul_le_mul_of_nonneg_left hi (norm_nonneg s) + have hpower : ‖(-(N:ℂ)^(1-s))/(1-s)‖=(N:ℝ)^(1-s.re)/‖1-s‖ := by + rw [norm_div,norm_neg] + congr 1 + simpa only [Complex.sub_re,Complex.one_re,Complex.ofReal_natCast] using + Complex.norm_cpow_eq_rpow_re_of_pos hNR (1-s) + have hhalf : ‖(-(N:ℂ)^(-s))/2‖=(N:ℝ)^(-s.re)/2 := by + rw [norm_div,norm_neg] + simp only [Complex.norm_ofNat] + congr 1 + simpa only [Complex.neg_re,Complex.ofReal_natCast] using Complex.norm_cpow_eq_rpow_re_of_pos hNR (-s) + rw [← Zeta0EqZeta hN0 hs hs1,riemannZeta0,hsum] + have heq : ((∑ n∈range N,((n+1:ℕ):ℂ)^(-s))+ + (-(N:ℂ)^(1-s))/(1-s)+(-(N:ℂ)^(-s))/2+ + s*∫ x in Set.Ioi (N:ℝ),(⌊x⌋+1/2-x)/(x:ℂ)^(s+1))- + (∑ n∈range N,((n+1:ℕ):ℂ)^(-s)) = + ((-(N:ℂ)^(1-s))/(1-s)+(-(N:ℂ)^(-s))/2)+ + s*∫ x in Set.Ioi (N:ℝ),(⌊x⌋+1/2-x)/(x:ℂ)^(s+1) := by ring + rw [heq] + exact (norm_add_le _ _).trans (add_le_add + ((norm_add_le _ _).trans_eq (by rw [hpower,hhalf])) hint) + +theorem halasz_hurwitz_cutoff {a : ℝ} (ha : a∈Set.Icc (0:ℝ) 1) + {s : ℂ} (hs : 0 by subst s; simp at hs) + have hh := norm_image_sub_le_of_norm_deriv_le_segment' + (f := fun y : ℝ => (y:ℂ)^(-s)) + (f' := fun y => -s*(y:ℂ)^(-s-1)) (a := x) (b := x+a) + (C := ‖s‖*x^(-(s.re+1))) + (fun y hy => (hasDerivAt_ofReal_cpow_const (by linarith [hy.1]) hs0).hasDerivWithinAt) + (fun y hy => by + rw [norm_mul,norm_neg,Complex.norm_cpow_eq_rpow_re_of_pos (by linarith [hy.1])] + simp only [Complex.sub_re,Complex.neg_re,Complex.one_re] + apply mul_le_mul_of_nonneg_left _ (norm_nonneg s) + rw [show -s.re-1= -(s.re+1) by ring] + exact Real.rpow_le_rpow_of_nonpos hx hy.1 (by linarith)) + (x+a) (by constructor <;> linarith) + simpa only [add_sub_cancel_left] using hh + +lemma halasz_hurwitz_difference_norm {a : ℝ} (ha : a∈Set.Icc (0:ℝ) 1) + (n : ℕ) {s : ℂ} (hs : 0 halaszHurwitzDifference a n s) := by + have hp : Summable (fun n : ℕ => ((n+1:ℕ):ℝ)^(-(s.re+1))) := + (Real.summable_nat_rpow.mpr (by linarith)).comp_injective Nat.succ_injective + exact (hp.mul_left ‖s‖).of_norm_bounded (halasz_hurwitz_difference_norm ha · hs) + +lemma halasz_hurwitz_difference_differentiable {a : ℝ} (ha : 0≤a) (n : ℕ) : + Differentiable ℂ (halaszHurwitzDifference a n) := by + have hn : ((n+1:ℕ):ℂ)≠0 := by exact_mod_cast (show n+1≠0 by omega) + have hna : ((((n+1:ℕ):ℝ)+a):ℂ)≠0 := by + exact_mod_cast (show (((n+1:ℕ):ℝ)+a)≠0 from (by positivity)) + exact (differentiable_id.neg.const_cpow (Or.inl hna)).sub + (differentiable_id.neg.const_cpow (Or.inl hn)) + +lemma halasz_hurwitz_difference_tsum_differentiableAt {a : ℝ} + (ha : a∈Set.Icc (0:ℝ) 1) {s : ℂ} (hs : 0 ∑' n,halaszHurwitzDifference a n z) s := by + let V := Metric.ball s (s.re/2) + have hp : Summable (fun n : ℕ => (‖s‖+s.re/2)*((n+1:ℕ):ℝ)^(-(s.re/2+1))) := + ((Real.summable_nat_rpow.mpr (by linarith : -(s.re/2+1)< -1)).comp_injective + Nat.succ_injective).mul_left _ + have hb : ∀ n z,z∈V → ‖halaszHurwitzDifference a n z‖≤ + (‖s‖+s.re/2)*((n+1:ℕ):ℝ)^(-(s.re/2+1)) := by + intro n z hz + have hdist : ‖z-s‖ (halasz_hurwitz_difference_differentiable ha.1 n).differentiableOn) + Metric.isOpen_ball hb).differentiableAt + (Metric.isOpen_ball.mem_nhds (Metric.mem_ball_self (half_pos hs))) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHurwitzGrowth.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHurwitzGrowth.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d7aaf0a7001c66a6cec19d8f16090c11efbb36f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHurwitzGrowth.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDyadicDirichlet +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDyadicCutoff +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCutoffRemainder + +namespace OAI + +/-! Polynomial logarithmic growth of the actual Hurwitz function in a +weak Vinogradov--Korobov strip, uniform in the translation parameter. -/ +namespace TwoPointCorrelations + +open Complex HurwitzZeta Finset + +theorem halasz_hurwitz_growth : ∃ A : ℝ, 1≤ A ∧ ∀ L : ℝ, 100≤ L → + ∀ a∈Set.Icc (0:ℝ) 1, ∀ s : ℂ, 2/3≤ s.re → s.re≤2 → + |s.im|=Real.exp L → max (1-s.re) 0≤4*L^(-(2/3:ℝ)) → + ‖hurwitzZeta (a:UnitAddCircle) s-mrtHurwitzFirstTerm a s‖≤ A*(L+1)^7 := by + obtain ⟨C,hC,hpoly⟩ := halasz_dyadic_dirichlet + refine ⟨7*C+15,by linarith,?_⟩ + intro L hL a ha s hσ hσhi ht hδ + let K := halaszDyadicCutoffDegree L + let N := 2^K-1 + obtain ⟨hN,hKL,hKhi,hNlo,hNhi⟩ := halasz_dyadic_cutoff_bounds hL + have hσ0 : 0 ((n+N+1:ℕ):ℝ)^(-(s.re+1))) := + (Real.summable_nat_rpow.mpr he).comp_injective (fun _ _ h => by omega) + have hanti : AntitoneOn (fun x : ℝ => x^(-(s.re+1))) (Set.Ici (N:ℝ)) := by + intro x hx y _ hxy + exact Real.rpow_le_rpow_of_nonpos (lt_of_lt_of_le hN0 hx) hxy (by linarith) + have ht := hanti.tsum_comp_add_le_integral N + (integrableOn_Ioi_rpow_of_lt he hN0) + (fun x hx => Real.rpow_nonneg (le_of_lt (lt_trans hN0 hx)) _) + have hi : (∫ x in Set.Ioi (N:ℝ),x^(-(s.re+1)))=(N:ℝ)^(-s.re)/s.re := by + rw [integral_Ioi_rpow_of_lt he hN0] + rw [show -(s.re+1)+1= -s.re by ring] + exact neg_div_neg_eq _ _ + calc + _ ≤ ∑' n : ℕ,‖s‖*((n+N+1:ℕ):ℝ)^(-(s.re+1)) := + tsum_of_norm_bounded (hp.mul_left ‖s‖).hasSum + (fun n => halasz_hurwitz_difference_norm ha (n+N) hs) + _ = ‖s‖*(∑' n : ℕ,((n+N+1:ℕ):ℝ)^(-(s.re+1))) := tsum_mul_left + _ ≤ ‖s‖*((N:ℝ)^(-s.re)/s.re) := + mul_le_mul_of_nonneg_left (ht.trans_eq hi) (norm_nonneg s) + _ = _ := by ring + +/-- Transfer any unshifted zeta truncation bound to a uniform Hurwitz +truncation bound. The additional error has the same decay as Euler's +first-order remainder. -/ +theorem halasz_hurwitz_cutoff_transfer {a : ℝ} (ha : a∈Set.Icc (0:ℝ) 1) + {s : ℂ} (hs : 0 p.1 * p.2 ≤ N) + +theorem halasz_sum_divisorsAntidiagonal (F : ℕ → ℕ → ℂ) (N : ℕ) : + (∑ n ∈ Icc 1 N, ∑ p ∈ n.divisorsAntidiagonal, F p.1 p.2) = + ∑ p ∈ halaszHyperbola N, F p.1 p.2 := by + rw [sum_sigma' (Icc 1 N) (fun n => n.divisorsAntidiagonal) (fun _ p => F p.1 p.2)] + apply sum_bij (fun x _ => x.2) + · intro x hx + obtain ⟨hn, hp⟩ := mem_sigma.mp hx + obtain ⟨hmul, hn0⟩ := Nat.mem_divisorsAntidiagonal.mp hp + have hpos : 0 < x.2.1 * x.2.2 := by rw [hmul]; exact (mem_Icc.mp hn).1 + have h₁ : 1 ≤ x.2.1 := Nat.pos_of_mul_pos_right hpos + have h₂ : 1 ≤ x.2.2 := Nat.pos_of_mul_pos_left hpos + apply mem_filter.mpr + refine ⟨mem_product.mpr ⟨mem_Icc.mpr ⟨h₁, ?_⟩, mem_Icc.mpr ⟨h₂, ?_⟩⟩, ?_⟩ + · calc + _ ≤ x.2.1 * x.2.2 := Nat.le_mul_of_pos_right _ h₂ + _ = x.1 := hmul + _ ≤ N := (mem_Icc.mp hn).2 + · calc + _ ≤ x.2.1 * x.2.2 := Nat.le_mul_of_pos_left _ h₁ + _ = x.1 := hmul + _ ≤ N := (mem_Icc.mp hn).2 + · exact hmul ▸ (mem_Icc.mp hn).2 + · intro x hx y hy hxy + obtain ⟨_, hpx⟩ := mem_sigma.mp hx + obtain ⟨_, hpy⟩ := mem_sigma.mp hy + have hxprod := (Nat.mem_divisorsAntidiagonal.mp hpx).1 + have hyprod := (Nat.mem_divisorsAntidiagonal.mp hpy).1 + have hn : x.1 = y.1 := by rw [← hxprod, ← hyprod, hxy] + cases x + cases y + simp_all + · intro p hp + obtain ⟨hp, hprod⟩ := mem_filter.mp hp + obtain ⟨h₁, h₂⟩ := mem_product.mp hp + have hpos : 0 < p.1 * p.2 := Nat.mul_pos (mem_Icc.mp h₁).1 (mem_Icc.mp h₂).1 + refine ⟨⟨p.1 * p.2, p⟩, mem_sigma.mpr ⟨mem_Icc.mpr ⟨hpos, hprod⟩, + Nat.mem_divisorsAntidiagonal.mpr ⟨rfl, Nat.ne_of_gt hpos⟩⟩, rfl⟩ + · intro x _ + rfl + +theorem halasz_logarithmic_sum (f : ℕ → ℂ) + (hf : ∀ m n : ℕ, 0 < m → 0 < n → f (m * n) = f m * f n) (N : ℕ) : + (∑ n ∈ Icc 1 N, f n * (Real.log (n : ℝ) : ℂ)) = + ∑ p ∈ halaszHyperbola N, + (ArithmeticFunction.vonMangoldt p.1 : ℂ) * f p.1 * f p.2 := by + calc + _ = ∑ n ∈ Icc 1 N, ∑ p ∈ n.divisorsAntidiagonal, + (ArithmeticFunction.vonMangoldt p.1 : ℂ) * f p.1 * f p.2 := by + apply sum_congr rfl + intro n _ + rw [Nat.sum_divisorsAntidiagonal (fun a b => + (ArithmeticFunction.vonMangoldt a : ℂ) * f a * f b)] + exact halasz_logarithmic_convolution f hf n + _ = _ := halasz_sum_divisorsAntidiagonal + (fun a b => (ArithmeticFunction.vonMangoldt a : ℂ) * f a * f b) N + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHyperbolaRows.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHyperbolaRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8f124b0860a811be0b6a948163d6d8c96b9dd45 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszHyperbolaRows.lean @@ -0,0 +1,36 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszHyperbola +import Mathlib.Algebra.BigOperators.Group.Finset.Sigma + +namespace OAI + +/-! Row decomposition of the finite positive hyperbola. -/ + +namespace TwoPointCorrelations + +open Finset + +theorem halasz_hyperbola_rows (F : ℕ → ℕ → ℂ) (N : ℕ) : + (∑ p ∈ halaszHyperbola N, F p.1 p.2) = + ∑ d ∈ Icc 1 N, ∑ m ∈ Icc 1 (N / d), F d m := by + classical + simp only [halaszHyperbola, sum_filter, Finset.product_eq_sprod] + rw [sum_product (Icc 1 N) (Icc 1 N) + (fun p : ℕ × ℕ => if p.1 * p.2 ≤ N then F p.1 p.2 else 0)] + apply sum_congr rfl + intro d hd + rw [← sum_filter] + apply sum_congr ?_ (fun _ _ => rfl) + ext m + have hdpos := (mem_Icc.mp hd).1 + simp only [mem_filter, mem_Icc] + constructor + · rintro ⟨⟨hm, _⟩, hprod⟩ + refine ⟨hm, (Nat.le_div_iff_mul_le hdpos).mpr ?_⟩ + simpa only [Nat.mul_comm] using hprod + · rintro ⟨hm, hquot⟩ + refine ⟨⟨hm, hquot.trans (Nat.div_le_self N d)⟩, ?_⟩ + simpa only [Nat.mul_comm] using (Nat.le_div_iff_mul_le hdpos).mp hquot + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszInnerApproximation.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszInnerApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..01973dc46f2688f70cc84af3870741e3aa8afc01 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszInnerApproximation.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimeConvolution + +namespace OAI + +/-! A complex-valued approximation, not just a norm bound, permits a second +application of the prime convolution inside the first one. -/ + +namespace TwoPointCorrelations + +open Finset + +lemma halasz_prime_log_approximation (f : ℕ → ℂ) (hf : OneBounded f) + (hmul : ∀ m n : ℕ, 0 < m → 0 < n → f (m * n) = f m * f n) + (M : ℕ) (hM : 1 ≤ M) : + ‖(∑ n ∈ Icc 1 M, f n) * (Real.log (M : ℝ) : ℂ) - + halaszPrimeConvolution f M‖ ≤ (halaszPrimePowerConstant + 1) * (M : ℝ) := by + have he := halasz_logarithmic_sum_error f hf M hM + have hp := halasz_log_sum_prime_error f hf hmul M + have ht := norm_add_le + ((∑ n ∈ Icc 1 M, f n) * (Real.log (M : ℝ) : ℂ) - + ∑ n ∈ Icc 1 M, f n * (Real.log (n : ℝ) : ℂ)) + ((∑ n ∈ Icc 1 M, f n * (Real.log (n : ℝ) : ℂ)) - + halaszPrimeConvolution f M) + rw [sub_add_sub_cancel] at ht + linarith + +lemma halasz_prime_inner_approximation (f : ℕ → ℂ) (hf : OneBounded f) + (hmul : ∀ m n : ℕ, 0 < m → 0 < n → f (m * n) = f m * f n) + (M : ℕ) (hM : 2 ≤ M) : + ‖(∑ n ∈ Icc 1 M, f n) - halaszPrimeConvolution f M / (Real.log (M : ℝ) : ℂ)‖ ≤ + (halaszPrimePowerConstant + 1) * (M : ℝ) / Real.log (M : ℝ) := by + have hlog : 0 < Real.log (M : ℝ) := Real.log_pos (by exact_mod_cast hM) + have hc : (Real.log (M : ℝ) : ℂ) ≠ 0 := by exact_mod_cast ne_of_gt hlog + have he : (∑ n ∈ Icc 1 M, f n) - + halaszPrimeConvolution f M / (Real.log (M : ℝ) : ℂ) = + ((∑ n ∈ Icc 1 M, f n) * (Real.log (M : ℝ) : ℂ) - + halaszPrimeConvolution f M) / (Real.log (M : ℝ) : ℂ) := by + field_simp + rw [he, norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hlog] + exact div_le_div_of_nonneg_right (halasz_prime_log_approximation f hf hmul M (by omega)) + (le_of_lt hlog) + +noncomputable def halaszInnerErrorConstant : ℝ := + halaszPrimePowerConstant + 1 + Real.log 2 + +lemma halaszInnerErrorConstant_nonneg : 0 ≤ halaszInnerErrorConstant := by + unfold halaszInnerErrorConstant + have hC := halaszPrimePowerConstant_nonneg + have h2 : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) + linarith + +/-- The logarithm may use the real cutoff, while the sum and convolution +retain the exact natural cutoff. Their rounding error is uniformly O(x). -/ +lemma halasz_real_log_approximation (f : ℕ → ℂ) (hf : OneBounded f) + (hmul : ∀ m n : ℕ, 0 < m → 0 < n → f (m * n) = f m * f n) + (M : ℕ) (hM : 1 ≤ M) {x : ℝ} (hMx : (M : ℝ) ≤ x) (hxM : x ≤ 2 * M) : + ‖(∑ n ∈ Icc 1 M, f n) * (Real.log x : ℂ) - + halaszPrimeConvolution f M‖ ≤ halaszInnerErrorConstant * x := by + have hM0 : (0 : ℝ) < M := by exact_mod_cast hM + have hx0 : 0 < x := hM0.trans_le hMx + have hlog0 : 0 ≤ Real.log x - Real.log (M : ℝ) := + sub_nonneg.mpr (Real.log_le_log hM0 hMx) + have hlog2 : Real.log x - Real.log (M : ℝ) ≤ Real.log 2 := by + have h := Real.log_le_log hx0 hxM + rw [Real.log_mul (by norm_num) hM0.ne'] at h + linarith + have he : (∑ n ∈ Icc 1 M, f n) * (Real.log x : ℂ) - + halaszPrimeConvolution f M = + (∑ n ∈ Icc 1 M, f n) * ((Real.log x - Real.log (M : ℝ) : ℝ) : ℂ) + + ((∑ n ∈ Icc 1 M, f n) * (Real.log (M : ℝ) : ℂ) - + halaszPrimeConvolution f M) := by push_cast; ring + rw [he] + calc + _ ≤ ‖(∑ n ∈ Icc 1 M, f n) * ((Real.log x - Real.log (M : ℝ) : ℝ) : ℂ)‖ + + ‖(∑ n ∈ Icc 1 M, f n) * (Real.log (M : ℝ) : ℂ) - + halaszPrimeConvolution f M‖ := norm_add_le _ _ + _ ≤ (M : ℝ) * Real.log 2 + (halaszPrimePowerConstant + 1) * M := by + apply add_le_add _ (halasz_prime_log_approximation f hf hmul M hM) + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg hlog0] + exact mul_le_mul (halasz_bounded_prefix_norm f hf M) hlog2 hlog0 (Nat.cast_nonneg _) + _ = halaszInnerErrorConstant * (M : ℝ) := by unfold halaszInnerErrorConstant; ring + _ ≤ _ := mul_le_mul_of_nonneg_left hMx halaszInnerErrorConstant_nonneg + +lemma halasz_real_inner_approximation (f : ℕ → ℂ) (hf : OneBounded f) + (hmul : ∀ m n : ℕ, 0 < m → 0 < n → f (m * n) = f m * f n) + (M : ℕ) (hM : 1 ≤ M) {x : ℝ} (hx : 1 < x) + (hMx : (M : ℝ) ≤ x) (hxM : x ≤ 2 * M) : + ‖(∑ n ∈ Icc 1 M, f n) - halaszPrimeConvolution f M / (Real.log x : ℂ)‖ ≤ + halaszInnerErrorConstant * x / Real.log x := by + have hlog : 0 < Real.log x := Real.log_pos hx + have hc : (Real.log x : ℂ) ≠ 0 := by exact_mod_cast ne_of_gt hlog + have he : (∑ n ∈ Icc 1 M, f n) - halaszPrimeConvolution f M / (Real.log x : ℂ) = + ((∑ n ∈ Icc 1 M, f n) * (Real.log x : ℂ) - + halaszPrimeConvolution f M) / (Real.log x : ℂ) := by field_simp + rw [he, norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hlog] + exact div_le_div_of_nonneg_right (halasz_real_log_approximation f hf hmul M hM hMx hxM) + hlog.le + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszIntegerKernel.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszIntegerKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..9bea44bd277ab6f5f8da1b012872a9dc4320a425 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszIntegerKernel.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPoissonBound +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTSparsePolynomial + +namespace OAI + +/-! The actual finite weighted integer kernel used by sparse cofactor energy. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def halaszTriangleSupport (N : ℝ) : Finset ℕ := + range (⌈5*N/2⌉₊+1) + +lemma halasz_triangle_nat_zero (N u : ℝ) (hN : 0 < N) (n : ℕ) + (hn : n ∉ halaszTriangleSupport N) : + halaszTriangleFunction N u 0 n = 0 := by + have hnat : ⌈5*N/2⌉₊ < n := by simpa [halaszTriangleSupport] using hn + have hreal : (⌈5*N/2⌉₊:ℝ) < n := by exact_mod_cast hnat + unfold halaszTriangleFunction + rw [halasz_triangle_weight_right_zero N n hN ((Nat.le_ceil _).trans hreal.le), + Complex.ofReal_zero,zero_mul] +lemma halasz_triangle_neg_zero (N u : ℝ) (hN : 0 < N) (n : ℕ) : + halaszTriangleFunction N u 0 (-(n+1:ℝ)) = 0 := by + unfold halaszTriangleFunction + rw [halasz_triangle_weight_left_zero N _ hN (by + have hn0 : (0:ℝ) ≤ n := Nat.cast_nonneg n + linarith),Complex.ofReal_zero,zero_mul] + +lemma halasz_triangle_finite_sum (N u : ℝ) (hN : 0 < N) : + (∑' n : ℤ, halaszTriangleFunction N u 0 n) = + ∑ n ∈ halaszTriangleSupport N, halaszTriangleFunction N u 0 n := by + have hn := halasz_triangle_nat_zero N u hN + have hs : Summable (fun n : ℕ => halaszTriangleFunction N u 0 n) := + summable_of_ne_finset_zero hn + have hneg : (fun n : ℕ => halaszTriangleFunction N u 0 (-(n+1:ℝ))) = 0 := by + funext n + exact halasz_triangle_neg_zero N u hN n + have hsn : Summable (fun n : ℕ => halaszTriangleFunction N u 0 (-(n+1:ℝ))) := by + rw [hneg] + exact summable_zero + have he := tsum_of_nat_of_neg_add_one (f := fun n : ℤ => + halaszTriangleFunction N u 0 n) (by simpa only [Int.cast_natCast] using hs) + (by simpa only [Int.cast_neg,Int.cast_add,Int.cast_natCast,Int.cast_one] using hsn) + simp only [Int.cast_neg,Int.cast_add,Int.cast_natCast,Int.cast_one] at he + rw [hneg] at he + simp only [Pi.zero_def,tsum_zero,add_zero] at he + exact he.trans (tsum_eq_sum hn) + +lemma halasz_triangle_polynomial (N t : ℝ) (hN : 0 < N) : + mrtExponentialPolynomial (halaszTriangleSupport N) + (fun n => (halaszTriangleWeight N n:ℂ)) (fun n => -Real.log n) t = + ∑' n : ℤ, halaszTriangleFunction N (-t) 0 n := by + rw [halasz_triangle_finite_sum N (-t) hN] + unfold mrtExponentialPolynomial + apply sum_congr rfl + intro n _ + unfold halaszTriangleFunction halaszLogPhase + congr 2 + push_cast + ring + +theorem halasz_integer_kernel (N t : ℝ) (hN : 0 < N) : + ‖mrtExponentialPolynomial (halaszTriangleSupport N) + (fun n => (halaszTriangleWeight N n:ℂ)) (fun n => -Real.log n) t‖ ≤ + 18600*N/(1+t^2) + (440/Real.pi)*Real.sqrt |t| + + (512/(N*(2*Real.pi)^2))*halaszIntegerSquareMass := by + rw [halasz_triangle_polynomial N t hN] + simpa only [neg_sq,abs_neg] using halasz_triangle_poisson_bound N (-t) hN + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszIntegerWindow.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszIntegerWindow.lean new file mode 100644 index 0000000000000000000000000000000000000000..c481b63fe5837db7bc9c4be087f7a3479d22a4a6 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszIntegerWindow.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszWindowSampling +import Mathlib.Data.Int.Interval + +namespace OAI + +/-! Counting lattice points near integers, with all interval endpoints real. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma halasz_integer_interval_card (S : Finset ℤ) {a b : ℝ} (hab : a≤b) + (hS : ∀ d∈S,a≤(d:ℝ) ∧ (d:ℝ)≤b) : (S.card:ℝ)≤b-a+1 := by + have hcf : ⌈a⌉≤⌊b⌋+1 := by + apply Int.ceil_le.mpr + push_cast + exact hab.trans (Int.lt_floor_add_one b).le + have hsub : S⊆Icc ⌈a⌉ ⌊b⌋ := by + intro d hd + exact mem_Icc.mpr ⟨Int.ceil_le.mpr (hS d hd).1,Int.le_floor.mpr (hS d hd).2⟩ + have hcard : ((Icc ⌈a⌉ ⌊b⌋).card:ℝ)=(⌊b⌋:ℝ)+1-(⌈a⌉:ℝ) := by + exact_mod_cast Int.card_Icc_of_le ⌈a⌉ ⌊b⌋ hcf + have hh : (S.card:ℝ)≤((Icc ⌈a⌉ ⌊b⌋).card:ℝ) := by + exact_mod_cast card_le_card hsub + rw [hcard] at hh + linarith [Int.floor_le b,Int.le_ceil a] + +/-- A finite set of integers lying in [-K,K] whose multiples by γ are close +to integers. This is the lattice count used by the double mean-value method. -/ +theorem halasz_integer_window_card (S : Finset ℤ) {K γ δ : ℝ} + (hK : 0≤K) (hγ : 0<γ) (hδ : 0≤δ) (hδhalf : δ≤1/2) + (hS : ∀ d∈S, |(d:ℝ)|≤K ∧ ‖((γ*(d:ℝ):ℝ):AddCircle (1:ℝ))‖≤δ) : + (S.card:ℝ)≤4*K*δ+2*K*γ+4*δ/γ+2 := by + let f : ℤ → ℤ := fun d => round (γ*(d:ℝ)) + have hnear (d : ℤ) (hd : d∈S) : |γ*(d:ℝ)-(f d:ℝ)|≤δ := by + simpa only [AddCircle.norm_eq,inv_one,one_mul,mul_one,f] using (hS d hd).2 + have himage : ∀ j∈S.image f, -K*γ-δ≤(j:ℝ) ∧ (j:ℝ)≤K*γ+δ := by + intro j hj + obtain ⟨d,hd,rfl⟩ := mem_image.mp hj + have hdK := abs_le.mp (hS d hd).1 + have hnd := abs_le.mp (hnear d hd) + constructor <;> nlinarith + have hjcard := halasz_integer_interval_card (S.image f) + (show -K*γ-δ≤K*γ+δ by nlinarith [mul_nonneg hK hγ.le]) himage + have hfcard (j : ℤ) : ((S.filter (fun d => f d=j)).card:ℝ)≤2*δ/γ+1 := by + have hh := halasz_integer_interval_card (S.filter (fun d => f d=j)) + (show ((j:ℝ)-δ)/γ≤((j:ℝ)+δ)/γ from + (div_le_div_iff_of_pos_right hγ).mpr (by linarith)) (by + intro d hd + obtain ⟨hd,hf⟩ := mem_filter.mp hd + have hn := abs_le.mp (hnear d hd) + rw [hf] at hn + constructor + · apply (div_le_iff₀ hγ).mpr + nlinarith [hn.2] + · apply (le_div_iff₀ hγ).mpr + nlinarith [hn.1]) + convert hh using 1; ring + have hsum : (S.card:ℝ)=∑ j∈S.image f,((S.filter (fun d => f d=j)).card:ℝ) := by + exact_mod_cast card_eq_sum_card_image f S + calc + _ = _ := hsum + _ ≤ ∑ _j∈S.image f,(2*δ/γ+1) := sum_le_sum (fun j _ => hfcard j) + _ = ((S.image f).card:ℝ)*(2*δ/γ+1) := by simp; ring + _ ≤ (2*K*γ+2*δ+1)*(2*δ/γ+1) := by + apply mul_le_mul_of_nonneg_right _ (by positivity) + linarith + _ ≤ _ := by + have hδ2 : 4*δ^2≤2*δ := by nlinarith + have hγ0 : γ≠0 := ne_of_gt hγ + apply (le_of_sub_nonneg ?_) + field_simp + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszIterationConstants.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszIterationConstants.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbadd21c037b1d510ed52771ea16094875ee6105 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszIterationConstants.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszIterationScale + +namespace OAI + +/-! Explicit constants for the classical iteration. -/ +namespace TwoPointCorrelations + +def halaszIterationBase (R₀ k : ℕ) : ℕ := + k.factorial+(halaszIterationThreshold R₀ k)^(k+k*(k-1)/2)+ + 2*(2*(k^2*k)+1)*k^k*32^(k*(k-1)/2)+1 + +def halaszIterationConstant (R₀ k n : ℕ) : ℕ := + (halaszIterationBase R₀ k)^(n+1)*32^(k*n*(n+1)) + +lemma halasz_iteration_base_bounds (R₀ k : ℕ) : + 1≤halaszIterationBase R₀ k ∧ k.factorial≤halaszIterationBase R₀ k ∧ + (halaszIterationThreshold R₀ k)^(k+k*(k-1)/2)≤halaszIterationBase R₀ k ∧ + 2*(2*(k^2*k)+1)*k^k*32^(k*(k-1)/2)≤halaszIterationBase R₀ k := by + unfold halaszIterationBase + omega + +lemma halasz_iteration_constant_ge_base (R₀ k n : ℕ) : + halaszIterationBase R₀ k≤halaszIterationConstant R₀ k n := by + have hb := (halasz_iteration_base_bounds R₀ k).1 + have hp : halaszIterationBase R₀ k≤(halaszIterationBase R₀ k)^(n+1) := by + simpa only [pow_one] using pow_le_pow_right₀ hb (by omega : 1≤n+1) + have h32 : 1≤(32:ℕ)^(k*n*(n+1)) := Nat.one_le_pow _ _ (by decide) + exact hp.trans (Nat.le_mul_of_pos_right _ (by omega)) + +lemma halasz_iteration_constant_zero (R₀ k : ℕ) : + halaszIterationConstant R₀ k 0=halaszIterationBase R₀ k := by + simp [halaszIterationConstant] + +theorem halasz_iteration_constant_step (R₀ k n : ℕ) : + halaszIterationConstant R₀ k n * + (2*(2*(k^2*k)+1)*k^k*32^(2*((n+1)*k)+k*(k-1)/2)) ≤ + halaszIterationConstant R₀ k (n+1) := by + have hc := (halasz_iteration_base_bounds R₀ k).2.2.2 + have hfactor : 2*(2*(k^2*k)+1)*k^k*32^(2*((n+1)*k)+k*(k-1)/2) = + (2*(2*(k^2*k)+1)*k^k*32^(k*(k-1)/2))*32^(2*((n+1)*k)) := by + rw [pow_add] + ring + rw [hfactor] + calc + _ ≤ halaszIterationConstant R₀ k n * + (halaszIterationBase R₀ k*32^(2*((n+1)*k))) := + Nat.mul_le_mul_left _ (Nat.mul_le_mul_right _ hc) + _ = halaszIterationConstant R₀ k (n+1) := by + unfold halaszIterationConstant + rw [pow_succ] + have he : k*n*(n+1)+2*((n+1)*k)=k*(n+1)*(n+1+1) := by ring + rw [← he,pow_add] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszIterationScale.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszIterationScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d6efddaadbb2db4f6020398f797507057c9f467 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszIterationScale.lean @@ -0,0 +1,46 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszRootScale + +namespace OAI + +/-! One explicit polynomial threshold for the root scale, and its +induced threshold for the summation endpoint. -/ +namespace TwoPointCorrelations + +def halaszIterationRootThreshold (R₀ k : ℕ) : ℕ := R₀+(2*(k^2*k)+1)^2+k+2 + +def halaszIterationThreshold (R₀ k : ℕ) : ℕ := + (halaszIterationRootThreshold R₀ k)^k+(4*k^2)^2+2^k+1 + +lemma halasz_iteration_threshold_pos (R₀ k : ℕ) : 0 by have hd := (le_min_iff.mp (hdeg j hj)).1; linarith) + (fun j hj => (le_min_iff.mp (le_min_iff.mp (hdeg j hj)).2).1) + (fun j hj => by have hd := (le_min_iff.mp (le_min_iff.mp (hdeg j hj)).2).2; linarith) + simpa only [halasz_large_degrees_card] using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLargeLogPolynomial.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLargeLogPolynomial.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7ae591d978ec3913dd66dbb48b9b03a0b89e4d1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLargeLogPolynomial.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLargeDegrees +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMomentRoot + +namespace OAI + +/-! The large-height logarithmic Taylor polynomial gains a quadratic +saving in the degree before taking its selected moment root. -/ +namespace TwoPointCorrelations + +open Finset + +theorem halasz_large_log_polynomial : ∃ R₀ : ℕ, ∀ m : ℕ, 8≤m → + ∀ M : ℕ, 1≤M → ∀ t z N lam : ℝ, (M:ℝ)≤N → N≤z → z≤2*N → + |t|=N^lam → N^(1/4:ℝ)≤2*(M:ℝ) → + 6*(m:ℝ)-6≤lam → lam≤6*m → + let k := 12*m + let r := halaszSelectedMoment k + let p := 2*r*r + ‖∑ b : Fin M,halaszVinogradovPolynomial k M + (halaszScaledFrequency (halaszLogCoefficient t z) + (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)))‖/(M:ℝ)^2 ≤ + ((32*(r:ℝ))^k*(R₀+k+32:ℝ)^(512*k^4)*(halaszLogWeightCost k r)^k)^((p:ℝ)⁻¹)* + N^(-(m:ℝ)^2/(4*(p:ℝ))) := by + obtain ⟨R₀,hR⟩ := halasz_selected_double_moment + refine ⟨R₀,?_⟩ + intro m hm M hM t z N lam hMN hz hzhi ht hscale hlo hhi + dsimp only + let k := 12*m + let r := halaszSelectedMoment k + let p := 2*r*r + have hk : 2≤k := by dsimp only [k]; omega + have hr : 1≤r := halasz_selected_moment_pos hk + have hp : 0

(((b.val+1)^(j.val+1):ℕ):ℤ)))‖^p ≤ + A*(M:ℝ)^(((2*p:ℕ):ℝ)+(k:ℝ)^2/1024)*D* + N^(-(((2*m+1:ℕ):ℝ)*((m:ℝ)-6))) := by + convert hbound using 1 + dsimp only [A,D,k,r] + rw [hexp] + ring_nf + have hmargin : (k:ℝ)^2/1024-((2*m+1:ℕ):ℝ)*((m:ℝ)-6)≤ -(m:ℝ)^2/4 := by + have hh := halasz_large_degree_margin (by exact_mod_cast hm : (8:ℝ)≤m) + dsimp only [k] + push_cast + nlinarith only [hh] + have hh := halasz_moment_transfer hp (by positivity) + (show 0≤A by dsimp only [A]; positivity) + (show 0≤D by dsimp only [D]; exact pow_nonneg (halasz_log_weight_cost_pos _ _).le _) + hMR hMN (by positivity : (0:ℝ)≤(k:ℝ)^2/1024) hmargin hbound' + convert hh using 1 + congr 1 + congr 1 + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLargeMinimum.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLargeMinimum.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5fe70402d7c2ad60b9fc720e68318aa79b28c7c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLargeMinimum.lean @@ -0,0 +1,122 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCofactorScale + +namespace OAI + +/-! A large minimum gives the same cofactor saving at every frequency; +no prime-repulsion input is needed in this case. -/ +namespace TwoPointCorrelations + +open Filter Finset + +lemma halasz_large_minimum_cutoff (K : ℝ) : + ∀ᶠ n : ℕ in atTop, ∀ X : ℕ, n ≤ X → X ≤ n^3 → + ∀ (F : ℕ → ℂ), OneBounded F → ∀ v : ℝ, + (1/10:ℝ)*Real.log (Real.log X) ≤ squaredDistance F (mrtArchimedeanTwist v) X → + 2*((3/100:ℝ)*Real.log (Real.log n))+K ≤ + squaredDistance F (mrtArchimedeanTwist v) n := by + obtain ⟨K₀,hK₀,hcut⟩ := halasz_distance_cutoff_loss + have hll := (Real.tendsto_log_atTop.comp + (Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop)).eventually + (eventually_ge_atTop (25*(K+K₀))) + filter_upwards [eventually_ge_atTop 2,hll] with n hn2 hlln + intro X hnX hX F hF v hv + have hlogn : 0 < Real.log (n:ℝ) := + Real.log_pos (by exact_mod_cast (show 1 mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) N a t‖ ≤ + (Real.log n)^(-1/40:ℝ) := by + obtain ⟨C,K,X₀,hC,hK,hcofactor⟩ := halasz_exceptional_typical_window + refine ⟨X₀,?_⟩ + have hlog : Tendsto (fun n:ℕ => Real.log n) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + filter_upwards [halasz_large_minimum_cutoff K,halasz_cofactor_band_count, + hlog.eventually (halasz_exceptional_decay C hC.le), + hlog.eventually (eventually_ge_atTop (1:ℝ))] with n hcut hcount hdec hln + intro N a ha hbase hn X hnX hX F hF1 hFm hFb hmin P Q J hQ hband A hA t ht + let R := (Real.log n)^(1/16:ℝ) + have hR : 0 ≤ R := Real.rpow_nonneg (by linarith) _ + have hM : 0 ≤ (3/100:ℝ)*Real.log (Real.log n) := + mul_nonneg (by norm_num) (Real.log_nonneg hln) + have hd : ∀ v:ℝ, |v-t| ≤ (Real.log n)^8 → 1/2 ≤ |v-(t+R)| → + 2*((3/100:ℝ)*Real.log (Real.log n))+K ≤ + squaredDistance F (mrtArchimedeanTwist v) n := by + intro v hv _ + have hvX : |v| ≤ X := by + have hh := abs_add_le (v-t) t + rw [sub_add_cancel] at hh + linarith + exact hcut X hnX hX F hFb v (hmin v hvX) + have hb := hcofactor N a ha hbase F hF1 hFm hFb ℕ (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) A + (fun _ _ _ hp => mrtPrimeBand_prime hp) hA t (t+R) + ((3/100:ℝ)*Real.log (Real.log n)) hM (by simpa only [← hn] using hd) + have haway : (Real.log n)^(1/16:ℝ)/2 ≤ |(t+R)-t| := by + rw [add_sub_cancel_left,abs_of_nonneg hR] + change R/2 ≤ R + linarith + have hsave := hdec ((2:ℝ)^(Icc 1 J).card) ((t+R)-t) (by positivity) + (hcount X hnX hX Q J hQ hband) haway + apply hb.trans + simpa only [← hn,mul_comm C] using hsave + +theorem halasz_large_minimum_extra_cofactor : + ∀ᶠ N : ℕ in atTop, ∀ (F : ℕ → ℂ), F 1 = 1 → Multiplicative F → OneBounded F → + (∀ v : ℝ, |v| ≤ 2*N → (1/10:ℝ)*Real.log (Real.log (2*N:ℕ)) ≤ + squaredDistance F (mrtArchimedeanTwist v) (2*N)) → + ∀ (P Q : ℝ) (J : ℕ), 1 ≤ Real.log Q → + mrtBandUpper Q J ≤ Real.exp (Real.sqrt (Real.log N)) → + ∀ (A : Finset ℕ), (∀ p ∈ A, p.Prime) → + ∀ a : ℝ, 1 ≤ a → a ≤ Real.exp (Real.log N/Real.log (Real.log N)) → + ∀ t : ℝ, |t| ≤ N → + ‖mrtCofactorPolynomial A (mrtTypicalCoefficient (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) N a t‖ ≤ + 2*(Real.log N)^(-1/40:ℝ) := by + obtain ⟨X₀,hcofactor⟩ := halasz_large_minimum_actual_cofactor + obtain ⟨n₀,hn₀⟩ := eventually_atTop.mp hcofactor + filter_upwards [halasz_cofactor_floor_scale X₀ n₀,eventually_ge_atTop 2] + with N hscale hN + intro F hF1 hFm hFb hmin P Q J hQ hband A hA a ha haU t ht + let n := ⌊(2*N:ℝ)/a⌋₊ + obtain ⟨hbase,hnlarge,hnupper,hncube,hloglow,hlogupper,hwidth⟩ := hscale a ha haU + have hN0 : 0 < (N:ℝ) := by exact_mod_cast (show 0 F p/(p:ℂ)) (fun p => -Real.log (p:ℝ)) t‖ → + ‖mrtCofactorPolynomial A B N a t‖ ≤ U) → + (∫ t in E ∩ {t | L^(-100:ℝ) ≤ ‖mrtExponentialPolynomial P + (fun p => F p/(p:ℂ)) (fun p => -Real.log (p:ℝ)) t‖}, + ‖mrtExponentialPolynomial P (fun p => F p/(p:ℂ)) + (fun p => -Real.log (p:ℝ)) t * mrtCofactorPolynomial A B N a t‖^2) ≤ + C*U^2/(H*(Real.log Y)^2) := by + obtain ⟨C,B₀,hC,hB₀,hprime⟩ := hprime.short_prime_energy + refine ⟨4*C,B₀,by positivity,hB₀,?_⟩ + filter_upwards [hprime,mrt_extra_prime_large_samples,eventually_ge_atTop (1:ℝ)] + with L hprime hcount hL + intro H Y hH hY hHY hYL hYU hlogY P F hP hwindow hF A B N a U _hU E hE hET hpoint + let Q := mrtExponentialPolynomial P (fun p => F p/(p:ℂ)) + (fun p => -Real.log (p:ℝ)) + let R := mrtCofactorPolynomial A B N a + let D := E ∩ {t | L^(-100:ℝ) ≤ ‖Q t‖} + have hQc : Continuous Q := mrtExponentialPolynomial_continuous _ _ _ + have hRc : Continuous R := mrtCofactorPolynomial_continuous _ _ _ _ + have hD : MeasurableSet D := hE.inter (isClosed_le continuous_const hQc.norm).measurableSet + have hDT : D ⊆ Set.Ioc (-Real.exp L) (Real.exp L) := + fun _ ht => hET ht.1 + have hsamples (S : Finset ℝ) (hS : ∀ t ∈ S, t ∈ D) + (hsep : ∀ t ∈ S, ∀ s ∈ S, t≠s → 1 ≤ |t-s|) : + (∑ t ∈ S, ‖Q t*R t‖^2) ≤ U^2*(C/(H*(Real.log Y)^2)) := by + have hheight : ∀ t ∈ S, |t| ≤ Real.exp L := by + intro t ht + exact abs_le.mpr ⟨(hDT (hS t ht)).1.le,(hDT (hS t ht)).2⟩ + have hcard := hcount Y (Real.exp L) (by linarith) hYL hYU + (Real.one_lt_exp_iff.mpr (by linarith)) le_rfl P + (fun p hp => (hP p hp).1) (fun p hp => (hP p hp).2) F hF S hheight hsep + (fun t ht => (hS t ht).2) + have hp := hprime H Y hH hY hHY hYL hlogY P F hP hwindow hF S hheight hsep hcard + calc + _ = ∑ t ∈ S, ‖Q t‖^2*‖R t‖^2 := by + apply sum_congr rfl + intro t _ + rw [norm_mul,mul_pow] + _ ≤ ∑ t ∈ S, ‖Q t‖^2*U^2 := by + apply sum_le_sum + intro t ht + apply mul_le_mul_of_nonneg_left _ (sq_nonneg _) + exact pow_le_pow_left₀ (norm_nonneg _) (hpoint t (hS t ht).1 (hS t ht).2) 2 + _ = U^2*∑ t ∈ S, ‖Q t‖^2 := by + rw [Finset.mul_sum] + apply sum_congr rfl + intro t _ + ring + _ ≤ _ := mul_le_mul_of_nonneg_left hp (sq_nonneg U) + have hi := mrt_set_integral_of_samples (fun t => ‖Q t*R t‖^2) + ((hQc.mul hRc).norm.pow 2) (fun _ => sq_nonneg _) hD + (Real.exp_pos L).le hDT hsamples + change (∫ t in D, ‖Q t*R t‖^2) ≤ _ + apply hi.trans_eq + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogBands.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogBands.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7ed5c4c1cbb7554033ec314f5412e4330f2925e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogBands.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimeMass + +namespace OAI + +/-! Mertens weights on the geometric bands of log(X/p) in the adaptive +double convolution. The bounds remain valid for the last band near p=2. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma halasz_mem_prime_band {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) + {p : ℕ} (hp : p.Prime) (hap : a < p) (hpb : (p : ℝ) ≤ b) : + p ∈ mrtPrimeBand a b := by + apply mem_sdiff.mpr + constructor + · exact mem_filter.mpr ⟨mem_Iic.mpr ((Nat.le_floor_iff hb).mpr hpb), hp⟩ + · intro h + have hpa := (Nat.le_floor_iff ha).mp (mem_Iic.mp (mem_filter.mp h).1) + linarith + +lemma halasz_log_band_endpoints {X v : ℝ} (hX : 0 < X) + {p : ℕ} (hp : p.Prime) + (hlo : v ≤ Real.log (X / p)) (hhi : Real.log (X / p) < 2 * v) : + X / Real.exp (2 * v) < p ∧ (p : ℝ) ≤ X / Real.exp v := by + have hp0 : (0 : ℝ) < p := by exact_mod_cast hp.pos + have hxquot : 0 < X / p := div_pos hX hp0 + have hexlo : Real.exp v ≤ X / p := (Real.le_log_iff_exp_le hxquot).mp hlo + have hexhi : X / p < Real.exp (2 * v) := (Real.log_lt_iff_lt_exp hxquot).mp hhi + constructor + · apply (div_lt_iff₀ (Real.exp_pos _)).mpr + have h := (div_lt_iff₀ hp0).mp hexhi + nlinarith + · apply (le_div_iff₀ (Real.exp_pos _)).mpr + have h := (le_div_iff₀ hp0).mp hexlo + nlinarith + +theorem halasz_log_band_mass {X v : ℝ} (hX : 0 < X) (hv : 0 < v) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime ∧ + v ≤ Real.log (X / p) ∧ Real.log (X / p) < 2 * v) : + (∑ p ∈ P, Real.log (p : ℝ) / p) ≤ v + 2 * halaszMertensConstant := by + let a := max 1 (X / Real.exp (2 * v)) + let b := X / Real.exp v + have hb0 : 0 < b := div_pos hX (Real.exp_pos _) + by_cases hb : 1 ≤ b + · have hlower : X / Real.exp (2 * v) ≤ b := + div_le_div_of_nonneg_left hX.le (Real.exp_pos _) + (Real.exp_le_exp.mpr (by linarith)) + have ha : 1 ≤ a := le_max_left _ _ + have hab : a ≤ b := max_le hb hlower + have hsub : P ⊆ mrtPrimeBand a b := by + intro p hp + obtain ⟨hprime, hlo, hhi⟩ := hP p hp + obtain ⟨hpa, hpb⟩ := halasz_log_band_endpoints hX hprime hlo hhi + exact halasz_mem_prime_band (by dsimp [a]; positivity) hb0.le hprime + (max_lt (by exact_mod_cast hprime.one_lt) hpa) hpb + have hsum := sum_le_sum_of_subset_of_nonneg (f := fun p : ℕ => Real.log (p : ℝ) / p) + hsub (fun p hp _ => + div_nonneg (Real.log_nonneg (by exact_mod_cast (mrtPrimeBand_prime hp).one_le)) + (Nat.cast_nonneg _)) + have hlog : Real.log b - Real.log a ≤ v := by + have hloga : Real.log (X / Real.exp (2 * v)) ≤ Real.log a := + Real.log_le_log (div_pos hX (Real.exp_pos _)) (le_max_right _ _) + rw [Real.log_div hX.ne' (Real.exp_ne_zero _), Real.log_exp] at hloga + dsimp [b] + rw [Real.log_div hX.ne' (Real.exp_ne_zero _), Real.log_exp] + linarith + exact hsum.trans ((halasz_prime_band_mass_le ha hab).trans (by linarith)) + · have hempty : P = ∅ := by + apply eq_empty_iff_forall_notMem.mpr + intro p hp + obtain ⟨hprime, hlo, hhi⟩ := hP p hp + have hpb := (halasz_log_band_endpoints hX hprime hlo hhi).2 + have hp1 : (1 : ℝ) < p := by exact_mod_cast hprime.one_lt + linarith + rw [hempty, sum_empty] + exact add_nonneg hv.le (mul_nonneg (by norm_num) halaszMertensConstant_nonneg) + +theorem halasz_log_band_mass_linear {X v : ℝ} (hX : 0 < X) (hv : Real.log 2 ≤ v) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime ∧ + v ≤ Real.log (X / p) ∧ Real.log (X / p) < 2 * v) : + (∑ p ∈ P, Real.log (p : ℝ) / p) ≤ + (1 + 2 * halaszMertensConstant / Real.log 2) * v := by + have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) + apply (halasz_log_band_mass hX (htwo.trans_le hv) P hP).trans + have hm := mul_le_mul_of_nonneg_left hv + (show 0 ≤ 2 * halaszMertensConstant / Real.log 2 from + div_nonneg (mul_nonneg (by norm_num) halaszMertensConstant_nonneg) htwo.le) + rw [div_mul_cancel₀ _ htwo.ne'] at hm + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogBilinear.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogBilinear.lean new file mode 100644 index 0000000000000000000000000000000000000000..d2d85706f6e98ce8c36f69a321e5b43445b02e74 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogBilinear.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLogCoefficients + +namespace OAI + +/-! Transfer the logarithmic bilinear sum to its complete-system Taylor +polynomial with an explicit uniform error. -/ +namespace TwoPointCorrelations + +open Finset Complex + +lemma halasz_log_taylor_phase_factor (k : ℕ) (t : ℝ) {z : ℝ} (hz : z≠0) (a b : ℕ) : + Complex.exp (Complex.I*((t*(Real.log z+halaszLogTaylor k z ((a*b:ℕ):ℝ)):ℝ):ℂ))= + Complex.exp (Complex.I*((t*Real.log z:ℝ):ℂ))* + halaszVinogradovCharacter (fun j : Fin k => ((a^(j.val+1):ℕ):ℤ)) + (halaszScaledFrequency (halaszLogCoefficient t z) + (fun j => ((b^(j.val+1):ℕ):ℤ))) := by + rw [halasz_log_taylor_character k t hz,← Complex.exp_add] + congr 1 + push_cast + ring + +theorem halasz_log_bilinear_taylor (k M₁ M₂ : ℕ) (t : ℝ) {z : ℝ} + (hz : 0 (((b.val+1)^(j.val+1):ℕ):ℤ)))‖+ + ((M₁*M₂:ℕ):ℝ)*(2*|t| * (((M₁*M₂:ℕ):ℝ)/z)^(k+1)) := by + let U := ∑ b : Fin M₂,∑ a : Fin M₁, + Complex.exp (Complex.I*((t*Real.log (z+(a.val+1)*(b.val+1)):ℝ):ℂ)) + let V := ∑ b : Fin M₂,∑ a : Fin M₁, + Complex.exp (Complex.I*((t*(Real.log z+ + halaszLogTaylor k z (((a.val+1)*(b.val+1):ℕ):ℝ)):ℝ):ℂ)) + have hdiff : ‖U-V‖≤((M₁*M₂:ℕ):ℝ)*(2*|t| * (((M₁*M₂:ℕ):ℝ)/z)^(k+1)) := by + dsimp only [U,V] + rw [← sum_sub_distrib] + simp_rw [← sum_sub_distrib] + apply (norm_sum_le _ _).trans + apply (sum_le_sum (fun _ _ => norm_sum_le _ _)).trans + calc + _ ≤ ∑ _b : Fin M₂,∑ _a : Fin M₁, + (2*|t| * (((M₁*M₂:ℕ):ℝ)/z)^(k+1)) := by + apply sum_le_sum + intro b _ + apply sum_le_sum + intro a _ + have hab : ((a.val+1)*(b.val+1):ℕ)≤M₁*M₂ := + Nat.mul_le_mul (by omega) (by omega) + have habR : (((a.val+1)*(b.val+1):ℕ):ℝ)≤((M₁*M₂:ℕ):ℝ) := by exact_mod_cast hab + have hh := halasz_log_taylor_phase k t hz + (Nat.cast_nonneg ((a.val+1)*(b.val+1))) (habR.trans hM) + have hp := pow_le_pow_left₀ (by positivity : + 0≤(((a.val+1)*(b.val+1):ℕ):ℝ)/z) + (div_le_div_of_nonneg_right habR hz.le) (k+1) + have hb := mul_le_mul_of_nonneg_left hp (by positivity : 0≤2*|t|) + simpa only [Nat.cast_mul,Nat.cast_add,Nat.cast_one] using hh.trans hb + _ = _ := by simp; ring + have hV : ‖V‖=‖∑ b : Fin M₂,halaszVinogradovPolynomial k M₁ + (halaszScaledFrequency (halaszLogCoefficient t z) + (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)))‖ := by + have he : V=Complex.exp (Complex.I*((t*Real.log z:ℝ):ℂ))* + (∑ b : Fin M₂,halaszVinogradovPolynomial k M₁ + (halaszScaledFrequency (halaszLogCoefficient t z) + (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)))) := by + dsimp only [V] + simp_rw [halasz_log_taylor_phase_factor k t hz.ne'] + rw [mul_sum] + apply sum_congr rfl + intro b _ + rw [halaszVinogradovPolynomial,mul_sum] + rw [he,norm_mul,Complex.norm_exp_I_mul_ofReal,one_mul] + have hn : ‖U‖≤‖V‖+‖U-V‖ := by + calc + _ = ‖V+(U-V)‖ := by congr 1; ring + _ ≤ _ := norm_add_le _ _ + exact hn.trans (by rw [hV]; exact add_le_add le_rfl hdiff) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogCoefficients.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogCoefficients.lean new file mode 100644 index 0000000000000000000000000000000000000000..c28a46662c7f48d5c7e7fbb20fb1bf289410aa0e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogCoefficients.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLogTaylor +import OAI.NumberTheory.TwoPoint.Halasz.HalaszScaledFrequency + +namespace OAI + +/-! Identification of the logarithmic Taylor polynomial with the exact +coefficient-torus character in the double mean-value estimate. -/ +namespace TwoPointCorrelations + +open Finset Complex + +noncomputable def halaszLogCoefficient {k : ℕ} (t z : ℝ) (j : Fin k) : ℝ := + t*(-1:ℝ)^j.val/(2*Real.pi*(j.val+1)*z^(j.val+1)) + +lemma halasz_log_coefficient_ne_zero {k : ℕ} {t z : ℝ} + (ht : t≠0) (hz : z≠0) (j : Fin k) : halaszLogCoefficient t z j≠0 := by + unfold halaszLogCoefficient + exact div_ne_zero (mul_ne_zero ht (pow_ne_zero _ (by norm_num))) + (mul_ne_zero (mul_ne_zero (mul_ne_zero (by norm_num) Real.pi_ne_zero) + (by positivity)) (pow_ne_zero _ hz)) + +lemma halasz_log_coefficient_abs {k : ℕ} (t z : ℝ) (j : Fin k) : + |halaszLogCoefficient t z j|=|t|/(2*Real.pi*(j.val+1)*|z|^(j.val+1)) := by + simp only [halaszLogCoefficient,abs_div,abs_mul,abs_pow,abs_neg,abs_one,one_pow, + mul_one,abs_of_nonneg (by norm_num : 0≤(2:ℝ)),abs_of_pos Real.pi_pos] + rw [abs_of_nonneg (show 0≤(j.val:ℝ)+1 by positivity)] + +lemma halasz_log_taylor_character (k : ℕ) (t : ℝ) {z : ℝ} (hz : z≠0) (a b : ℕ) : + halaszVinogradovCharacter (fun j : Fin k => ((a^(j.val+1):ℕ):ℤ)) + (halaszScaledFrequency (halaszLogCoefficient t z) + (fun j => ((b^(j.val+1):ℕ):ℤ)))= + Complex.exp (Complex.I*((t*halaszLogTaylor k z ((a*b:ℕ):ℝ):ℝ):ℂ)) := by + have he (j : Fin k) : + fourier ((a^(j.val+1):ℕ):ℤ) + (halaszScaledFrequency (halaszLogCoefficient t z) + (fun j => ((b^(j.val+1):ℕ):ℤ)) j)= + Complex.exp (Complex.I*((t*((-1:ℝ)^j.val* + (((a*b:ℕ):ℝ)/z)^(j.val+1)/(j.val+1)):ℝ):ℂ)) := by + dsimp only [halaszScaledFrequency] + rw [fourier_coe_apply] + dsimp only [halaszLogCoefficient] + congr 1 + push_cast + have hzC : (z:ℂ)≠0 := by exact_mod_cast hz + have hpiC : (Real.pi:ℂ)≠0 := by exact_mod_cast Real.pi_ne_zero + simp only [div_pow,mul_pow] + field_simp [hzC,hpiC] + unfold halaszVinogradovCharacter + simp_rw [he] + rw [← Complex.exp_sum] + congr 1 + rw [halaszLogTaylor,← Fin.sum_univ_eq_sum_range] + push_cast + rw [mul_sum,mul_sum] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogConvolution.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogConvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad8674e9dab8b5739c4cd4cf1f4c98a871ff0aab --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogConvolution.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.TwoPoint.Basic +import Mathlib.NumberTheory.ArithmeticFunction.VonMangoldt +import Mathlib.NumberTheory.LSeries.Deriv + +namespace OAI + +/-! Exact logarithmic identities at the start of Halász's method. The +multiplicativity hypothesis here is complete multiplicativity on positive +arguments, as supplied by the corrected MRT reduction. -/ + +namespace TwoPointCorrelations + +open Finset + +theorem halasz_logarithmic_convolution (f : ℕ → ℂ) + (hf : ∀ m n : ℕ, 0 < m → 0 < n → f (m * n) = f m * f n) (n : ℕ) : + f n * (Real.log (n : ℝ) : ℂ) = + ∑ d ∈ n.divisors, + (ArithmeticFunction.vonMangoldt d : ℂ) * f d * f (n / d) := by + by_cases hn : n = 0 + · subst n + simp + have hterm (d : ℕ) (hd : d ∈ n.divisors) : + (ArithmeticFunction.vonMangoldt d : ℂ) * f d * f (n / d) = + (ArithmeticFunction.vonMangoldt d : ℂ) * f n := by + have hdn : d ∣ n := (Nat.mem_divisors.mp hd).1 + have hdpos : 0 < d := Nat.pos_of_dvd_of_pos hdn (Nat.pos_of_ne_zero hn) + have hquot : 0 < n / d := Nat.div_pos (Nat.le_of_dvd (Nat.pos_of_ne_zero hn) hdn) hdpos + rw [mul_assoc, ← hf d (n / d) hdpos hquot, Nat.mul_div_cancel' hdn] + calc + _ = (∑ d ∈ n.divisors, (ArithmeticFunction.vonMangoldt d : ℂ)) * f n := by + rw [← Complex.ofReal_sum, ArithmeticFunction.vonMangoldt_sum] + ring + _ = _ := by rw [sum_mul]; exact sum_congr rfl hterm |>.symm + +noncomputable def halaszDirichletPolynomial (f : ℕ → ℂ) (N : ℕ) (s : ℂ) : ℂ := + ∑ n ∈ Icc 1 N, LSeries.term f s n + +theorem halaszDirichletPolynomial_hasDerivAt (f : ℕ → ℂ) (N : ℕ) (s : ℂ) : + HasDerivAt (halaszDirichletPolynomial f N) + (-∑ n ∈ Icc 1 N, (Real.log (n : ℝ) : ℂ) * LSeries.term f s n) s := by + change HasDerivAt (fun z => ∑ n ∈ Icc 1 N, LSeries.term f z n) _ s + have h := HasDerivAt.fun_sum (fun n (_ : n ∈ Icc 1 N) => LSeries.hasDerivAt_term f n s) + convert h using 1 + rw [sum_neg_distrib] + congr 1 + apply sum_congr rfl + intro n hn + have hn0 : n ≠ 0 := by have := (mem_Icc.mp hn).1; omega + simp [hn0, mul_div_assoc] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogDirichletBlock.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogDirichletBlock.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4e0c9fba1d5d987080aea97ad21ae52fb9f1a29 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogDirichletBlock.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLogPhase +import OAI.NumberTheory.TwoPoint.Halasz.HalaszWeightedPrefix +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCubicMaximum + +namespace OAI + +/-! Uniform Dirichlet block bounds in the weak Vinogradov--Korobov strip. +The harmless power of the height replaces all degree-selection constants. -/ +namespace TwoPointCorrelations + +open Finset Complex + +theorem halasz_log_dirichlet_block : ∃ C : ℝ, 1≤C ∧ ∀ N H : ℕ, + 1≤N → H≤N → ∀ a : ℝ, a∈Set.Icc (0:ℝ) 1 → ∀ s : ℂ, + 2/3≤s.re → ∀ L lam : ℝ, 0 by + have hh := hphase N n hN (hn.trans hH) a (-s.im) lam ha hlam hhalf + (by simpa only [abs_neg] using ht) + simpa only [A,η,neg_div] using hh) + have hwbase : ((N:ℝ)+a)^(-s.re)≤(N:ℝ)^(-s.re) := + Real.rpow_le_rpow_of_nonpos hN0 (by linarith [ha.1]) (by linarith) + apply hw.trans + apply (mul_le_mul_of_nonneg_right hwbase (by positivity)).trans + have hmain : (N:ℝ)^(-s.re)*((N:ℝ)*A)= + C*(lam+1)^6*Real.exp ((1-s.re)*Real.log N- + (Real.log N)^3/((10^15:ℝ)*L^2)) := by + have hp : (N:ℝ)^(-s.re)*(N:ℝ)*(N:ℝ)^(-η)= + (N:ℝ)^(1-s.re-η) := by + calc + _ = (N:ℝ)^(-s.re+1)*(N:ℝ)^(-η) := by + rw [Real.rpow_add hN0,Real.rpow_one] + _ = _ := by rw [← Real.rpow_add hN0]; congr 1; ring + dsimp only [A] + calc + _ = C*(lam+1)^6*((N:ℝ)^(-s.re)*(N:ℝ)*(N:ℝ)^(-η)) := by ring + _ = C*(lam+1)^6*Real.exp ((1-s.re-η)*Real.log N) := by + rw [hp,Real.rpow_def_of_pos hN0] + congr 2 + ring + _ = _ := by + congr 2 + have he := halasz_log_cubic_identity hL (show 0 simp + | succ N ih => + rw [sum_Icc_succ_top (by omega : 1 ≤ N + 1), ih, Nat.factorial_succ, Nat.cast_mul, + Real.log_mul (by positivity) (by positivity)] + ring + +lemma halasz_sum_log_gap (N : ℕ) (hN : 1 ≤ N) : + (∑ n ∈ Icc 1 N, (Real.log (N : ℝ) - Real.log (n : ℝ))) ≤ N := by + rw [sum_sub_distrib, sum_const, nsmul_eq_mul, Nat.card_Icc, halasz_sum_log_factorial] + have hst := Stirling.le_log_factorial_stirling (Nat.ne_zero_of_lt hN) + have hlogN : 0 ≤ Real.log (N : ℝ) := Real.log_nonneg (by exact_mod_cast hN) + have hlogpi : 0 ≤ Real.log (2 * Real.pi) := Real.log_nonneg (by linarith [Real.two_le_pi]) + simp only [Nat.add_sub_cancel] at * + linarith + +lemma halasz_logarithmic_sum_error (f : ℕ → ℂ) (hf : OneBounded f) + (N : ℕ) (hN : 1 ≤ N) : + ‖(∑ n ∈ Icc 1 N, f n) * (Real.log (N : ℝ) : ℂ) - + ∑ n ∈ Icc 1 N, f n * (Real.log (n : ℝ) : ℂ)‖ ≤ (N : ℝ) := by + let S := ∑ n ∈ Icc 1 N, f n + let W := ∑ n ∈ Icc 1 N, f n * (Real.log (n : ℝ) : ℂ) + have he : S * (Real.log (N : ℝ) : ℂ) - W = + ∑ n ∈ Icc 1 N, f n * ((Real.log (N : ℝ) - Real.log (n : ℝ) : ℝ) : ℂ) := by + dsimp [S, W] + rw [sum_mul, ← sum_sub_distrib] + apply sum_congr rfl + intro n _ + push_cast + ring + rw [he] + apply (norm_sum_le _ _).trans + apply (sum_le_sum ?_).trans (halasz_sum_log_gap N hN) + intro n hn + have hn' := mem_Icc.mp hn + have hlog : 0 ≤ Real.log (N : ℝ) - Real.log (n : ℝ) := + sub_nonneg.mpr (Real.log_le_log (by exact_mod_cast hn'.1) (by exact_mod_cast hn'.2)) + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg hlog] + exact mul_le_of_le_one_left hlog (hf n hn'.1) + +theorem halasz_logarithmic_mean_bound (f : ℕ → ℂ) (hf : OneBounded f) + (N : ℕ) (hN : 1 ≤ N) : + Real.log (N : ℝ) * ‖∑ n ∈ Icc 1 N, f n‖ ≤ + ‖∑ n ∈ Icc 1 N, f n * (Real.log (n : ℝ) : ℂ)‖ + N := by + let S := ∑ n ∈ Icc 1 N, f n + let W := ∑ n ∈ Icc 1 N, f n * (Real.log (n : ℝ) : ℂ) + have hgap := halasz_logarithmic_sum_error f hf N hN + have hh := norm_add_le W (S * (Real.log (N : ℝ) : ℂ) - W) + have hlogN : 0 ≤ Real.log (N : ℝ) := Real.log_nonneg (by exact_mod_cast hN) + have hnorm : ‖S * (Real.log (N : ℝ) : ℂ)‖ = Real.log (N : ℝ) * ‖S‖ := by + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg hlogN, mul_comm] + rw [add_sub_cancel, hnorm] at hh + exact hh.trans (add_le_add le_rfl hgap) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogOscillation.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogOscillation.lean new file mode 100644 index 0000000000000000000000000000000000000000..f697ea40292045307dc52b57b28075b86f536b37 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogOscillation.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPhaseIntegral +import Mathlib.Analysis.Complex.RealDeriv + +namespace OAI + +/-! Calculus for the logarithmic phases in the sparse Dirichlet Gram +kernel. The linear frequency is kept real for the later Poisson sum. -/ + +namespace TwoPointCorrelations + +open MeasureTheory + +noncomputable def halaszLogPhase (u v x : ℝ) : ℂ := + Complex.exp (((u*Real.log x-v*x : ℝ):ℂ)*Complex.I) + +noncomputable def halaszLogSlope (u v x : ℝ) : ℝ := u/x-v + +noncomputable def halaszLogReciprocalDeriv (u v x : ℝ) : ℝ := + u/(x^2*(halaszLogSlope u v x)^2) + +lemma halasz_log_phase_norm (u v x : ℝ) : ‖halaszLogPhase u v x‖ = 1 := + Complex.norm_exp_ofReal_mul_I _ + +lemma halasz_log_phase_deriv (u v x : ℝ) (hx : x ≠ 0) : + HasDerivAt (halaszLogPhase u v) + (Complex.I*(halaszLogSlope u v x:ℂ)*halaszLogPhase u v x) x := by + have hf := ((Real.hasDerivAt_log hx).const_mul u).sub ((hasDerivAt_id x).const_mul v) + have hh := (hf.ofReal_comp.mul_const Complex.I).cexp + convert hh using 1 + · rfl + · dsimp only [halaszLogPhase, halaszLogSlope, Pi.sub_apply, id_eq] + simp only [mul_one] + push_cast + ring + +lemma halasz_log_reciprocal_deriv (u v x : ℝ) (hx : x ≠ 0) + (hd : halaszLogSlope u v x ≠ 0) : + HasDerivAt (fun y => (halaszLogSlope u v y)⁻¹) + (halaszLogReciprocalDeriv u v x) x := by + have hh := (((hasDerivAt_const x u).div (hasDerivAt_id x) hx).sub_const v).inv hd + convert hh using 1 + · rfl + · change u / (x^2*(u/x-v)^2) = -((0*x-u*1)/x^2)/(u/x-v)^2 + simp only [halaszLogSlope] at hd + field_simp [hx, hd] + ring + +lemma halasz_log_phase_primitive_deriv (u v x : ℝ) (hx : x ≠ 0) + (hd : halaszLogSlope u v x ≠ 0) : + HasDerivAt (fun y => -Complex.I * halaszLogPhase u v y * + ((halaszLogSlope u v y)⁻¹:ℝ)) + (halaszLogPhase u v x - Complex.I * halaszLogPhase u v x * + (halaszLogReciprocalDeriv u v x:ℂ)) x := by + have hh := ((halasz_log_phase_deriv u v x hx).const_mul (-Complex.I)).mul + (halasz_log_reciprocal_deriv u v x hx hd).ofReal_comp + convert hh using 1 + push_cast + have hd' : (halaszLogSlope u v x:ℂ) ≠ 0 := by exact_mod_cast hd + field_simp [hd'] + linear_combination (halaszLogPhase u v x) * Complex.I_sq + +lemma halasz_log_reciprocal_integral (u v a b : ℝ) (ha : 0 < a) (hab : a ≤ b) + (hd : ∀ x ∈ Set.Icc a b, halaszLogSlope u v x ≠ 0) : + (∫ x in a..b, halaszLogReciprocalDeriv u v x) = + (halaszLogSlope u v b)⁻¹-(halaszLogSlope u v a)⁻¹ := by + have hx (x : ℝ) (h : x ∈ Set.Icc a b) : x ≠ 0 := (ha.trans_le h.1).ne' + have hc : ContinuousOn (halaszLogReciprocalDeriv u v) (Set.Icc a b) := by + apply continuousOn_const.div + ((continuousOn_id.pow 2).mul (((continuousOn_const.div continuousOn_id hx).sub + continuousOn_const).pow 2)) + intro x h + exact mul_ne_zero (pow_ne_zero 2 (hx x h)) (pow_ne_zero 2 (hd x h)) + exact intervalIntegral.integral_eq_sub_of_hasDerivAt + (fun x h => halasz_log_reciprocal_deriv u v x + (hx x (by simpa only [Set.uIcc_of_le hab] using h)) + (hd x (by simpa only [Set.uIcc_of_le hab] using h))) + (hc.intervalIntegrable_of_Icc hab) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogPhase.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogPhase.lean new file mode 100644 index 0000000000000000000000000000000000000000..654b72f746fd4765d0b93f4ef0658dd3cada0887 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogPhase.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszBoundedLogPolynomial +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPhaseFromPolynomial + +namespace OAI + +/-! An absolute logarithmic phase estimate on every prefix of a dyadic block. +The only size restriction separates off finitely many small blocks. -/ +namespace TwoPointCorrelations + +open Finset Complex + +theorem halasz_log_phase_bound : ∃ C : ℝ, 1≤C ∧ ∀ N H : ℕ, + 1≤N → H≤N → ∀ a t lam : ℝ, a∈Set.Icc (0:ℝ) 1 → 49/100≤lam → + (N:ℝ)^(2/3:ℝ)≤(N:ℝ)/2 → |t|=(N:ℝ)^lam → + ‖∑ n∈range H,Complex.exp (Complex.I*((t*Real.log ((N:ℝ)+a+n):ℝ):ℂ))‖≤ + (N:ℝ)*(C*(lam+1)^6*(N:ℝ)^(-1/((10^15:ℝ)*lam^2)))+ + 4*(N:ℝ)^(2/3:ℝ) := by + obtain ⟨R₁,hR₁⟩ := halasz_bounded_log_polynomial + obtain ⟨R₂,hR₂⟩ := halasz_large_log_polynomial_saving + let R := max R₁ R₂ + let C : ℝ := (R+200:ℝ)^6 + have hC : 1≤C := by + dsimp only [C] + exact one_le_pow₀ (by have := (Nat.cast_nonneg R : (0:ℝ)≤R); linarith) + refine ⟨C,hC,?_⟩ + intro N H hN hH a t lam ha hlam hhalf ht + have hNR : 1≤(N:ℝ) := by exact_mod_cast hN + have hN0 : 0<(N:ℝ) := by linarith + have hlam0 : 0 (((b.val+1)^(j.val+1):ℕ):ℤ)))‖/(M:ℝ)^2 ≤ + (R₀+12*m+32:ℝ)^6*N^(-1/((10^8:ℝ)*lam^2)) := by + obtain ⟨R₀,hR⟩ := halasz_large_log_polynomial + refine ⟨R₀,?_⟩ + intro m hm M hM t z N lam hMN hz hzhi ht hscale hlo hhi + have h := hR m hm M hM t z N lam hMN hz hzhi ht hscale hlo hhi + have hC := halasz_moment_constant_root (k := 12*m) (by omega) R₀ + push_cast at hC + have hN : 1≤N := (show (1:ℝ)≤M by exact_mod_cast hM).trans hMN + have hb := neg_le_neg (halasz_large_root_saving hm hlo) + have he : -(m:ℝ)^2/(4*((2*halaszSelectedMoment (12*m)*halaszSelectedMoment (12*m):ℕ):ℝ)) ≤ + -1/((10^8:ℝ)*lam^2) := by simpa only [neg_div] using hb + push_cast at h he + exact h.trans (mul_le_mul hC (Real.rpow_le_rpow_of_exponent_le hN he) + (Real.rpow_nonneg (by linarith) _) (by positivity)) + +theorem halasz_single_log_polynomial_saving : ∃ R₀ : ℕ, ∀ k : ℕ, 2≤k → + ∀ M : ℕ, 1≤M → ∀ d : ℕ, 1≤d → d≤k → ∀ t z N lam q : ℝ, + (M:ℝ)≤N → N≤z → z≤2*N → |t|=N^lam → N^(1/3:ℝ)≤2*(M:ℝ) → + q+(k:ℝ)^2/1024≤min ((d:ℝ)/3) (min ((d:ℝ)-lam) (lam-(d:ℝ)/3)) → + ‖∑ b : Fin M,halaszVinogradovPolynomial k M + (halaszScaledFrequency (halaszLogCoefficient t z) + (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)))‖/(M:ℝ)^2 ≤ + (R₀+k+32:ℝ)^6*N^(-q/((2*halaszSelectedMoment k*halaszSelectedMoment k:ℕ):ℝ)) := by + obtain ⟨R₀,hR⟩ := halasz_selected_double_moment + refine ⟨R₀,?_⟩ + intro k hk M hM d hd hdk t z N lam q hMN hz hzhi ht hscale hsave + let r := halaszSelectedMoment k + let p := 2*r*r + let ε : ℝ := (k:ℝ)^2/1024 + let A := (32*(r:ℝ))^k*(R₀+k+32:ℝ)^(512*k^4) + let D := (halaszLogWeightCost k r)^k + have hr : 1≤r := halasz_selected_moment_pos hk + have hp : 0

(((b.val+1)^(j.val+1):ℕ):ℤ)))‖^p ≤ + A*(M:ℝ)^(((2*p:ℕ):ℝ)+ε)*D*N^(-(q+ε)) := by + convert hh using 1 + dsimp only [A,D,ε,r] + rw [hexp] + ring + have hroot := halasz_moment_transfer hp (by positivity) + (show 0≤A by dsimp only [A]; positivity) + (show 0≤D by dsimp only [D]; exact pow_nonneg (halasz_log_weight_cost_pos _ _).le _) + (show (1:ℝ)≤M by exact_mod_cast hM) hMN (by dsimp only [ε]; positivity) + (show ε-(q+ε)≤-q by linarith) hbound + exact hroot.trans (mul_le_mul_of_nonneg_right (halasz_moment_constant_root hk R₀) + (Real.rpow_nonneg hN0.le _)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogShiftBound.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogShiftBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..dda17410df6e7322c53145709ed773e69d1298cd --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLogShiftBound.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLogBilinear +import OAI.NumberTheory.TwoPoint.Halasz.HalaszShiftAveraging + +namespace OAI + +/-! From a normalized logarithmic polynomial bound to the actual ordinary +exponential sum, with both Taylor and shift-boundary errors retained. -/ +namespace TwoPointCorrelations + +open Complex Finset + +theorem halasz_log_shift_bound (k H M : ℕ) (hM : 1≤M) (t : ℝ) + {x A : ℝ} (hx : 0 (((b.val+1)^(j.val+1):ℕ):ℤ)))‖/(M:ℝ)^2≤A) : + ‖∑ n∈range H,Complex.exp (Complex.I*((t*Real.log (x+n):ℝ):ℂ))‖≤ + (H:ℝ)*(A+2*|t| *((M:ℝ)^2/x)^(k+1))+2*(M:ℝ)^2 := by + let f : ℕ → ℂ := fun n => Complex.exp (Complex.I*((t*Real.log (x+n):ℝ):ℂ)) + let T := 2*|t| *((M:ℝ)^2/x)^(k+1) + have hM0 : 0<(M:ℝ) := by exact_mod_cast (show 0 halasz_normalized_weight_nonneg γ j) (fun j _ => hw j) + _ = C^k*(M:ℝ)^(-(∑ j,w j)) := by + rw [prod_mul_distrib,prod_const,card_univ,Fintype.card_fin, + ← Real.rpow_sum_of_pos hM0, sum_neg_distrib] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLongShortCongruences.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLongShortCongruences.lean new file mode 100644 index 0000000000000000000000000000000000000000..58622861ec53d09266553b4452af9be857858629 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLongShortCongruences.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCongruenceEnergy + +namespace OAI + +/-! The congruence energy bound for the actual long/short monomial system. +No abstract analytic input occurs in this finite counting step. -/ +namespace TwoPointCorrelations + +open Finset Polynomial +open scoped Classical + +def halaszNatPowerFrequency {s N : ℕ} (k : ℕ) (x : Fin s → Fin N) : Fin k → ℕ := + fun j => ∑ i, ((x i).val+1)^(j.val+1) + +def halaszLongShortFrequency {s k N Q : ℕ} (p q : ℕ) + (x : (Fin k → Fin N) × (Fin s → Fin Q)) : Fin k → ℕ := + fun j => halaszNatPowerFrequency k x.1 j + + (p*q)^(j.val+1)*halaszNatPowerFrequency k x.2 j + +def halaszLongResidues {s k N Q : ℕ} (p r : ℕ) + (x : (Fin k → Fin N) × (Fin s → Fin Q)) : Fin k → ZMod (p^(r+1)) := + fun i => ((x.1 i).val+1:ℕ) + +lemma halasz_long_short_congruence {s k N Q : ℕ} (p q r : ℕ) + (x : (Fin k → Fin N) × (Fin s → Fin Q)) (j : Fin k) : + (∑ i, ((X^(j.val+1) : (ZMod (p^(r+1)))[X]).eval + (halaszLongResidues p r x i))).val % p^(min (j.val+1) (r+1)) = + halaszLongShortFrequency p q x j % p^(min (j.val+1) (r+1)) := by + have hcast : (∑ i, ((X^(j.val+1) : (ZMod (p^(r+1)))[X]).eval + (halaszLongResidues p r x i))) = + (halaszNatPowerFrequency k x.1 j : ZMod (p^(r+1))) := by + simp only [eval_pow,eval_X,halaszLongResidues,halaszNatPowerFrequency, + Nat.cast_sum,Nat.cast_pow] + rw [hcast,ZMod.val_natCast,Nat.mod_mod_of_dvd _ + (pow_dvd_pow p (Nat.min_le_right _ _))] + have hd : p^(min (j.val+1) (r+1)) ∣ + (p*q)^(j.val+1)*halaszNatPowerFrequency k x.2 j := by + apply dvd_mul_of_dvd_left + exact (pow_dvd_pow p (Nat.min_le_left _ _)).trans + (by rw [mul_pow]; exact dvd_mul_right _ _) + simp only [halaszLongShortFrequency,Nat.add_mod,Nat.mod_eq_zero_of_dvd hd, + add_zero,Nat.mod_mod] + +theorem halasz_long_short_congruence_energy {s k N Q p r : ℕ} [Fact p.Prime] + (hkp : k (((x.1 i).val+1:ℕ) : ZMod p))) : + halaszFiberEnergy F (halaszLongShortFrequency p q) ≤ + (k^k*p^((r+1)*r/2)) * halaszFiberEnergy F + (fun x => (halaszLongShortFrequency p q x,halaszLongResidues p r x)) := by + apply halasz_mixed_congruence_energy_triangular hkp hrk + (fun j => X^(j.val+1)) + · intro j + exact natDegree_X_pow_le _ + · intro j + simp + · intro x hx + simpa only [halaszLongResidues,map_natCast] using hF x hx + · exact fun x _ j => halasz_long_short_congruence p q r x j + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLongShortEnergy.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLongShortEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc7807e0a8ab4664ce337e63dd701cf14456f614 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszLongShortEnergy.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLongShortCongruences + +namespace OAI + +/-! Once the long variables agree modulo a prime power exceeding their +range, the remaining energy is the ordinary complete-system moment. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma halasz_nat_power_frequency_eq {s k N : ℕ} (x y : Fin s → Fin N) : + halaszNatPowerFrequency k y = halaszNatPowerFrequency k x ↔ + y ∈ halaszVinogradovFiber x k := by + rw [mem_halaszVinogradovFiber] + constructor + · intro h j hj + have hj1 := (mem_Icc.mp hj).1 + have hjk := (mem_Icc.mp hj).2 + have he := congrFun h (⟨j-1,by omega⟩ : Fin k) + simpa only [halaszNatPowerFrequency,Nat.sub_add_cancel hj1] using he.symm + · intro h + funext j + exact (h (j.val+1) (mem_Icc.mpr ⟨by omega,by omega⟩)).symm + +lemma halasz_nat_power_energy (s k N : ℕ) : + halaszFiberEnergy (univ : Finset (Fin s → Fin N)) (halaszNatPowerFrequency k) = + halaszVinogradovCount s k N := by + rw [halasz_fiber_energy_rows,halaszVinogradovCount] + apply sum_congr rfl + intro x _ + congr 1 + ext y + simp only [mem_filter,mem_univ,true_and,halasz_nat_power_frequency_eq] + +lemma halasz_long_residues_injective {s k N Q p r : ℕ} (hN : N (halaszLongShortFrequency p q x,halaszLongResidues p r x)) ≤ + N^k * halaszVinogradovCount s k Q := by + have he : halaszFiberEnergy F + (fun x => (halaszLongShortFrequency p q x,halaszLongResidues p r x)) = + halaszFiberEnergy F (fun x => (x.1,halaszNatPowerFrequency k x.2)) := by + apply halasz_fiber_energy_congr + intro x _ y _ + simp only [Prod.mk.injEq] + constructor + · rintro ⟨hf,hz⟩ + have hxy := halasz_long_residues_injective hN y x hz + refine ⟨hxy,?_⟩ + funext j + have hj := congrFun hf j + simp only [halaszLongShortFrequency,hxy] at hj + exact Nat.eq_of_mul_eq_mul_left (pow_pos (Nat.mul_pos hp hq) _) + (Nat.add_left_cancel hj) + · rintro ⟨hz,hf⟩ + constructor + · funext j + simp only [halaszLongShortFrequency,hz,hf] + · funext i + simp only [halaszLongResidues,hz] + rw [he] + calc + _ ≤ halaszFiberEnergy + ((univ : Finset (Fin k → Fin N)) ×ˢ (univ : Finset (Fin s → Fin Q))) + (fun x => (x.1,halaszNatPowerFrequency k x.2)) := + halasz_fiber_energy_mono (fun _ _ => mem_product.mpr ⟨mem_univ _,mem_univ _⟩) _ + _ = _ := by + rw [halasz_fiber_energy_product,halasz_nat_power_energy] + simp + +theorem halasz_nonsingular_long_short_energy {s k N Q p r : ℕ} [Fact p.Prime] + (hkp : k (((x.1 i).val+1:ℕ) : ZMod p))) : + halaszFiberEnergy F (halaszLongShortFrequency p q) ≤ + (k^k*p^((r+1)*r/2)) * (N^k*halaszVinogradovCount s k Q) := by + exact (halasz_long_short_congruence_energy hkp hrk q F hF).trans + (Nat.mul_le_mul_left _ (halasz_long_short_refined_energy + (Fact.out : p.Prime).pos q hq hN F)) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMeanValue.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMeanValue.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4a45ea9b929869577aa8c115b90ec1cdc10a094 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMeanValue.lean @@ -0,0 +1,109 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDoubleEstimate +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDoubleMean +import OAI.NumberTheory.TwoPoint.Halasz.HalaszNumericalErrors +import OAI.NumberTheory.TwoPoint.Halasz.HalaszSmoothBounds + +namespace OAI + +/-! An ordinary Halász mean estimate, with an absolute constant and +the logarithmic-height range needed in the MRT argument. -/ + +namespace TwoPointCorrelations + +open Finset Filter + +/-- Uniform ordinary mean estimate for completely multiplicative functions. +The distance lower bound is required only for |t| ≤ (log N)^8. -/ +theorem halasz_mean_value : ∃ C X₀ : ℝ, 0 < C ∧ + ∀ (N : ℕ), X₀ ≤ N → + ∀ (f : ℕ → ℂ), f 1 = 1 → + (∀ a b, 0 < a → 0 < b → f (a * b) = f a * f b) → OneBounded f → + ∀ (M : ℝ), 0 ≤ M → + (∀ t ∈ Set.Icc (-(Real.log (N : ℝ) ^ 8)) (Real.log (N : ℝ) ^ 8), + M ≤ squaredDistance f (mrtArchimedeanTwist t) N) → + ‖∑ n ∈ Icc 1 N, f n‖ ≤ C * N * + ((M + 1) * Real.exp (-M) + Real.log (Real.log N) / Real.log N) := by + obtain ⟨C₁, B, hC₁, hB, hdouble⟩ := halasz_double_convolution_estimate + obtain ⟨H₀, hH₀, hEuler⟩ := mrt_smooth_distance_bound + let H := max 1 H₀ + let D := 2 * C₁ * H + 8 * C₁ + (halaszDoubleErrorConstant + 12) + let C := 1 + C₁ * H + D + have hH : 1 ≤ H := le_max_left _ _ + have hH₀H : H₀ ≤ H := le_max_right _ _ + have hD : 0 ≤ D := by + dsimp [D] + have := halaszDoubleErrorConstant_nonneg + positivity + have hC : 0 < C := by dsimp [C]; positivity + obtain ⟨X₀, hX₀⟩ := eventually_atTop.mp (halasz_eventually_numeric_scale B) + obtain ⟨X₁, hX₁⟩ := eventually_atTop.mp + (Real.tendsto_log_atTop.eventually (eventually_ge_atTop (2 : ℝ))) + refine ⟨C, max X₀ X₁, hC, ?_⟩ + intro N hXN f hf1 hf hbound M hM hdist + obtain ⟨hNr, hll, hl4, hl16, hBT⟩ := hX₀ N ((le_max_left _ _).trans hXN) + have hN : 3 ≤ N := by exact_mod_cast hNr + have hN2 : 2 ≤ N := by omega + have hℓ2 : 2 ≤ Real.log (N : ℝ) := hX₁ N ((le_max_right _ _).trans hXN) + have hℓ : 1 ≤ Real.log (N : ℝ) := by linarith + have hℓ0 : 0 < Real.log (N : ℝ) := by linarith + have hl4N : Real.log (N : ℝ) ^ 4 ≤ N := + (pow_le_pow_right₀ hℓ (by norm_num : (4 : ℕ) ≤ 16)).trans (by linarith) + let m := ⌈(N : ℝ) / Real.log (N : ℝ) ^ 4⌉₊ + obtain ⟨hm, hmN, _, hml, hmu⟩ := halasz_smoothing_integer hN2 hl4 hl4N + have hglobal (t : ℝ) : + ‖LSeries (halaszSmoothFunction f N) (1 + (t : ℂ) * Complex.I)‖ ≤ + H * Real.log N := by + rw [halasz_smooth_LSeries] + have he := hEuler f hf1 hf hbound N hN2 t + have hd := halasz_distance_nonneg f hbound N t + have hx : Real.exp (-squaredDistance f (mrtArchimedeanTwist t) N) ≤ 1 := + Real.exp_le_one_iff.mpr (by linarith) + calc + _ ≤ H₀ * Real.log N * Real.exp (-squaredDistance f (mrtArchimedeanTwist t) N) := he + _ ≤ H₀ * Real.log N := by simpa only [mul_one] using + mul_le_mul_of_nonneg_left hx (by positivity : 0 ≤ H₀ * Real.log (N : ℝ)) + _ ≤ H * Real.log N := mul_le_mul_of_nonneg_right hH₀H hℓ0.le + have hcentral (t : ℝ) + (ht : t ∈ Set.Icc (-(Real.log (N : ℝ) ^ 8)) (Real.log (N : ℝ) ^ 8)) : + ‖LSeries (halaszSmoothFunction f N) (1 + (t : ℂ) * Complex.I)‖ ≤ + (H * Real.log N) * Real.exp (-M) := by + rw [halasz_smooth_LSeries] + apply (hEuler f hf1 hf hbound N hN2 t).trans + apply mul_le_mul + · exact mul_le_mul_of_nonneg_right hH₀H hℓ0.le + · exact Real.exp_le_exp.mpr (neg_le_neg (hdist t ht)) + · positivity + · positivity + have hb := hdouble f hf1 hf hbound N m (Real.log N ^ 16) (Real.log N ^ 8) + (H * Real.log N) (H * Real.log N) M hN2 hm hmN + (one_le_pow₀ hℓ) (by rw [← pow_mul]) hBT + (le_mul_of_one_le_left hℓ0.le hH) (by positivity) hM hcentral hglobal + have herr := halasz_numerical_errors hN hC₁.le (by linarith : 0 ≤ H) hℓ hm hml hmu + have hreduce := halasz_double_mean_log_sixteenth f hbound hf N hll (one_le_pow₀ hℓ) hl16 + have hsmall : (2 * C₁ * H + 8 * C₁) * N ≤ + (2 * C₁ * H + 8 * C₁) * N * Real.log (Real.log N) := + le_mul_of_one_le_right (by positivity) hll + have hmain : Real.log (N : ℝ) * ‖∑ n ∈ Icc 1 N, f n‖ ≤ + C₁ * N * (H * Real.log N) * (M + 1) * Real.exp (-M) + + D * N * Real.log (Real.log N) := by + dsimp [D] + linarith + have hdiv := div_le_div_of_nonneg_right hmain hℓ0.le + have heq : (C₁ * N * (H * Real.log N) * (M + 1) * Real.exp (-M) + + D * N * Real.log (Real.log N)) / Real.log N = + C₁ * H * N * ((M + 1) * Real.exp (-M)) + + D * N * (Real.log (Real.log N) / Real.log N) := by + field_simp + rw [mul_div_cancel_left₀ _ hℓ0.ne', heq] at hdiv + have hC₁H : C₁ * H ≤ C := by dsimp [C]; linarith + have hDC : D ≤ C := by dsimp [C]; linarith [show 0 ≤ C₁ * H by positivity] + calc + _ ≤ C₁ * H * N * ((M + 1) * Real.exp (-M)) + + D * N * (Real.log (Real.log N) / Real.log N) := hdiv + _ ≤ C * N * ((M + 1) * Real.exp (-M)) + + C * N * (Real.log (Real.log N) / Real.log N) := by gcongr + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedBounds.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..afa17504630a2f3e156141b31729ad009dff7570 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedBounds.lean @@ -0,0 +1,134 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMixedInner +import OAI.NumberTheory.TwoPoint.Halasz.HalaszGroupedBounds + +namespace OAI + +/-! Trivial estimates for the mixed prime convolution. The underlying +prime values and the bounded typical cofactor are different sequences. -/ + +namespace TwoPointCorrelations + +open Finset Complex +open scoped Classical + +noncomputable def halaszMixedGrouped (G B : ℕ → ℂ) (N : ℕ) (L : ℝ) + (P : Finset ℕ) : ℂ := + ∑ p ∈ P, (Real.log (p:ℝ):ℂ)*G p* + (halaszMixedPrimeConvolution G B (N/p) L ((N/p:ℕ):ℝ)/(Real.log ((N:ℝ)/p):ℂ)) + +lemma halasz_mixed_prime_term_bound (G B : ℕ → ℂ) (hG : OneBounded G) + (hB : OneBounded B) (N p : ℕ) (hp : p.Prime) : + ‖(Real.log (p:ℝ):ℂ)*G p*(∑ m ∈ Icc 1 (N/p), B m)‖ ≤ + (N:ℝ)*(Real.log (p:ℝ)/p) := by + have hp0 : (0:ℝ)

+ halasz_mixed_prime_term_bound G B hG hB N p (mrtPrimeBand_prime hp))) + _ ≤ (N:ℝ)*∑ p ∈ sievePrimesUpTo (N:ℝ), Real.log (p:ℝ)/p := by + apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg N) + exact sum_le_sum_of_subset_of_nonneg sdiff_subset (fun p hp _ => + div_nonneg (Real.log_nonneg (by exact_mod_cast + (sievePrimesUpTo_prime (N:ℝ) p hp).one_le)) (Nat.cast_nonneg p)) + _ ≤ _ := mul_le_mul_of_nonneg_left + (halasz_prime_prefix_mass_le (by exact_mod_cast hN)) (Nat.cast_nonneg N) + +lemma halasz_mixed_convolution_div_log (G B : ℕ → ℂ) (hG : OneBounded G) + (hB : OneBounded B) (L : ℝ) {M : ℕ} {y : ℝ} (hy : 2 ≤ y) (hMy : (M:ℝ) ≤ y) : + ‖halaszMixedPrimeConvolution G B M L M/(Real.log y:ℂ)‖ ≤ + (1+halaszMertensConstant/Real.log 2)*y := by + have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hlog : Real.log 2 ≤ Real.log y := Real.log_le_log (by norm_num) hy + have hly : 0 < Real.log y := htwo.trans_le hlog + have hC := halaszMertensConstant_nonneg + rw [norm_div,Complex.norm_real,Real.norm_eq_abs,abs_of_pos hly] + by_cases hM : M = 0 + · subst M + norm_num only [Nat.cast_zero] + have he : mrtPrimeBand L 0 = ∅ := by + apply eq_empty_iff_forall_notMem.mpr + intro p hp + have hle := sievePrimesUpTo_le 0 (by norm_num) p (mem_sdiff.mp hp).1 + have hpos : (0:ℝ)

halaszPrimePowerReduction p r (x i))) + (hmod : ∀ x∈F, ∀ j, + (∑ i, (P j).eval (x i)).val % (p^(min (j.val+1) (r+1))) = b j) : + F.card ≤ k^k * ∏ j : Fin k, p^(r+1-min (j.val+1) (r+1)) := by + classical + let T : (Fin k → ZMod (p^(r+1))) → (Fin k → ZMod (p^(r+1))) := + fun x j => ∑ i, (P j).eval (x i) + let S := F.image T + let R : Fin k → Finset (ZMod (p^(r+1))) := fun j => F.image (fun x => T x j) + have hR (j : Fin k) : (R j).card ≤ p^(r+1-min (j.val+1) (r+1)) := by + apply halasz_prime_power_residue_card (Nat.min_le_right _ _) (R j) + intro z hz + obtain ⟨x,hx,rfl⟩ := mem_image.mp hz + exact hmod x hx j + have hS : S ⊆ Fintype.piFinset R := by + intro t ht + obtain ⟨x,hx,rfl⟩ := mem_image.mp ht + apply Fintype.mem_piFinset.mpr + intro j + exact mem_image.mpr ⟨x,hx,rfl⟩ + have hcardS : S.card ≤ ∏ j : Fin k, p^(r+1-min (j.val+1) (r+1)) := by + calc + S.card ≤ (Fintype.piFinset R).card := card_le_card hS + _ = ∏ j, (R j).card := Fintype.card_piFinset R + _ ≤ _ := prod_le_prod (fun j _ => hR j) + have hfiber (t : Fin k → ZMod (p^(r+1))) : + (F.filter (fun y => T y=t)).card ≤ k^k := by + let B := F.filter (fun y => T y=t) + change B.card ≤ k^k + by_cases hB : B.Nonempty + · obtain ⟨w,hw⟩ := hB + apply halasz_prime_power_polynomial_count hkp P hdeg hunit w + (hnonsing w (mem_filter.mp hw).1) B + intro y hy j + have he : T w=T y := (mem_filter.mp hw).2.trans (mem_filter.mp hy).2.symm + exact congrFun he j + · simp only [not_nonempty_iff_eq_empty.mp hB,card_empty] + exact Nat.zero_le _ + calc + F.card = ∑ t∈S, (F.filter (fun y => T y=t)).card := card_eq_sum_card_image T F + _ ≤ ∑ _t∈S, k^k := sum_le_sum (fun t _ => hfiber t) + _ = S.card*k^k := by simp + _ ≤ (∏ j : Fin k, p^(r+1-min (j.val+1) (r+1)))*k^k := + Nat.mul_le_mul_right _ hcardS + _ = _ := Nat.mul_comm _ _ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedConvolution.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedConvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..95ad5a40184a2e1b906e0036d9457bb0c5cd485f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedConvolution.lean @@ -0,0 +1,156 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimeTruncation + +namespace OAI + +/-! Logarithmic convolution for a typical coefficient. Only multiplication +by primes above the deleted bands is used. The prime coefficient and the +remaining typical coefficient are kept distinct. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def halaszRawPrimeTerm (B : ℕ → ℂ) (N p : ℕ) : ℂ := + (Real.log (p:ℝ):ℂ) * ∑ m ∈ Icc 1 (N/p), B (p*m) + +noncomputable def halaszMixedPrimeConvolution (G B : ℕ → ℂ) (N : ℕ) (L U : ℝ) : ℂ := + ∑ p ∈ mrtPrimeBand L U, + (Real.log (p:ℝ):ℂ)*G p*(∑ m ∈ Icc 1 (N/p), B m) + +lemma halasz_raw_logarithmic_sum (B : ℕ → ℂ) (N : ℕ) : + (∑ n ∈ Icc 1 N, B n*(Real.log (n:ℝ):ℂ)) = + ∑ d ∈ Icc 1 N, (ArithmeticFunction.vonMangoldt d:ℂ)* + ∑ m ∈ Icc 1 (N/d), B (d*m) := by + calc + _ = ∑ n ∈ Icc 1 N, ∑ p ∈ n.divisorsAntidiagonal, + (ArithmeticFunction.vonMangoldt p.1:ℂ)*B (p.1*p.2) := by + apply sum_congr rfl + intro n _ + rw [Nat.sum_divisorsAntidiagonal (fun a b => + (ArithmeticFunction.vonMangoldt a:ℂ)*B (a*b))] + have he : (∑ d ∈ n.divisors, (ArithmeticFunction.vonMangoldt d:ℂ)*B n) = + B n*(Real.log (n:ℝ):ℂ) := by + rw [← sum_mul, ← Complex.ofReal_sum, ArithmeticFunction.vonMangoldt_sum] + ring + rw [← he] + apply sum_congr rfl + intro d hd + rw [Nat.mul_div_cancel' (Nat.mem_divisors.mp hd).1] + _ = ∑ p ∈ halaszHyperbola N, + (ArithmeticFunction.vonMangoldt p.1:ℂ)*B (p.1*p.2) := + halasz_sum_divisorsAntidiagonal + (fun a b => (ArithmeticFunction.vonMangoldt a:ℂ)*B (a*b)) N + _ = _ := by + rw [halasz_hyperbola_rows + (fun a b => (ArithmeticFunction.vonMangoldt a:ℂ)*B (a*b)) N] + apply sum_congr rfl + intro d _ + rw [mul_sum] + +lemma halasz_raw_row_bound (B : ℕ → ℂ) (hB : OneBounded B) + (N d : ℕ) (hd : 0 < d) : + ‖∑ m ∈ Icc 1 (N/d), B (d*m)‖ ≤ (N:ℝ)/d := by + have hdiv : ((N/d:ℕ):ℝ) ≤ (N:ℝ)/d := by + apply (le_div_iff₀ (show (0:ℝ) + hB (d*m) (Nat.mul_pos hd (mem_Icc.mp hm).1))) + _ = ((N/d:ℕ):ℝ) := by simp + _ ≤ _ := hdiv + +lemma halasz_raw_prime_term_bound (B : ℕ → ℂ) (hB : OneBounded B) + (N p : ℕ) (hp : p.Prime) : + ‖halaszRawPrimeTerm B N p‖ ≤ (N:ℝ)*(Real.log (p:ℝ)/p) := by + have hl : 0 ≤ Real.log (p:ℝ) := Real.log_nonneg (by exact_mod_cast hp.one_le) + rw [halaszRawPrimeTerm, norm_mul, Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg hl] + calc + _ ≤ Real.log (p:ℝ)*((N:ℝ)/p) := + mul_le_mul_of_nonneg_left (halasz_raw_row_bound B hB N p hp.pos) hl + _ = _ := by ring + +lemma halasz_raw_prime_power_error (B : ℕ → ℂ) (hB : OneBounded B) (N : ℕ) : + ‖(∑ n ∈ Icc 1 N, B n*(Real.log (n:ℝ):ℂ)) - + ∑ p ∈ (Icc 1 N).filter Nat.Prime, halaszRawPrimeTerm B N p‖ ≤ + (N:ℝ)*halaszPrimePowerConstant := by + rw [halasz_raw_logarithmic_sum, sum_filter, ← sum_sub_distrib] + have he (d:ℕ) : (ArithmeticFunction.vonMangoldt d:ℂ)* + (∑ m ∈ Icc 1 (N/d), B (d*m)) - + (if d.Prime then halaszRawPrimeTerm B N d else 0) = + (halaszPrimePowerWeight d:ℂ)*(∑ m ∈ Icc 1 (N/d), B (d*m)) := by + by_cases hd : d.Prime + · simp [hd,halaszRawPrimeTerm,halaszPrimePowerWeight, + ArithmeticFunction.vonMangoldt_apply_prime hd] + · simp [hd,halaszPrimePowerWeight] + simp_rw [he] + calc + _ ≤ ∑ d ∈ Icc 1 N, (N:ℝ)*(halaszPrimePowerWeight d/d) := by + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro d hd + have hw := halaszPrimePowerWeight_nonneg d + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg hw] + calc + _ ≤ halaszPrimePowerWeight d*((N:ℝ)/d) := + mul_le_mul_of_nonneg_left + (halasz_raw_row_bound B hB N d (mem_Icc.mp hd).1) hw + _ = _ := by ring + _ = (N:ℝ)*∑ d ∈ Icc 1 N, halaszPrimePowerWeight d/d := (mul_sum _ _ _).symm + _ ≤ _ := mul_le_mul_of_nonneg_left + (halaszPrimePowerWeight_summable.sum_le_tsum _ + (fun d _ => div_nonneg (halaszPrimePowerWeight_nonneg d) (Nat.cast_nonneg d))) + (Nat.cast_nonneg N) + +lemma halasz_raw_prime_band_error (B : ℕ → ℂ) (hB : OneBounded B) + (N : ℕ) {L : ℝ} (hL : 1 ≤ L) (hLN : L ≤ N) : + ‖(∑ p ∈ (Icc 1 N).filter Nat.Prime, halaszRawPrimeTerm B N p) - + ∑ p ∈ mrtPrimeBand L N, halaszRawPrimeTerm B N p‖ ≤ + (N:ℝ)*(Real.log L+halaszMertensConstant) := by + have hnat : (Icc 1 N).filter Nat.Prime = sievePrimesUpTo (N:ℝ) := by + ext p + simp only [mem_filter,mem_Icc,sievePrimesUpTo,Nat.floor_natCast,mem_Iic] + exact ⟨fun h => ⟨h.1.2,h.2⟩,fun h => ⟨⟨h.2.pos,h.1⟩,h.2⟩⟩ + rw [hnat, mrtPrimeBand, sum_sdiff_eq_sub (mrt_sievePrimesUpTo_mono hLN), + sub_sub_cancel] + calc + _ ≤ (N:ℝ)*∑ p ∈ sievePrimesUpTo L, Real.log (p:ℝ)/p := by + rw [mul_sum] + exact (norm_sum_le _ _).trans (sum_le_sum (fun p hp => + halasz_raw_prime_term_bound B hB N p (sievePrimesUpTo_prime L p hp))) + _ ≤ _ := mul_le_mul_of_nonneg_left (halasz_prime_prefix_mass_le hL) (Nat.cast_nonneg N) + +theorem halasz_mixed_logarithmic_approximation (G B : ℕ → ℂ) (hB : OneBounded B) + (N : ℕ) {L : ℝ} (hL : 1 ≤ L) (hLN : L ≤ N) + (hmul : ∀ p : ℕ, p.Prime → L < (p:ℝ) → ∀ m : ℕ, 0 < m → B (p*m)=G p*B m) : + ‖(∑ n ∈ Icc 1 N, B n*(Real.log (n:ℝ):ℂ)) - + halaszMixedPrimeConvolution G B N L N‖ ≤ + (N:ℝ)*(halaszPrimePowerConstant+Real.log L+halaszMertensConstant) := by + have hmixed : (∑ p ∈ mrtPrimeBand L N, halaszRawPrimeTerm B N p) = + halaszMixedPrimeConvolution G B N L N := by + unfold halaszMixedPrimeConvolution halaszRawPrimeTerm + apply sum_congr rfl + intro p hp + have hpl := (mrtPrimeBand_bounds (by linarith) (Nat.cast_nonneg N) hp).1 + rw [mul_assoc] + congr 1 + rw [mul_sum] + apply sum_congr rfl + intro m hm + exact hmul p (mrtPrimeBand_prime hp) hpl m (mem_Icc.mp hm).1 + have hp := halasz_raw_prime_power_error B hB N + have hl := halasz_raw_prime_band_error B hB N hL hLN + rw [hmixed] at hl + have hh := norm_add_le + ((∑ n ∈ Icc 1 N, B n*(Real.log (n:ℝ):ℂ)) - + ∑ p ∈ (Icc 1 N).filter Nat.Prime, halaszRawPrimeTerm B N p) + ((∑ p ∈ (Icc 1 N).filter Nat.Prime, halaszRawPrimeTerm B N p) - + halaszMixedPrimeConvolution G B N L N) + rw [sub_add_sub_cancel] at hh + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedDouble.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedDouble.lean new file mode 100644 index 0000000000000000000000000000000000000000..e72394ed348cb19fdb4653bd206a04f6040e8280 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedDouble.lean @@ -0,0 +1,109 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMixedInner +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDenominatorMass +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMixedBounds + +namespace OAI + +/-! Two logarithmic convolutions with a prime cutoff above every selected +typical band. No multiplicativity of the typical coefficient is asserted. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def halaszMixedDouble (G B : ℕ → ℂ) (N : ℕ) (R : ℝ) : ℂ := + halaszMixedGrouped G B N R (mrtPrimeBand R ((N:ℝ)/2)) + +noncomputable def halaszMixedErrorConstant (R : ℝ) : ℝ := + halaszPrimePowerConstant+Real.log R+halaszMertensConstant+1+Real.log 2 + +lemma halasz_mixed_error_nonneg {R : ℝ} (hR : 1 ≤ R) : + 0 ≤ halaszMixedErrorConstant R := by + have := halaszPrimePowerConstant_nonneg + have := halaszMertensConstant_nonneg + have := Real.log_nonneg hR + unfold halaszMixedErrorConstant + positivity + +theorem halasz_mixed_double_error (G B : ℕ → ℂ) (hG : OneBounded G) (hB : OneBounded B) + (N : ℕ) {R : ℝ} (hR : 1 ≤ R) + (hmul : ∀ p : ℕ, p.Prime → R < (p:ℝ) → ∀ m : ℕ, 0 < m → B (p*m)=G p*B m) : + ‖halaszMixedPrimeConvolution G B N R ((N:ℝ)/2)-halaszMixedDouble G B N R‖ ≤ + halaszMixedErrorConstant R*(N:ℝ)*∑ p ∈ mrtPrimeBand R ((N:ℝ)/2), + Real.log (p:ℝ)/((p:ℝ)*Real.log ((N:ℝ)/p)) := by + unfold halaszMixedPrimeConvolution halaszMixedDouble halaszMixedGrouped + rw [← sum_sub_distrib,mul_sum] + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro p hp + have hprime := mrtPrimeBand_prime hp + have hb := mrtPrimeBand_bounds (by linarith : 0 ≤ R) (by positivity : (0:ℝ)≤(N:ℝ)/2) hp + have hpN : 2*p ≤ N := by exact_mod_cast (show 2*(p:ℝ)≤N by linarith) + obtain ⟨hM,hMx,hxM⟩ := halasz_divisor_cutoff hprime.pos hpN + have hp0 : (0:ℝ)

+ halasz_mixed_prime_term_bound G B hG hB N p (mrtPrimeBand_prime hp))) + _ ≤ _ := mul_le_mul_of_nonneg_left + (halasz_upper_half_prime_mass (by linarith : (2:ℝ)≤N)) (Nat.cast_nonneg N) + +theorem halasz_mixed_double_mean (G B : ℕ → ℂ) (hG : OneBounded G) (hB : OneBounded B) + (N : ℕ) {R : ℝ} (hR : 1 ≤ R) (hRN : R ≤ (N:ℝ)/2) + (hmul : ∀ p : ℕ, p.Prime → R < (p:ℝ) → ∀ m : ℕ, 0 < m → B (p*m)=G p*B m) : + Real.log (N:ℝ)*‖∑ n ∈ Icc 1 N, B n‖ ≤ ‖halaszMixedDouble G B N R‖ + + (N:ℝ)*((halaszPrimePowerConstant+Real.log R+3*halaszMertensConstant+1+Real.log 2)+ + halaszMixedErrorConstant R*(Real.log (Real.log N)-Real.log (Real.log 2)+ + 2*halaszMertensConstant/Real.log 2)) := by + have hN : 1 ≤ N := by exact_mod_cast (show (1:ℝ)≤N by linarith) + have hp := halasz_mixed_prefix_log G B hB N hN hR hmul + have hu := halasz_mixed_upper_truncation G B hG hB N hR hRN + have hd := halasz_mixed_double_error G B hG hB N hR hmul + have hm := mul_le_mul_of_nonneg_left (halasz_denominator_prime_mass hR hRN) + (mul_nonneg (halasz_mixed_error_nonneg hR) (Nat.cast_nonneg N)) + have hn := norm_add_le (halaszMixedDouble G B N R) + (halaszMixedPrimeConvolution G B N R ((N:ℝ)/2)-halaszMixedDouble G B N R) + rw [add_sub_cancel] at hn + have ht := norm_add_le (halaszMixedPrimeConvolution G B N R ((N:ℝ)/2)) + (halaszMixedPrimeConvolution G B N R N-halaszMixedPrimeConvolution G B N R ((N:ℝ)/2)) + rw [add_sub_cancel] at ht + have hs := norm_add_le (halaszMixedPrimeConvolution G B N R N) + ((∑ n ∈ Icc 1 N, B n)*(Real.log (N:ℝ):ℂ)-halaszMixedPrimeConvolution G B N R N) + rw [add_sub_cancel,norm_mul,Complex.norm_real,Real.norm_eq_abs, + abs_of_nonneg (Real.log_nonneg (by exact_mod_cast hN))] at hs + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedEstimate.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedEstimate.lean new file mode 100644 index 0000000000000000000000000000000000000000..281785ec3e3b65eeb51f4c869c6244dc25633f23 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedEstimate.lean @@ -0,0 +1,139 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMixedGrouped +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMixedDouble +import OAI.NumberTheory.TwoPoint.Halasz.HalaszBandSummation + +namespace OAI + +/-! The mixed double-convolution estimate with its actual cutoff. The +typical smooth series supplies the central bound; the logarithmic +prime blocks retain summable error weights. -/ + +namespace TwoPointCorrelations + +open Finset Complex +open scoped Classical + +theorem halasz_mixed_double_estimate : ∃ C T₀ : ℝ, 0 < C ∧ 2 ≤ T₀ ∧ + ∀ (G B : ℕ → ℂ), OneBounded G → OneBounded B → + ∀ (N m : ℕ) (R T V W M : ℝ), 2 ≤ N → 0 < m → m ≤ N → + 1 ≤ R → T ^ 2 ≤ R → T₀ ≤ T → Real.log N ≤ V → 0 ≤ W → 0 ≤ M → + (∀ t ∈ Set.Icc (-T) T, + ‖LSeries (halaszSmoothFunction B N) (1 + (t : ℂ) * I)‖ ≤ V * Real.exp (-M)) → + (∀ t : ℝ, ‖LSeries (halaszSmoothFunction B N) (1 + (t : ℂ) * I)‖ ≤ W) → + ‖halaszMixedDouble G B N R‖ ≤ + C * N * V * (M + 1) * Real.exp (-M) + + C * N * W * Real.log N / (((m : ℝ) / ((N : ℝ) + 1 / 2)) * T) + + C * m * Real.log (3 * N) ^ 2 := by + obtain ⟨C₁, T₀, hC₁, hT₀, hanalytic⟩ := halasz_mixed_grouped_estimate + obtain ⟨C₂, hC₂, htrivial⟩ := halasz_mixed_grouped_trivial + obtain ⟨K, hK, hgeometric⟩ := halasz_band_saving_sum + let D := C₁ + C₂ + let C := 1 + D * K + 2 * D + 2 / Real.log 2 + have hD : 0 < D := add_pos hC₁ hC₂ + have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hC : 0 < C := by dsimp [C]; positivity + refine ⟨C, T₀, hC, hT₀, ?_⟩ + intro G B hG hB N m R T V W M hN hm hmN hR hTR hBT hNV hW hM hFA hFW + let P := mrtPrimeBand R ((N : ℝ) / 2) + let J := halaszBandIndex (Real.log (N : ℝ)) + 1 + let A := V * Real.exp (-M) + let δ := (m : ℝ) / ((N : ℝ) + 1 / 2) + have hN0 : (0 : ℝ) < N := by exact_mod_cast (by omega : 0 < N) + have hNlog : Real.log 2 ≤ Real.log (N : ℝ) := + Real.log_le_log (by norm_num) (by exact_mod_cast hN) + have hlog0 : 0 < Real.log (N : ℝ) := htwo.trans_le hNlog + have hV : 0 ≤ V := hlog0.le.trans hNV + have hA : 0 ≤ A := by dsimp [A]; positivity + have hT : 0 < T := lt_of_lt_of_le (by linarith : (0 : ℝ) < T₀) hBT + have hδ : 0 < δ := by dsimp [δ]; positivity + have hC₁D : C₁ ≤ D := by dsimp [D]; linarith + have hC₂D : C₂ ≤ D := by dsimp [D]; linarith + have hPl (p : ℕ) (hp : p ∈ P) : p.Prime := mrtPrimeBand_prime hp + have hpbounds (p : ℕ) (hp : p ∈ P) : Real.log 2 ≤ Real.log ((N : ℝ) / p) ∧ + Real.log ((N : ℝ) / p) ≤ Real.log (N : ℝ) := by + have hp0 : (0 : ℝ) < p := by exact_mod_cast (hPl p hp).pos + have hb := mrtPrimeBand_bounds (show 0 ≤ R by linarith) (by positivity) hp + have hquot : (2 : ℝ) ≤ (N : ℝ) / p := (le_div_iff₀ hp0).mpr (by linarith) + exact ⟨Real.log_le_log (by norm_num) hquot, + Real.log_le_log (div_pos hN0 hp0) (div_le_self hN0.le (by exact_mod_cast (hPl p hp).one_le))⟩ + have hpart : halaszMixedDouble G B N R = + ∑ j ∈ range J, halaszMixedGrouped G B N R (halaszPrimeBandPart P N j) := by + exact halasz_prime_band_partition P (fun p hp => (hpbounds p hp).2) _ + have hpiece (j : ℕ) : ‖halaszMixedGrouped G B N R (halaszPrimeBandPart P N j)‖ ≤ + D * N * min A (halaszBandScale j) + + D * N * halaszBandScale j * W / (δ * T) + + (m : ℝ) / halaszBandScale j * Real.log (3 * N) ^ 2 := by + let v := halaszBandScale j + have hv : Real.log 2 ≤ v := halasz_band_scale_ge_log_two j + have hv0 : 0 < v := htwo.trans_le hv + have hPb : ∀ p ∈ halaszPrimeBandPart P N j, p.Prime ∧ + v ≤ Real.log ((N : ℝ) / p) ∧ Real.log ((N : ℝ) / p) < 2 * v := by + intro p hp + exact ⟨hPl p (mem_filter.mp hp).1, + halasz_prime_band_part_bounds P (fun p hp => (hpbounds p hp).1) hp⟩ + have hPbig : ∀ p ∈ halaszPrimeBandPart P N j, p.Prime ∧ T ^ 2 ≤ (p : ℝ) ∧ + v ≤ Real.log ((N : ℝ) / p) ∧ Real.log ((N : ℝ) / p) < 2 * v := by + intro p hp + have hpp := (mem_filter.mp hp).1 + have hb := mrtPrimeBand_bounds (show 0 ≤ R by linarith) (by positivity) hpp + exact ⟨(hPb p hp).1, hTR.trans hb.1.le, (hPb p hp).2⟩ + have ht := htrivial G B hG hB N R v (by omega) hv _ hPb + have ha := hanalytic G B hG hB N m R v T A W (by linarith) hN hm hmN hv hBT hA hW _ hPbig hFA hFW + have htD : ‖halaszMixedGrouped G B N R (halaszPrimeBandPart P N j)‖ ≤ D * N * v := + ht.trans (by gcongr) + have haD : ‖halaszMixedGrouped G B N R (halaszPrimeBandPart P N j)‖ ≤ + D * N * A + D * N * v * W / (δ * T) + (m : ℝ) / v * Real.log (3 * N) ^ 2 := + ha.trans (by gcongr) + change ‖halaszMixedGrouped G B N R (halaszPrimeBandPart P N j)‖ ≤ + D * N * min A v + D * N * v * W / (δ * T) + (m : ℝ) / v * Real.log (3 * N) ^ 2 + by_cases hvA : v ≤ A + · rw [min_eq_right hvA] + have herr : 0 ≤ D * N * v * W / (δ * T) + (m : ℝ) / v * Real.log (3 * N) ^ 2 := by positivity + linarith + · rw [min_eq_left (le_of_not_ge hvA)] + exact haD + have htop : halaszBandScale J ≤ 2 * Real.log (N : ℝ) := by + have hb := (halasz_band_scale_bounds hNlog).1 + have he : halaszBandScale J = 2 * halaszBandScale (halaszBandIndex (Real.log (N : ℝ))) := by + dsimp [J, halaszBandScale] + rw [pow_succ] + ring + rw [he] + linarith + have hmin := hgeometric J V M hV hM (htop.trans (by linarith)) + have hscales := (halasz_band_scale_sum_le J).trans htop + have hinverses := halasz_band_inverse_sum_le J + have hsum : ‖halaszMixedDouble G B N R‖ ≤ + (D * N) * (∑ j ∈ range J, min A (halaszBandScale j)) + + (D * N * W / (δ * T)) * (∑ j ∈ range J, halaszBandScale j) + + ((m : ℝ) * Real.log (3 * N) ^ 2) * (∑ j ∈ range J, (halaszBandScale j)⁻¹) := by + rw [hpart] + apply (norm_sum_le _ _).trans + apply (sum_le_sum (fun j _ => hpiece j)).trans_eq + simp only [mul_sum, ← sum_add_distrib] + apply sum_congr rfl + intro j _ + ring + have hc1 : D * K ≤ C := by + dsimp [C] + linarith [show 0 ≤ 2 / Real.log 2 by positivity] + have hc2 : 2 * D ≤ C := by + dsimp [C] + linarith [show 0 ≤ D * K by positivity, show 0 ≤ 2 / Real.log 2 by positivity] + have hc3 : 2 / Real.log 2 ≤ C := by + dsimp [C] + linarith [show 0 ≤ D * K by positivity] + calc + _ ≤ _ := hsum + _ ≤ (D * N) * (K * V * (M + 1) * Real.exp (-M)) + + (D * N * W / (δ * T)) * (2 * Real.log (N : ℝ)) + + ((m : ℝ) * Real.log (3 * N) ^ 2) * (2 / Real.log 2) := by + gcongr + _ = (D * K) * N * V * (M + 1) * Real.exp (-M) + + (2 * D) * N * W * Real.log N / (δ * T) + + (2 / Real.log 2) * m * Real.log (3 * N) ^ 2 := by ring + _ ≤ _ := by gcongr + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedGrouped.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedGrouped.lean new file mode 100644 index 0000000000000000000000000000000000000000..215e6b87122fbb894e6fea6b2b9d821a64275920 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedGrouped.lean @@ -0,0 +1,163 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMixedTriplePrefix +import OAI.NumberTheory.TwoPoint.Fourier.ModFivePsiDecay + +namespace OAI + +/-! The Perron estimate for one mixed logarithmic prime block. Both prime +factors avoid the small deleted bands; the smooth coefficient retains +the literal typical mask. -/ + +namespace TwoPointCorrelations + +open Finset Complex +open scoped Classical LSeries.notation + +theorem halasz_mixed_grouped_estimate : ∃ C T₀ : ℝ, 0 < C ∧ 2 ≤ T₀ ∧ + ∀ (G B : ℕ → ℂ), OneBounded G → OneBounded B → + ∀ (N m : ℕ) (R v T A W : ℝ), 0 ≤ R → 2 ≤ N → 0 < m → m ≤ N → Real.log 2 ≤ v → + T₀ ≤ T → 0 ≤ A → 0 ≤ W → + ∀ (P : Finset ℕ), (∀ p ∈ P, p.Prime ∧ T ^ 2 ≤ (p : ℝ) ∧ + v ≤ Real.log ((N : ℝ) / p) ∧ Real.log ((N : ℝ) / p) < 2 * v) → + (∀ t ∈ Set.Icc (-T) T, ‖LSeries (halaszSmoothFunction B N) (1 + (t : ℂ) * I)‖ ≤ A) → + (∀ t : ℝ, ‖LSeries (halaszSmoothFunction B N) (1 + (t : ℂ) * I)‖ ≤ W) → + ‖halaszMixedGrouped G B N R P‖ ≤ C * N * A + + C * N * v * W / (((m : ℝ) / ((N : ℝ) + 1 / 2)) * T) + + (m : ℝ) / v * Real.log (3 * N) ^ 2 := by + obtain ⟨C₀, T₀, hC₀, hT₀, htriple⟩ := halasz_bounded_prime_triple_estimate + obtain ⟨K, hK, hweights⟩ := halasz_band_mean_square_weights + let U := 1 + 2 * halaszMertensConstant / Real.log 2 + let V := 2 + halaszMertensConstant / Real.log 2 + let C := 2 * C₀ * K + 80 * U * V + have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hM := halaszMertensConstant_nonneg + have hU : 0 < U := by dsimp [U]; positivity + have hV : 0 < V := by dsimp [V]; positivity + have hC : 0 < C := by dsimp [C]; positivity + refine ⟨C, T₀, hC, hT₀, ?_⟩ + intro G B hG hB N m R v T A W hL hN hm hmN hv hBT hA hW P hP hFA hFW + let x : ℝ := (N : ℝ) + 1 / 2 + let Q := mrtPrimeBand R (Real.exp (2 * v)) + let a := fun p : ℕ => G p / (Real.log ((N : ℝ) / p) : ℂ) + have hN0 : (0 : ℝ) < N := by exact_mod_cast (by omega : 0 < N) + have hx : 0 < x := by dsimp [x]; positivity + have hxle : x ≤ 2 * N := by + have hNr : (2 : ℝ) ≤ N := by exact_mod_cast hN + dsimp [x] + linarith + have hv0 : 0 < v := htwo.trans_le hv + have hT : 0 < T := lt_of_lt_of_le (by linarith : (0 : ℝ) < T₀) hBT + have hmR : (0 : ℝ) < m := by exact_mod_cast hm + have hmle : (m : ℝ) ≤ x := by + have hmr : (m : ℝ) ≤ N := by exact_mod_cast hmN + dsimp [x] + linarith + have hPl : ∀ p ∈ P, p.Prime := fun p hp => (hP p hp).1 + have hPb : ∀ p ∈ P, p.Prime ∧ v ≤ Real.log ((N : ℝ) / p) ∧ + Real.log ((N : ℝ) / p) < 2 * v := fun p hp => ⟨(hP p hp).1, (hP p hp).2.2⟩ + have hQl : ∀ q ∈ Q, q.Prime := fun _ hq => mrtPrimeBand_prime hq + have hQb : ∀ q ∈ Q, q.Prime ∧ (q : ℝ) ≤ Real.exp (2 * v) := fun q hq => + ⟨hQl q hq, (mrtPrimeBand_bounds hL (Real.exp_pos _).le hq).2⟩ + have hPsub : P ⊆ Icc 1 N := by + intro p hp + have he := (halasz_log_band_endpoints hN0 (hPl p hp) (hP p hp).2.2.1 (hP p hp).2.2.2).2 + have hdiv : (N : ℝ) / Real.exp v ≤ N := + div_le_self hN0.le (Real.one_le_exp_iff.mpr hv0.le) + exact mem_Icc.mpr ⟨(hPl p hp).pos, by exact_mod_cast he.trans hdiv⟩ + have hcover : ∀ p ∈ P, ∀ q, q.Prime → q ≤ N / p → (q ∈ Q ↔ R < (q:ℝ)) := by + intro p hp q hq hqN + have hp0 : (0 : ℝ) < p := by exact_mod_cast (hPl p hp).pos + have hcut : ((N / p : ℕ) : ℝ) ≤ (N : ℝ) / p := by + apply (le_div_iff₀ hp0).mpr + exact_mod_cast Nat.div_mul_le_self N p + have hy0 : 0 < (N : ℝ) / p := div_pos hN0 hp0 + have hupper := (Real.log_lt_iff_lt_exp hy0).mp (hP p hp).2.2.2 + have hqr : (q : ℝ) ≤ Real.exp (2 * v) := (by exact_mod_cast hqN : (q : ℝ) ≤ ((N / p : ℕ) : ℝ)).trans + (hcut.trans hupper.le) + constructor + · intro hmem + exact (mrtPrimeBand_bounds hL (Real.exp_pos _).le hmem).1 + · intro hlarge + apply mem_sdiff.mpr + refine ⟨mem_filter.mpr ⟨mem_Iic.mpr + ((Nat.le_floor_iff (Real.exp_pos _).le).mpr hqr),hq⟩,?_⟩ + intro hsmall + exact (not_le_of_gt hlarge) (sievePrimesUpTo_le R hL q hsmall) + have ha : ∀ p ∈ P, ‖a p‖ ≤ v⁻¹ := fun p hp => + halasz_adaptive_coefficient_bound G hG hv0 (hPl p hp).pos (hP p hp).2.2.1 + have hb : ∀ q ∈ Q, ‖G q‖ ≤ 1 := fun q hq => hG q (hQl q hq).pos + have hestimate := htriple B hB N x T A W (v⁻¹) m hx hm hmle + (modFive_half_cutoff_nonnat N) hBT hA hW (inv_nonneg.mpr hv0.le) P Q + (fun p hp => ⟨(hP p hp).1, (hP p hp).2.1⟩) hQl a G ha hb hFA hFW + have heqa : (fun p : ℕ => (Real.log (p : ℝ) : ℂ) * a p) = + fun p : ℕ => (Real.log (p : ℝ) : ℂ) * G p / (Real.log ((N : ℝ) / p) : ℂ) := by + funext p + dsimp [a] + ring + rw [show ⌊x⌋₊ = N from modFive_half_cutoff_floor N, heqa, + halasz_mixed_grouped_triple_prefix G B N hL P Q hPsub hQl hcover] at hestimate + have hweight := hweights G hG N v hN0 hv P Q hPb hQb + have hpMass : (∑ p ∈ P, Real.log (p : ℝ) / p) ≤ U * v := + halasz_log_band_mass_linear hN0 hv P hPb + have hqMass : (∑ q ∈ Q, Real.log (q : ℝ) / q) ≤ V * v := by + have hq := halasz_prime_set_mass_le (Y := Real.exp (2 * v)) + (Real.one_le_exp_iff.mpr (by linarith)) Q hQb + rw [Real.log_exp] at hq + have hscale := mul_le_mul_of_nonneg_left hv + (show 0 ≤ halaszMertensConstant / Real.log 2 from div_nonneg hM htwo.le) + rw [div_mul_cancel₀ _ htwo.ne'] at hscale + dsimp [V] + linarith + have hp0 : 0 ≤ ∑ p ∈ P, Real.log (p : ℝ) / p := sum_nonneg (fun p hp => + div_nonneg (Real.log_nonneg (by exact_mod_cast (hPl p hp).one_le)) (Nat.cast_nonneg _)) + have hq0 : 0 ≤ ∑ q ∈ Q, Real.log (q : ℝ) / q := sum_nonneg (fun q hq => + div_nonneg (Real.log_nonneg (by exact_mod_cast (hQl q hq).one_le)) (Nat.cast_nonneg _)) + have hsmall : v⁻¹ * (∑ p ∈ P, Real.log (p : ℝ) / p) ≤ U := by + apply (mul_le_mul_of_nonneg_left hpMass (inv_nonneg.mpr hv0.le)).trans_eq + field_simp + have hprod : (v⁻¹ * ∑ p ∈ P, Real.log (p : ℝ) / p) * + (∑ q ∈ Q, Real.log (q : ℝ) / q) ≤ U * (V * v) := + mul_le_mul hsmall hqMass hq0 hU.le + have hlog : Real.log (x + m) ^ 2 ≤ Real.log (3 * N) ^ 2 := by + have hmr : (m : ℝ) ≤ N := by exact_mod_cast hmN + have hNr : (2 : ℝ) ≤ N := by exact_mod_cast hN + apply pow_le_pow_left₀ (Real.log_nonneg (by dsimp [x]; linarith)) + exact Real.log_le_log (by positivity) (by dsimp [x]; linarith) + have hcmain : 2 * C₀ * K ≤ C := by + dsimp [C] + linarith [show 0 ≤ 80 * U * V by positivity] + have hctail : 80 * U * V ≤ C := by + dsimp [C] + linarith [show 0 ≤ 2 * C₀ * K by positivity] + change ‖halaszMixedGrouped G B N R P‖ ≤ _ at hestimate ⊢ + calc + _ ≤ _ := hestimate + _ ≤ (C₀ * (2 * N) * A) * K + + 40 * (2 * N) * (U * (V * v)) * W / ((m / x) * T) + + v⁻¹ * Real.log (3 * N) ^ 2 * m := by + apply add_le_add + · apply add_le_add + · calc + _ ≤ (C₀ * x * A) * K := mul_le_mul_of_nonneg_left hweight (by positivity) + _ ≤ _ := by gcongr + · calc + _ = (40 * x * W / ((m / x) * T)) * + ((v⁻¹ * ∑ p ∈ P, Real.log (p : ℝ) / p) * + (∑ q ∈ Q, Real.log (q : ℝ) / q)) := by ring + _ ≤ (40 * x * W / ((m / x) * T)) * (U * (V * v)) := + mul_le_mul_of_nonneg_left hprod (by positivity) + _ ≤ (40 * (2 * N) * W / ((m / x) * T)) * (U * (V * v)) := by + gcongr + _ = _ := by ring + · exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hlog (inv_nonneg.mpr hv0.le)) (Nat.cast_nonneg m) + _ ≤ C * N * A + C * N * v * W / ((m / x) * T) + + (m : ℝ) / v * Real.log (3 * N) ^ 2 := by + have hfirst := mul_le_mul_of_nonneg_right hcmain (show 0 ≤ (N : ℝ) * A by positivity) + have hlast := mul_le_mul_of_nonneg_right hctail + (show 0 ≤ (N : ℝ) * v * W / ((m / x) * T) by positivity) + ring_nf at hfirst hlast ⊢ + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedInner.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedInner.lean new file mode 100644 index 0000000000000000000000000000000000000000..358fed39fc97cc7f495d793c10f12668e2e50583 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedInner.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMixedConvolution + +namespace OAI + +/-! The inner logarithmic approximation for the actual typical sequence. +The same estimate covers cofactors shorter than the deleted-prime cutoff. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma halasz_mixed_logarithmic_approximation_all (G B : ℕ → ℂ) (hB : OneBounded B) + (N : ℕ) (_hN : 1 ≤ N) {L : ℝ} (hL : 1 ≤ L) + (hmul : ∀ p : ℕ, p.Prime → L < (p:ℝ) → ∀ m : ℕ, 0 < m → B (p*m)=G p*B m) : + ‖(∑ n ∈ Icc 1 N, B n*(Real.log (n:ℝ):ℂ)) - + halaszMixedPrimeConvolution G B N L N‖ ≤ + (N:ℝ)*(halaszPrimePowerConstant+Real.log L+halaszMertensConstant) := by + by_cases hLN : L ≤ (N:ℝ) + · exact halasz_mixed_logarithmic_approximation G B hB N hL hLN hmul + have hNL : (N:ℝ) < L := lt_of_not_ge hLN + have hempty : mrtPrimeBand L N = ∅ := by + apply eq_empty_iff_forall_notMem.mpr + intro p hp + have hb := mrtPrimeBand_bounds (by linarith : 0 ≤ L) (Nat.cast_nonneg N) hp + linarith + simp only [halaszMixedPrimeConvolution,hempty,sum_empty,sub_zero] + have hc := halaszPrimePowerConstant_nonneg + have hm := halaszMertensConstant_nonneg + have hlogL : 0 ≤ Real.log L := Real.log_nonneg hL + calc + _ ≤ ∑ n ∈ Icc 1 N, Real.log L := by + apply (norm_sum_le _ _).trans + apply sum_le_sum + intro n hn + have hn1 := (mem_Icc.mp hn).1 + have hln : 0 ≤ Real.log (n:ℝ) := Real.log_nonneg (by exact_mod_cast hn1) + rw [norm_mul,Complex.norm_real,Real.norm_eq_abs,abs_of_nonneg hln] + apply (mul_le_of_le_one_left hln (hB n hn1)).trans + apply Real.log_le_log (by exact_mod_cast hn1) + exact (show (n:ℝ) ≤ N by exact_mod_cast (mem_Icc.mp hn).2).trans hNL.le + _ = (N:ℝ)*Real.log L := by simp + _ ≤ _ := by nlinarith [Nat.cast_nonneg (α:=ℝ) N] + +lemma halasz_mixed_prefix_log (G B : ℕ → ℂ) (hB : OneBounded B) + (N : ℕ) (hN : 1 ≤ N) {L : ℝ} (hL : 1 ≤ L) + (hmul : ∀ p : ℕ, p.Prime → L < (p:ℝ) → ∀ m : ℕ, 0 < m → B (p*m)=G p*B m) : + ‖(∑ n ∈ Icc 1 N, B n)*(Real.log (N:ℝ):ℂ) - + halaszMixedPrimeConvolution G B N L N‖ ≤ + (halaszPrimePowerConstant+Real.log L+halaszMertensConstant+1)*(N:ℝ) := by + have he := halasz_logarithmic_sum_error B hB N hN + have hp := halasz_mixed_logarithmic_approximation_all G B hB N hN hL hmul + have ht := norm_add_le + ((∑ n ∈ Icc 1 N, B n)*(Real.log (N:ℝ):ℂ) - + ∑ n ∈ Icc 1 N, B n*(Real.log (n:ℝ):ℂ)) + ((∑ n ∈ Icc 1 N, B n*(Real.log (n:ℝ):ℂ)) - + halaszMixedPrimeConvolution G B N L N) + rw [sub_add_sub_cancel] at ht + nlinarith + +lemma halasz_mixed_real_log_approximation (G B : ℕ → ℂ) (hB : OneBounded B) + (N : ℕ) (hN : 1 ≤ N) {L : ℝ} (hL : 1 ≤ L) + (hmul : ∀ p : ℕ, p.Prime → L < (p:ℝ) → ∀ m : ℕ, 0 < m → B (p*m)=G p*B m) + {x : ℝ} (hNx : (N:ℝ) ≤ x) (hxN : x ≤ 2*N) : + ‖(∑ n ∈ Icc 1 N, B n)*(Real.log x:ℂ) - + halaszMixedPrimeConvolution G B N L N‖ ≤ + (halaszPrimePowerConstant+Real.log L+halaszMertensConstant+1+Real.log 2)*x := by + have hN0 : (0:ℝ) < N := by exact_mod_cast hN + have hx0 : 0 < x := hN0.trans_le hNx + have hgap0 : 0 ≤ Real.log x-Real.log (N:ℝ) := + sub_nonneg.mpr (Real.log_le_log hN0 hNx) + have hgap2 : Real.log x-Real.log (N:ℝ) ≤ Real.log 2 := by + have hh := Real.log_le_log hx0 hxN + rw [Real.log_mul (by norm_num : (2:ℝ)≠0) hN0.ne'] at hh + linarith + have he : (∑ n ∈ Icc 1 N, B n)*(Real.log x:ℂ) - + halaszMixedPrimeConvolution G B N L N = + (∑ n ∈ Icc 1 N, B n)*((Real.log x-Real.log (N:ℝ):ℝ):ℂ) + + ((∑ n ∈ Icc 1 N, B n)*(Real.log (N:ℝ):ℂ) - + halaszMixedPrimeConvolution G B N L N) := by push_cast; ring + have hC : 0 ≤ halaszPrimePowerConstant+Real.log L+halaszMertensConstant+1+Real.log 2 := by + have := halaszPrimePowerConstant_nonneg + have := halaszMertensConstant_nonneg + have := Real.log_nonneg hL + positivity + rw [he] + calc + _ ≤ ‖(∑ n ∈ Icc 1 N, B n)*((Real.log x-Real.log (N:ℝ):ℝ):ℂ)‖ + + ‖(∑ n ∈ Icc 1 N, B n)*(Real.log (N:ℝ):ℂ) - + halaszMixedPrimeConvolution G B N L N‖ := norm_add_le _ _ + _ ≤ (N:ℝ)*Real.log 2 + + (halaszPrimePowerConstant+Real.log L+halaszMertensConstant+1)*(N:ℝ) := by + apply add_le_add _ (halasz_mixed_prefix_log G B hB N hN hL hmul) + rw [norm_mul,Complex.norm_real,Real.norm_eq_abs,abs_of_nonneg hgap0] + exact mul_le_mul (halasz_bounded_prefix_norm B hB N) hgap2 hgap0 (Nat.cast_nonneg N) + _ = (halaszPrimePowerConstant+Real.log L+halaszMertensConstant+1+Real.log 2)*(N:ℝ) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left hNx hC + +lemma halasz_mixed_real_inner_approximation (G B : ℕ → ℂ) (hB : OneBounded B) + (N : ℕ) (hN : 1 ≤ N) {L : ℝ} (hL : 1 ≤ L) + (hmul : ∀ p : ℕ, p.Prime → L < (p:ℝ) → ∀ m : ℕ, 0 < m → B (p*m)=G p*B m) + {x : ℝ} (hx : 1 < x) (hNx : (N:ℝ) ≤ x) (hxN : x ≤ 2*N) : + ‖(∑ n ∈ Icc 1 N, B n) - halaszMixedPrimeConvolution G B N L N/(Real.log x:ℂ)‖ ≤ + (halaszPrimePowerConstant+Real.log L+halaszMertensConstant+1+Real.log 2)*x/Real.log x := by + have hlog : 0 < Real.log x := Real.log_pos hx + have hlogC : (Real.log x:ℂ) ≠ 0 := by exact_mod_cast hlog.ne' + have he : (∑ n ∈ Icc 1 N, B n) - halaszMixedPrimeConvolution G B N L N/(Real.log x:ℂ) = + ((∑ n ∈ Icc 1 N, B n)*(Real.log x:ℂ) - + halaszMixedPrimeConvolution G B N L N)/(Real.log x:ℂ) := by field_simp + rw [he,norm_div,Complex.norm_real,Real.norm_eq_abs,abs_of_pos hlog] + exact div_le_div_of_nonneg_right + (halasz_mixed_real_log_approximation G B hB N hN hL hmul hNx hxN) hlog.le + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedNumeric.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedNumeric.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5a766dfe161ee6e5dd12b8d611b7b34d805cc2d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedNumeric.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMixedDouble +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDoubleMean + +namespace OAI + +/-! The cost of deleting primes below the upper endpoint of the typical +bands, before applying the mixed Perron estimate. -/ + +namespace TwoPointCorrelations + +open Finset + +noncomputable def halaszMixedNumericConstant : ℝ := + (halaszPrimePowerConstant+3*halaszMertensConstant+1+Real.log 2+1)+ + (halaszPrimePowerConstant+halaszMertensConstant+1+Real.log 2+1)* + (1+|halaszDenominatorConstant|) + +lemma halaszMixedNumericConstant_nonneg : 0 ≤ halaszMixedNumericConstant := by + have := halaszPrimePowerConstant_nonneg + have := halaszMertensConstant_nonneg + have : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) + unfold halaszMixedNumericConstant + positivity + +lemma halasz_mixed_mean_numeric (G B : ℕ → ℂ) (hG : OneBounded G) + (hB : OneBounded B) (N : ℕ) {R : ℝ} (hR : 1 ≤ R) (hRN : R ≤ (N:ℝ)/2) + (hll : 1 ≤ Real.log (Real.log (N:ℝ))) + (hmul : ∀ p : ℕ, p.Prime → R < (p:ℝ) → ∀ m : ℕ, 0 < m → B (p*m)=G p*B m) : + Real.log (N:ℝ)*‖∑ n ∈ Icc 1 N, B n‖ ≤ ‖halaszMixedDouble G B N R‖ + + halaszMixedNumericConstant*(N:ℝ)*(1+Real.log R)*Real.log (Real.log N) := by + have hh := halasz_mixed_double_mean G B hG hB N hR hRN hmul + let A := halaszPrimePowerConstant+3*halaszMertensConstant+1+Real.log 2 + let E := halaszPrimePowerConstant+halaszMertensConstant+1+Real.log 2 + let r := Real.log R + let l := Real.log (Real.log (N:ℝ)) + have hA : 0 ≤ A := by + dsimp [A] + have := halaszPrimePowerConstant_nonneg + have := halaszMertensConstant_nonneg + have : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) + positivity + have hE : 0 ≤ E := by + dsimp [E] + have := halaszPrimePowerConstant_nonneg + have := halaszMertensConstant_nonneg + have : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) + positivity + have hr : 0 ≤ r := Real.log_nonneg hR + have hl : 1 ≤ l := hll + have hb : A+r ≤ (A+1)*(1+r)*l := by + calc + _ ≤ (A+1)*(1+r) := by nlinarith + _ ≤ _ := le_mul_of_one_le_right (by positivity) hl + have he : E+r ≤ (E+1)*(1+r) := by nlinarith + have hd : l+halaszDenominatorConstant ≤ (1+|halaszDenominatorConstant|)*l := by + have ha := le_abs_self halaszDenominatorConstant + have hb := le_mul_of_one_le_right (abs_nonneg halaszDenominatorConstant) hl + nlinarith + have hc : (E+r)*(l+halaszDenominatorConstant) ≤ + ((E+1)*(1+r))*((1+|halaszDenominatorConstant|)*l) := by + calc + _ ≤ (E+r)*((1+|halaszDenominatorConstant|)*l) := + mul_le_mul_of_nonneg_left hd (by positivity) + _ ≤ _ := mul_le_mul_of_nonneg_right he (by positivity) + have hs : A+r+(E+r)*(l+halaszDenominatorConstant) ≤ + halaszMixedNumericConstant*(1+r)*l := by + dsimp [halaszMixedNumericConstant] + change A+r+(E+r)*(l+halaszDenominatorConstant) ≤ + ((A+1)+(E+1)*(1+|halaszDenominatorConstant|))*(1+r)*l + nlinarith + have hn := mul_le_mul_of_nonneg_left hs (Nat.cast_nonneg N : (0:ℝ)≤N) + dsimp [halaszMixedErrorConstant] at hh + dsimp [A,E,r,l,halaszDenominatorConstant] at hn + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedTriplePrefix.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedTriplePrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..67cfef308cf68aeb4d2419d24ee4b12d427b0836 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMixedTriplePrefix.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszMixedBounds +import OAI.NumberTheory.TwoPoint.Halasz.HalaszBoundedTriple + +namespace OAI + +/-! The mixed double convolution is the finite prefix of the +prime-prime-typical smooth series used by Perron inversion. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical LSeries.notation + +lemma halasz_mixed_smooth_prefix (G B : ℕ → ℂ) (N M : ℕ) (hMN : M ≤ N) + {R : ℝ} (hL : 0 ≤ R) (Q : Finset ℕ) (hQ : ∀ q ∈ Q, q.Prime) + (hcover : ∀ q : ℕ, q.Prime → q ≤ M → (q ∈ Q ↔ R < (q:ℝ))) : + (∑ n ∈ Icc 1 M, + (halaszFiniteCoefficient Q (fun q => (Real.log (q:ℝ):ℂ)*G q) ⍟ + halaszSmoothFunction B N) n) = halaszMixedPrimeConvolution G B M R M := by + have hband : mrtPrimeBand R M = (Icc 1 M).filter (fun q => q∈Q) := by + ext q + constructor + · intro hq + have hp := mrtPrimeBand_prime hq + have hb := mrtPrimeBand_bounds hL (Nat.cast_nonneg M) hq + have hqM : q ≤ M := by exact_mod_cast hb.2 + exact mem_filter.mpr ⟨mem_Icc.mpr ⟨hp.pos,hqM⟩,(hcover q hp hqM).mpr hb.1⟩ + · intro hq + obtain ⟨hqM,hqQ⟩ := mem_filter.mp hq + have hp := hQ q hqQ + have hlarge := (hcover q hp (mem_Icc.mp hqM).2).mp hqQ + apply mem_sdiff.mpr + constructor + · apply mem_filter.mpr + exact ⟨by simpa only [Nat.floor_natCast,mem_Iic] using (mem_Icc.mp hqM).2,hp⟩ + · intro hsmall + have hh := sievePrimesUpTo_le R hL q hsmall + linarith + rw [halasz_convolution_prefix,halaszMixedPrimeConvolution,hband,sum_filter] + apply sum_congr rfl + intro q hq + have hs : (∑ m ∈ Icc 1 (M/q), halaszSmoothFunction B N m) = + ∑ m ∈ Icc 1 (M/q), B m := by + apply sum_congr rfl + intro m hm + exact halasz_smooth_function_eq (mem_Icc.mp hm).1 + (((mem_Icc.mp hm).2.trans (Nat.div_le_self M q)).trans hMN) + rw [hs] + by_cases hqQ : q∈Q <;> simp [halaszFiniteCoefficient,hqQ,mul_assoc] + +lemma halasz_mixed_grouped_triple_prefix (G B : ℕ → ℂ) (N : ℕ) + {R : ℝ} (hL : 0 ≤ R) (P Q : Finset ℕ) (hP : P ⊆ Icc 1 N) + (hQ : ∀ q ∈ Q, q.Prime) + (hcover : ∀ p ∈ P, ∀ q : ℕ, q.Prime → q ≤ N/p → (q∈Q ↔ R < (q:ℝ))) : + (∑ n ∈ Icc 1 N, + (halaszFiniteCoefficient P + (fun p => (Real.log (p:ℝ):ℂ)*G p/(Real.log ((N:ℝ)/p):ℂ)) ⍟ + (halaszFiniteCoefficient Q (fun q => (Real.log (q:ℝ):ℂ)*G q) ⍟ + halaszSmoothFunction B N)) n) = halaszMixedGrouped G B N R P := by + rw [halasz_finite_convolution_prefix P _ _ N hP] + unfold halaszMixedGrouped + apply sum_congr rfl + intro p hp + rw [halasz_mixed_smooth_prefix G B N (N/p) (Nat.div_le_self N p) hL Q hQ (hcover p hp)] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszModerateCofactor.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszModerateCofactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..a78eba45bc9da853653c71803212ab191d2b0d2e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszModerateCofactor.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszModerateCutoff +import OAI.NumberTheory.TwoPoint.Halasz.HalaszExceptionalCofactor +import OAI.NumberTheory.TwoPoint.Halasz.HalaszExceptionalDecay + +namespace OAI + +/-! Actual cofactor decay on the moderate-frequency part of the +complement of the minimizing twist. -/ +namespace TwoPointCorrelations + +open Filter Finset +open scoped Classical + +theorem halasz_moderate_cofactor : + ∃ X₀ : ℝ, ∀ᶠ n : ℕ in atTop, + ∀ (N : ℕ) (a : ℝ), 1 ≤ a → X₀ ≤ (⌊(N:ℝ)/a⌋₊:ℝ) → + n = ⌊(2*N:ℝ)/a⌋₊ → ∀ X : ℕ, n ≤ X → X ≤ n^3 → + ∀ (F : ℕ → ℂ), F 1 = 1 → Multiplicative F → OneBounded F → + ∀ (ι : Type*) (J : Finset ι) (P : ι → Finset ℕ) (Q : Finset ℕ), + (∀ j ∈ J, ∀ p ∈ P j, p.Prime) → (∀ p ∈ Q, p.Prime) → + (2:ℝ)^J.card ≤ (Real.log n)^(1/1000:ℝ) → + ∀ t τ : ℝ, + (∀ v : ℝ, |v| ≤ X → squaredDistance F (mrtArchimedeanTwist τ) X ≤ + squaredDistance F (mrtArchimedeanTwist v) X) → + |t|+(Real.log n)^8 ≤ X → + |t-τ|+(Real.log n)^8 ≤ (Real.log X)^20 → + (Real.log n)^(1/16:ℝ)/2 ≤ |t-τ| → + ‖mrtCofactorPolynomial Q (mrtTypicalCoefficient J P F) N a t‖ ≤ + (Real.log n)^(-1/40:ℝ) := by + obtain ⟨C,K,X₀,hC,hK,hcofactor⟩ := halasz_exceptional_typical_window + refine ⟨X₀,?_⟩ + have hlog : Tendsto (fun n:ℕ => Real.log n) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + filter_upwards [halasz_moderate_cutoff K, + hlog.eventually (halasz_exceptional_decay C hC.le), + hlog.eventually (eventually_ge_atTop (1:ℝ))] with n hcut hdec hln + intro N a ha hbase hn X hnX hX F hF1 hFm hFb ι J P Q hP hQ hJ t τ hmin ht hmoderate haway + have hln0 : 0 ≤ Real.log (n:ℝ) := by linarith + have hM : 0 ≤ (3/100:ℝ)*Real.log (Real.log n) := + mul_nonneg (by norm_num) (Real.log_nonneg hln) + have hd : ∀ v:ℝ, |v-t| ≤ (Real.log n)^8 → 1/2 ≤ |v-τ| → + 2*((3/100:ℝ)*Real.log (Real.log n))+K ≤ + squaredDistance F (mrtArchimedeanTwist v) n := by + intro v hv hunit + have hvX : |v| ≤ X := by + have hh := abs_add_le (v-t) t + rw [sub_add_cancel] at hh + linarith + have hvτ : |v-τ| ≤ (Real.log X)^20 := by + have hh := abs_add_le (v-t) (t-τ) + have he : v-t+(t-τ)=v-τ := by ring + rw [he] at hh + linarith + exact hcut X hnX hX F hFb v τ hunit hvτ (hmin v hvX) + have hb := hcofactor N a ha hbase F hF1 hFm hFb ι J P Q hP hQ t τ + ((3/100:ℝ)*Real.log (Real.log n)) hM (by simpa only [← hn] using hd) + have hsave := hdec ((2:ℝ)^J.card) (τ-t) (by positivity) hJ + (by simpa only [abs_sub_comm] using haway) + apply hb.trans + simpa only [← hn, mul_comm C] using hsave + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszModerateCutoff.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszModerateCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..1fa57e85e677f8b6f632e8d959ed509acb58c6fb --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszModerateCutoff.lean @@ -0,0 +1,43 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszUnitRepulsion +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDistanceCutoff + +namespace OAI + +/-! Moderate twist repulsion at the smaller cofactor cutoff. -/ +namespace TwoPointCorrelations + +open Filter + +theorem halasz_moderate_cutoff (K : ℝ) : + ∀ᶠ n : ℕ in atTop, ∀ X : ℕ, n ≤ X → X ≤ n^3 → + ∀ (F : ℕ → ℂ), OneBounded F → ∀ v τ : ℝ, + 1/2 ≤ |v-τ| → |v-τ| ≤ (Real.log X)^20 → + squaredDistance F (mrtArchimedeanTwist τ) X ≤ + squaredDistance F (mrtArchimedeanTwist v) X → + 2*((3/100:ℝ)*Real.log (Real.log n))+K ≤ + squaredDistance F (mrtArchimedeanTwist v) n := by + obtain ⟨K₀,hK₀,hcut⟩ := halasz_distance_cutoff_loss + obtain ⟨n₀,hn₀⟩ := eventually_atTop.mp halasz_moderate_distance_unit + have hll := (Real.tendsto_log_atTop.comp + (Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop)).eventually + (eventually_ge_atTop (500*(K+K₀))) + filter_upwards [eventually_ge_atTop n₀,eventually_ge_atTop 2,hll] + with n hn hn2 hlln + intro X hnX hX F hF v τ hlo hhi hmin + have hrep := hn₀ X (hn.trans hnX) F hF ∅ v τ hlo hhi hmin + have he : mrtMissingCoefficient F ∅ = F := by + funext k + simp [mrtMissingCoefficient,mrtPrimeMask,mrtPrimeAvoids] + rw [he] at hrep + have hlogn : 0 < Real.log (n:ℝ) := + Real.log_pos (by exact_mod_cast (show 1 (8 + y ^ 80) * K * Real.exp (-c * y)) + atTop (𝓝 0) := by + convert hh using 1 + · ext y + simp only [Real.rpow_zero, one_mul] + ring + · norm_num + exact (hlim.eventually (gt_mem_nhds (by norm_num : (0 : ℝ) < 1))).mono + (fun _ h => h.le) + +lemma halasz_logarithmic_phase_scale (N : ℕ) (y : ℝ) (hy : 1 < y) + (hN : Real.log N = y ^ 4) : + Real.exp 1 ≤ Real.exp (y ^ 2) ∧ Real.exp (y ^ 2) ≤ N ∧ + Real.log (Real.log N / Real.log (Real.exp (y ^ 2))) = + Real.log (Real.log N) / 2 := by + have hy0 : 0 < y := zero_lt_one.trans hy + have hy2 : 1 < y ^ 2 := by nlinarith + have hNp : 0 < (N : ℝ) := by + have hh : 1 < (N : ℝ) := (Real.log_pos_iff (Nat.cast_nonneg N)).mp + (by rw [hN]; positivity) + linarith + refine ⟨Real.exp_le_exp.mpr hy2.le, ?_, ?_⟩ + · rw [← Real.exp_log hNp, hN] + apply Real.exp_le_exp.mpr + nlinarith [sq_nonneg (y ^ 2 - 1)] + · rw [Real.log_exp, hN, Real.log_div (by positivity) (by positivity), + Real.log_pow, Real.log_pow] + ring + +/-- Uniform masked distance repulsion in the moderate frequency range. +The lower bound is independent of the deleted prime set. -/ +theorem halasz_moderate_masked_distance : + ∀ᶠ y : ℝ in atTop, ∀ (F : ℕ → ℂ), OneBounded F → + ∀ (Q : Finset ℕ) (N : ℕ) (t t₁ : ℝ), Real.log N = y ^ 4 → + 1 ≤ |t - t₁| * y ^ 2 → |t - t₁| ≤ y ^ 80 → + squaredDistance F (mrtArchimedeanTwist t₁) N ≤ + squaredDistance F (mrtArchimedeanTwist t) N → + Real.log (Real.log N) / 16 - 1 / 2 ≤ + squaredDistance (mrtMissingCoefficient F Q) (mrtArchimedeanTwist t) N := by + obtain ⟨c, K, hc, hK, hphase⟩ := modFiveThetaInput.halasz_masked_phase_lower + filter_upwards [eventually_gt_atTop (1 : ℝ), halasz_polynomial_phase_error c K hc] + with y hy herr + intro F hF Q N t t₁ hN htlo hthi hmin + obtain ⟨hlo, hhi, hlog⟩ := halasz_logarithmic_phase_scale N y hy hN + have hh := hphase F hF Q N (Real.exp (y ^ 2)) t t₁ hlo hhi + (by simpa only [Real.log_exp] using htlo) hmin + rw [hlog, Real.log_exp, Real.sqrt_sq (by linarith : 0 ≤ y)] at hh + have hy2 : 1 ≤ y ^ 2 := by nlinarith + have hnum : (8 + |t - t₁|) * K * Real.exp (-c * y) ≤ 1 := by + apply le_trans _ herr + gcongr + have herr' : (8 + |t - t₁|) * K * Real.exp (-c * y) / y ^ 2 ≤ 1 := by + exact (div_le_one (by positivity : 0 < y ^ 2)).mpr (hnum.trans hy2) + linarith + +/-- The moderate-frequency clause in the original natural cutoff, with a +fixed positive margin over the exponent needed in the last MRT class. -/ +theorem halasz_moderate_distance_nat : + ∀ᶠ N : ℕ in atTop, ∀ (F : ℕ → ℂ), OneBounded F → + ∀ (Q : Finset ℕ) (t t₁ : ℝ), + (Real.log N) ^ (1 / (16 : ℝ)) / 2 ≤ |t - t₁| → + |t - t₁| ≤ (Real.log N) ^ 20 → + squaredDistance F (mrtArchimedeanTwist t₁) N ≤ + squaredDistance F (mrtArchimedeanTwist t) N → + (31 / 500 : ℝ) * Real.log (Real.log N) ≤ + squaredDistance (mrtMissingCoefficient F Q) (mrtArchimedeanTwist t) N := by + have hlog : Tendsto (fun N : ℕ => Real.log N) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + have hroot : Tendsto (fun N : ℕ => Real.sqrt (Real.sqrt (Real.log N))) + atTop atTop := Real.tendsto_sqrt_atTop.comp (Real.tendsto_sqrt_atTop.comp hlog) + have hll := (Real.tendsto_log_atTop.comp hlog).eventually + (eventually_ge_atTop (1000 : ℝ)) + filter_upwards [hroot.eventually halasz_moderate_masked_distance, + hlog.eventually (eventually_ge_atTop (4 : ℝ)), hll] with N hN hl hllN + dsimp only [Function.comp_def] at hllN + intro F hF Q t t₁ htlo hthi hmin + have hl0 : 0 ≤ Real.log N := by linarith + have hs : Real.sqrt (Real.sqrt (Real.log N)) ^ 2 = Real.sqrt (Real.log N) := + Real.sq_sqrt (Real.sqrt_nonneg _) + have hfour : Real.sqrt (Real.sqrt (Real.log N)) ^ 4 = Real.log N := by + calc + _ = (Real.sqrt (Real.sqrt (Real.log N)) ^ 2) ^ 2 := by ring + _ = Real.log N := by rw [hs, Real.sq_sqrt hl0] + have h80 : Real.sqrt (Real.sqrt (Real.log N)) ^ 80 = (Real.log N) ^ 20 := by + calc + _ = (Real.sqrt (Real.sqrt (Real.log N)) ^ 4) ^ 20 := by rw [← pow_mul] + _ = _ := by rw [hfour] + have hs2 : 2 ≤ Real.sqrt (Real.log N) := by + have hsq := Real.sq_sqrt hl0 + have hn := Real.sqrt_nonneg (Real.log N) + nlinarith + have hrpow : 1 ≤ (Real.log N) ^ (1 / (16 : ℝ)) := + Real.one_le_rpow (by linarith) (by norm_num) + have hu : 1 / 2 ≤ |t - t₁| := by linarith + have ht : 1 ≤ |t - t₁| * Real.sqrt (Real.log N) := by nlinarith + have hh := hN F hF Q N t t₁ hfour.symm + (by simpa only [hs] using ht) (by simpa only [h80] using hthi) hmin + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMomentConstant.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMomentConstant.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0d1a207a02096e76da55c82252ade821e3e9c11 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMomentConstant.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLogWeightCost +import OAI.NumberTheory.TwoPoint.Halasz.HalaszSelectedDoubleMoment + +namespace OAI + +/-! The apparently large complete-system constants become a fixed sixth +power after taking the selected double-moment root. -/ +namespace TwoPointCorrelations + +lemma halasz_moment_constant_nat {k : ℕ} (hk : 2≤k) (R₀ : ℕ) : + (32*halaszSelectedMoment k)^k*(R₀+k+32)^(512*k^4)* + (8^(k+2)*(halaszSelectedMoment k+k+1))^k ≤ + (R₀+k+32)^(6*(2*halaszSelectedMoment k*halaszSelectedMoment k)) := by + let R := R₀+k+32 + let r := halaszSelectedMoment k + have hRk : k≤R := by dsimp [R]; omega + have hR32 : 32≤R := by dsimp [R]; omega + have hR1 : 1≤R := by omega + have hkk : k≤k^2 := by nlinarith + have hr : r≤11*k^2 := by dsimp [r,halaszSelectedMoment]; nlinarith only [hkk] + have hrlo : 10*k^2≤r := by dsimp [r,halaszSelectedMoment]; nlinarith + have hR2 : k^2≤R^2 := Nat.pow_le_pow_left hRk 2 + have h32 : 1024≤R^2 := by simpa using Nat.pow_le_pow_left hR32 2 + have hbase : 32*r≤R^4 := by + calc + _ ≤ 352*k^2 := by nlinarith only [hr] + _ ≤ 1024*k^2 := by omega + _ ≤ R^2*k^2 := Nat.mul_le_mul_right _ h32 + _ ≤ R^2*R^2 := Nat.mul_le_mul_left _ hR2 + _ = _ := by ring + have hshort : r+k+1≤R^3 := by + have hkpos : 1≤k^2 := by nlinarith + calc + _ ≤ 13*k^2 := by nlinarith only [hr,hkk,hkpos] + _ ≤ 32*k^2 := by omega + _ ≤ R*k^2 := Nat.mul_le_mul_right _ hR32 + _ ≤ R*R^2 := Nat.mul_le_mul_left _ hR2 + _ = _ := by ring + have hcost : 8^(k+2)*(r+k+1)≤R^(k+5) := by + calc + _ ≤ R^(k+2)*R^3 := Nat.mul_le_mul + (Nat.pow_le_pow_left (by omega : 8≤R) _) hshort + _ = _ := by rw [← pow_add] + have hk4 : k^2≤k^4 := by + have hh := Nat.pow_le_pow_right (by omega : 1≤k) (by norm_num : 2≤4) + exact hh + have hr2 : 100*k^4≤r^2 := by + have hh := Nat.pow_le_pow_left hrlo 2 + nlinarith only [hh] + have he : 4*k+512*k^4+(k+5)*k≤6*(2*r*r) := by + nlinarith only [hkk,hk4,hr2] + calc + _ ≤ (R^4)^k*R^(512*k^4)*(R^(k+5))^k := + Nat.mul_le_mul (Nat.mul_le_mul_right _ (Nat.pow_le_pow_left hbase k)) + (Nat.pow_le_pow_left hcost k) + _ = R^(4*k+512*k^4+(k+5)*k) := by rw [← pow_mul,← pow_mul,← pow_add,← pow_add] + _ ≤ _ := Nat.pow_le_pow_right hR1 he + +lemma halasz_moment_constant_root {k : ℕ} (hk : 2≤k) (R₀ : ℕ) : + ((32*(halaszSelectedMoment k:ℝ))^k*(R₀+k+32:ℝ)^(512*k^4)* + (halaszLogWeightCost k (halaszSelectedMoment k))^k)^ + (((2*halaszSelectedMoment k*halaszSelectedMoment k:ℕ):ℝ)⁻¹) ≤ + (R₀+k+32:ℝ)^6 := by + have hp : 0<2*halaszSelectedMoment k*halaszSelectedMoment k := by + have hr := halasz_selected_moment_pos hk + positivity + have hB : (32*(halaszSelectedMoment k:ℝ))^k*(R₀+k+32:ℝ)^(512*k^4)* + (halaszLogWeightCost k (halaszSelectedMoment k))^k ≤ + (R₀+k+32:ℝ)^(6*(2*halaszSelectedMoment k*halaszSelectedMoment k)) := by + dsimp only [halaszLogWeightCost] + exact_mod_cast halasz_moment_constant_nat hk R₀ + apply (Real.rpow_inv_le_iff_of_pos (by dsimp only [halaszLogWeightCost]; positivity) (by positivity) + (by exact_mod_cast hp)).mpr + simpa only [Real.rpow_natCast,← pow_mul] using hB + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMomentInterpolation.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMomentInterpolation.lean new file mode 100644 index 0000000000000000000000000000000000000000..95fef8a244863123edf85e7c5041743dc84aadbd --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMomentInterpolation.lean @@ -0,0 +1,45 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszFinitePhase +import Mathlib.MeasureTheory.Integral.MeanInequalities + +namespace OAI + +/-! The moment interpolation used to absorb colliding long variables. +All functions live on the same finite coefficient torus. -/ +namespace TwoPointCorrelations + +open MeasureTheory + +lemma halasz_torus_geometric_mean {k : ℕ} + (F G : (Fin k → AddCircle (1:ℝ)) → ℝ) + (hF : Continuous F) (hG : Continuous G) + (hF0 : ∀ x, 0≤F x) (hG0 : ∀ x, 0≤G x) + {θ : ℝ} (hθ0 : 0<θ) (hθ1 : θ<1) : + (∫ x, (F x)^θ*(G x)^(1-θ) ∂halaszVinogradovHaar k) ≤ + (∫ x, F x ∂halaszVinogradovHaar k)^θ * + (∫ x, G x ∂halaszVinogradovHaar k)^(1-θ) := by + have hq0 : 0<1-θ := by linarith + have hFc : Continuous (fun x => (F x)^θ) := + hF.rpow_const (fun x => Or.inr hθ0.le) + have hGc : Continuous (fun x => (G x)^(1-θ)) := + hG.rpow_const (fun x => Or.inr hq0.le) + have hpq : (1/θ).HolderConjugate (1/(1-θ)) := by + apply Real.holderConjugate_iff.mpr + constructor + · exact (one_lt_div hθ0).mpr hθ1 + · simp only [one_div,inv_inv] + ring + have h := integral_mul_le_Lp_mul_Lq_of_nonneg (μ := halaszVinogradovHaar k) hpq + (Filter.Eventually.of_forall (fun x => Real.rpow_nonneg (hF0 x) _)) + (Filter.Eventually.of_forall (fun x => Real.rpow_nonneg (hG0 x) _)) + (hFc.memLp_of_hasCompactSupport (HasCompactSupport.of_compactSpace _)) + (hGc.memLp_of_hasCompactSupport (HasCompactSupport.of_compactSpace _)) + have hp (x : Fin k → AddCircle (1:ℝ)) : ((F x)^θ)^(1/θ)=F x := by + rw [← Real.rpow_mul (hF0 x),mul_one_div_cancel hθ0.ne',Real.rpow_one] + have hq (x : Fin k → AddCircle (1:ℝ)) : ((G x)^(1-θ))^(1/(1-θ))=G x := by + rw [← Real.rpow_mul (hG0 x),mul_one_div_cancel hq0.ne',Real.rpow_one] + simp_rw [hp,hq] at h + simpa only [one_div,inv_inv] using h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMomentRoot.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMomentRoot.lean new file mode 100644 index 0000000000000000000000000000000000000000..901521159e39eba52446ab238f296a1245e42d40 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszMomentRoot.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszSelectedDoubleMoment + +namespace OAI + +/-! Extracting the normalized exponential-sum saving from its even moment. -/ +namespace TwoPointCorrelations + +lemma halasz_moment_root {x B M N d : ℝ} {p : ℕ} + (hp : 0 (((b.val+1)^(j.val+1):ℕ):ℤ)))‖^(2*s))≤ + (∏ j,2*δ j)*(halaszVinogradovCount s k M:ℝ)* + ∏ j,min (2*((s*M^(j.val+1):ℕ):ℝ)+1) + (8*((s*M^(j.val+1):ℕ):ℝ)*δ j+2*((s*M^(j.val+1):ℕ):ℝ)* |γ j| + + 8*δ j/ |γ j| +2) := by + let F : (Fin s → Fin M) → Fin k → ℤ := halaszVinogradovFrequency k + let A : (Fin s → Fin M) → ℂ := fun x => ∏ i,a (x i) + let β : (Fin s → Fin M) → Fin k → AddCircle (1:ℝ) := + fun x => halaszScaledFrequency γ (F x) + have hA (x : Fin s → Fin M) : ‖A x‖≤1 := by + change ‖∏ i,a (x i)‖≤1 + rw [norm_prod] + calc + _ ≤ ∏ _i : Fin s,(1:ℝ) := prod_le_prod₀ (fun _ _ => norm_nonneg _) (fun _ _ => ha _) + _ = 1 := by simp + have hh := halasz_window_sampling (univ : Finset (Fin s → Fin M)) S β A δ + (fun x _ => hA x) hδ (fun j => (hδquarter j).trans (by norm_num)) hphase + have hc := halasz_near_pair_count_abs F (fun j => s*M^(j.val+1)) γ δ hγ hδ hδquarter + (fun x y j => halasz_vinogradov_difference_abs x y j) + rw [← halasz_fiber_energy_representation,halasz_frequency_energy] at hc + have hV : 0≤∏ j,2*δ j := prod_nonneg (fun j _ => + mul_nonneg (by norm_num) (hδ j)) + have hp := mul_le_mul_of_nonneg_left hc hV + simp only [univ_product_univ] at hh + have hs := hh.trans hp + have he (m : Fin k → ℤ) : + ‖∑ x : Fin s → Fin M,A x*halaszVinogradovCharacter m (β x)‖^2= + ‖∑ b : Fin M,a b*halaszVinogradovCharacter m + (halaszScaledFrequency γ (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)))‖^(2*s) := by + rw [show (∑ x : Fin s → Fin M,A x*halaszVinogradovCharacter m (β x))= + (∑ b : Fin M,a b*halaszVinogradovCharacter m + (halaszScaledFrequency γ (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ))))^s from + (halasz_scaled_power s γ a m).symm] + rw [norm_pow,← pow_mul,Nat.mul_comm s 2] + simpa only [he,mul_assoc] using hs + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearActualScale.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearActualScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8fee4831160ad3d109656bcd63d8dbb254b9e48 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearActualScale.lean @@ -0,0 +1,145 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszBandNearEnergy +import OAI.NumberTheory.TwoPoint.Halasz.HalaszNearRestriction +import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics + +namespace OAI + +/-! Near-frequency energy with the single actual scale L=log N. +The density and mean-value thresholds are taken independently before +this diagonal specialization. -/ +namespace TwoPointCorrelations + +open Finset Filter MeasureTheory +open scoped Classical + +theorem halasz_band_near_actual_scale : ∃ C : ℝ, 0 < C ∧ + ∀ᶠ N : ℕ in atTop, ∀ (P Q : ℝ) (J : ℕ), + 2 ≤ P → P ≤ Q → 1 ≤ Real.log Q → + (∀ j ∈ Icc 1 J, mrtBandUpper Q j ≤ Real.exp (Real.sqrt (Real.log N))) → + ∀ (F : ℕ → ℂ), F 1 = 1 → Multiplicative F → OneBounded F → + ∀ τ M : ℝ, 0 ≤ M → |τ|+Real.log (2*N:ℕ)^8 ≤ 2*N → + (∀ v:ℝ, |v| ≤ 2*N → M ≤ squaredDistance F (mrtArchimedeanTwist v) (2*N)) → + squaredDistance F (mrtArchimedeanTwist τ) (2*N) ≤ + Real.log (Real.log (2*N:ℕ))/10 → + (∫ u in -((Real.log N)^(1/16:ℝ))..((Real.log N)^(1/16:ℝ)), + ‖mrtDyadicPolynomial (mrtTypicalCoefficient (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) + N (τ+u)‖^2) ≤ + C*(Real.log P/Real.log Q+Real.exp (-M)+(Real.log N)^(-1/16:ℝ)) := by + obtain ⟨C₁,hC₁,hnear⟩ := halasz_centered_typical_energy + obtain ⟨C₂,hC₂,hdensity⟩ := mrt_typical_density + refine ⟨48*Real.exp 1*C₂+C₁,by positivity,?_⟩ + have hlog : Tendsto (fun N:ℕ => Real.log N) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + filter_upwards [hnear,hlog.eventually hdensity, + hlog.eventually (eventually_ge_atTop (1:ℝ)),eventually_ge_atTop 2] + with N hnear hdensity hlogN hN2 + intro P Q J hP hPQ hQ hmax F hF1 hFm hFb τ M hM hτ hd hsmall + let V := fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j) + have hN0 : 0 < (N:ℝ) := by exact_mod_cast (show 0 V j) n ↔ + mrtTypical (Icc 1 J) V n := by simp [mrtTypical] + have hp := hdensity P Q J hP hPQ hQ + (fun j hj => (hmax j hj).trans (Real.exp_le_exp.mpr hs)) (N+1) N hscale + change (uniformFiniteLaw (Fin N)).probability + (fun n => ¬mrtTypical univ + (fun j:{j:ℕ // j∈(Icc 1 J:Finset ℕ)} => V j) (N+1+n.val)) ≤ _ at hp + have hp' : (uniformFiniteLaw (Fin N)).probability + (fun n => ¬mrtTypical (Icc 1 J) V (N+1+n.val)) ≤ C₂*Real.log P/Real.log Q := by + simpa only [heq] using hp + have hcount := halasz_typical_dyadic_density_bound (Icc 1 J) V _ hp' + have hcube : 2*N ≤ N^3 := by + have hs : 2 ≤ N^2 := by nlinarith + calc + 2*N ≤ N^2*N := Nat.mul_le_mul_right N hs + _ = N^3 := by ring + have hh := hnear (2*N) (by omega) hcube F hF1 hFm hFb τ (2*N) M hM hτ hd hsmall + (Icc 1 J) V + have hR : 0 ≤ Real.log P/Real.log Q := div_nonneg + (Real.log_nonneg (by linarith)) (by linarith) + have hB : 0 ≤ Real.exp (-M)+(Real.log N)^(-1/16:ℝ) := by positivity + have hA : 0 ≤ 48*Real.exp 1*C₂ := by positivity + calc + _ ≤ 48*Real.exp 1*(C₂*Real.log P/Real.log Q)+ + C₁*(Real.exp (-M)+(Real.log N)^(-1/16:ℝ)) := by + apply hh.trans + have hs' := mul_le_mul_of_nonneg_left hcount (show (0:ℝ)≤48*Real.exp 1 by positivity) + simpa only [mul_div_assoc,add_comm] using add_le_add_right hs' + (C₁*(Real.exp (-M)+(Real.log N)^(-1/16:ℝ))) + _ = (48*Real.exp 1*C₂)*(Real.log P/Real.log Q)+ + C₁*(Real.exp (-M)+(Real.log N)^(-1/16:ℝ)) := by ring + _ ≤ _ := by nlinarith [mul_nonneg hA hB,mul_nonneg hC₁.le hR] + +lemma halasz_center_window_room : + ∀ᶠ N : ℕ in atTop, + Real.log (2*N:ℕ)^8+(Real.log N)^(1/16:ℝ) ≤ N := by + have hlog : Tendsto (fun N:ℕ => Real.log N) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + have hb := (isLittleO_pow_exp_pos_mul_atTop 8 (b := 1) (by norm_num)).bound + (show (0:ℝ)<1/512 by norm_num) + filter_upwards [hlog.eventually hb,hlog.eventually (eventually_ge_atTop (1:ℝ)), + eventually_ge_atTop 2] with N hb hLN hN + have hN0 : 0 < (N:ℝ) := by exact_mod_cast (show 0 mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) N t‖^2) ≤ + C*(Real.log P/Real.log Q+Real.exp (-M)+(Real.log N)^(-1/16:ℝ)) := by + obtain ⟨C,hC,hnear⟩ := halasz_band_near_actual_scale + refine ⟨C,hC,?_⟩ + filter_upwards [hnear,halasz_center_window_room,eventually_ge_atTop 2] with N hnear hroom hN2 + intro P Q J hP hPQ hQ hmax F hF1 hFm hFb τ M hM hd hsmall E hEN hEt + by_cases hE : E.Nonempty + · obtain ⟨t,ht⟩ := hE + have hN := hEN ht + have hT := hEt ht + have hτ : |τ| ≤ (N:ℝ)+(Real.log N)^(1/16:ℝ) := by + apply abs_le.mpr + constructor <;> linarith [hN.1,hN.2,hT.1,hT.2] + have hroom' : |τ|+Real.log (2*N:ℕ)^8 ≤ 2*N := by linarith + exact halasz_restricted_near_energy _ N τ ((Real.log N)^(1/16:ℝ)) _ + (Real.rpow_nonneg (Real.log_nonneg (by exact_mod_cast (show 1≤N by omega))) _) + (hnear P Q J hP hPQ hQ hmax F hF1 hFm hFb τ M hM hroom' hd hsmall) E hEt + · rw [Set.not_nonempty_iff_eq_empty.mp hE] + simp only [MeasureTheory.setIntegral_empty] + have hlogP : 0 ≤ Real.log P := Real.log_nonneg (by linarith) + positivity + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearDiscrepancy.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearDiscrepancy.lean new file mode 100644 index 0000000000000000000000000000000000000000..df6591aedb72f9caf68cd727e8a6cf3459711c53 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearDiscrepancy.lean @@ -0,0 +1,174 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimeTheta +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTSmoothDistance + +namespace OAI + +/-! Prime discrepancy for the near-minimizing twist in MRT Appendix A. +The deleted-prime contribution is kept separate in Cauchy--Schwarz; this +retains the strict exponent needed by the renormalization error. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped ComplexConjugate Classical + +noncomputable def halaszPrimeDiscrepancy (F : ℕ → ℂ) (t : ℝ) (N : ℕ) : ℝ := + ∑ p ∈ primesUpTo N, ‖1 - F p * conj (mrtArchimedeanTwist t p)‖ / p + +lemma halasz_one_sub_norm_sq {z : ℂ} (hz : ‖z‖ ≤ 1) : + ‖1 - z‖ ^ 2 ≤ 2 * (1 - z.re) := by + have hs : ‖z‖ ^ 2 ≤ 1 := by nlinarith [norm_nonneg z] + simp only [Complex.sq_norm, Complex.normSq_apply, Complex.sub_re, + Complex.sub_im, Complex.one_re, Complex.one_im] at hs ⊢ + nlinarith + +lemma halasz_prime_unit_bound (F : ℕ → ℂ) (hF : OneBounded F) + (t : ℝ) {N p : ℕ} (hp : p ∈ primesUpTo N) : + ‖F p * conj (mrtArchimedeanTwist t p)‖ ≤ 1 := by + rw [norm_mul, Complex.norm_conj, mrtArchimedeanTwist_norm, mul_one] + exact hF p (mem_filter.mp hp).2.pos + +lemma halasz_masked_discrepancy_split (F : ℕ → ℂ) (Q : Finset ℕ) + (hQ : ∀ p ∈ Q, p.Prime) (t : ℝ) (N : ℕ) : + halaszPrimeDiscrepancy (mrtMissingCoefficient F Q) t N = + (∑ p ∈ (primesUpTo N).filter (fun p => p ∈ Q), (1 : ℝ) / p) + + ∑ p ∈ (primesUpTo N).filter (fun p => p ∉ Q), + ‖1 - F p * conj (mrtArchimedeanTwist t p)‖ / p := by + unfold halaszPrimeDiscrepancy + rw [← sum_filter_add_sum_filter_not (primesUpTo N) (fun p => p ∈ Q)] + congr 1 <;> apply sum_congr rfl + · intro p hp + obtain ⟨hpN, hpQ⟩ := mem_filter.mp hp + rw [mrtMissingCoefficient, mrtPrimeMask_prime Q hQ (mem_filter.mp hpN).2, + ite_eq_left hpQ] + simp + · intro p hp + obtain ⟨hpN, hpQ⟩ := mem_filter.mp hp + rw [mrtMissingCoefficient, mrtPrimeMask_prime Q hQ (mem_filter.mp hpN).2, + ite_eq_right hpQ] + simp + +lemma halasz_undeleted_discrepancy_sq (F : ℕ → ℂ) (hF : OneBounded F) + (Q : Finset ℕ) (t : ℝ) (N : ℕ) : + (∑ p ∈ (primesUpTo N).filter (fun p => p ∉ Q), + ‖1 - F p * conj (mrtArchimedeanTwist t p)‖ / p) ^ 2 ≤ + 2 * (∑ p ∈ (primesUpTo N).filter (fun p => p ∉ Q), (1 : ℝ) / p) * + squaredDistance F (mrtArchimedeanTwist t) N := by + let S := (primesUpTo N).filter (fun p => p ∉ Q) + have hdef (p : ℕ) (hp : p ∈ primesUpTo N) : + 0 ≤ 1 - (F p * conj (mrtArchimedeanTwist t p)).re := + sub_nonneg.mpr ((Complex.re_le_norm _).trans (halasz_prime_unit_bound F hF t hp)) + have hh := sum_sq_le_sum_mul_sum_of_sq_le_mul S + (r := fun p => ‖1 - F p * conj (mrtArchimedeanTwist t p)‖ / (p : ℝ)) + (f := fun p => (1 : ℝ) / p) + (g := fun p => 2 * (1 - (F p * conj (mrtArchimedeanTwist t p)).re) / p) + (fun _ _ => by positivity) + (fun p hp => div_nonneg (mul_nonneg (by norm_num) (hdef p (mem_filter.mp hp).1)) + (Nat.cast_nonneg p)) (fun p hp => ?_) + · have hd : (∑ p ∈ S, (1 - (F p * conj (mrtArchimedeanTwist t p)).re) / p) ≤ + squaredDistance F (mrtArchimedeanTwist t) N := by + apply sum_le_sum_of_subset_of_nonneg (filter_subset _ _) + intro p hp _ + exact div_nonneg (hdef p hp) (Nat.cast_nonneg p) + have he : (∑ p ∈ S, 2 * (1 - (F p * conj (mrtArchimedeanTwist t p)).re) / p) = + 2 * ∑ p ∈ S, (1 - (F p * conj (mrtArchimedeanTwist t p)).re) / p := by + rw [mul_sum] + apply sum_congr rfl + intro p _ + ring + rw [he] at hh + exact hh.trans (by + have h := mul_le_mul_of_nonneg_left hd + (show 0 ≤ 2 * ∑ p ∈ S, (1 : ℝ) / p by positivity) + convert h using 1 + ring) + · have hsq := halasz_one_sub_norm_sq (halasz_prime_unit_bound F hF t (mem_filter.mp hp).1) + rw [div_pow] + apply (div_le_div_of_nonneg_right hsq (sq_nonneg (p : ℝ))).trans_eq + ring + +lemma halasz_near_discrepancy_numeric (L A B Z D : ℝ) (hL : 0 ≤ L) + (hAB : A ≤ B) + (hAhi : A ≤ 51 / 100 * L) (hBhi : B ≤ 101 / 100 * L) + (hD : D ≤ L / 8) (hZsq : Z ^ 2 ≤ 2 * (B - A) * D) : + A + Z ≤ 7 / 8 * L := by + have hm := mul_le_mul_of_nonneg_left hD (by linarith : 0 ≤ 2 * (B - A)) + have hprod : 0 ≤ (A - 51 / 100 * L) * (A - 99 / 100 * L) := + mul_nonneg_of_nonpos_of_nonpos (by linarith) (by linarith) + by_contra hh + have hz : 7 / 8 * L - A < Z := by linarith + have hz0 : 0 ≤ 7 / 8 * L - A := by linarith + have hs := mul_self_lt_mul_self hz0 hz + nlinarith + +/-- The `7/8` prime-discrepancy estimate used for near-twist renormalization. +Only primes below the actual Appendix-A cutoff may be deleted. -/ +theorem halasz_near_masked_discrepancy : + ∀ᶠ N : ℕ in atTop, ∀ (F : ℕ → ℂ), OneBounded F → + ∀ (Q : Finset ℕ), (∀ p ∈ Q, p.Prime) → + (∀ p ∈ Q, (p : ℝ) ≤ Real.exp (Real.sqrt (Real.log N))) → + ∀ t : ℝ, squaredDistance F (mrtArchimedeanTwist t) N ≤ + Real.log (Real.log N) / 8 → + halaszPrimeDiscrepancy (mrtMissingCoefficient F Q) t N ≤ + 7 / 8 * Real.log (Real.log N) := by + obtain ⟨C, hC⟩ := primeReciprocalInput + have hlog : Tendsto (fun N : ℕ => Real.log N) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + have hll := (Real.tendsto_log_atTop.comp hlog).eventually + (eventually_ge_atTop (100 * |C|)) + filter_upwards [hlog.eventually (eventually_ge_atTop (4 : ℝ)), hll] with N hl hllN + dsimp only [Function.comp_def] at hllN + intro F hF Q hQ hcut t hD + let L := Real.log (Real.log N) + let A := ∑ p ∈ (primesUpTo N).filter (fun p => p ∈ Q), (1 : ℝ) / p + let B := ∑ p ∈ primesUpTo N, (1 : ℝ) / p + let Z := ∑ p ∈ (primesUpTo N).filter (fun p => p ∉ Q), + ‖1 - F p * conj (mrtArchimedeanTwist t p)‖ / p + have hL : 0 ≤ L := by dsimp [L]; linarith [abs_nonneg C] + have hCsmall : C ≤ L / 100 := by dsimp [L]; linarith [le_abs_self C] + have hN1 : 1 < (N : ℝ) := (Real.log_pos_iff (Nat.cast_nonneg N)).mp (by linarith) + have hN2 : (2 : ℝ) ≤ N := by + have : 2 ≤ N := by exact_mod_cast hN1 + exact_mod_cast this + have hB : B ≤ 101 / 100 * L := by + have hh := (abs_le.mp (hC N hN2)).2 + rw [mrt_sievePrimesUpTo_nat] at hh + dsimp [B, L] + linarith + have hsqrt : 2 ≤ Real.sqrt (Real.log N) := by + have hs := Real.sq_sqrt (by linarith : 0 ≤ Real.log N) + have hn := Real.sqrt_nonneg (Real.log N) + nlinarith + have hY2 : 2 ≤ Real.exp (Real.sqrt (Real.log N)) := by + linarith [Real.add_one_le_exp (Real.sqrt (Real.log N))] + have hA : A ≤ 51 / 100 * L := by + have hsub : (primesUpTo N).filter (fun p => p ∈ Q) ⊆ + sievePrimesUpTo (Real.exp (Real.sqrt (Real.log N))) := by + intro p hp + obtain ⟨hpN, hpQ⟩ := mem_filter.mp hp + exact mem_filter.mpr ⟨mem_Iic.mpr ((Nat.le_floor_iff (by positivity)).mpr + (hcut p hpQ)), (mem_filter.mp hpN).2⟩ + have ha := sum_le_sum_of_subset_of_nonneg hsub + (f := fun p : ℕ => (1 : ℝ) / p) (by intros; positivity) + have hb := (abs_le.mp (hC _ hY2)).2 + rw [Real.log_exp, Real.log_sqrt (by linarith : 0 ≤ Real.log N)] at hb + dsimp [A, L] at * + linarith + have hmass : (∑ p ∈ (primesUpTo N).filter (fun p => p ∉ Q), (1 : ℝ) / p) = B - A := by + have hh := sum_filter_add_sum_filter_not (primesUpTo N) (fun p => p ∈ Q) + (fun p : ℕ => (1 : ℝ) / p) + dsimp [A, B] + linarith + have hAB : A ≤ B := by + have hh : 0 ≤ ∑ p ∈ (primesUpTo N).filter (fun p => p ∉ Q), (1 : ℝ) / p := by positivity + rw [hmass] at hh + linarith + have hZ := halasz_undeleted_discrepancy_sq F hF Q t N + rw [hmass] at hZ + have hh := halasz_near_discrepancy_numeric L A B Z + (squaredDistance F (mrtArchimedeanTwist t) N) hL hAB hA hB hD hZ + simpa only [halasz_masked_discrepancy_split F Q hQ t N, A, Z] using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearEnergy.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..adf7285aa38dac7b27aee0c8ff3e772dbe70bbb2 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearEnergy.lean @@ -0,0 +1,120 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszNearRenormalization +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTWeightedPrefix +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTDyadicMeanSquare + +namespace OAI + +/-! Conversion of the centered prefix comparison into the actual dyadic +Fourier energy. The main term is integrated with its exact Cauchy kernel. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory + +lemma halasz_dyadic_phase (F : ℕ → ℂ) (N : ℕ) (u : ℝ) : + mrtDyadicPolynomial F N u = + ∑ n ∈ Ioc N (2 * N), (F n * halaszPowerPhase u n) / (n : ℂ) := by + unfold mrtDyadicPolynomial mrtExponentialPolynomial + apply sum_congr rfl + intro n _ + have he : Complex.exp (((-Real.log (n : ℝ)) * u : ℝ) * Complex.I) = + halaszPowerPhase u n := by + unfold halaszPowerPhase + congr 2 + push_cast + ring + rw [he] + ring + +lemma halasz_phase_factor_sq (u : ℝ) : + (‖(1 : ℂ) + (-u : ℂ) * Complex.I‖⁻¹) ^ 2 = 1 / (1 + u ^ 2) := by + rw [inv_pow, Complex.sq_norm, Complex.normSq_apply] + simp [Complex.mul_re, Complex.mul_im] + ring + +lemma halasz_near_dyadic_bound (F : ℕ → ℂ) {N : ℕ} (hN : 0 < N) + (A E u : ℝ) (hA : 0 ≤ A) (hE : 0 ≤ E) + (hcenter : ∀ k ∈ Icc N (2 * N), ‖halaszPhaseMean F 0 k‖ ≤ A * k) + (hnear : ∀ k ∈ Icc N (2 * N), + ‖halaszPhaseMean F u k - + (halaszPowerPhase u k / (1 + (-u : ℂ) * Complex.I)) * halaszPhaseMean F 0 k‖ ≤ E * k) : + ‖mrtDyadicPolynomial F N u‖ ≤ + 5 * (‖(1 : ℂ) + (-u : ℂ) * Complex.I‖⁻¹ * A + E) := by + rw [halasz_dyadic_phase] + apply mrt_weighted_prefix_bound (fun n => F n * halaszPowerPhase u n) hN + (by omega) (by omega) (by positivity) + intro k hk + change ‖halaszPhaseMean F u k‖ ≤ _ + have hc := hcenter k hk + have hn := hnear k hk + let w := halaszPowerPhase u k / (1 + (-u : ℂ) * Complex.I) + have hw : ‖w‖ = ‖(1 : ℂ) + (-u : ℂ) * Complex.I‖⁻¹ := by + simp [w] + calc + _ = ‖(halaszPhaseMean F u k - w * halaszPhaseMean F 0 k) + + w * halaszPhaseMean F 0 k‖ := by congr 1; ring + _ ≤ ‖halaszPhaseMean F u k - w * halaszPhaseMean F 0 k‖ + + ‖w * halaszPhaseMean F 0 k‖ := norm_add_le _ _ + _ ≤ E * k + ‖w‖ * (A * k) := add_le_add hn + (by rw [norm_mul]; exact mul_le_mul_of_nonneg_left hc (norm_nonneg w)) + _ = _ := by rw [hw]; ring + +lemma halasz_near_dyadic_square (F : ℕ → ℂ) {N : ℕ} (hN : 0 < N) + (A E u : ℝ) (hA : 0 ≤ A) (hE : 0 ≤ E) + (hcenter : ∀ k ∈ Icc N (2 * N), ‖halaszPhaseMean F 0 k‖ ≤ A * k) + (hnear : ∀ k ∈ Icc N (2 * N), + ‖halaszPhaseMean F u k - + (halaszPowerPhase u k / (1 + (-u : ℂ) * Complex.I)) * halaszPhaseMean F 0 k‖ ≤ E * k) : + ‖mrtDyadicPolynomial F N u‖ ^ 2 ≤ 50 * (A ^ 2 / (1 + u ^ 2) + E ^ 2) := by + have hb := halasz_near_dyadic_bound F hN A E u hA hE hcenter hnear + have hs := pow_le_pow_left₀ (norm_nonneg (mrtDyadicPolynomial F N u)) hb 2 + let K := ‖(1 : ℂ) + (-u : ℂ) * Complex.I‖⁻¹ + have he : K ^ 2 = 1 / (1 + u ^ 2) := halasz_phase_factor_sq u + have hsq : (K * A + E) ^ 2 ≤ 2 * (K ^ 2 * A ^ 2 + E ^ 2) := by + nlinarith [sq_nonneg (K * A - E)] + calc + _ ≤ (5 * (K * A + E)) ^ 2 := hs + _ ≤ 50 * (K ^ 2 * A ^ 2 + E ^ 2) := by nlinarith + _ = _ := by rw [he]; ring + +/-- Only the squared renormalization error pays for the length of the +near-center frequency interval. -/ +theorem halasz_near_dyadic_energy (F : ℕ → ℂ) {N : ℕ} (hN : 0 < N) + (A E U : ℝ) (hA : 0 ≤ A) (hE : 0 ≤ E) (hU : 0 ≤ U) + (hcenter : ∀ k ∈ Icc N (2 * N), ‖halaszPhaseMean F 0 k‖ ≤ A * k) + (hnear : ∀ u ∈ Set.Icc (-U) U, ∀ k ∈ Icc N (2 * N), + ‖halaszPhaseMean F u k - + (halaszPowerPhase u k / (1 + (-u : ℂ) * Complex.I)) * halaszPhaseMean F 0 k‖ ≤ E * k) : + (∫ u in -U..U, ‖mrtDyadicPolynomial F N u‖ ^ 2) ≤ + 50 * Real.pi * A ^ 2 + 100 * U * E ^ 2 := by + have hf : Continuous (fun u => ‖mrtDyadicPolynomial F N u‖ ^ 2) := + (mrtExponentialPolynomial_continuous _ _ _).norm.pow 2 + have hg : Continuous (fun u : ℝ => 1 / (1 + u ^ 2)) := by + fun_prop (disch := intro u; nlinarith [sq_nonneg u]) + have hh := intervalIntegral.integral_mono_on (μ := volume) (by linarith : -U ≤ U) + (hf.intervalIntegrable _ _) + (((hg.mul_const (A ^ 2)).add (continuous_const : Continuous (fun _ : ℝ => E ^ 2))).const_mul 50 + |>.intervalIntegrable (-U) U) + (fun u hu => ?_) + · simp only [Pi.add_apply] at hh + have hi : (∫ u in -U..U, 50 * ((1 / (1 + u ^ 2)) * A ^ 2 + E ^ 2)) = + 50 * ((Real.arctan U - Real.arctan (-U)) * A ^ 2 + (2 * U) * E ^ 2) := by + rw [intervalIntegral.integral_const_mul, + intervalIntegral.integral_add ((hg.mul_const (A ^ 2)).intervalIntegrable _ _) + (continuous_const.intervalIntegrable _ _), + intervalIntegral.integral_mul_const, integral_one_div_one_add_sq, + intervalIntegral.integral_const] + simp only [smul_eq_mul] + ring + rw [hi] at hh + have ha := Real.arctan_lt_pi_div_two U + rw [Real.arctan_neg] at hh + have hm := mul_le_mul_of_nonneg_right (show 2 * Real.arctan U ≤ Real.pi by linarith) (sq_nonneg A) + nlinarith + · convert halasz_near_dyadic_square F hN A E u hA hE hcenter (hnear u hu) using 1 + dsimp only [Pi.add_apply] + ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearRenormalization.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearRenormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..10d8593d1c83eb598223082912e3b02f089142df --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearRenormalization.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszUnitRenormalization +import OAI.NumberTheory.TwoPoint.Halasz.HalaszGeneralTwist + +namespace OAI + +/-! Uniform renormalization on the small neighborhood of the minimizing twist. +This is the near-twist ingredient needed for the MRT Fourier energy estimate. -/ + +namespace TwoPointCorrelations + +open Finset Filter + +/-- The elementary unit-correction argument loses only `log(N)^(-1/16)` +on the whole near-center frequency interval. -/ +theorem halasz_near_renormalization : + ∀ᶠ N : ℕ in atTop, ∀ (F : ℕ → ℂ), F 1 = 1 → Multiplicative F → OneBounded F → + ∀ (Q : Finset ℕ), (∀ p ∈ Q, p.Prime) → + (∀ p ∈ Q, (p : ℝ) ≤ Real.exp (Real.sqrt (Real.log N))) → + ∀ t : ℝ, squaredDistance F (mrtArchimedeanTwist t) N ≤ + Real.log (Real.log N) / 8 → + ∀ u : ℝ, |u| ≤ (Real.log N) ^ (1 / (16 : ℝ)) → + let G := halaszTwistedFunction (mrtMissingCoefficient F Q) t + ‖halaszPhaseMean G u N - + (halaszPowerPhase u N / (1 + (-u : ℂ) * Complex.I)) * halaszPhaseMean G 0 N‖ ≤ + (36 * (halaszPrimePowerLogConstant + 1) * Real.exp 8) * N * + (Real.log N) ^ (-1 / (16 : ℝ)) := by + have hlog : ∀ᶠ N : ℕ in atTop, 1 ≤ Real.log (N : ℝ) := + (Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop).eventually (eventually_ge_atTop 1) + filter_upwards [halasz_near_correction_mean, hlog] with N hmean hlogN + intro F hF1 hFm hFb Q hQ hcut t hD u hu + dsimp only + let G := halaszTwistedFunction (mrtMissingCoefficient F Q) t + have hGm : Multiplicative G := halasz_twisted_multiplicative _ + (mrtMissingCoefficient_multiplicative F hFm Q hQ) t + have hG1 : G 1 = 1 := halasz_twisted_one _ (mrtMissingCoefficient_one F hF1 Q hQ) t + have hh := halasz_unit_renormalization G hGm hG1 u N + have hm := hmean F hF1 hFb Q hQ hcut t hD + have hl : 0 < Real.log (N : ℝ) := by linarith + have hp : 1 ≤ (Real.log N) ^ (1 / (16 : ℝ)) := Real.one_le_rpow hlogN (by norm_num) + have hb : 18 * (1 + |u|) ≤ 36 * (Real.log N) ^ (1 / (16 : ℝ)) := by linarith + have hc : 0 ≤ (halaszPrimePowerLogConstant + 1) * Real.exp 8 := by + unfold halaszPrimePowerLogConstant + positivity + have he : (Real.log N) ^ (1 / (16 : ℝ)) * (Real.log N) ^ (-1 / (8 : ℝ)) = + (Real.log N) ^ (-1 / (16 : ℝ)) := by + rw [← Real.rpow_add hl] + norm_num + apply hh.trans + calc + _ ≤ (36 * (Real.log N) ^ (1 / (16 : ℝ))) * + (((halaszPrimePowerLogConstant + 1) * Real.exp 8) * N * + (Real.log N) ^ (-1 / (8 : ℝ))) := by + exact mul_le_mul hb hm (sum_nonneg (fun _ _ => norm_nonneg _)) (by positivity) + _ = (36 * (halaszPrimePowerLogConstant + 1) * Real.exp 8) * N * + ((Real.log N) ^ (1 / (16 : ℝ)) * (Real.log N) ^ (-1 / (8 : ℝ))) := by ring + _ = _ := by rw [he] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearRestriction.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa9ea96e2bc7d23c4d8e3718ba39643669d527db --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearRestriction.lean @@ -0,0 +1,35 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszBandNearEnergy + +namespace OAI + +/-! Transfer the proved centered energy to the actual frequency subsets +in the logarithmic prime-band partition. -/ + +namespace TwoPointCorrelations + +open MeasureTheory Set + +lemma halasz_restricted_near_energy (b : ℕ → ℂ) (N : ℕ) + (t U A : ℝ) (hU : 0 ≤ U) + (hnear : (∫ u in -U..U, ‖mrtDyadicPolynomial b N (t + u)‖^2) ≤ A) + (E : Set ℝ) (hE : E ⊆ Ioc (t-U) (t+U)) : + (∫ s in E, ‖mrtDyadicPolynomial b N s‖^2) ≤ A := by + have hc : Continuous (fun s => ‖mrtDyadicPolynomial b N s‖^2) := + (mrtExponentialPolynomial_continuous _ _ _).norm.pow 2 + have hab : t-U ≤ t+U := by linarith + have he : (∫ u in -U..U, ‖mrtDyadicPolynomial b N (t + u)‖^2) = + ∫ s in (t-U)..(t+U), ‖mrtDyadicPolynomial b N s‖^2 := by + simpa only [sub_eq_add_neg, add_comm] using + (intervalIntegral.integral_comp_add_left + (fun s => ‖mrtDyadicPolynomial b N s‖^2) t (a := -U) (b := U)) + rw [he, intervalIntegral.integral_of_le hab] at hnear + apply le_trans _ hnear + exact setIntegral_mono_set + ((intervalIntegrable_iff_integrableOn_Ioc_of_le hab).mp + (hc.intervalIntegrable _ _)) + (Filter.Eventually.of_forall (fun _ => sq_nonneg _)) + (Filter.Eventually.of_forall hE) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearScales.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearScales.lean new file mode 100644 index 0000000000000000000000000000000000000000..066e8f18c64c55c4a74402b85dc4a16bf2178fa8 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNearScales.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszCenteredPrefix + +namespace OAI + +/-! The near-center comparison is uniform on every prefix of the actual +dyadic interval, with the pretentious condition at the original cutoff. -/ + +namespace TwoPointCorrelations + +open Finset Filter +open scoped Classical ComplexConjugate + +lemma halasz_loglog_power_cutoff (N X : ℕ) (hN : 2 ≤ N) (hX2 : 2 ≤ X) (hX : X ≤ N ^ 3) : + Real.log (Real.log X) ≤ Real.log (Real.log N) + Real.log 3 := by + have hX1 : 1 < (X : ℝ) := by exact_mod_cast (show 1 < X by omega) + have hLN : 0 < Real.log (N : ℝ) := Real.log_pos (by exact_mod_cast (show 1 < N by omega)) + have hh := Real.log_le_log (zero_lt_one.trans hX1) + (show (X : ℝ) ≤ (N : ℝ) ^ 3 by exact_mod_cast hX) + rw [Real.log_pow] at hh + norm_num only [Nat.cast_ofNat] at hh + have hh' := Real.log_le_log (Real.log_pos hX1) hh + rw [Real.log_mul (by norm_num : (3 : ℝ) ≠ 0) hLN.ne'] at hh' + linarith + +/-- Small distance at X suffices for every prefix in `[N,2N]`, without +redefining the minimizing twist at each prefix. -/ +theorem halasz_near_prefix_uniform : + ∀ᶠ N : ℕ in atTop, ∀ X : ℕ, N ≤ 2 * X → X ≤ N ^ 3 → + ∀ (F : ℕ → ℂ), F 1 = 1 → Multiplicative F → OneBounded F → + ∀ t : ℝ, squaredDistance F (mrtArchimedeanTwist t) X ≤ + Real.log (Real.log X) / 10 → + ∀ u : ℝ, |u| ≤ (Real.log N) ^ (1 / (16 : ℝ)) → + ∀ k ∈ Icc N (2 * N), + ‖halaszPhaseMean (halaszTwistedFunction F t) u k - + (halaszPowerPhase u k / (1 + (-u : ℂ) * Complex.I)) * + halaszPhaseMean (halaszTwistedFunction F t) 0 k‖ ≤ + (36 * (halaszPrimePowerLogConstant + 1) * Real.exp 8) * + (Real.log N) ^ (-1 / (16 : ℝ)) * k := by + obtain ⟨K, hK⟩ := eventually_atTop.mp halasz_near_renormalization + obtain ⟨B, hB, hcut⟩ := halasz_distance_cutoff_loss + have hLL : ∀ᶠ N : ℕ in atTop, 4 * Real.log 3 + 40 * B ≤ Real.log (Real.log (N : ℝ)) := + (Real.tendsto_log_atTop.comp + (Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop)).eventually + (eventually_ge_atTop (4 * Real.log 3 + 40 * B)) + filter_upwards [eventually_ge_atTop K, eventually_ge_atTop 4, hLL] with N hNK hN2 hLLN + intro X hNX hXN F hF1 hFm hFb t hD u hu k hk + have hNk := (mem_Icc.mp hk).1 + have hX2 : 2 ≤ X := by omega + have hN0 : 0 < (N : ℝ) := by exact_mod_cast (show 0 < N by omega) + have hLN : 0 < Real.log (N : ℝ) := Real.log_pos (by exact_mod_cast (show 1 < N by omega)) + have hLNk : Real.log (N : ℝ) ≤ Real.log k := Real.log_le_log hN0 (by exact_mod_cast hNk) + have hLLNk : Real.log (Real.log (N : ℝ)) ≤ Real.log (Real.log k) := + Real.log_le_log hLN hLNk + have hLLX := halasz_loglog_power_cutoff N X (by omega) hX2 hXN + have hDk : squaredDistance F (mrtArchimedeanTwist t) k ≤ Real.log (Real.log k) / 8 := by + have hupp : squaredDistance F (mrtArchimedeanTwist t) k ≤ + squaredDistance F (mrtArchimedeanTwist t) X + B := by + by_cases hkX : k ≤ X + · have hm := halasz_distance_monotone F hFb t hkX + linarith + · have hXk : X ≤ k := by omega + have hkc : k ≤ X ^ 3 := by + have hsq : 4 ≤ X ^ 2 := by nlinarith + calc + k ≤ 2 * N := (mem_Icc.mp hk).2 + _ ≤ 4 * X := by omega + _ ≤ X * X ^ 2 := by nlinarith + _ = X ^ 3 := by ring + exact hcut F hFb X k hX2 hXk hkc t + linarith + have huk : |u| ≤ (Real.log k) ^ (1 / (16 : ℝ)) := hu.trans + (Real.rpow_le_rpow hLN.le hLNk (by norm_num)) + have hh := hK k (hNK.trans hNk) F hF1 hFm hFb ∅ (by simp) (by simp) t hDk u huk + have he : mrtMissingCoefficient F ∅ = F := by + funext n + simp [mrtMissingCoefficient, mrtPrimeMask, mrtPrimeAvoids] + rw [he] at hh + apply hh.trans + have hr := Real.rpow_le_rpow_of_nonpos hLN hLNk (by norm_num : (-1 / (16 : ℝ)) ≤ 0) + have hc : 0 ≤ 36 * (halaszPrimePowerLogConstant + 1) * Real.exp 8 := by + unfold halaszPrimePowerLogConstant + positivity + calc + _ ≤ (36 * (halaszPrimePowerLogConstant + 1) * Real.exp 8) * k * + (Real.log N) ^ (-1 / (16 : ℝ)) := by gcongr + _ = _ := by ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNonsingularMoment.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNonsingularMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ea26a2b21153c078dc401f74f9a91f330c73c82 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNonsingularMoment.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszResidueQuotient +import OAI.NumberTheory.TwoPoint.Halasz.HalaszResidueAveraging + +namespace OAI + +/-! The nonsingular branch of the classical complete-system iteration. +All short-variable residue classes are included. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +theorem halasz_fixed_residue_moment {s k N M p r : ℕ} [Fact p.Prime] + (hkp : k (((z i).val+1:ℕ):ZMod p))) (b : Fin p) : + halaszFiberEnergy + (Z×ˢFintype.piFinset (fun _ : Fin s => + univ.filter (fun x : Fin M => halaszResidueIndex (Fact.out : p.Prime).pos x=b))) + (fun x j => halaszNatPowerFrequency k x.1 j+halaszNatPowerFrequency k x.2 j) ≤ + (k^k*p^((r+1)*r/2)) * (N^k*halaszVinogradovCount s k (M/p+1)) := by + let F := Z×ˢFintype.piFinset (fun _ : Fin s => + univ.filter (fun x : Fin M => halaszResidueIndex (Fact.out : p.Prime).pos x=b)) + let q := halaszResidueTupleQuotient (s := s) (k := k) (N := N) (M := M) p + let I := F.image q + have hq : Set.InjOn q F := halasz_residue_tuple_quotient_injOn (Fact.out : p.Prime).pos Z b + have hI : ∀ x∈I, Function.Injective (fun i => (((x.1 i).val+1:ℕ):ZMod p)) := by + intro x hx + obtain ⟨y,hy,rfl⟩ := mem_image.mp hx + exact hZ y.1 (mem_product.mp hy).1 + have ha : p-1-b.val

halaszNatPowerFrequency k x.1 j+halaszNatPowerFrequency k x.2 j) + (halaszCommonResidueFrequency p (p-1-b.val)) + (fun x hx => halasz_residue_tuple_trace (Fact.out : p.Prime).pos Z b x hx) + have hb := halasz_common_residue_energy (a := p-1-b.val) (r := r) + (s := s) (N := N) (Q := M/p+1) hkp hrk ha hN I hI + apply he.trans_le + convert hb using 1 + congr 1 + ext z + simp only [I,mem_image] + +theorem halasz_nonsingular_moment {s k N M p r : ℕ} [Fact p.Prime] + (hs : 0 (((z i).val+1:ℕ):ZMod p))) : + halaszFiberEnergy (Z×ˢ(univ : Finset (Fin s → Fin M))) + (fun x j => halaszNatPowerFrequency k x.1 j+halaszNatPowerFrequency k x.2 j) ≤ + p^(2*s) * ((k^k*p^((r+1)*r/2)) * (N^k*halaszVinogradovCount s k (M/p+1))) := by + let f (z : Fin k → Fin N) : Fin k → ℤ := fun j => halaszNatPowerFrequency k z j + let g (x : Fin M) : Fin k → ℤ := fun j => ((x.val+1)^(j.val+1):ℕ) + have he (G : Finset (Fin M)) : + halaszFiberEnergy (Z×ˢFintype.piFinset (fun _ : Fin s => G)) + (fun x => f x.1+∑ i, g (x.2 i)) = + halaszFiberEnergy (Z×ˢFintype.piFinset (fun _ : Fin s => G)) + (fun x j => halaszNatPowerFrequency k x.1 j+halaszNatPowerFrequency k x.2 j) := by + rw [← halasz_fiber_energy_natCast] + congr 1 + funext x j + simp only [f,g,Pi.add_apply,Finset.sum_apply,halaszNatPowerFrequency,Nat.cast_add,Nat.cast_sum] + have hh := halasz_residue_average_energy hs Z (univ : Finset (Fin M)) + (halaszResidueIndex (Fact.out : p.Prime).pos) f g + ((k^k*p^((r+1)*r/2)) * (N^k*halaszVinogradovCount s k (M/p+1))) + (by + intro b + rw [he] + exact halasz_fixed_residue_moment hkp hrk hN Z hZ b) + rw [he] at hh + simpa only [Fintype.piFinset_univ] using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNormalizedDoubleMoment.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNormalizedDoubleMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..309b9e6cb676ff8222a9aedbc0079cf801cb7017 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNormalizedDoubleMoment.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszWeightNormalization +import OAI.NumberTheory.TwoPoint.Halasz.HalaszQuantitativeMeanValue + +namespace OAI + +/-! Cancellation of the two complete-system degree costs against the +coordinate volumes in the double moment. -/ +namespace TwoPointCorrelations + +open Finset + +lemma halasz_coordinate_degree (k : ℕ) : + (∑ j : Fin k, ((j.val+1:ℕ):ℝ))=(k:ℝ)*(k+1)/2 := by + induction k with + | zero => simp + | succ k ih => + rw [Fin.sum_univ_castSucc] + simp only [Fin.val_castSucc,Fin.val_last] + rw [ih] + push_cast + ring + +lemma halasz_coordinate_total_degree {k : ℕ} (hk : 0 (((b.val+1)^(j.val+1):ℕ):ℤ)))‖^(2*r*r) ≤ + (32*(r:ℝ))^k*C^2*(M:ℝ)^(4*(r:ℝ)^2+2*ε)* + ∏ j,halaszNormalizedWeight r M γ j := by + let K := ∑ j : Fin k,(j.val+1) + let e : ℝ := 2*(r:ℝ)-(K:ℝ)+ε + let W := ∏ j,halaszNormalizedWeight r M γ j + have hM0 : 0<(M:ℝ) := by exact_mod_cast (show 0 halasz_normalized_weight_nonneg γ j) + have hweights : (∏ j,halaszDoubleWeight r r M M γ j)≤(M:ℝ)^K*W := by + calc + _ ≤ ∏ j : Fin k,(M:ℝ)^(j.val+1)*halaszNormalizedWeight r M γ j := + prod_le_prod₀ (fun j _ => halasz_double_weight_nonneg γ j) + (fun j _ => halasz_weight_normalized hr hM γ hγ j) + _ = _ := by rw [prod_mul_distrib,prod_pow_eq_pow_sum] + have hJ2 : (halaszVinogradovCount r k M:ℝ)^2≤(C*(M:ℝ)^e)^2 := + pow_le_pow_left₀ (Nat.cast_nonneg _) hJ 2 + have hbase := halasz_double_specialized k M M r r hr hr hM γ hγ + have hbound : + ‖∑ b : Fin M,halaszVinogradovPolynomial k M + (halaszScaledFrequency γ (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)))‖^(2*r*r) ≤ + (32*(r:ℝ))^k*(M:ℝ)^K*(M:ℝ)^((r-1)*(2*r))*(M:ℝ)^(r*(2*r-2))* + (C*(M:ℝ)^e)^2*((M:ℝ)^K*W) := by + apply hbase.trans + calc + _ = (32*(r:ℝ))^k*(M:ℝ)^K*(M:ℝ)^((r-1)*(2*r))*(M:ℝ)^(r*(2*r-2))* + (halaszVinogradovCount r k M:ℝ)^2*(∏ j,halaszDoubleWeight r r M M γ j) := by ring + _ ≤ _ := mul_le_mul + (mul_le_mul_of_nonneg_left hJ2 (by positivity)) hweights + (prod_nonneg (fun j _ => halasz_double_weight_nonneg γ j)) (by positivity) + apply hbound.trans_eq + have hr2 : 2≤2*r := by omega + have hexp : (K:ℝ)+(((r-1)*(2*r):ℕ):ℝ)+((r*(2*r-2):ℕ):ℝ)+2*e+(K:ℝ)= + 4*(r:ℝ)^2+2*ε := by + dsimp only [e] + push_cast [Nat.cast_sub hr,Nat.cast_sub hr2] + ring + calc + _ = (32*(r:ℝ))^k*C^2* + ((M:ℝ)^K*(M:ℝ)^((r-1)*(2*r))*(M:ℝ)^(r*(2*r-2))* + ((M:ℝ)^e)^2*(M:ℝ)^K)*W := by ring + _ = (32*(r:ℝ))^k*C^2*(M:ℝ)^(4*(r:ℝ)^2+2*ε)*W := by + rw [← Real.rpow_natCast (M:ℝ) K,← Real.rpow_natCast (M:ℝ) ((r-1)*(2*r)), + ← Real.rpow_natCast (M:ℝ) (r*(2*r-2)), + ← Real.rpow_natCast ((M:ℝ)^e) 2,← Real.rpow_mul hM0.le] + rw [← Real.rpow_add hM0,← Real.rpow_add hM0,← Real.rpow_add hM0, + ← Real.rpow_add hM0] + norm_num only [Nat.cast_ofNat] + rw [show (K:ℝ)+(((r-1)*(2*r):ℕ):ℝ)+((r*(2*r-2):ℕ):ℝ)+e*2+(K:ℝ)= + 4*(r:ℝ)^2+2*ε by nlinarith only [hexp]] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNormalizedStep.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNormalizedStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..9263d1dbfddafad7c697d6c2805df0ec9524ed9e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszNormalizedStep.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszRootScale + +namespace OAI + +/-! The classical step in the power-bound form used by iteration. -/ +namespace TwoPointCorrelations + +def halaszStepExponent (s k : ℕ) : ℕ := 2*s+k*(k-1)/2 + +theorem halasz_normalize_classical_bound {s k N R : ℕ} {A e : ℝ} + (hN : 0 mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) N a t‖ ≤ + (Real.log n)^(-1/40:ℝ) := by + obtain ⟨C,K,X₀,hC,hK,hcofactor⟩ := halasz_exceptional_typical_window + refine ⟨X₀,?_⟩ + have hlog : Tendsto (fun n:ℕ => Real.log n) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + filter_upwards [hhigh.distance_cutoff K,halasz_cofactor_band_count, + hlog.eventually (halasz_exceptional_decay C hC.le), + hlog.eventually (eventually_ge_atTop (1:ℝ))] with n hcut hcount hdec hln + intro N a ha hbase hn X hnX hX F hF1 hFm hFb P Q J hQ hband A hA t τ hτ hmin ht haway + have hM : 0 ≤ (3/100:ℝ)*Real.log (Real.log n) := + mul_nonneg (by norm_num) (Real.log_nonneg hln) + have hd : ∀ v:ℝ, |v-t| ≤ (Real.log n)^8 → 1/2 ≤ |v-τ| → + 2*((3/100:ℝ)*Real.log (Real.log n))+K ≤ + squaredDistance F (mrtArchimedeanTwist v) n := by + intro v hv hunit + have hvX : |v| ≤ X := by + have hh := abs_add_le (v-t) t + rw [sub_add_cancel] at hh + linarith + exact hcut X hnX hX F hFb v τ hvX hτ hunit (hmin v hvX) + have hb := hcofactor N a ha hbase F hF1 hFm hFb ℕ (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) A + (fun _ _ _ hp => mrtPrimeBand_prime hp) hA t τ + ((3/100:ℝ)*Real.log (Real.log n)) hM (by simpa only [← hn] using hd) + have hsave := hdec ((2:ℝ)^(Icc 1 J).card) (τ-t) (by positivity) + (hcount X hnX hX Q J hQ hband) (by simpa only [abs_sub_comm] using haway) + apply hb.trans + simpa only [← hn,mul_comm C] using hsave + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalKernel.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0fbe13d7ab84c64a3d394d6ed0c6b1a24af32bf --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalKernel.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszOriginalNoSmall +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTCommonFinalBand + +namespace OAI + +/-! The lower half of the short-window kernel uses distance information +only up to the original published cutoff and height. -/ + +namespace TwoPointCorrelations + +open Finset Filter MeasureTheory +open scoped Classical + +theorem halasz_original_kernel_bound + (hprime : HalaszPrimeSparseInput) (hhigh : HalaszHighPrimeInput) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ N : ℕ in atTop, + ∀ F : ℕ → ℂ, F 1=1 → Multiplicative F → OneBounded F → + ∀ P Q : ℝ, 2 ≤ P → P ≤ Q → 1 ≤ Real.log Q → + 2 ≤ mrtBaseResolution P Q (1/100) → + ∀ J : ℕ, 1 ≤ J → + (∀ k ∈ ({N,2*N}:Finset ℕ), + 200*Real.log (Real.log k)+1 ≤ Real.log (mrtBandLower P Q J) ∧ + mrtBandUpper Q J ≤ Real.exp (Real.sqrt (Real.log k))) → + ∀ X : ℕ, N ≤ X → X ≤ N^3 → + ∀ M : ℝ, 0 ≤ M → + (∀ u:ℝ, |u| ≤ X → M ≤ squaredDistance F (mrtArchimedeanTwist u) X) → + ∀ k ∈ ({N,2*N}:Finset ℕ), ∀ v:ℝ, 0 ≤ v → v ≤ (k:ℝ)/4 → + (∫ t in Set.Ioc (-v) v ∩ mrtNoSmallBand (mrtLogFamilyBins P Q (1/100)) + (mrtLogFamilyPolynomial + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F P Q (1/100)) + (mrtLogFamilyThreshold P Q (1/100)) J, + ‖mrtDyadicPolynomial (mrtTypicalCoefficient (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) k t‖^2) ≤ + C*((Real.log P/Real.log Q)^2+Real.exp (-M)+ + Real.log (Real.log N)/(Real.log N)^(1/100:ℝ))*(v/k+1) := by + obtain ⟨C,hC,henergy⟩ := halasz_original_no_small_energy hprime hhigh + obtain ⟨N₀,hN₀⟩ := eventually_atTop.mp henergy + refine ⟨2*C,by positivity,?_⟩ + have hlog : Tendsto (fun N:ℕ => Real.log N) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + filter_upwards [eventually_ge_atTop N₀,eventually_ge_atTop 2, + hlog.eventually (eventually_ge_atTop (1:ℝ)), + (Real.tendsto_log_atTop.comp hlog).eventually (eventually_ge_atTop (1:ℝ))] + with N hNN hN2 hL hLL + intro F hF1 hFm hFb P Q hP hPQ hQ hres J hJ hband X hNX hXN M hM hd k hk v hv hvk + have hNk : N ≤ k := by simp only [mem_insert,mem_singleton] at hk; omega + have hkN : k ≤ 2*N := by simp only [mem_insert,mem_singleton] at hk; omega + have hk0 : 0 < (k:ℝ) := by exact_mod_cast (show 0 hd u (hu.trans (by + have hh : (k:ℝ) ≤ 2*(N:ℝ) := by exact_mod_cast hkN + have hNXr : (N:ℝ) ≤ X := by exact_mod_cast hNX + linarith))) + let B := mrtTypicalCoefficient (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F + let G := fun t:ℝ => ‖mrtDyadicPolynomial B k t‖^2 + let E := Set.Ioc (-v) v ∩ mrtNoSmallBand (mrtLogFamilyBins P Q (1/100)) + (mrtLogFamilyPolynomial + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F P Q (1/100)) + (mrtLogFamilyThreshold P Q (1/100)) J + let E₀ := mrtActualNoSmall P Q J k F ∩ Set.Ioc (-((k:ℝ)/4)) ((k:ℝ)/4) + have hsub : E ⊆ E₀ := by + intro t ht + refine ⟨⟨⟨?_,?_⟩,ht.2⟩,⟨?_,?_⟩⟩ <;> linarith [ht.1.1,ht.1.2] + have hGc : Continuous G := (mrtExponentialPolynomial_continuous _ _ _).norm.pow 2 + have hGi : IntegrableOn G E₀ := by + apply ((intervalIntegrable_iff_integrableOn_Ioc_of_le (by linarith : -(k:ℝ)≤k)).mp + (hGc.intervalIntegrable (-(k:ℝ)) k)).mono_set + exact fun _ ht => ht.1.1 + have htrunc : (∫ t in E,G t) ≤ ∫ t in E₀,G t := + setIntegral_mono_set hGi (Filter.Eventually.of_forall (fun _ => sq_nonneg _)) + (Filter.Eventually.of_forall hsub) + have hδ := mrt_dyadic_log_error hN2 hL hLL hNk hkN + let R := (Real.log P/Real.log Q)^2+Real.exp (-M) + let δ := Real.log (Real.log N)/(Real.log N)^(1/100:ℝ) + have hR : 0 ≤ R := add_nonneg (sq_nonneg _) (Real.exp_pos _).le + have hδ0 : 0 ≤ δ := div_nonneg (zero_le_one.trans hLL) (by positivity) + have hb : (∫ t in E,G t) ≤ (2*C)*(R+δ) := by + apply htrunc.trans (he.trans ?_) + dsimp only [R,δ] at ⊢ + nlinarith [mul_le_mul_of_nonneg_left hδ hC.le, mul_nonneg hC.le hR] + change (∫ t in E,G t) ≤ _ + apply hb.trans + change (2*C)*(R+δ) ≤ (2*C)*(R+δ)*(v/k+1) + exact le_mul_of_one_le_right (by positivity) (by + have hh : 0 ≤ v/(k:ℝ) := div_nonneg hv hk0.le + linarith) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalNearEnergy.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalNearEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..25e40aad39bf52239b0f5719528de22c7e22128f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalNearEnergy.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszSharpNearActual + +namespace OAI + +/-! Keep the original pretentious cutoff and height in the sharp +near-center bound, independently of the dyadic polynomial's cutoff. -/ + +namespace TwoPointCorrelations + +open Finset Filter MeasureTheory +open scoped Classical + +theorem halasz_sharp_near_original_scale : ∃ C : ℝ, 0 < C ∧ + ∀ᶠ N : ℕ in atTop, ∀ (P Q : ℝ) (J : ℕ), + 2 ≤ P → P ≤ Q → 1 ≤ Real.log Q → 1 ≤ J → + (∀ j ∈ Icc 1 J, mrtBandUpper Q j ≤ Real.exp (Real.sqrt (Real.log N))) → + ∀ X : ℕ, N ≤ 2*X → X ≤ N^3 → + ∀ (F : ℕ → ℂ), F 1 = 1 → Multiplicative F → OneBounded F → + ∀ τ T M : ℝ, 0 ≤ M → |τ|+Real.log (2*N:ℕ)^8 ≤ T → + (∀ v:ℝ, |v| ≤ T → M ≤ squaredDistance F (mrtArchimedeanTwist v) X) → + squaredDistance F (mrtArchimedeanTwist τ) (2*N) ≤ + Real.log (Real.log (2*N:ℕ))/10 → + (∫ u in -((Real.log N)^(1/16:ℝ))..((Real.log N)^(1/16:ℝ)), + ‖mrtDyadicPolynomial (mrtTypicalCoefficient (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) + N (τ+u)‖^2) ≤ + C*((Real.log P/Real.log Q)^2+Real.exp (-M)+(Real.log N)^(-1/32:ℝ)) := by + obtain ⟨C₁,hC₁,hcenter⟩ := halasz_centered_prefix + obtain ⟨C₂,hC₂,hprefix⟩ := mrt_typical_centered_prefix_density + let D := 36*(halaszPrimePowerLogConstant+1)*Real.exp 8 + refine ⟨600*Real.pi*C₁^2+300*Real.pi*C₂^2+100*D^2,by positivity,?_⟩ + have hlog : Tendsto (fun N:ℕ => Real.log N) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + filter_upwards [hcenter,hprefix,mrt_band_near_renormalization, + hlog.eventually (eventually_ge_atTop (1:ℝ)),eventually_ge_atTop 2] + with N hcenter hprefix hnear hL hN2 + intro P Q J hP hPQ hQ hJ hmax X hNX hXN F hF1 hFm hFb τ T M hM hτ hd hsmall + let V := fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j) + let B := halaszTwistedFunction (mrtTypicalCoefficient (Icc 1 J) V F) τ + have hc := hcenter X hNX hXN F hF1 hFm hFb τ T M hM hτ hd + have hp := hprefix P Q J hP hPQ hQ hmax F hFb τ + have hR : 0 ≤ Real.log P/Real.log Q := + div_nonneg (Real.log_nonneg (by linarith)) (by linarith) + have hD : 0 ≤ D := by dsimp [D,halaszPrimePowerLogConstant]; positivity + have hn : ∀ u ∈ Set.Icc (-((Real.log N)^(1/16:ℝ))) ((Real.log N)^(1/16:ℝ)), + ∀ k ∈ Icc N (2*N), + ‖halaszPhaseMean B u k - + (halaszPowerPhase u k/(1+(-u:ℂ)*Complex.I))*halaszPhaseMean B 0 k‖ ≤ + (D*(Real.log N)^(-3/50:ℝ))*k := by + intro u hu k hk + exact hnear P Q J hQ hJ hmax F hF1 hFm hFb τ hsmall u (abs_le.mpr hu) k hk + have hh := halasz_sharp_near_energy B (halaszTwistedFunction F τ) (by omega) + C₁ C₂ D (Real.log N) M (Real.log P/Real.log Q) hC₁.le hC₂.le hD hL hR hc hp hn + simpa only [B,halasz_twisted_dyadic] using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalNearRestriction.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalNearRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbb0c56e20d64df3422137aacf959b8195d64854 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalNearRestriction.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszOriginalNearEnergy + +namespace OAI + +/-! Near-center energy restricted to the lower half of the frequency +range, where the original published height controls all required twists. -/ + +namespace TwoPointCorrelations + +open Finset Filter MeasureTheory +open scoped Classical + +lemma halasz_center_window_quarter_room : + ∀ᶠ N : ℕ in atTop, + Real.log (2*N:ℕ)^8+(Real.log N)^(1/16:ℝ) ≤ (N:ℝ)/4 := by + have hlog : Tendsto (fun N:ℕ => Real.log N) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + have hb := (isLittleO_pow_exp_pos_mul_atTop 8 (b := 1) (by norm_num)).bound + (show (0:ℝ)<1/2048 by norm_num) + filter_upwards [hlog.eventually hb,hlog.eventually (eventually_ge_atTop (1:ℝ)), + eventually_ge_atTop 2] with N hb hLN hN + have hN0 : 0 < (N:ℝ) := by exact_mod_cast (show 0 mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) N t‖^2) ≤ + C*((Real.log P/Real.log Q)^2+Real.exp (-M)+(Real.log N)^(-1/32:ℝ)) := by + obtain ⟨C,hC,hnear⟩ := halasz_sharp_near_original_scale + refine ⟨C,hC,?_⟩ + filter_upwards [hnear,halasz_center_window_quarter_room,eventually_ge_atTop 2] with N hnear hroom hN2 + intro P Q J hP hPQ hQ hJ hmax X hNX hXN F hF1 hFm hFb τ M hM hd hsmall E hEN hEt + by_cases hE : E.Nonempty + · obtain ⟨t,ht⟩ := hE + have hN := hEN ht + have hT := hEt ht + have hτ : |τ| ≤ (N:ℝ)/4+(Real.log N)^(1/16:ℝ) := by + apply abs_le.mpr + constructor <;> linarith [hN.1,hN.2,hT.1,hT.2] + have hroom' : |τ|+Real.log (2*N:ℕ)^8 ≤ (N:ℝ)/2 := by linarith + exact halasz_restricted_near_energy _ N τ ((Real.log N)^(1/16:ℝ)) _ + (Real.rpow_nonneg (Real.log_nonneg (by exact_mod_cast (show 1≤N by omega))) _) + (hnear P Q J hP hPQ hQ hJ hmax X hNX hXN F hF1 hFm hFb τ ((N:ℝ)/2) M hM hroom' hd hsmall) E hEt + · rw [Set.not_nonempty_iff_eq_empty.mp hE] + simp only [MeasureTheory.setIntegral_empty] + positivity + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalNoSmall.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalNoSmall.lean new file mode 100644 index 0000000000000000000000000000000000000000..fcd689a1e94e3f2477c9e94bd7b665cf2054845b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalNoSmall.lean @@ -0,0 +1,147 @@ +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTNoSmallFull +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLargeMinimum +import OAI.NumberTheory.TwoPoint.Halasz.HalaszOriginalNearRestriction + +namespace OAI + +/-! Low-frequency no-small energy with the original published distance +cutoff and height. The upper half of the kernel is handled by its decay. -/ +namespace TwoPointCorrelations + +open Filter Finset MeasureTheory +open scoped Classical + +theorem halasz_original_no_small_energy + (hprime : HalaszPrimeSparseInput) (hhigh : HalaszHighPrimeInput) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ N : ℕ in atTop, + ∀ F : ℕ → ℂ, F 1=1 → Multiplicative F → OneBounded F → + ∀ P Q : ℝ, 2 ≤ P → P ≤ Q → 1 ≤ Real.log Q → + 2 ≤ mrtBaseResolution P Q (1/100) → + ∀ J : ℕ, 1 ≤ J → + 200*Real.log (Real.log N)+1 ≤ Real.log (mrtBandLower P Q J) → + mrtBandUpper Q J ≤ Real.exp (Real.sqrt (Real.log N)) → + ∀ X : ℕ, N ≤ 2*X → X ≤ N^3 → + ∀ M : ℝ, 0 ≤ M → + (∀ v : ℝ, |v| ≤ (N:ℝ)/2 → M ≤ squaredDistance F (mrtArchimedeanTwist v) X) → + (∫ t in mrtActualNoSmall P Q J N F ∩ Set.Ioc (-((N:ℝ)/4)) ((N:ℝ)/4), + ‖mrtDyadicPolynomial (mrtTypicalCoefficient (Icc 1 J) + (fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j)) F) N t‖^2) ≤ + C*((Real.log P/Real.log Q)^2+Real.exp (-M)+ + Real.log (Real.log N)/(Real.log N)^(1/100:ℝ)) := by + obtain ⟨C₁,hC₁,hnear⟩ := halasz_sharp_near_original_restriction + obtain ⟨C₂,hC₂,hoff⟩ := mrt_no_small_off_center_energy hprime hhigh + obtain ⟨C₃,hC₃,hfull⟩ := mrt_no_small_full_energy hprime + refine ⟨C₁+C₂+C₃,by positivity,?_⟩ + have hlog : Tendsto (fun N:ℕ => Real.log N) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + filter_upwards [hnear,hoff,hfull,halasz_large_minimum_extra_cofactor, + hlog.eventually (eventually_ge_atTop (1:ℝ)), + (Real.tendsto_log_atTop.comp hlog).eventually (eventually_ge_atTop (1:ℝ))] + with N hnear hoff hfull hlarge hL hLL + intro F hF1 hFm hFb P Q hP hPQ hQ hres J hJ hlo hu X hNX hXN M hM hd + let V := fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j) + let B := mrtTypicalCoefficient (Icc 1 J) V F + let E := mrtActualNoSmall P Q J N F ∩ Set.Ioc (-((N:ℝ)/4)) ((N:ℝ)/4) + let G := fun t:ℝ => ‖mrtDyadicPolynomial B N t‖^2 + let δ := Real.log (Real.log N)/(Real.log N)^(1/100:ℝ) + let R := (Real.log P/Real.log Q)^2 + have hR : 0 ≤ R := sq_nonneg _ + have hδ : 0 ≤ δ := div_nonneg (by exact hLL.trans' (by norm_num)) (by positivity) + have hE : E ⊆ Set.Ioc (-(N:ℝ)) N := fun _ ht => ht.1.1 + have hmax : ∀ j ∈ Icc 1 J, mrtBandUpper Q j ≤ Real.exp (Real.sqrt (Real.log N)) := by + intro j hj + have hh := Real.exp_le_exp.mpr (mrt_band_upper_log_mono hQ + (mem_Icc.mp hj).1 (mem_Icc.mp hj).2) + rw [Real.exp_log (show 0 < mrtBandUpper Q j from Real.exp_pos _), + Real.exp_log (show 0 < mrtBandUpper Q J from Real.exp_pos _)] at hh + exact hh.trans hu + have hGc : Continuous G := (mrtExponentialPolynomial_continuous _ _ _).norm.pow 2 + have hGi : IntegrableOn G (Set.Ioc (-(N:ℝ)) N) := + (intervalIntegrable_iff_integrableOn_Ioc_of_le (by linarith [Nat.cast_nonneg (α:=ℝ) N])).mp + (hGc.intervalIntegrable _ _) + obtain ⟨τ,hτ,hmin⟩ := halasz_minimizing_twist F (2*N) + have hτ' : |τ| ≤ 2*(N:ℝ) := by simpa only [Nat.cast_mul,Nat.cast_ofNat] using hτ + have hmin' : ∀ v:ℝ, |v| ≤ 2*N → + squaredDistance F (mrtArchimedeanTwist τ) (2*N) ≤ + squaredDistance F (mrtArchimedeanTwist v) (2*N) := by + simpa only [Nat.cast_mul,Nat.cast_ofNat] using hmin + by_cases hsmall : squaredDistance F (mrtArchimedeanTwist τ) (2*N) ≤ + Real.log (Real.log (2*N:ℕ))/10 + · let I := Set.Ioc (τ-(Real.log N)^(1/16:ℝ)) (τ+(Real.log N)^(1/16:ℝ)) + have hn := hnear P Q J hP hPQ hQ hJ hmax X hNX hXN + F hF1 hFm hFb τ M hM hd hsmall (E∩I) + (fun _ ht => ht.1.2) Set.inter_subset_right + have ho := hoff F hF1 hFm hFb P Q (by linarith) hPQ hQ hres J hJ hlo hu τ hτ' hmin' + have hsub : E \ I ⊆ mrtNoSmallOffCenter P Q J N F τ := by + intro t ht + refine ⟨ht.1.1,?_⟩ + change (Real.log N)^(1/16:ℝ) ≤ |t-τ| + have hout := ht.2 + change ¬(τ-(Real.log N)^(1/16:ℝ) < t ∧ t ≤ τ+(Real.log N)^(1/16:ℝ)) at hout + by_cases htlo : τ-(Real.log N)^(1/16:ℝ) < t + · have hhi : τ+(Real.log N)^(1/16:ℝ) < t := by + push Not at hout + exact hout htlo + rw [abs_of_nonneg (by + have hp := Real.rpow_nonneg (show 0≤Real.log (N:ℝ) by linarith) (1/16:ℝ) + linarith)] + linarith + · have hle : t ≤ τ-(Real.log N)^(1/16:ℝ) := le_of_not_gt htlo + rw [abs_of_nonpos (by + have hp := Real.rpow_nonneg (show 0≤Real.log (N:ℝ) by linarith) (1/16:ℝ) + linarith)] + linarith + have hOff : mrtNoSmallOffCenter P Q J N F τ ⊆ Set.Ioc (-(N:ℝ)) N := + fun _ ht => ht.1.1 + have ho₀ : (∫ t in mrtNoSmallOffCenter P Q J N F τ, G t) ≤ C₂*δ := by + simpa only [G,B,V,δ,mul_div_assoc] using ho + have ho' : (∫ t in E \ I, G t) ≤ C₂*δ := by + apply le_trans _ ho₀ + exact setIntegral_mono_set (hGi.mono_set hOff) + (Filter.Eventually.of_forall (fun _ => sq_nonneg _)) + (Filter.Eventually.of_forall hsub) + have hpow : (Real.log N)^(-1/32:ℝ) ≤ δ := by + calc + _ ≤ (Real.log N)^(-1/100:ℝ) := Real.rpow_le_rpow_of_exponent_le hL (by norm_num) + _ = 1/(Real.log N)^(1/100:ℝ) := by + rw [show (-1/100:ℝ)=-(1/100:ℝ) by ring,Real.rpow_neg (by linarith : 0≤Real.log (N:ℝ))] + simp only [one_div] + _ ≤ δ := div_le_div_of_nonneg_right hLL (by positivity) + have hn' : (∫ t in E∩I, G t) ≤ C₁*(R+Real.exp (-M)+δ) := by + apply hn.trans + apply mul_le_mul_of_nonneg_left _ hC₁.le + dsimp only [R] + linarith + have hsplit := integral_inter_add_sdiff (f := G) (s := E) (t := I) + measurableSet_Ioc (hGi.mono_set hE) + change (∫ t in E, G t) ≤ _ + rw [← hsplit] + have hs := add_le_add hn' ho' + have he : 0 ≤ Real.exp (-M) := (Real.exp_pos _).le + nlinarith [mul_nonneg hC₂.le (add_nonneg hR he), + mul_nonneg hC₃.le (add_nonneg (add_nonneg hR he) hδ)] + · have hminlarge : ∀ v:ℝ, |v| ≤ 2*N → + (1/10:ℝ)*Real.log (Real.log (2*N:ℕ)) ≤ + squaredDistance F (mrtArchimedeanTwist v) (2*N) := by + intro v hv + have hh := hmin' v hv + linarith + have hb := hlarge F hF1 hFm hFb hminlarge P Q J hQ hu + (mrtPrimeBand (mrtExtraPrimeLower (Real.log N)) (mrtExtraPrimeUpper (Real.log N))) + (fun _ hp => mrtPrimeBand_prime hp) + have hh := hfull F hFm hFb P Q (by linarith) hPQ hQ hres J hJ hlo hu hb + change (∫ t in E, G t) ≤ _ + have hh' : (∫ t in E, G t) ≤ C₃*δ := by + apply le_trans _ (show (∫ t in mrtActualNoSmall P Q J N F,G t) ≤ C₃*δ by + simpa only [G,B,V,δ,mul_div_assoc] using hh) + exact setIntegral_mono_set + (hGi.mono_set (fun _ ht => ht.1)) + (Filter.Eventually.of_forall (fun _ => sq_nonneg _)) + (Filter.Eventually.of_forall (fun _ ht => ht.1)) + have he : 0 ≤ Real.exp (-M) := (Real.exp_pos _).le + nlinarith [mul_nonneg (add_nonneg hC₁.le hC₂.le) hδ, + mul_nonneg (show 0≤C₁+C₂+C₃ by positivity) (add_nonneg hR he)] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalShortMean.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalShortMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..adbc54a65cc642a5538714203883ca6310c80a4a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOriginalShortMean.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszOriginalKernel +import OAI.NumberTheory.TwoPoint.Halasz.HalaszShortMean +import OAI.NumberTheory.TwoPoint.Halasz.HalaszBandDensity +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTLogShortQuarter + +namespace OAI + +/-! Literal short-interval L1 means with one original distance cutoff +and exactly its published frequency range. -/ + +namespace TwoPointCorrelations + +open Finset Filter MeasureTheory +open scoped Classical + +theorem halasz_original_short_mean + (hprime : HalaszPrimeSparseInput) (hhigh : HalaszHighPrimeInput) : + ∃ C₁ C₂ : ℝ, 0 < C₁ ∧ 0 < C₂ ∧ ∀ᶠ N : ℕ in atTop, + ∀ P Q : ℝ, 2 ≤ P → P ≤ Q → 2 ≤ Real.log P → 1 ≤ Real.log Q → + 8192*(Real.log (Real.log Q)+1) ≤ (1/100:ℝ)*Real.log P → + 2 ≤ mrtBaseResolution P Q (1/100) → + ∀ J : ℕ, 1 ≤ J → + (∀ k ∈ ({N,2*N}:Finset ℕ), + 200*Real.log (Real.log k)+1 ≤ Real.log (mrtBandLower P Q J) ∧ + ∀ j ∈ Icc 1 J, mrtBandUpper Q j ≤ Real.exp (Real.sqrt (Real.log k))) → + ∀ X : ℕ, N ≤ X → X ≤ N^3 → + ∀ H : ℕ, 4 ≤ H → H ≤ N → 2*Q ≤ (N:ℝ) → + ∀ F : ℕ → ℂ, F 1=1 → Multiplicative F → OneBounded F → + ∀ M : ℝ, 0 ≤ M → + (∀ u:ℝ, |u| ≤ X → M ≤ squaredDistance F (mrtArchimedeanTwist u) X) → + (∫ x in (N:ℝ)..(2*N), ‖shortExponentialSum F H 0 x‖)/((N:ℝ)*H) ≤ + Real.sqrt ((139968/(2*Real.pi)) * + (12*(C₁*((Real.log P/Real.log Q)^2+Real.exp (-M)+ + Real.log (Real.log N)/(Real.log N)^(1/100:ℝ)) + + 33792*Real.exp 1*(mrtBaseResolution P Q (1/100))⁻¹ + 2*P⁻¹ + + 1024*Real.exp 2*(mrtBaseResolution P Q (1/100))⁻¹*(1+Q/H)) + + 2048*Real.exp 1/(H:ℝ)^2)) + C₂*(Real.log P/Real.log Q) := by + obtain ⟨C₁,hC₁,hkernel⟩ := halasz_original_kernel_bound hprime hhigh + obtain ⟨C₂,hC₂,hdensity⟩ := mrt_typical_density + refine ⟨C₁,2*C₂,hC₁,by positivity,?_⟩ + have hlog : Tendsto (fun N:ℕ => Real.log N) atTop atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + filter_upwards [hkernel,hlog.eventually hdensity, + hlog.eventually (eventually_ge_atTop (1:ℝ)),eventually_ge_atTop 2] + with N hkernel hdensity hL hN2 + intro P Q hP hPQ hlP hlQ hbudget hres J hJ hbands X hNX hXN H hH2 hHN hsize F hF1 hFm hFb M hM hd + have hH : 0 < H := by omega + let V := fun j => mrtPrimeBand (mrtBandLower P Q j) (mrtBandUpper Q j) + let δ := C₁*((Real.log P/Real.log Q)^2+Real.exp (-M)+ + Real.log (Real.log N)/(Real.log N)^(1/100:ℝ)) + have hN0 : 0 < (N:ℝ) := by exact_mod_cast (show 0 ⟨(hbands k hk).1,(hbands k hk).2 J (mem_Icc.mpr ⟨hJ,le_rfl⟩)⟩) + X hNX hXN M hM hd + have hprimeV : ∀ j ∈ Icc 1 J, ∀ p ∈ V j, p.Prime := + fun _ _ _ hp => mrtPrimeBand_prime hp + have hdis : Set.PairwiseDisjoint (Icc 1 J : Set ℕ) V := + halasz_actual_bands_disjoint P Q J hP hPQ (by linarith) + have hrange : ∀ j ∈ Icc 1 J, ∀ p ∈ V j, + mrtBandLower P Q j ≤ (p:ℝ) ∧ (p:ℝ) ≤ mrtBandUpper Q j := by + intro j _ p hp + have hh := mrtPrimeBand_bounds (Real.exp_pos _).le (Real.exp_pos _).le hp + exact ⟨hh.1.le,hh.2⟩ + have henergy := mrt_log_short_energy_quarter V J hprimeV hdis (by linarith) (by linarith) + hlP hlQ (Real.log_le_log (by linarith) hPQ) (by norm_num : (0:ℝ)<1/100) + (by norm_num : (1/100:ℝ)≤1/12) hbudget hres hrange hH2 hHN hsize F hFm hFb hδ + (fun k hk' v hv hvk => hk k hk' v + ((div_nonneg (Nat.cast_nonneg N) (Nat.cast_nonneg H)).trans hv) hvk) + have : NeZero (N+H) := ⟨by omega⟩ + have hscale : (1/2:ℝ)*Real.exp ((Real.log N)^(199/200:ℝ)) ≤ (N+H:ℕ) := by + have hp := Real.rpow_le_self_of_one_le hL (show (199/200:ℝ)≤1 by norm_num) + have he := Real.exp_le_exp.mpr hp + rw [Real.exp_log hN0] at he + have hn : (N:ℝ) ≤ (N+H:ℕ) := by exact_mod_cast (Nat.le_add_right N H) + nlinarith [Real.exp_pos ((Real.log N)^(199/200:ℝ))] + have hcut : ∀ j ∈ Icc 1 J, mrtBandUpper Q j ≤ Real.exp ((Real.log N)^(99/100:ℝ)) := + mrt_common_density_cutoff hL J hmax + have heq (n:ℕ) : + mrtTypical univ (fun j:{j:ℕ // j∈(Icc 1 J:Finset ℕ)} => V j) n ↔ + mrtTypical (Icc 1 J) V n := by simp [mrtTypical] + have hp := hdensity P Q J hP hPQ hlQ hcut (N+1) (N+H) hscale + change (uniformFiniteLaw (Fin (N+H))).probability + (fun n => ¬mrtTypical univ + (fun j:{j:ℕ // j∈(Icc 1 J:Finset ℕ)} => V j) (N+1+n.val)) ≤ _ at hp + have hp' : (uniformFiniteLaw (Fin (N+H))).probability + (fun n => ¬mrtTypical (Icc 1 J) V (N+1+n.val)) ≤ C₂*(Real.log P/Real.log Q) := by + simpa only [heq,mul_div_assoc] using hp + have hmean := halasz_short_mean_transfer (Icc 1 J) V F hFb hH hHN + (mul_nonneg hC₂.le hR) hp' henergy + simpa only [δ,mul_assoc] using hmean + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOscillationBounds.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOscillationBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c2923028796aca919cf00bddc50723765a38042 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOscillationBounds.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszDoubleOscillation + +namespace OAI + +/-! Pointwise bounds for the exact twice-integrated affine amplitude. -/ +namespace TwoPointCorrelations + +lemma halasz_log_amplitude2_bound (u v m c x a lam W : ℝ) + (ha : 0 < a) (hax : a ≤ x) (hlam : 0 < lam) + (hs : lam ≤ |halaszLogSlope u v x|) (hw : |m*x+c| ≤ W) : + |halaszLogAmplitude2 u v m c x| ≤ + |m|/lam^2 + W*|u|/(a^2*lam^3) := by + have hx : 0 ≤ x := (ha.trans_le hax).le + have hW : 0 ≤ W := (abs_nonneg _).trans hw + unfold halaszLogAmplitude2 + calc + _ ≤ |m/(halaszLogSlope u v x)^2| + + |(m*x+c)*u/(x^2*(halaszLogSlope u v x)^3)| := abs_add_le _ _ + _ = |m|/|halaszLogSlope u v x|^2 + + |m*x+c| *|u|/(x^2*|halaszLogSlope u v x|^3) := by + simp only [abs_div, abs_mul, abs_pow, abs_of_nonneg hx] + _ ≤ _ := by + gcongr + +lemma halasz_log_amplitude2_deriv_bound (u v m c x a lam W : ℝ) + (ha : 0 < a) (hax : a ≤ x) (hlam : 0 < lam) + (hs : lam ≤ |halaszLogSlope u v x|) (hw : |m*x+c| ≤ W) : + |halaszLogAmplitude2Deriv u v m c x| ≤ + 3*|m| *|u|/(a^2*lam^3) + 2*W*|u|/(a^3*lam^3) + + 3*W*u^2/(a^4*lam^4) := by + have hx : 0 ≤ x := (ha.trans_le hax).le + have hW : 0 ≤ W := (abs_nonneg _).trans hw + unfold halaszLogAmplitude2Deriv + calc + _ ≤ |3*m*u/(x^2*(halaszLogSlope u v x)^3)| + + |2*(m*x+c)*u/(x^3*(halaszLogSlope u v x)^3)| + + |3*(m*x+c)*u^2/(x^4*(halaszLogSlope u v x)^4)| := + (abs_add_le _ _).trans (add_le_add (abs_sub _ _) le_rfl) + _ = 3*|m| *|u|/(x^2*|halaszLogSlope u v x|^3) + + 2*|m*x+c| *|u|/(x^3*|halaszLogSlope u v x|^3) + + 3*|m*x+c| *u^2/(x^4*|halaszLogSlope u v x|^4) := by + simp only [abs_div, abs_mul, abs_pow, abs_of_nonneg hx, + abs_of_nonneg (by norm_num : (0:ℝ) ≤ 2), + abs_of_nonneg (by norm_num : (0:ℝ) ≤ 3), sq_abs] + _ ≤ _ := by + gcongr + +open MeasureTheory + +lemma halasz_log_remainder_integral (u v m c A a b lam W : ℝ) + (hA : 0 < A) (hAa : A ≤ a) (hab : a ≤ b) (hlam : 0 < lam) + (hs : ∀ x ∈ Set.Icc a b, lam ≤ |halaszLogSlope u v x|) + (hw : ∀ x ∈ Set.Icc a b, |m*x+c| ≤ W) : + ‖∫ x in a..b, (halaszLogAmplitude2Deriv u v m c x:ℂ)*halaszLogPhase u v x‖ ≤ + (3*|m| *|u|/(A^2*lam^3) + 2*W*|u|/(A^3*lam^3) + + 3*W*u^2/(A^4*lam^4))*(b-a) := by + have hh := intervalIntegral.norm_integral_le_of_norm_le_const + (a := a) (b := b) + (C := 3*|m| *|u|/(A^2*lam^3) + 2*W*|u|/(A^3*lam^3) + 3*W*u^2/(A^4*lam^4)) + (f := fun x => (halaszLogAmplitude2Deriv u v m c x:ℂ)*halaszLogPhase u v x) (by + intro x hx + have hx' : x ∈ Set.Icc a b := by + rw [Set.uIoc_of_le hab] at hx + exact ⟨hx.1.le, hx.2⟩ + rw [norm_mul, halasz_log_phase_norm, mul_one, Complex.norm_real, Real.norm_eq_abs] + exact halasz_log_amplitude2_deriv_bound u v m c x A lam W hA + (hAa.trans hx'.1) hlam (hs x hx') (hw x hx')) + simpa only [abs_of_nonneg (sub_nonneg.mpr hab)] using hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOverlapSynthesis.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOverlapSynthesis.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb18ba2b451a88333399be5af695a3bd9d0b4984 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszOverlapSynthesis.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTorusBessel + +namespace OAI + +/-! Finite synthesis bounded by the number of overlapping localization +windows, retaining the actual pair count. -/ +namespace TwoPointCorrelations + +open Finset Complex +open scoped Classical ComplexConjugate + +lemma halasz_synthesis_pair_sum {ι E : Type*} [NormedAddCommGroup E] + [InnerProductSpace ℂ E] (S : Finset ι) (v : ι → E) (a : ι → ℂ) + (ha : ∀ i∈S, ‖a i‖≤1) : + ‖∑ i∈S,a i • v i‖^2≤∑ i∈S,∑ j∈S,‖inner ℂ (v i) (v j)‖ := by + calc + _ = (inner ℂ (∑ i∈S,a i • v i) (∑ i∈S,a i • v i)).re := + norm_sq_eq_re_inner (𝕜 := ℂ) _ + _ ≤ ‖inner ℂ (∑ i∈S,a i • v i) (∑ i∈S,a i • v i)‖ := re_le_norm _ + _ = ‖∑ i∈S,∑ j∈S,conj (a i)*a j*inner ℂ (v i) (v j)‖ := by + simp only [sum_inner,inner_sum,inner_smul_left,inner_smul_right,mul_sum] + rw [sum_comm] + congr 1 + apply sum_congr rfl + intro i _ + apply sum_congr rfl + intro j _ + ring + _ ≤ ∑ i∈S,∑ j∈S,‖conj (a i)*a j*inner ℂ (v i) (v j)‖ := + (norm_sum_le _ _).trans (sum_le_sum (fun _ _ => norm_sum_le _ _)) + _ ≤ _ := by + apply sum_le_sum + intro i hi + apply sum_le_sum + intro j hj + rw [norm_mul,norm_mul,norm_conj] + have hmul : ‖a i‖*‖a j‖≤1 := by + calc + _ ≤ 1*1 := mul_le_mul (ha i hi) (ha j hj) (norm_nonneg _) zero_le_one + _ = 1 := mul_one _ + simpa only [one_mul] using mul_le_mul_of_nonneg_right hmul (norm_nonneg _) + +theorem halasz_synthesis_overlap {ι E : Type*} [NormedAddCommGroup E] + [InnerProductSpace ℂ E] (S : Finset ι) (v : ι → E) (a : ι → ℂ) + (R : ι → ι → Prop) {V : ℝ} (ha : ∀ i∈S,‖a i‖≤1) + (hR : ∀ i∈S,∀ j∈S,‖inner ℂ (v i) (v j)‖ ≤ (if R i j then V else 0)) : + ‖∑ i∈S,a i • v i‖^2≤V*(((S×ˢS).filter (fun p => R p.1 p.2)).card:ℝ) := by + apply (halasz_synthesis_pair_sum S v a ha).trans + calc + _ ≤ ∑ i∈S,∑ j∈S,if R i j then V else 0 := + sum_le_sum (fun i hi => sum_le_sum (fun j hj => hR i hi j hj)) + _ = _ := by + rw [← sum_product S S (fun p : ι×ι => if R p.1 p.2 then V else 0)] + simp only [card_eq_sum_ones,Nat.cast_sum,sum_filter] + rw [mul_sum] + apply sum_congr rfl + intro p _ + by_cases h : R p.1 p.2 <;> simp [h] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszParameters.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..da5b9f0d2ee4389c49fb57240a50ee3293acbab3 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszParameters.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszBandSummation +import Mathlib.Analysis.SpecialFunctions.Log.Basic + +namespace OAI + +/-! The logarithmic truncation height and integer smoothing length used +in the grouped Perron estimate. -/ + +namespace TwoPointCorrelations + +open Filter + +lemma halasz_eventually_numeric_scale (B : ℝ) : + ∀ᶠ x : ℝ in atTop, 3 ≤ x ∧ 1 ≤ Real.log (Real.log x) ∧ + 2 ≤ Real.log x ^ 4 ∧ Real.log x ^ 16 ≤ x / 2 ∧ B ≤ Real.log x ^ 8 := by + have hsmall := (Real.isLittleO_pow_log_id_atTop (n := 16)).bound + (by norm_num : (0 : ℝ) < 1 / 2) + have hlog := Real.tendsto_log_atTop.eventually (eventually_ge_atTop (max 2 B)) + have hloglog := (Real.tendsto_log_atTop.comp Real.tendsto_log_atTop).eventually + (eventually_ge_atTop (1 : ℝ)) + filter_upwards [eventually_ge_atTop (3 : ℝ), hlog, hloglog, hsmall] with x hx hl hll hs + have hl2 : 2 ≤ Real.log x := (le_max_left _ _).trans hl + have hl1 : 1 ≤ Real.log x := by linarith + dsimp only [id] at hs + rw [Real.norm_eq_abs, abs_of_nonneg (pow_nonneg (by linarith : 0 ≤ Real.log x) 16), + Real.norm_eq_abs, abs_of_pos (by linarith : 0 < x)] at hs + refine ⟨hx, hll, ?_, by linarith, ?_⟩ + · exact hl2.trans (le_self_pow₀ hl1 (by norm_num : (4 : ℕ) ≠ 0)) + · exact ((le_max_right _ _).trans hl).trans (le_self_pow₀ hl1 (by norm_num : (8 : ℕ) ≠ 0)) + +lemma halasz_smoothing_integer {N : ℕ} (hN : 2 ≤ N) + (hlog : 2 ≤ Real.log (N : ℝ) ^ 4) (hsmall : Real.log (N : ℝ) ^ 4 ≤ N) : + let m := ⌈(N : ℝ) / Real.log (N : ℝ) ^ 4⌉₊ + 0 < m ∧ m ≤ N ∧ (N : ℝ) / Real.log (N : ℝ) ^ 4 ≤ m ∧ + (m : ℝ) ≤ 2 * ((N : ℝ) / Real.log (N : ℝ) ^ 4) ∧ + ((N : ℝ) + 1 / 2) / m ≤ 2 * Real.log (N : ℝ) ^ 4 := by + let L := Real.log (N : ℝ) ^ 4 + let m := ⌈(N : ℝ) / L⌉₊ + have hL : 0 < L := by dsimp [L]; linarith + have hNr : (2 : ℝ) ≤ N := by exact_mod_cast hN + have hratio : 1 ≤ (N : ℝ) / L := (le_div_iff₀ hL).mpr (by simpa [L] using hsmall) + have hratioHigh : (N : ℝ) / L ≤ (N : ℝ) / 2 := + div_le_div_of_nonneg_left (by positivity) (by norm_num) hlog + have hmlo : (N : ℝ) / L ≤ m := Nat.le_ceil _ + have hmhi : (m : ℝ) < (N : ℝ) / L + 1 := Nat.ceil_lt_add_one (by positivity) + have hmp : (0 : ℝ) < m := by linarith + have hmNat : 0 < m := by exact_mod_cast hmp + have hmN : m ≤ N := by exact_mod_cast (show (m : ℝ) ≤ N by linarith) + refine ⟨hmNat, hmN, hmlo, by linarith, ?_⟩ + apply (div_le_iff₀ hmp).mpr + have hmul : (N : ℝ) ≤ (m : ℝ) * L := (div_le_iff₀ hL).mp hmlo + dsimp [L] at hmul ⊢ + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPerronWindowKernel.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPerronWindowKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee191d88acd3c47dd84334c9f6fd59a6f07bc101 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPerronWindowKernel.lean @@ -0,0 +1,140 @@ +import OAI.NumberTheory.TwoPoint.Fourier.ModFiveContourKernel +import Mathlib.Analysis.SpecialFunctions.Trigonometric.Bounds + +namespace OAI + +/-! A short multiplicative smoothing of Perron's kernel. The difference +has both the first-order bound and an integrable inverse-square tail. -/ + +namespace TwoPointCorrelations + +open Complex + +noncomputable def halaszPerronWindowKernel (x δ : ℝ) (s : ℂ) : ℂ := + (((1 + δ : ℝ) : ℂ) * modFivePerronKernel ((1 + δ) * x) s - + modFivePerronKernel x s) / (δ : ℂ) + +lemma halasz_exp_window_difference {δ : ℝ} (hδ : 0 < δ) (hδ1 : δ ≤ 1) (t : ℝ) : + ‖Complex.exp (((2 : ℂ) + (t : ℂ) * Complex.I) * (Real.log (1 + δ) : ℂ)) - 1‖ ≤ + δ * (3 + |t|) := by + have hy : 0 < 1 + δ := by linarith + have hlog0 : 0 ≤ Real.log (1 + δ) := Real.log_nonneg (by linarith) + have hlog : Real.log (1 + δ) ≤ δ := by + simpa only [add_sub_cancel_left] using Real.log_le_sub_one_of_pos hy + let z := Complex.exp (((t * Real.log (1 + δ) : ℝ) : ℂ) * Complex.I) + have hz : ‖z‖ = 1 := Complex.norm_exp_ofReal_mul_I _ + have hz1 : ‖z - 1‖ ≤ |t| * Real.log (1 + δ) := by + have h := Real.norm_exp_I_mul_ofReal_sub_one_le (x := t * Real.log (1 + δ)) + simpa only [z, mul_comm Complex.I, Real.norm_eq_abs, abs_mul, abs_of_nonneg hlog0] using h + have he : Complex.exp (((2 : ℂ) + (t : ℂ) * Complex.I) * + (Real.log (1 + δ) : ℂ)) = (((1 + δ) ^ 2 : ℝ) : ℂ) * z := by + rw [show ((2 : ℂ) + (t : ℂ) * Complex.I) * (Real.log (1 + δ) : ℂ) = + ((2 * Real.log (1 + δ) : ℝ) : ℂ) + + (((t * Real.log (1 + δ) : ℝ) : ℂ) * Complex.I) by push_cast; ring, + Complex.exp_add, ← Complex.ofReal_exp] + congr 1 + exact_mod_cast (show Real.exp (2 * Real.log (1 + δ)) = (1 + δ) ^ 2 by + simpa only [Nat.cast_ofNat, Real.exp_log hy] using Real.exp_nat_mul (Real.log (1 + δ)) 2) + rw [he, show (((1 + δ) ^ 2 : ℝ) : ℂ) * z - 1 = + (((1 + δ) ^ 2 - 1 : ℝ) : ℂ) * z + (z - 1) by push_cast; ring] + calc + _ ≤ ‖(((1 + δ) ^ 2 - 1 : ℝ) : ℂ) * z‖ + ‖z - 1‖ := norm_add_le _ _ + _ ≤ ((1 + δ) ^ 2 - 1) + |t| * Real.log (1 + δ) := by + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, hz, mul_one, + abs_of_nonneg (by nlinarith : 0 ≤ (1 + δ) ^ 2 - 1)] + exact add_le_add le_rfl hz1 + _ ≤ δ * (3 + |t|) := by + have hm := mul_le_mul_of_nonneg_left hlog (abs_nonneg t) + nlinarith + +lemma halasz_perron_window_factor {x δ : ℝ} (hx : 0 < x) (hδ : 0 < δ) (s : ℂ) : + halaszPerronWindowKernel x δ s = + (x : ℂ) ^ s * (Complex.exp ((s + 1) * (Real.log (1 + δ) : ℂ)) - 1) / + ((δ : ℂ) * s * (s + 1)) := by + have hy : 0 < 1 + δ := by linarith + have hyexp : ((1 + δ : ℝ) : ℂ) * ((1 + δ : ℝ) : ℂ) ^ s = + Complex.exp ((s + 1) * (Real.log (1 + δ) : ℂ)) := by + calc + _ = ((1 + δ : ℝ) : ℂ) ^ (s + 1) := by + rw [Complex.cpow_add _ _ (Complex.ofReal_ne_zero.mpr hy.ne'), Complex.cpow_one] + ring + _ = _ := by + rw [Complex.cpow_def_of_ne_zero (Complex.ofReal_ne_zero.mpr hy.ne'), + ← Complex.ofReal_log hy.le] + congr 1 + ring + unfold halaszPerronWindowKernel modFivePerronKernel + rw [Complex.ofReal_mul, Complex.mul_cpow_ofReal_nonneg hy.le hx.le] + calc + _ = (x : ℂ) ^ s * + (((1 + δ : ℝ) : ℂ) * ((1 + δ : ℝ) : ℂ) ^ s - 1) / + ((δ : ℂ) * s * (s + 1)) := by + simp only [div_eq_mul_inv, mul_inv_rev] + ring + _ = _ := by rw [hyexp] + +theorem halasz_perron_window_bound {x δ : ℝ} (hx : 0 < x) (hδ : 0 < δ) + (hδ1 : δ ≤ 1) (t : ℝ) : + ‖halaszPerronWindowKernel x δ (1 + (t : ℂ) * Complex.I)‖ ≤ + 4 * x / ‖1 + (t : ℂ) * Complex.I‖ := by + let s : ℂ := 1 + (t : ℂ) * Complex.I + have hs : 1 ≤ ‖s‖ := by simpa [s] using Complex.abs_re_le_norm s + have hs1 : 2 ≤ ‖s + 1‖ := by + have h := Complex.abs_re_le_norm (s + 1) + norm_num [s] at h + exact h + have ht : |t| ≤ ‖s + 1‖ := by simpa [s] using Complex.abs_im_le_norm (s + 1) + have hs0 : 0 < ‖s‖ := by linarith + have hs10 : 0 < ‖s + 1‖ := by linarith + have he : ‖Complex.exp ((s + 1) * (Real.log (1 + δ) : ℂ)) - 1‖ ≤ + δ * (4 * ‖s + 1‖) := by + have he := halasz_exp_window_difference hδ hδ1 t + have hshape : s + 1 = (2 : ℂ) + (t : ℂ) * Complex.I := by dsimp [s]; ring + rw [hshape] + apply he.trans + have hnorm : 3 + |t| ≤ 4 * ‖s + 1‖ := by linarith + rw [← hshape] + exact mul_le_mul_of_nonneg_left hnorm hδ.le + rw [halasz_perron_window_factor hx hδ, norm_div, norm_mul, + Complex.norm_cpow_eq_rpow_re_of_pos hx] + change x ^ s.re * ‖Complex.exp ((s + 1) * (Real.log (1 + δ) : ℂ)) - 1‖ / + ‖(δ : ℂ) * s * (s + 1)‖ ≤ 4 * x / ‖s‖ + have hre : s.re = 1 := by simp [s] + rw [hre, Real.rpow_one, norm_mul, norm_mul, Complex.norm_real, + Real.norm_eq_abs, abs_of_pos hδ] + calc + _ ≤ x * (δ * (4 * ‖s + 1‖)) / (δ * ‖s‖ * ‖s + 1‖) := by + exact div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left he hx.le) (by positivity) + _ = _ := by field_simp [ne_of_gt hδ, ne_of_gt hs0, ne_of_gt hs10] + +theorem halasz_perron_window_tail {x δ : ℝ} (hx : 0 < x) (hδ : 0 < δ) + (hδ1 : δ ≤ 1) (t : ℝ) : + ‖halaszPerronWindowKernel x δ (1 + (t : ℂ) * Complex.I)‖ ≤ + 20 * x / (δ * (1 + t ^ 2)) := by + have hy : 0 < 1 + δ := by linarith + have hk1 := modFive_perron_kernel_vertical (mul_pos hy hx) (by norm_num : (1 / 2 : ℝ) ≤ 1) t + have hk0 := modFive_perron_kernel_vertical hx (by norm_num : (1 / 2 : ℝ) ≤ 1) t + simp only [Real.rpow_one] at hk1 hk0 + unfold halaszPerronWindowKernel + rw [norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hδ] + apply (div_le_div_of_nonneg_right (norm_sub_le _ _) hδ.le).trans + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hy] + have htop : (1 + δ) * ‖modFivePerronKernel ((1 + δ) * x) + (1 + (t : ℂ) * Complex.I)‖ + ‖modFivePerronKernel x (1 + (t : ℂ) * Complex.I)‖ ≤ + 20 * x / (1 + t ^ 2) := by + calc + _ ≤ (1 + δ) * (4 * ((1 + δ) * x) / (1 + t ^ 2)) + 4 * x / (1 + t ^ 2) := + add_le_add (mul_le_mul_of_nonneg_left hk1 hy.le) hk0 + _ ≤ _ := by + have hδ2 : (1 + δ) ^ 2 ≤ 4 := by nlinarith + have hnum : (1 + δ) * (4 * ((1 + δ) * x)) + 4 * x ≤ 20 * x := by + nlinarith [mul_nonneg hx.le (sub_nonneg.mpr hδ2)] + calc + _ = ((1 + δ) * (4 * ((1 + δ) * x)) + 4 * x) / (1 + t ^ 2) := by ring + _ ≤ _ := div_le_div_of_nonneg_right hnum (by positivity) + exact (div_le_div_of_nonneg_right htop hδ.le).trans_eq (by + field_simp [ne_of_gt hδ, show (1 + t ^ 2 : ℝ) ≠ 0 by positivity]) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseCells.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..12fcde7b3d6751b01152faa202ac7f6f497221db --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseCells.lean @@ -0,0 +1,112 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPhaseTaylor +import Mathlib.Analysis.SpecialFunctions.Integrals.Basic +import Mathlib.Analysis.PSeries + +namespace OAI + +/-! Unit cells for the elementary power-sum approximation. Centering the +cells cancels the linear phase error, leaving a summable quadratic error. -/ + +namespace TwoPointCorrelations + +open MeasureTheory Finset + +noncomputable def halaszPowerPhase (t x : ℝ) : ℂ := + Complex.exp (((-t * Real.log x : ℝ) : ℂ) * Complex.I) + +@[simp] lemma halasz_power_phase_norm (t x : ℝ) : ‖halaszPowerPhase t x‖ = 1 := by + simp [halaszPowerPhase, Complex.norm_exp, Complex.mul_re] + +lemma halasz_power_phase_add (t x y : ℝ) (hx : 0 < x) (hxy : 0 < x + y) : + halaszPowerPhase t (x + y) = halaszPowerPhase t x * + Complex.exp (((-t * Real.log (1 + y / x) : ℝ) : ℂ) * Complex.I) := by + have he : x + y = x * (1 + y / x) := by field_simp + have hp : 0 < 1 + y / x := by rw [← mul_pos_iff_of_pos_left hx, ← he]; exact hxy + rw [halaszPowerPhase, he, Real.log_mul hx.ne' hp.ne', mul_add, + Complex.ofReal_add, add_mul, Complex.exp_add] + rfl + +lemma halasz_power_phase_cell_error (t x y : ℝ) (hx : 1 ≤ x) + (ht : |t| ≤ x) (hy : |y| ≤ 1 / 2) : + ‖halaszPowerPhase t (x + y) - + halaszPowerPhase t x * (1 + (((-t * (y / x) : ℝ) : ℂ) * Complex.I))‖ ≤ + (t ^ 2 + |t|) / x ^ 2 := by + have hx0 : 0 < x := by linarith + have hxy : 0 < x + y := by linarith [(abs_le.mp hy).1] + have hratio : |y / x| ≤ 1 / 2 := by + rw [abs_div, abs_of_pos hx0] + apply (div_le_iff₀ hx0).mpr + linarith + have htratio : |t * (y / x)| ≤ 1 / 2 := by + rw [abs_mul, abs_div, abs_of_pos hx0] + calc + _ ≤ x * ((1 / 2) / x) := mul_le_mul ht + (div_le_div_of_nonneg_right hy hx0.le) (by positivity) hx0.le + _ = 1 / 2 := by field_simp + have hh := halasz_phase_linear_error t (y / x) hratio htratio + have he : halaszPowerPhase t (x + y) - + halaszPowerPhase t x * (1 + (((-t * (y / x) : ℝ) : ℂ) * Complex.I)) = + halaszPowerPhase t x * + (Complex.exp (((-t * Real.log (1 + y / x) : ℝ) : ℂ) * Complex.I) - 1 - + (((-t * (y / x) : ℝ) : ℂ) * Complex.I)) := by + rw [halasz_power_phase_add t x y hx0 hxy] + ring + rw [he, norm_mul, halasz_power_phase_norm, one_mul] + apply hh.trans + have hy2 : y ^ 2 ≤ 1 / 4 := by + have hh := pow_le_pow_left₀ (abs_nonneg y) hy 2 + norm_num [sq_abs] at hh + exact hh + rw [div_pow] + calc + _ ≤ 4 * (t ^ 2 + |t|) * ((1 / 4) / x ^ 2) := by gcongr + _ = _ := by ring + +lemma halasz_power_phase_continuousOn (t a b : ℝ) (ha : 0 < a) (hab : a ≤ b) : + ContinuousOn (halaszPowerPhase t) (Set.uIcc a b) := by + have hne : ∀ x ∈ Set.uIcc a b, x ≠ 0 := by + intro x hx + rw [Set.uIcc_of_le hab] at hx + exact (ha.trans_le hx.1).ne' + unfold halaszPowerPhase + fun_prop (disch := assumption) + +lemma halasz_power_phase_cell_integral (t x : ℝ) (hx : 1 ≤ x) (ht : |t| ≤ x) : + ‖(∫ y in (-1 / 2 : ℝ)..(1 / 2 : ℝ), halaszPowerPhase t (x + y)) - + halaszPowerPhase t x‖ ≤ (t ^ 2 + |t|) / x ^ 2 := by + let lin : ℝ → ℂ := fun y => + halaszPowerPhase t x * (1 + (((-t * (y / x) : ℝ) : ℂ) * Complex.I)) + have hlin : Continuous lin := by dsimp [lin]; fun_prop + have hf : ContinuousOn (fun y => halaszPowerPhase t (x + y)) + (Set.uIcc (-1 / 2 : ℝ) (1 / 2 : ℝ)) := by + have hne : ∀ y ∈ Set.uIcc (-1 / 2 : ℝ) (1 / 2 : ℝ), x + y ≠ 0 := by + intro y hy + rw [Set.uIcc_of_le (by norm_num)] at hy + have hp : 0 < x + y := by linarith [hy.1] + exact hp.ne' + unfold halaszPowerPhase + fun_prop (disch := assumption) + have hli : (∫ y in (-1 / 2 : ℝ)..(1 / 2 : ℝ), lin y) = halaszPowerPhase t x := by + dsimp [lin] + rw [intervalIntegral.integral_const_mul, intervalIntegral.integral_add] + · rw [intervalIntegral.integral_const, intervalIntegral.integral_mul_const, + intervalIntegral.integral_ofReal, intervalIntegral.integral_const_mul, + intervalIntegral.integral_div, integral_id] + norm_num + · exact continuous_const.intervalIntegrable _ _ + · exact (by fun_prop : Continuous (fun y : ℝ => + (((-t * (y / x) : ℝ) : ℂ) * Complex.I))).intervalIntegrable _ _ + have hh := intervalIntegral.norm_integral_le_of_norm_le_const + (a := (-1 / 2 : ℝ)) (b := (1 / 2 : ℝ)) + (f := fun y => halaszPowerPhase t (x + y) - lin y) + (C := (t ^ 2 + |t|) / x ^ 2) (fun y hy => by + apply halasz_power_phase_cell_error t x y hx ht + rw [Set.uIoc_of_le (by norm_num)] at hy + exact abs_le.mpr ⟨by linarith [hy.1], hy.2⟩) + rw [intervalIntegral.integral_sub hf.intervalIntegrable (hlin.intervalIntegrable _ _), hli] at hh + norm_num at hh ⊢ + exact hh + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseConjugation.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseConjugation.lean new file mode 100644 index 0000000000000000000000000000000000000000..41f75d01dffbac1d0d05a59c1770dd5c6e3d44aa --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseConjugation.lean @@ -0,0 +1,47 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTriangleIntegral + +namespace OAI + +/-! Reflection of the logarithmic phase, needed for both signs of a +frequency difference in the sparse Gram kernel. -/ +namespace TwoPointCorrelations + +open MeasureTheory Complex +open scoped ComplexConjugate + +lemma halasz_log_phase_neg (u v x : ℝ) : + halaszLogPhase (-u) (-v) x = conj (halaszLogPhase u v x) := by + unfold halaszLogPhase + rw [← Complex.exp_conj] + congr 1 + simp only [map_mul, map_sub, conj_ofReal, conj_I, Complex.ofReal_sub, Complex.ofReal_mul, + Complex.ofReal_neg] + ring + +lemma halasz_log_affine_integral_neg (u v m c a b : ℝ) : + (∫ x in a..b, ((m*x+c:ℝ):ℂ)*halaszLogPhase (-u) (-v) x) = + conj (∫ x in a..b, ((m*x+c:ℝ):ℂ)*halaszLogPhase u v x) := by + simp_rw [halasz_log_phase_neg] + have he (x : ℝ) : ((m*x+c:ℝ):ℂ)*conj (halaszLogPhase u v x) = + conj (((m*x+c:ℝ):ℂ)*halaszLogPhase u v x) := by simp + simp_rw [he] + unfold intervalIntegral + rw [integral_conj, integral_conj, map_sub] + +lemma halasz_triangle_integral_neg (N u v : ℝ) : + halaszTriangleIntegral N (-u) (-v) = conj (halaszTriangleIntegral N u v) := by + unfold halaszTriangleIntegral + simp only [sub_eq_add_neg] + rw [halasz_log_affine_integral_neg, halasz_log_affine_integral_neg, map_add] + +lemma halasz_triangle_stationary_abs (N u v : ℝ) (hN : 0 < N) (hu : u ≠ 0) : + ‖halaszTriangleIntegral N u v‖ ≤ 110*N/Real.sqrt |u| := by + rcases lt_or_gt_of_ne hu with hn | hp + · have hh := halasz_triangle_stationary N (-u) (-v) hN (neg_pos.mpr hn) + rw [halasz_triangle_integral_neg, norm_conj, ← abs_of_neg hn] at hh + exact hh + · simpa only [abs_of_pos hp] using halasz_triangle_stationary N u v hN hp + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseFromPolynomial.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseFromPolynomial.lean new file mode 100644 index 0000000000000000000000000000000000000000..db853a8568888bc0e68fa4d14393278f927ebc3c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseFromPolynomial.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLogShiftBound +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTaylorScale + +namespace OAI + +/-! Uniform logarithmic phase prefixes from the normalized polynomial +estimate, with one common boundary error for both short-variable scales. -/ +namespace TwoPointCorrelations + +open Finset Complex + +theorem halasz_phase_from_polynomial {N H k : ℕ} (hN : 1≤N) (hH : H≤N) + {a t α lam A : ℝ} (ha : a∈Set.Icc (0:ℝ) 1) (hα : 0≤α) (hαhi : α≤1/3) + (hA : 0≤A) (hhalf : (N:ℝ)^(2/3:ℝ)≤(N:ℝ)/2) (ht : |t|=(N:ℝ)^lam) + (htaylor : lam+(2*α-1)*((k:ℝ)+1)≤-(1/2:ℝ)) + (hpoly : ∀ z∈Set.Icc (N:ℝ) (2*N), + ‖∑ b : Fin (halaszShortScale N α),halaszVinogradovPolynomial k (halaszShortScale N α) + (halaszScaledFrequency (halaszLogCoefficient t z) + (fun j => (((b.val+1)^(j.val+1):ℕ):ℤ)))‖/(halaszShortScale N α:ℝ)^2≤A) : + ‖∑ n∈range H,Complex.exp (Complex.I*((t*Real.log ((N:ℝ)+a+n):ℝ):ℂ))‖≤ + (N:ℝ)*A+4*(N:ℝ)^(2/3:ℝ) := by + have hNR : 1≤(N:ℝ) := by exact_mod_cast hN + have hN0 : 0<(N:ℝ) := by linarith + let M := halaszShortScale N α + have hM := (halasz_short_scale_bounds hNR hα).1 + have hM2 : (M:ℝ)^2≤(N:ℝ)^(2*α) := halasz_short_scale_square hNR hα + have hM23 : (M:ℝ)^2≤(N:ℝ)^(2/3:ℝ) := hM2.trans + (Real.rpow_le_rpow_of_exponent_le hNR (by linarith)) + have hMx : (M:ℝ)^2≤((N:ℝ)+a)/2 := by linarith [ha.1] + have hx : 0<(N:ℝ)+a := by linarith [ha.1] + have h := halasz_log_shift_bound k H M hM t hx hMx (A := A) (fun n hn => by + apply hpoly + have hnN : n+1≤N := by have := mem_range.mp hn; omega + have hnNR : (n:ℝ)+1≤N := by exact_mod_cast hnN + exact ⟨by linarith [ha.1,show (0:ℝ)≤n from Nat.cast_nonneg n],by linarith [ha.2]⟩) + have he := halasz_taylor_scale hNR (show (N:ℝ)≤(N:ℝ)+a by linarith [ha.1]) hM2 ht htaylor + have hHR : (H:ℝ)≤N := by exact_mod_cast hH + have herr : (H:ℝ)*(2*(N:ℝ)^(-(1/2:ℝ)))≤2*(N:ℝ)^(2/3:ℝ) := by + calc + _ ≤ (N:ℝ)*(2*(N:ℝ)^(-(1/2:ℝ))) := + mul_le_mul_of_nonneg_right hHR (by positivity) + _ = 2*((N:ℝ)^(1:ℝ)*(N:ℝ)^(-(1/2:ℝ))) := by rw [Real.rpow_one]; ring + _ = 2*(N:ℝ)^(1/2:ℝ) := by rw [← Real.rpow_add hN0]; norm_num + _ ≤ _ := mul_le_mul_of_nonneg_left + (Real.rpow_le_rpow_of_exponent_le hNR (by norm_num : (1/2:ℝ)≤2/3)) (by norm_num) + apply h.trans + have hmain := mul_le_mul_of_nonneg_right hHR hA + have herror := mul_le_mul_of_nonneg_left he (Nat.cast_nonneg H) + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseIntegral.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7910026af659e20490f322af80c8222af9c8a08 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseIntegral.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPhaseCells + +namespace OAI + +/-! Exact primitive of the Archimedean phase, including the zero endpoint. -/ + +namespace TwoPointCorrelations + +open MeasureTheory + +lemma halasz_power_phase_eq_cpow (t x : ℝ) (hx : 0 < x) : + halaszPowerPhase t x = (x : ℂ) ^ ((-t : ℂ) * Complex.I) := by + rw [Complex.cpow_def_of_ne_zero (by exact_mod_cast hx.ne'), + ← Complex.ofReal_log hx.le] + unfold halaszPowerPhase + congr 1 + push_cast + ring + +lemma halasz_power_phase_cpow_primitive (t x : ℝ) (hx : 0 ≤ x) : + (x : ℂ) ^ ((-t : ℂ) * Complex.I + 1) = (x : ℂ) * halaszPowerPhase t x := by + by_cases hx0 : x = 0 + · subst x + simp only [Complex.ofReal_zero, zero_mul] + apply Complex.zero_cpow + intro h + have hr := congrArg Complex.re h + norm_num [Complex.mul_re] at hr + · have hxp : 0 < x := lt_of_le_of_ne hx (Ne.symm hx0) + rw [Complex.cpow_add _ _ (by exact_mod_cast hx0), Complex.cpow_one, + halasz_power_phase_eq_cpow t x hxp, mul_comm] + +lemma halasz_power_phase_integral (t a b : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) : + (∫ x in a..b, halaszPowerPhase t x) = + ((b : ℂ) * halaszPowerPhase t b - (a : ℂ) * halaszPowerPhase t a) / + (1 + (-t : ℂ) * Complex.I) := by + have he : (∫ x in a..b, halaszPowerPhase t x) = + ∫ x : ℝ in a..b, (x : ℂ) ^ ((-t : ℂ) * Complex.I) := by + apply intervalIntegral.integral_congr_uIoo + intro x hx + exact halasz_power_phase_eq_cpow t x + (lt_of_le_of_lt (le_min ha hb) hx.1) + rw [he, integral_cpow (Or.inl (by norm_num [Complex.mul_re])), + halasz_power_phase_cpow_primitive t b hb, + halasz_power_phase_cpow_primitive t a ha, add_comm ((-t : ℂ) * Complex.I) 1] + +lemma halasz_power_phase_intervalIntegrable (t a b : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) : + IntervalIntegrable (halaszPowerPhase t) volume a b := by + apply (intervalIntegral.intervalIntegrable_cpow' (r := (-t : ℂ) * Complex.I) + (by norm_num [Complex.mul_re])).congr_uIoo + intro x hx + exact (halasz_power_phase_eq_cpow t x + (lt_of_le_of_lt (le_min ha hb) hx.1)).symm + +lemma halasz_power_phase_integral_norm (t a b : ℝ) : + ‖∫ x in a..b, halaszPowerPhase t x‖ ≤ |b - a| := by + simpa using intervalIntegral.norm_integral_le_of_norm_le_const + (a := a) (b := b) (C := 1) (f := halaszPowerPhase t) + (fun x _ => (halasz_power_phase_norm t x).le) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseSum.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..207064a98f22839a74275b749918ac6d828a51cf --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseSum.lean @@ -0,0 +1,167 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPhaseIntegral + +namespace OAI + +/-! A uniform power-sum estimate, using centered cells past the frequency. -/ + +namespace TwoPointCorrelations + +open MeasureTheory Finset + +lemma halasz_phase_cells_telescope (t : ℝ) (A N : ℕ) (hA : 1 ≤ A) (hAN : A ≤ N) : + (∑ n ∈ Ioc A N, ∫ x in ((n : ℝ) - 1 / 2)..((n : ℝ) + 1 / 2), + halaszPowerPhase t x) = + ∫ x in ((A : ℝ) + 1 / 2)..((N : ℝ) + 1 / 2), halaszPowerPhase t x := by + induction N, hAN using Nat.le_induction with + | base => simp + | succ N hAN ih => + rw [sum_Ioc_succ_top hAN, ih] + have he : ((N + 1 : ℕ) : ℝ) - 1 / 2 = (N : ℝ) + 1 / 2 := by push_cast; ring + rw [he] + apply intervalIntegral.integral_add_adjacent_intervals + · exact halasz_power_phase_intervalIntegrable t ((A : ℝ) + 1 / 2) + ((N : ℝ) + 1 / 2) (by positivity) (by positivity) + · exact halasz_power_phase_intervalIntegrable t ((N : ℝ) + 1 / 2) + (((N + 1 : ℕ) : ℝ) + 1 / 2) (by positivity) (by positivity) + +lemma halasz_phase_cell_sum_error (t : ℝ) (A N : ℕ) (hA : 1 ≤ A) + (hAN : A ≤ N) (ht : |t| ≤ (A : ℝ)) : + ‖(∑ n ∈ Ioc A N, halaszPowerPhase t n) - + ∫ x in ((A : ℝ) + 1 / 2)..((N : ℝ) + 1 / 2), halaszPowerPhase t x‖ ≤ + (t ^ 2 + |t|) / A := by + rw [← halasz_phase_cells_telescope t A N hA hAN, ← sum_sub_distrib] + calc + _ ≤ ∑ n ∈ Ioc A N, + ‖halaszPowerPhase t n - + ∫ x in ((n : ℝ) - 1 / 2)..((n : ℝ) + 1 / 2), halaszPowerPhase t x‖ := + norm_sum_le _ _ + _ ≤ ∑ n ∈ Ioc A N, (t ^ 2 + |t|) / (n : ℝ) ^ 2 := by + apply sum_le_sum + intro n hn + have hnA := (mem_Ioc.mp hn).1 + have hn1 : (1 : ℝ) ≤ n := by exact_mod_cast hA.trans hnA.le + have htn : |t| ≤ (n : ℝ) := ht.trans (by exact_mod_cast hnA.le) + have hh := halasz_power_phase_cell_integral t n hn1 htn + rw [intervalIntegral.integral_comp_add_left] at hh + have he : (n : ℝ) + (-1 / 2) = (n : ℝ) - 1 / 2 := by ring + rw [he] at hh + simpa only [norm_sub_rev] using hh + _ = (t ^ 2 + |t|) * ∑ n ∈ Ioc A N, ((n : ℝ) ^ 2)⁻¹ := by + simp_rw [div_eq_mul_inv, mul_sum] + _ ≤ (t ^ 2 + |t|) * ((A : ℝ)⁻¹ - (N : ℝ)⁻¹) := + mul_le_mul_of_nonneg_left (sum_Ioc_inv_sq_le_sub (by omega : A ≠ 0) hAN) (by positivity) + _ ≤ (t ^ 2 + |t|) / A := by + rw [div_eq_mul_inv] + exact mul_le_mul_of_nonneg_left (sub_le_self _ (by positivity)) (by positivity) + +lemma halasz_power_phase_prefix_norm (t : ℝ) (N : ℕ) : + ‖∑ n ∈ Ioc 0 N, halaszPowerPhase t n‖ ≤ N := by + calc + _ ≤ ∑ n ∈ Ioc 0 N, ‖halaszPowerPhase t n‖ := norm_sum_le _ _ + _ = _ := by simp + +theorem halasz_power_phase_sum_integral (t : ℝ) (N : ℕ) : + ‖(∑ n ∈ Ioc 0 N, halaszPowerPhase t n) - + ∫ x in (0 : ℝ)..(N : ℝ), halaszPowerPhase t x‖ ≤ 8 * (1 + |t|) := by + let A : ℕ := ⌈1 + |t|⌉₊ + have hAlo : 1 + |t| ≤ (A : ℝ) := Nat.le_ceil _ + have hAhi : (A : ℝ) < 2 + |t| := by + have hh : (A : ℝ) < 1 + |t| + 1 := Nat.ceil_lt_add_one (by positivity) + linarith + have hA1 : 1 ≤ A := by exact_mod_cast (show (1 : ℝ) ≤ A by linarith [abs_nonneg t]) + have hi (a b : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) := + halasz_power_phase_intervalIntegrable t a b ha hb + have hb : ∀ M : ℕ, + ‖(∑ n ∈ Ioc 0 M, halaszPowerPhase t n) - + ∫ x in (0 : ℝ)..(M : ℝ), halaszPowerPhase t x‖ ≤ 2 * M := by + intro M + calc + _ ≤ ‖∑ n ∈ Ioc 0 M, halaszPowerPhase t n‖ + + ‖∫ x in (0 : ℝ)..(M : ℝ), halaszPowerPhase t x‖ := norm_sub_le _ _ + _ ≤ (M : ℝ) + M := add_le_add (halasz_power_phase_prefix_norm t M) + (by simpa using halasz_power_phase_integral_norm t 0 M) + _ = _ := by ring + by_cases hNA : N ≤ A + · have hNr : (N : ℝ) ≤ A := by exact_mod_cast hNA + exact (hb N).trans (by linarith [abs_nonneg t]) + · have hAN : A ≤ N := by omega + have hs := sum_Ioc_consecutive (fun n : ℕ => halaszPowerPhase t n) + (Nat.zero_le A) hAN + have hj := intervalIntegral.integral_add_adjacent_intervals + (hi 0 ((A : ℝ) + 1 / 2) (by norm_num) (by positivity)) + (hi ((A : ℝ) + 1 / 2) ((N : ℝ) + 1 / 2) (by positivity) (by positivity)) + have hk := intervalIntegral.integral_add_adjacent_intervals + (hi 0 N (by norm_num) (by positivity)) + (hi N ((N : ℝ) + 1 / 2) (by positivity) (by positivity)) + have he : (∑ n ∈ Ioc 0 N, halaszPowerPhase t n) - + ∫ x in (0 : ℝ)..(N : ℝ), halaszPowerPhase t x = + ((∑ n ∈ Ioc 0 A, halaszPowerPhase t n) - + ∫ x in (0 : ℝ)..((A : ℝ) + 1 / 2), halaszPowerPhase t x) + + ((∑ n ∈ Ioc A N, halaszPowerPhase t n) - + ∫ x in ((A : ℝ) + 1 / 2)..((N : ℝ) + 1 / 2), halaszPowerPhase t x) + + ∫ x in (N : ℝ)..((N : ℝ) + 1 / 2), halaszPowerPhase t x := by + rw [← hs] + linear_combination hj - hk + have hhead : ‖(∑ n ∈ Ioc 0 A, halaszPowerPhase t n) - + ∫ x in (0 : ℝ)..((A : ℝ) + 1 / 2), halaszPowerPhase t x‖ ≤ 2 * A + 1 / 2 := by + calc + _ ≤ ‖∑ n ∈ Ioc 0 A, halaszPowerPhase t n‖ + + ‖∫ x in (0 : ℝ)..((A : ℝ) + 1 / 2), halaszPowerPhase t x‖ := norm_sub_le _ _ + _ ≤ (A : ℝ) + ((A : ℝ) + 1 / 2) := add_le_add (halasz_power_phase_prefix_norm t A) + (by + have hh := halasz_power_phase_integral_norm t 0 ((A : ℝ) + 1 / 2) + rw [sub_zero, abs_of_nonneg (by positivity)] at hh + exact hh) + _ = _ := by ring + have htail := halasz_phase_cell_sum_error t A N hA1 hAN (by linarith) + have hend : ‖∫ x in (N : ℝ)..((N : ℝ) + 1 / 2), halaszPowerPhase t x‖ ≤ 1 / 2 := by + simpa using halasz_power_phase_integral_norm t N ((N : ℝ) + 1 / 2) + have hratio : (t ^ 2 + |t|) / (A : ℝ) ≤ |t| := by + apply (div_le_iff₀ (by exact_mod_cast (show 0 < A by omega))).mpr + have hm := mul_le_mul_of_nonneg_left hAlo (abs_nonneg t) + nlinarith [sq_abs t] + rw [he] + exact ((norm_add_le _ _).trans (add_le_add + ((norm_add_le _ _).trans (add_le_add hhead htail)) hend)).trans + (by linarith [abs_nonneg t]) + +theorem halasz_power_phase_sum (t : ℝ) (N : ℕ) : + ‖(∑ n ∈ Icc 1 N, halaszPowerPhase t n) - + (N : ℂ) * halaszPowerPhase t N / (1 + (-t : ℂ) * Complex.I)‖ ≤ + 8 * (1 + |t|) := by + have hset : Icc 1 N = Ioc 0 N := by ext n; simp; omega + have hh := halasz_power_phase_sum_integral t N + rw [halasz_power_phase_integral t 0 N (by norm_num) (by positivity)] at hh + simpa [hset] using hh + +theorem halasz_power_phase_sum_real (t x : ℝ) (hx : 0 ≤ x) : + ‖(∑ n ∈ Icc 1 ⌊x⌋₊, halaszPowerPhase t n) - + (x : ℂ) * halaszPowerPhase t x / (1 + (-t : ℂ) * Complex.I)‖ ≤ + 9 * (1 + |t|) := by + have hN : (⌊x⌋₊ : ℝ) ≤ x := Nat.floor_le hx + have hN' : x - (⌊x⌋₊ : ℝ) < 1 := by linarith [Nat.lt_floor_add_one x] + have hj := intervalIntegral.integral_add_adjacent_intervals + (halasz_power_phase_intervalIntegrable t 0 ⌊x⌋₊ (by norm_num) (by positivity)) + (halasz_power_phase_intervalIntegrable t ⌊x⌋₊ x (by positivity) hx) + have he : (∑ n ∈ Icc 1 ⌊x⌋₊, halaszPowerPhase t n) - + ∫ y in (0 : ℝ)..x, halaszPowerPhase t y = + ((∑ n ∈ Icc 1 ⌊x⌋₊, halaszPowerPhase t n) - + ∫ y in (0 : ℝ)..(⌊x⌋₊ : ℝ), halaszPowerPhase t y) - + ∫ y in (⌊x⌋₊ : ℝ)..x, halaszPowerPhase t y := by + rw [← hj] + ring + have hset : Icc 1 ⌊x⌋₊ = Ioc 0 ⌊x⌋₊ := by ext n; simp; omega + have hh := halasz_power_phase_sum_integral t ⌊x⌋₊ + rw [← hset] at hh + have ht : ‖∫ y in (⌊x⌋₊ : ℝ)..x, halaszPowerPhase t y‖ ≤ 1 := by + apply (halasz_power_phase_integral_norm t ⌊x⌋₊ x).trans + rw [abs_of_nonneg (sub_nonneg.mpr hN)] + exact hN'.le + have h := ((norm_sub_le _ _).trans (add_le_add hh ht)).trans + (show 8 * (1 + |t|) + 1 ≤ 9 * (1 + |t|) by linarith [abs_nonneg t]) + rw [← he, halasz_power_phase_integral t 0 x (by norm_num) hx] at h + simpa using h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseTaylor.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseTaylor.lean new file mode 100644 index 0000000000000000000000000000000000000000..400b3293627cd9efe760062678b57d881cfda2f5 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseTaylor.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimeOscillation +import Mathlib.Analysis.SpecialFunctions.Complex.LogBounds + +namespace OAI + +/-! Local phase expansion for the elementary near-twist sum comparison. +The linear term cancels on intervals centered at an integer. -/ + +namespace TwoPointCorrelations + +open scoped ComplexConjugate + +lemma halasz_log_one_add_small (u : ℝ) (hu : |u| ≤ 1 / 2) : + |Real.log (1 + u) - u| ≤ u ^ 2 ∧ |Real.log (1 + u)| ≤ 3 / 2 * |u| := by + have hp : 0 ≤ 1 + u := by linarith [(abs_le.mp hu).1] + have hn : ‖(u : ℂ)‖ ≤ 1 / 2 := by simpa only [Complex.norm_real, Real.norm_eq_abs] using hu + have he : Complex.log (1 + (u : ℂ)) = (Real.log (1 + u) : ℂ) := by + rw [← Complex.ofReal_one, ← Complex.ofReal_add, ← Complex.ofReal_log hp] + have hfirst := Complex.norm_log_one_add_sub_self_le (lt_of_le_of_lt hn (by norm_num)) + have hsecond := Complex.norm_log_one_add_half_le_self hn + rw [he, ← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs, + Complex.norm_real, Real.norm_eq_abs] at hfirst + rw [he, Complex.norm_real, Real.norm_eq_abs, Complex.norm_real, Real.norm_eq_abs] at hsecond + refine ⟨hfirst.trans ?_, hsecond⟩ + have hi : (1 - |u|)⁻¹ ≤ 2 := by + rw [inv_eq_one_div] + apply (div_le_iff₀ (by linarith : 0 < 1 - |u|)).mpr + linarith + rw [sq_abs] + nlinarith [mul_le_mul_of_nonneg_left hi (sq_nonneg u)] + +lemma halasz_phase_linear_error (t u : ℝ) (hu : |u| ≤ 1 / 2) + (htu : |t * u| ≤ 1 / 2) : + ‖Complex.exp (((-t * Real.log (1 + u) : ℝ) : ℂ) * Complex.I) - 1 - + (((-t * u : ℝ) : ℂ) * Complex.I)‖ ≤ 4 * (t ^ 2 + |t|) * u ^ 2 := by + obtain ⟨hlog, hsize⟩ := halasz_log_one_add_small u hu + let a : ℝ := -t * Real.log (1 + u) + let b : ℝ := -t * u + have ha : |a| ≤ 1 := by + have hh := mul_le_mul_of_nonneg_left hsize (abs_nonneg t) + rw [abs_mul] at htu + dsimp [a] + rw [abs_mul, abs_neg] + nlinarith + have hcn : ‖(a : ℂ) * Complex.I‖ ≤ 1 := by + simpa only [norm_mul, Complex.norm_real, Real.norm_eq_abs, Complex.norm_I, mul_one] using ha + have hexp := Complex.norm_exp_sub_one_sub_id_le hcn + have hab : |a - b| ≤ |t| * u ^ 2 := by + have he : a - b = -t * (Real.log (1 + u) - u) := by dsimp [a, b]; ring + rw [he, abs_mul, abs_neg] + exact mul_le_mul_of_nonneg_left hlog (abs_nonneg t) + have ha2 : a ^ 2 ≤ 9 / 4 * t ^ 2 * u ^ 2 := by + have hh := pow_le_pow_left₀ (abs_nonneg (Real.log (1 + u))) hsize 2 + rw [sq_abs, mul_pow, sq_abs] at hh + have hm := mul_le_mul_of_nonneg_left hh (sq_nonneg t) + dsimp [a] + nlinarith + have hsplit : Complex.exp ((a : ℂ) * Complex.I) - 1 - (b : ℂ) * Complex.I = + (Complex.exp ((a : ℂ) * Complex.I) - 1 - (a : ℂ) * Complex.I) + + ((a - b : ℝ) : ℂ) * Complex.I := by push_cast; ring + change ‖Complex.exp ((a : ℂ) * Complex.I) - 1 - (b : ℂ) * Complex.I‖ ≤ _ + rw [hsplit] + apply (norm_add_le _ _).trans + simp only [norm_mul, Complex.norm_real, Real.norm_eq_abs, Complex.norm_I, mul_one, + sq_abs] at hexp ⊢ + have hn : 0 ≤ |t| * u ^ 2 := by positivity + have hn2 : 0 ≤ t ^ 2 * u ^ 2 := by positivity + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseTranslation.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseTranslation.lean new file mode 100644 index 0000000000000000000000000000000000000000..efcc0351c3e9c2228964bcaca94643e4f5a3800f --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPhaseTranslation.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszExceptionalEnergy + +namespace OAI + +/-! Frequency translation and the actual typical-set coefficient. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped ComplexConjugate + +lemma halasz_power_phase_frequency_add (t u x : ℝ) : + halaszPowerPhase (t + u) x = halaszPowerPhase t x * halaszPowerPhase u x := by + simp only [halaszPowerPhase, neg_add, add_mul, Complex.ofReal_add, Complex.exp_add] + +lemma halasz_power_phase_twist (t : ℝ) (n : ℕ) : + conj (mrtArchimedeanTwist t n) = halaszPowerPhase t n := by + rw [mrtArchimedeanTwist, ← Complex.exp_conj] + unfold halaszPowerPhase + congr 1 + simp only [map_mul, Complex.conj_ofReal, Complex.conj_I] + push_cast + ring + +lemma halasz_twisted_phase_mean (F : ℕ → ℂ) (t u : ℝ) (N : ℕ) : + halaszPhaseMean (halaszTwistedFunction F t) u N = halaszPhaseMean F (t + u) N := by + unfold halaszPhaseMean + apply sum_congr rfl + intro n _ + rw [halaszTwistedFunction, halasz_power_phase_twist, halasz_power_phase_frequency_add] + ring + +lemma halasz_twisted_dyadic (F : ℕ → ℂ) (t u : ℝ) (N : ℕ) : + mrtDyadicPolynomial (halaszTwistedFunction F t) N u = mrtDyadicPolynomial F N (t + u) := by + rw [halasz_dyadic_phase, halasz_dyadic_phase] + apply sum_congr rfl + intro n _ + rw [halaszTwistedFunction, halasz_power_phase_twist, halasz_power_phase_frequency_add] + ring + +lemma halasz_typical_twist {ι : Type*} (J : Finset ι) (P : ι → Finset ℕ) + (F : ℕ → ℂ) (t : ℝ) : + mrtTypicalCoefficient J P (halaszTwistedFunction F t) = + halaszTwistedFunction (mrtTypicalCoefficient J P F) t := by + funext n + by_cases ht : mrtTypical J P n <;> + simp [mrtTypicalCoefficient, halaszTwistedFunction, ht] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPoissonBound.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPoissonBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3850833963b6911aa0673c7745fbdfdf7d9569c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPoissonBound.lean @@ -0,0 +1,103 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPoissonModes + +namespace OAI + +/-! Summing the stationary and nonstationary Poisson modes. -/ +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +noncomputable def halaszIntegerSquareMass : ℝ := ∑' k : ℤ, 1/(k:ℝ)^2 + +lemma halasz_integer_square_mass_nonneg : 0 ≤ halaszIntegerSquareMass := + tsum_nonneg (fun _ => by positivity) + +theorem halasz_triangle_poisson_bound (N u : ℝ) (hN : 0 < N) : + ‖∑' n : ℤ, halaszTriangleFunction N u 0 n‖ ≤ + 18600*N/(1+u^2) + (440/Real.pi)*Real.sqrt |u| + + (512/(N*(2*Real.pi)^2))*halaszIntegerSquareMass := by + let R := 2*|u|/(Real.pi*N) + let S := halaszNearModes R + let Z := 18600*N/(1+u^2) + let B := 110*N/Real.sqrt |u| + let C := 512/(N*(2*Real.pi)^2) + let a : ℤ → ℝ := fun k => if k=0 then Z else 0 + let b : ℤ → ℝ := fun k => if k ∈ S then B else 0 + let c : ℤ → ℝ := fun k => C*(1/(k:ℝ)^2) + have ha : Summable a := summable_of_ne_finset_zero (s := {0}) (by + intro k hk + dsimp [a] + simp only [mem_singleton] at hk + exact ite_eq_right hk) + have hb : Summable b := summable_of_ne_finset_zero (s := S) (by + intro k hk + exact ite_eq_right hk) + have hc : Summable c := + (Real.summable_one_div_int_pow.mpr (by norm_num : 1<2)).mul_left C + have hterm (k : ℤ) : ‖halaszTriangleIntegral N u (2*Real.pi*k)‖ ≤ a k+b k+c k := by + by_cases hk : k=0 + · subst k + simpa [a,b,c,Z,S,halasz_mem_near_modes] using halasz_triangle_zero N u hN + have hkR : (k:ℝ) ≠ 0 := by exact_mod_cast hk + have hp : 0 < |(k:ℝ)| := abs_pos.mpr hkR + have hv : 2*Real.pi*(k:ℝ) ≠ 0 := + mul_ne_zero (mul_ne_zero (by norm_num) Real.pi_ne_zero) hkR + by_cases hs : k ∈ S + · have hks := (halasz_mem_near_modes R k).mp hs + have hu : u ≠ 0 := by + intro hu + subst u + have hR : R=0 := by simp [R] + rw [hR] at hks + linarith [hks.2] + have h := halasz_triangle_stationary_abs N u (2*Real.pi*k) hN hu + have hcn : 0 ≤ c k := by dsimp [c,C]; positivity + simpa only [a,b,ite_eq_right hk,ite_eq_left hs,zero_add] using h.trans (le_add_of_nonneg_right hcn) + · have hout : R < |(k:ℝ)| := by + by_contra hn + exact hs ((halasz_mem_near_modes R k).mpr ⟨hk,le_of_not_gt hn⟩) + have hfar : 4*|u| ≤ N*|2*Real.pi*(k:ℝ)| := by + have hpN : 0 < Real.pi*N := mul_pos Real.pi_pos hN + have hh := (div_lt_iff₀ hpN).mp hout + rw [abs_mul, abs_of_pos (mul_pos (by norm_num) Real.pi_pos)] + nlinarith + have h := halasz_triangle_far N u (2*Real.pi*k) hN hv hfar + have he : 512/(N*(2*Real.pi*(k:ℝ))^2) = c k := by dsimp [c,C]; ring + simpa only [a,b,ite_eq_right hk,ite_eq_right hs,zero_add] using h.trans_eq he + have hnorm : Summable (fun k : ℤ => ‖halaszTriangleIntegral N u (2*Real.pi*k)‖) := + Summable.of_nonneg_of_le (fun _ => norm_nonneg _) hterm ((ha.add hb).add hc) + have hZA : (∑' k : ℤ, a k) = Z := by + rw [tsum_eq_sum (s := {0}) (fun k hk => by + dsimp [a] + simp only [mem_singleton] at hk + exact ite_eq_right hk)] + simp [a] + have hSB : (∑' k : ℤ, b k) = (S.card:ℝ)*B := by + rw [tsum_eq_sum (s := S) (fun k hk => ite_eq_right hk)] + simp + have hTC : (∑' k : ℤ, c k) = C*halaszIntegerSquareMass := by + exact tsum_mul_left + have hcard : (S.card:ℝ) ≤ 2*R := + halasz_near_modes_card R (by dsimp [R]; positivity) + have hmode : (2*R)*B = (440/Real.pi)*Real.sqrt |u| := by + by_cases hu : u=0 + · subst u + simp [R,B] + have hsu : 0 < Real.sqrt |u| := Real.sqrt_pos.mpr (abs_pos.mpr hu) + have he := Real.sq_sqrt (abs_nonneg u) + dsimp [R,B] + field_simp + nlinarith + rw [halasz_triangle_poisson N u hN] + calc + _ ≤ ∑' k : ℤ, ‖halaszTriangleIntegral N u (2*Real.pi*k)‖ := norm_tsum_le_tsum_norm hnorm + _ ≤ ∑' k : ℤ, (a k+b k+c k) := hnorm.tsum_le_tsum hterm ((ha.add hb).add hc) + _ = Z+(S.card:ℝ)*B+C*halaszIntegerSquareMass := by + rw [(ha.add hb).tsum_add hc,ha.tsum_add hb,hZA,hSB,hTC] + _ ≤ Z+(2*R)*B+C*halaszIntegerSquareMass := by gcongr + _ = _ := by rw [hmode] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPoissonModes.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPoissonModes.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f8ee37057895cdaf02d32d3bda69b21e61c56bf --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPoissonModes.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszTrianglePoisson + +namespace OAI + +/-! Counting the nonzero integer Fourier modes near a stationary point. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def halaszNearModes (R : ℝ) : Finset ℤ := + (Icc (-⌊R⌋) ⌊R⌋).erase 0 + +lemma halasz_mem_near_modes (R : ℝ) (k : ℤ) : + k ∈ halaszNearModes R ↔ k ≠ 0 ∧ |(k:ℝ)| ≤ R := by + unfold halaszNearModes + simp only [mem_erase, mem_Icc] + constructor + · rintro ⟨hk,hlo,hhi⟩ + refine ⟨hk,abs_le.mpr ⟨?_,Int.le_floor.mp hhi⟩⟩ + have hh : -k ≤ ⌊R⌋ := by omega + have hr := Int.le_floor.mp hh + push_cast at hr + linarith + · rintro ⟨hk,hr⟩ + have hh := abs_le.mp hr + refine ⟨hk,?_,Int.le_floor.mpr hh.2⟩ + have hneg : ((-k:ℤ):ℝ) ≤ R := by push_cast; linarith [hh.1] + have hi := Int.le_floor.mpr hneg + omega + +lemma halasz_near_modes_card (R : ℝ) (hR : 0 ≤ R) : + ((halaszNearModes R).card:ℝ) ≤ 2*R := by + have hm : (0:ℤ) ≤ ⌊R⌋ := Int.floor_nonneg.mpr hR + have hz : (0:ℤ) ∈ Icc (-⌊R⌋) ⌊R⌋ := mem_Icc.mpr ⟨by omega,hm⟩ + have he := card_erase_add_one hz + have hc := Int.card_Icc_of_le (a := -⌊R⌋) (b := ⌊R⌋) (by omega) + have heR : ((halaszNearModes R).card:ℝ)+1 = ((Icc (-⌊R⌋) ⌊R⌋).card:ℝ) := by + exact_mod_cast he + have hcR : ((Icc (-⌊R⌋) ⌊R⌋).card:ℝ) = 2*(⌊R⌋:ℝ)+1 := by + have hc' : ((Icc (-⌊R⌋) ⌊R⌋).card:ℤ) = 2*⌊R⌋+1 := by omega + exact_mod_cast hc' + have hf := Int.floor_le R + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPositiveLog.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPositiveLog.lean new file mode 100644 index 0000000000000000000000000000000000000000..c04d16ae213072b791ebd5bc4cb49351d40d825b --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPositiveLog.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszUnitCorrection +import Mathlib.Data.Nat.Factorization.PrimePow +import Mathlib.Data.Nat.Prime.Int + +namespace OAI + +/-! Logarithmic majorization of the absolute constant-one correction. +Only its bound by two on positive prime powers is used. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def halaszPrimePowerLog (n : ℕ) : ℝ := + if IsPrimePow n then 2 * Real.log n else 0 + +lemma halaszPrimePowerLog_nonneg (n : ℕ) : 0 ≤ halaszPrimePowerLog n := by + unfold halaszPrimePowerLog + split_ifs with h + · exact mul_nonneg (by norm_num) (Real.log_nonneg (by exact_mod_cast h.one_lt.le)) + · exact le_rfl + +lemma halasz_log_factorization (n : ℕ) (hn : n ≠ 0) : + Real.log n = ∑ p ∈ n.factorization.support, Real.log ((p ^ n.factorization p : ℕ) : ℝ) := by + have he := Nat.prod_factorization_pow_eq_self hn + calc + _ = Real.log ((n.factorization.prod (fun p k => p ^ k) : ℕ) : ℝ) := by rw [he] + _ = Real.log (∏ p ∈ n.factorization.support, ((p ^ n.factorization p : ℕ) : ℝ)) := by + simp only [Finsupp.prod, Nat.cast_prod] + _ = _ := Real.log_prod (fun p hp => by + exact_mod_cast pow_ne_zero (n.factorization p) (Nat.prime_of_mem_primeFactors + (by simpa only [Nat.support_factorization] using hp)).ne_zero) + +lemma halasz_unit_correction_log_bound (F : ℕ → ℂ) (hF : OneBounded F) (n : ℕ) : + ‖halaszUnitCorrection F n‖ * Real.log n ≤ + ∑ d ∈ n.divisors, halaszPrimePowerLog d * ‖halaszUnitCorrection F (n / d)‖ := by + by_cases hn : n = 0 + · subst n + simp + let S := n.factorization.support + let v := fun p => p ^ n.factorization p + have hp (p : ℕ) (h : p ∈ S) : p.Prime := + Nat.prime_of_mem_primeFactors (by simpa only [S, Nat.support_factorization] using h) + have hk (p : ℕ) (h : p ∈ S) : 0 < n.factorization p := + Nat.pos_of_ne_zero (Finsupp.mem_support_iff.mp h) + have hpower (p : ℕ) (h : p ∈ S) : IsPrimePow (v p) := + ⟨p, n.factorization p, (hp p h).prime, hk p h, rfl⟩ + have hvpos (p : ℕ) (h : p ∈ S) : 0 < v p := pow_pos (hp p h).pos _ + have hnorm (p : ℕ) (h : p ∈ S) : + ‖halaszUnitCorrection F n‖ ≤ 2 * ‖halaszUnitCorrection F (n / v p)‖ := by + have hquot : 0 < n / v p := Nat.ordCompl_pos p hn + have hcop := (Nat.coprime_ordCompl (hp p h) hn).pow_left (n.factorization p) + have he := fromPrimePowers_multiplicative (halaszUnitCorrectionLocal F) + (v p) (n / v p) (hvpos p h) hquot hcop + change halaszUnitCorrection F (v p * (n / v p)) = + halaszUnitCorrection F (v p) * halaszUnitCorrection F (n / v p) at he + rw [Nat.mul_div_cancel' (Nat.ordProj_dvd n p)] at he + rw [he, norm_mul] + exact mul_le_mul_of_nonneg_right + (by rw [halasz_unit_correction_prime_pow F (hp p h)]; + exact halasz_unit_correction_local_bound F hF (hp p h) (hk p h)) (norm_nonneg _) + have hinj : Set.InjOn v (S : Set ℕ) := by + intro p hpS q hqS he + exact ((hp p hpS).pow_inj' (hp q hqS) (hk p hpS).ne' (hk q hqS).ne' he).1 + have hsub : S.image v ⊆ n.divisors.filter IsPrimePow := by + intro d hd + obtain ⟨p, hpS, rfl⟩ := mem_image.mp hd + exact mem_filter.mpr ⟨Nat.mem_divisors.mpr ⟨Nat.ordProj_dvd n p, hn⟩, hpower p hpS⟩ + calc + _ = ∑ p ∈ S, ‖halaszUnitCorrection F n‖ * Real.log (v p) := by + rw [halasz_log_factorization n hn, mul_sum] + _ ≤ ∑ p ∈ S, halaszPrimePowerLog (v p) * ‖halaszUnitCorrection F (n / v p)‖ := by + apply sum_le_sum + intro p hpS + rw [halaszPrimePowerLog, ite_eq_left (hpower p hpS)] + have hl : 0 ≤ Real.log (v p : ℝ) := + Real.log_nonneg (by exact_mod_cast (hpower p hpS).one_lt.le) + nlinarith [mul_le_mul_of_nonneg_right (hnorm p hpS) hl] + _ = ∑ d ∈ S.image v, halaszPrimePowerLog d * ‖halaszUnitCorrection F (n / d)‖ := + (sum_image (f := fun d : ℕ => halaszPrimePowerLog d * ‖halaszUnitCorrection F (n / d)‖) hinj).symm + _ ≤ ∑ d ∈ n.divisors.filter IsPrimePow, + halaszPrimePowerLog d * ‖halaszUnitCorrection F (n / d)‖ := + sum_le_sum_of_subset_of_nonneg hsub (fun d _ _ => mul_nonneg + (halaszPrimePowerLog_nonneg d) (norm_nonneg _)) + _ = _ := by + rw [sum_filter] + apply sum_congr rfl + intro d _ + by_cases hd : IsPrimePow d <;> simp [halaszPrimePowerLog, hd] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPowerTranslation.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPowerTranslation.lean new file mode 100644 index 0000000000000000000000000000000000000000..12ee86b3742e37309a9ff39fa099a6614f37762e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPowerTranslation.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszVinogradovTranslation + +namespace OAI + +/-! Translation of the complete system on a finite set of coordinates. +The natural-number version uses an integer translation for the reverse +implication, so no truncated subtraction is hidden in the statement. -/ +namespace TwoPointCorrelations + +open Finset + +lemma halasz_finite_power_translate {ι R : Type*} [Fintype ι] [CommSemiring R] + {k : ℕ} (x y : ι → R) + (hpower : ∀ j : ℕ, 1≤j → j≤k → ∑ i, x i^j=∑ i, y i^j) + (c : R) : ∀ j : ℕ, 1≤j → j≤k → ∑ i, (x i+c)^j=∑ i, (y i+c)^j := by + intro j _ hjk + have he (z : ι → R) : (∑ i, (z i+c)^j) = + ∑ m∈range (j+1), (∑ i, z i^m)*c^(j-m)*(Nat.choose j m:R) := by + simp only [add_pow] + rw [sum_comm] + apply sum_congr rfl + intro m _ + rw [← sum_mul,← sum_mul] + rw [he,he] + apply sum_congr rfl + intro m hm + have hmj : m≤j := by have := mem_range.mp hm; omega + have hp : (∑ i, x i^m)=∑ i, y i^m := by + by_cases hz : m=0 + · simp [hz] + · exact hpower m (by omega) (hmj.trans hjk) + rw [hp] + +lemma halasz_nat_power_translate_iff {ι : Type*} [Fintype ι] {k : ℕ} + (x y : ι → ℕ) (a : ℕ) : + (∀ j : ℕ, 1≤j → j≤k → ∑ i, x i^j=∑ i, y i^j) ↔ + (∀ j : ℕ, 1≤j → j≤k → ∑ i, (x i+a)^j=∑ i, (y i+a)^j) := by + constructor + · exact fun h => halasz_finite_power_translate x y h a + · intro h j hj hjk + have hz : ∀ j : ℕ, 1≤j → j≤k → + (∑ i, ((x i:ℤ)+a)^j)=∑ i, ((y i:ℤ)+a)^j := by + intro j hj hjk + exact_mod_cast h j hj hjk + have ht := halasz_finite_power_translate _ _ hz (-(a:ℤ)) j hj hjk + simp only [add_neg_cancel_right] at ht + exact_mod_cast ht + +lemma halasz_power_vector_eq_iff {ι : Type*} [Fintype ι] {k : ℕ} + (x y : ι → ℕ) : + (fun j : Fin k => ∑ i, x i^(j.val+1)) = (fun j : Fin k => ∑ i, y i^(j.val+1)) ↔ + ∀ j : ℕ, 1≤j → j≤k → ∑ i, x i^j=∑ i, y i^j := by + constructor + · intro h j hj hjk + have he := congrFun h (⟨j-1,by omega⟩ : Fin k) + simpa only [Nat.sub_add_cancel hj] using he + · intro h + funext j + exact h (j.val+1) (by omega) (by omega) + +lemma halasz_power_vector_translate_iff {ι : Type*} [Fintype ι] {k : ℕ} + (x y : ι → ℕ) (a : ℕ) : + (fun j : Fin k => ∑ i, x i^(j.val+1)) = (fun j : Fin k => ∑ i, y i^(j.val+1)) ↔ + (fun j : Fin k => ∑ i, (x i+a)^(j.val+1)) = + (fun j : Fin k => ∑ i, (y i+a)^(j.val+1)) := by + rw [halasz_power_vector_eq_iff,halasz_power_vector_eq_iff] + exact halasz_nat_power_translate_iff x y a + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPretentiousCenter.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPretentiousCenter.lean new file mode 100644 index 0000000000000000000000000000000000000000..d36b15edd319d7466495a6d85065a79b49035010 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPretentiousCenter.lean @@ -0,0 +1,108 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszGeneralTwist +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTCountMean +import Mathlib.Topology.Order.Compact + +namespace OAI + +/-! The minimizing twist and the elementary part of MRT Lemma A.4(ii). +Two nearby candidates for the minimum force a lower bound by an explicit +prime cosine sum. Analytic estimates for that prime sum are kept separate. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped ComplexConjugate + +lemma halasz_distance_continuous (F : ℕ → ℂ) (N : ℕ) : + Continuous (fun t : ℝ => squaredDistance F (mrtArchimedeanTwist t) N) := by + unfold squaredDistance mrtArchimedeanTwist + fun_prop + +theorem halasz_minimizing_twist (F : ℕ → ℂ) (N : ℕ) : + ∃ t₁ : ℝ, |t₁| ≤ (N : ℝ) ∧ ∀ t : ℝ, |t| ≤ (N : ℝ) → + squaredDistance F (mrtArchimedeanTwist t₁) N ≤ + squaredDistance F (mrtArchimedeanTwist t) N := by + have hn : -(N : ℝ) ≤ N := by linarith [Nat.cast_nonneg (α := ℝ) N] + obtain ⟨t₁, ht₁, hmin⟩ := isCompact_Icc.exists_isMinOn + (Set.nonempty_Icc.mpr hn) (halasz_distance_continuous F N).continuousOn + refine ⟨t₁, abs_le.mpr ht₁, fun t ht => hmin (abs_le.mp ht)⟩ + +lemma halasz_twist_sum_norm (t s : ℝ) (n : ℕ) : + ‖mrtArchimedeanTwist t n + mrtArchimedeanTwist s n‖ = + 2 * |Real.cos ((t - s) * Real.log (n : ℝ) / 2)| := by + let u := (t + s) / 2 + let v := (t - s) * Real.log (n : ℝ) / 2 + have he : mrtArchimedeanTwist t n + mrtArchimedeanTwist s n = + mrtArchimedeanTwist u n * ((2 : ℂ) * (Real.cos v : ℂ)) := by + rw [Complex.ofReal_cos, Complex.two_cos, mul_add] + unfold mrtArchimedeanTwist + rw [← Complex.exp_add, ← Complex.exp_add] + congr 1 <;> congr 1 <;> dsimp [u, v] <;> push_cast <;> ring + rw [he, norm_mul, mrtArchimedeanTwist_norm, one_mul, norm_mul, + Complex.norm_ofNat, Complex.norm_real, Real.norm_eq_abs] + +theorem halasz_two_twist_distance (F : ℕ → ℂ) (hF : OneBounded F) + (N : ℕ) (t s : ℝ) : + 2 * (∑ p ∈ primesUpTo N, + (1 - |Real.cos ((t - s) * Real.log (p : ℝ) / 2)|) / (p : ℝ)) ≤ + squaredDistance F (mrtArchimedeanTwist t) N + + squaredDistance F (mrtArchimedeanTwist s) N := by + unfold squaredDistance + rw [mul_sum, ← sum_add_distrib] + apply sum_le_sum + intro p hp + rw [← add_div, ← mul_div_assoc] + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg p) + have hp0 := (mem_filter.mp hp).2.pos + have hre : (F p * conj (mrtArchimedeanTwist t p)).re + + (F p * conj (mrtArchimedeanTwist s p)).re ≤ + ‖mrtArchimedeanTwist t p + mrtArchimedeanTwist s p‖ := by + calc + _ = (F p * conj (mrtArchimedeanTwist t p + mrtArchimedeanTwist s p)).re := by + simp only [map_add, mul_add, Complex.add_re] + _ ≤ ‖F p * conj (mrtArchimedeanTwist t p + mrtArchimedeanTwist s p)‖ := + Complex.re_le_norm _ + _ = ‖F p‖ * ‖mrtArchimedeanTwist t p + mrtArchimedeanTwist s p‖ := by + rw [norm_mul, Complex.norm_conj] + _ ≤ _ := mul_le_of_le_one_left (norm_nonneg _) (hF p hp0) + rw [halasz_twist_sum_norm] at hre + linarith + +lemma halasz_distance_from_minimizer (F : ℕ → ℂ) (hF : OneBounded F) + (N : ℕ) (t t₁ : ℝ) + (hmin : squaredDistance F (mrtArchimedeanTwist t₁) N ≤ + squaredDistance F (mrtArchimedeanTwist t) N) : + (∑ p ∈ primesUpTo N, + (1 - |Real.cos ((t - t₁) * Real.log (p : ℝ) / 2)|) / (p : ℝ)) ≤ + squaredDistance F (mrtArchimedeanTwist t) N := by + have h := halasz_two_twist_distance F hF N t t₁ + linarith + +lemma halasz_prime_cosine_tail_lower (F : ℕ → ℂ) (hF : OneBounded F) + (N : ℕ) (Y t t₁ : ℝ) + (hmin : squaredDistance F (mrtArchimedeanTwist t₁) N ≤ + squaredDistance F (mrtArchimedeanTwist t) N) : + (∑ p ∈ (primesUpTo N).filter (fun p : ℕ => Y < (p : ℝ)), + (1 - |Real.cos ((t - t₁) * Real.log (p : ℝ) / 2)|) / (p : ℝ)) ≤ + squaredDistance F (mrtArchimedeanTwist t) N := by + apply le_trans _ (halasz_distance_from_minimizer F hF N t t₁ hmin) + apply sum_le_sum_of_subset_of_nonneg (filter_subset _ _) + intro p _ _ + exact div_nonneg (sub_nonneg.mpr (Real.abs_cos_le_one _)) (Nat.cast_nonneg p) + +lemma halasz_masked_cosine_tail_lower (F : ℕ → ℂ) (hF : OneBounded F) + (Q : Finset ℕ) (N : ℕ) (Y t t₁ : ℝ) + (hmin : squaredDistance F (mrtArchimedeanTwist t₁) N ≤ + squaredDistance F (mrtArchimedeanTwist t) N) : + (∑ p ∈ (primesUpTo N).filter (fun p : ℕ => Y < (p : ℝ)), + (1 - |Real.cos ((t - t₁) * Real.log (p : ℝ) / 2)|) / (p : ℝ)) ≤ + 2 * squaredDistance (mrtMissingCoefficient F Q) (mrtArchimedeanTwist t) N := by + apply (halasz_prime_cosine_tail_lower F hF N Y t t₁ hmin).trans + exact mrt_masked_distance_lower F (mrtArchimedeanTwist t) (mrtPrimeMask Q) N + (fun p hp => hF p (mem_filter.mp hp).2.pos) + (fun p _ => (mrtArchimedeanTwist_norm t p).le) + (fun p _ => mrtPrimeMask_bounds Q p) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeConvolution.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeConvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..3130f546e7fd9af48ee041f10037b24cbd5e785e --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeConvolution.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimePowers +import OAI.NumberTheory.TwoPoint.Halasz.HalaszLogMean + +namespace OAI + +/-! Prime-only convolution and its explicit O(N) error. This is the first +step of the Granville--Harper--Soundararajan double-convolution argument. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def halaszPrimeConvolution (f : ℕ → ℂ) (N : ℕ) : ℂ := + ∑ p ∈ (Icc 1 N).filter Nat.Prime, + (Real.log (p : ℝ) : ℂ) * f p * (∑ m ∈ Icc 1 (N / p), f m) + +lemma halasz_log_sum_rows (f : ℕ → ℂ) + (hf : ∀ m n : ℕ, 0 < m → 0 < n → f (m * n) = f m * f n) (N : ℕ) : + (∑ n ∈ Icc 1 N, f n * (Real.log (n : ℝ) : ℂ)) = + ∑ d ∈ Icc 1 N, (ArithmeticFunction.vonMangoldt d : ℂ) * f d * + (∑ m ∈ Icc 1 (N / d), f m) := by + rw [halasz_logarithmic_sum f hf N, halasz_hyperbola_rows + (fun a b => (ArithmeticFunction.vonMangoldt a : ℂ) * f a * f b) N] + apply sum_congr rfl + intro d _ + rw [mul_sum] + +lemma halasz_prime_convolution_difference (f : ℕ → ℂ) + (hf : ∀ m n : ℕ, 0 < m → 0 < n → f (m * n) = f m * f n) (N : ℕ) : + (∑ n ∈ Icc 1 N, f n * (Real.log (n : ℝ) : ℂ)) - halaszPrimeConvolution f N = + ∑ d ∈ Icc 1 N, (halaszPrimePowerWeight d : ℂ) * f d * + (∑ m ∈ Icc 1 (N / d), f m) := by + rw [halasz_log_sum_rows f hf N, halaszPrimeConvolution, sum_filter, ← sum_sub_distrib] + apply sum_congr rfl + intro d _ + by_cases hd : d.Prime + · simp [hd, halaszPrimePowerWeight, ArithmeticFunction.vonMangoldt_apply_prime hd] + · simp [hd, halaszPrimePowerWeight] + +/-- The exact logarithmic sum differs from its prime-only convolution by +at most a constant times N, uniformly in the bounded multiplicative function. -/ +theorem halasz_log_sum_prime_error (f : ℕ → ℂ) (hbound : OneBounded f) + (hmul : ∀ m n : ℕ, 0 < m → 0 < n → f (m * n) = f m * f n) (N : ℕ) : + ‖(∑ n ∈ Icc 1 N, f n * (Real.log (n : ℝ) : ℂ)) - halaszPrimeConvolution f N‖ ≤ + (N : ℝ) * halaszPrimePowerConstant := by + rw [halasz_prime_convolution_difference f hmul N] + exact halasz_prime_power_error f hbound N + +/-- First Halasz reduction, with a uniform and completely proved error. -/ +theorem halasz_prime_convolution_mean_bound (f : ℕ → ℂ) (hbound : OneBounded f) + (hmul : ∀ m n : ℕ, 0 < m → 0 < n → f (m * n) = f m * f n) + (N : ℕ) (hN : 1 ≤ N) : + Real.log (N : ℝ) * ‖∑ n ∈ Icc 1 N, f n‖ ≤ + ‖halaszPrimeConvolution f N‖ + (halaszPrimePowerConstant + 1) * (N : ℝ) := by + have he := halasz_log_sum_prime_error f hbound hmul N + have ht := norm_add_le (halaszPrimeConvolution f N) + ((∑ n ∈ Icc 1 N, f n * (Real.log (n : ℝ) : ℂ)) - halaszPrimeConvolution f N) + rw [add_sub_cancel] at ht + have hh := halasz_logarithmic_mean_bound f hbound N hN + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeCounting.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeCounting.lean new file mode 100644 index 0000000000000000000000000000000000000000..02bbea0ad5d3af85125ed5d68a6589c3f852ef69 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeCounting.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.Jacobsthal.Partitions.RealProgressionCoordinates + +namespace OAI + +/-! The short-interval prime-counting consequence needed for the weighted +Halasz mean-value argument, obtained by specializing the +Brun--Titchmarsh sieve to modulus one. -/ + +namespace TwoPointCorrelations + +open Finset +open Erdos970.ErdosPrimeInputs + +/-- Uniform upper bound for any finite set of primes in a real interval. +The location of the interval is unrestricted. -/ +theorem halasz_prime_interval_bound : ∃ C B : ℝ, 0 < C ∧ 1 < B ∧ + ∀ (x H : ℝ) (P : Finset ℕ), B ≤ H → + (∀ p ∈ P, p.Prime ∧ x < (p : ℝ) ∧ (p : ℝ) ≤ x + H) → + (P.card : ℝ) ≤ C * H / Real.log H := by + classical + obtain ⟨C, B, hC, hB, hupper⟩ := ProgressionPrimeUpper.progression_prime_upper + refine ⟨C, B, hC, hB, ?_⟩ + intro x H P hBH hP + have hH : 0 < H := lt_trans zero_lt_one (hB.trans_le hBH) + obtain ⟨N, a, index, hcount, hcoord⟩ := + RealProgressionCoordinates.exists_coordinates x H 1 0 (by norm_num) hH.le + let f : ℕ → ℕ := fun p => index (p : ℤ) + have hdata : ∀ p ∈ P, f p < N ∧ AffinePrimeSieve.value a 1 (f p) = (p : ℤ) := by + intro p hp + obtain ⟨_, hlo, hhi⟩ := hP p hp + exact hcoord (p : ℤ) (by exact_mod_cast hlo) (by exact_mod_cast hhi) (by + rw [Int.modEq_iff_dvd] + exact one_dvd _) + have hinj : Set.InjOn f P := by + intro p hp t ht heq + have hz : (p : ℤ) = (t : ℤ) := (hdata p hp).2.symm.trans + ((congrArg (AffinePrimeSieve.value a 1) heq).trans (hdata t ht).2) + exact_mod_cast hz + have hsub : P.image f ⊆ AffinePrimeSieve.primeIndices N a 1 := by + intro i hi + obtain ⟨p, hp, rfl⟩ := mem_image.mp hi + apply mem_filter.mpr + refine ⟨mem_range.mpr (hdata p hp).1, ?_⟩ + rw [(hdata p hp).2] + simpa only [Int.natAbs_natCast] using And.intro (hP p hp).1 (Int.natCast_nonneg p) + have hc : P.card ≤ (AffinePrimeSieve.primeIndices N a 1).card := by + calc + _ = (P.image f).card := (card_image_iff.mpr hinj).symm + _ ≤ _ := card_le_card hsub + calc + (P.card : ℝ) ≤ ((AffinePrimeSieve.primeIndices N a 1).card : ℝ) := by exact_mod_cast hc + _ ≤ C * H / Real.log H := by + simpa using hupper N a 1 H hBH (by norm_num) (by simpa using hcount) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeEnergyCover.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeEnergyCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..015a9fe7499f64b11c57d4a4cd738e5af2faf1a1 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeEnergyCover.lean @@ -0,0 +1,50 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszAvoidPrimes + +namespace OAI + +/-! Cover each pair of good long tuples by a prime at which both +remain nonsingular. This is a cover of solutions, not just of tuples. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma halasz_fiber_energy_cover {α ι : Type*} {k : ℕ} + (F : Finset α) (S : Finset ι) (G : ι → Finset α) (f : α → Fin k → ℤ) + (hcover : ∀ x∈F, ∀ y∈F, f x=f y → ∃ i∈S, x∈G i ∧ y∈G i) : + halaszFiberEnergy F f≤∑ i∈S, halaszFiberEnergy (G i) f := by + let T := fun i => ((G i×ˢG i).filter (fun xy => f xy.1=f xy.2)) + have hsub : ((F×ˢF).filter (fun xy => f xy.1=f xy.2))⊆S.biUnion T := by + intro xy hxy + obtain ⟨hxy,hf⟩ := mem_filter.mp hxy + obtain ⟨hx,hy⟩ := mem_product.mp hxy + obtain ⟨i,hi,hxi,hyi⟩ := hcover xy.1 hx xy.2 hy hf + exact mem_biUnion.mpr ⟨i,hi,mem_filter.mpr ⟨mem_product.mpr ⟨hxi,hyi⟩,hf⟩⟩ + calc + halaszFiberEnergy F f = ((F×ˢF).filter (fun xy => f xy.1=f xy.2)).card := + (halasz_cross_count_self F f).symm + _ ≤ (S.biUnion T).card := card_le_card hsub + _ ≤ ∑ i∈S, (T i).card := card_biUnion_le + _ = _ := sum_congr rfl (fun i _ => halasz_cross_count_self (G i) f) + +noncomputable def halaszResidueGoodTuples {n N ℓ : ℕ} + (L : Fin ℓ → Fin n) (p : ℕ) : Finset (Fin n → Fin N) := + univ.filter (fun x => Function.Injective (fun i => (((x (L i)).val+1:ℕ):ZMod p))) + +theorem halasz_distinct_energy_prime_cover {n k N ℓ R r : ℕ} (hR : 0 a p*((Real.log (p:ℝ)/p:ℝ):ℂ)) (fun p => -Real.log (p:ℝ)) + let Q₁ := mrtExponentialPolynomial Q + (fun q => b q*((Real.log (q:ℝ)/q:ℝ):ℂ)) (fun q => -Real.log (q:ℝ)) + IntegrableOn (fun t => P₁ t*Q₁ t*F t* + halaszPerronWindowKernel x δ (1+(t:ℂ)*Complex.I)) (Set.Ioc (-T) T) → + (∀ t ∈ Set.Ioc (-T) T, t ∉ Set.Ioc (c-1/2) (c+1/2) → ‖F t‖ ≤ A) → + (∀ t ∈ Set.Ioc (-T) T, ‖F t‖ ≤ W) → + ‖∫ t in -T..T, P₁ t*Q₁ t*F t* + halaszPerronWindowKernel x δ (1+(t:ℂ)*Complex.I)‖ ≤ + (C*x*(A+W/(1+|c|)))* + (Real.sqrt (∑ p ∈ P, ‖a p‖^2*(Real.log (p:ℝ)/p))* + Real.sqrt (∑ q ∈ Q, ‖b q‖^2*(Real.log (q:ℝ)/q))) := by + obtain ⟨C₁,B,hC₁,hB,hfirst⟩ := halasz_prime_mean_square + obtain ⟨C₂,hC₂,hsecond⟩ := halasz_prime_mean_square_cauchy + obtain ⟨C₃,hC₃,hunit⟩ := halasz_prime_mean_square_unit + let C := 4*Real.sqrt C₁*Real.sqrt C₂+12*C₃ + have hC : 0 < C := by dsimp [C]; positivity + refine ⟨C,B,hC,hB,?_⟩ + intro x δ T A W c hx hδ hδ1 hBT hA hW P Q hP hQ a b F + dsimp only + intro hi hFA hFW + let P₁ := mrtExponentialPolynomial P + (fun p => a p*((Real.log (p:ℝ)/p:ℝ):ℂ)) (fun p => -Real.log (p:ℝ)) + let Q₁ := mrtExponentialPolynomial Q + (fun q => b q*((Real.log (q:ℝ)/q:ℝ):ℂ)) (fun q => -Real.log (q:ℝ)) + let Mp := ∑ p ∈ P, ‖a p‖^2*(Real.log (p:ℝ)/p) + let Mq := ∑ q ∈ Q, ‖b q‖^2*(Real.log (q:ℝ)/q) + have hT : 0 ≤ T := (show (0:ℝ) ≤ B by linarith).trans hBT + have hp : (∫ t in -T..T, ‖P₁ t‖^2) ≤ C₁*Mp := hfirst T P hBT hP a + have hqi := halasz_cauchy_polynomial_integrable Q + (fun q => b q*((Real.log (q:ℝ)/q:ℝ):ℂ)) (fun q => -Real.log (q:ℝ)) + have hq : (∫ t in -T..T, ‖Q₁ t‖^2*(1+t^2)⁻¹) ≤ C₂*Mq := by + rw [intervalIntegral.integral_of_le (by linarith : -T ≤ T)] + exact (setIntegral_le_integral hqi (Filter.Eventually.of_forall (fun t => by positivity))).trans + (hsecond Q hQ b) + have hpu : (∫ t in (c-1/2)..(c+1/2), ‖P₁ t‖^2) ≤ C₃*Mp := + hunit P (fun p hp => (hP p hp).1) a c + have hqu : (∫ t in (c-1/2)..(c+1/2), ‖Q₁ t‖^2) ≤ C₃*Mq := hunit Q hQ b c + have hmid := halasz_window_middle_exception hx hδ hδ1 hT hA hW P₁ Q₁ F + (halasz_polynomial_continuous P _ _) (halasz_polynomial_continuous Q _ _) hi hFA hFW + apply hmid.trans + calc + _ ≤ (4*x*A)*(Real.sqrt (C₁*Mp)*Real.sqrt (C₂*Mq)) + + (12*x*W/(1+|c|))*(Real.sqrt (C₃*Mp)*Real.sqrt (C₃*Mq)) := by + gcongr + _ = (4*Real.sqrt C₁*Real.sqrt C₂*x*A+12*C₃*x*(W/(1+|c|)))* + (Real.sqrt Mp*Real.sqrt Mq) := by + simp only [Real.sqrt_mul hC₁.le,Real.sqrt_mul hC₂.le,Real.sqrt_mul hC₃.le] + conv_rhs => rw [← Real.sq_sqrt hC₃.le] + ring + _ ≤ (C*x*(A+W/(1+|c|)))*(Real.sqrt Mp*Real.sqrt Mq) := by + have hmain : 4*Real.sqrt C₁*Real.sqrt C₂ ≤ C := + le_add_of_nonneg_right (by positivity) + have hbad : 12*C₃ ≤ C := le_add_of_nonneg_left (by positivity) + apply mul_le_mul_of_nonneg_right _ (by positivity) + nlinarith [mul_le_mul_of_nonneg_right hmain (show 0 ≤ x*A by positivity), + mul_le_mul_of_nonneg_right hbad (show 0 ≤ x*(W/(1+|c|)) by positivity)] + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeMass.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..501820d24eea80e0594c9eccc8c97991a9a3ce18 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeMass.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.TwoPoint.ShortIntervals.MRTPrimeBands + +namespace OAI + +/-! Mertens' first theorem, in the prime-band convention needed for the +small- and large-prime truncations in the Halasz convolution. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def halaszMertensConstant : ℝ := Real.log 4 + 4 + +lemma halaszMertensConstant_nonneg : 0 ≤ halaszMertensConstant := by + unfold halaszMertensConstant + positivity + +lemma halasz_prime_prefix_mass {x : ℝ} (hx : 1 ≤ x) : + |(∑ p ∈ sievePrimesUpTo x, Real.log (p : ℝ) / p) - Real.log x| ≤ + halaszMertensConstant := by + rw [sievePrimesUpTo_eq_Ioc] + exact Erdos970.Mertens.sum_log_prime_div_eq_log hx + +lemma halasz_prime_band_mass {P Q : ℝ} (hPQ : P ≤ Q) : + (∑ p ∈ mrtPrimeBand P Q, Real.log (p : ℝ) / p) = + (∑ p ∈ sievePrimesUpTo Q, Real.log (p : ℝ) / p) - + ∑ p ∈ sievePrimesUpTo P, Real.log (p : ℝ) / p := by + exact sum_sdiff_eq_sub (f := fun p : ℕ => Real.log (p : ℝ) / p) + (mrt_sievePrimesUpTo_mono hPQ) + +lemma halasz_prime_band_mertens {P Q : ℝ} (hP : 1 ≤ P) (hPQ : P ≤ Q) : + |(∑ p ∈ mrtPrimeBand P Q, Real.log (p : ℝ) / p) - + (Real.log Q - Real.log P)| ≤ 2 * halaszMertensConstant := by + rw [halasz_prime_band_mass hPQ] + have he : (∑ p ∈ sievePrimesUpTo Q, Real.log (p : ℝ) / p) - + (∑ p ∈ sievePrimesUpTo P, Real.log (p : ℝ) / p) - + (Real.log Q - Real.log P) = + ((∑ p ∈ sievePrimesUpTo Q, Real.log (p : ℝ) / p) - Real.log Q) - + ((∑ p ∈ sievePrimesUpTo P, Real.log (p : ℝ) / p) - Real.log P) := by ring + rw [he] + exact (abs_sub _ _).trans (by + linarith [halasz_prime_prefix_mass hP, halasz_prime_prefix_mass (hP.trans hPQ)]) + +lemma halasz_prime_prefix_mass_le {x : ℝ} (hx : 1 ≤ x) : + (∑ p ∈ sievePrimesUpTo x, Real.log (p : ℝ) / p) ≤ + Real.log x + halaszMertensConstant := by + linarith [(abs_le.mp (halasz_prime_prefix_mass hx)).2] + +lemma halasz_prime_band_mass_le {P Q : ℝ} (hP : 1 ≤ P) (hPQ : P ≤ Q) : + (∑ p ∈ mrtPrimeBand P Q, Real.log (p : ℝ) / p) ≤ + Real.log Q - Real.log P + 2 * halaszMertensConstant := by + linarith [(abs_le.mp (halasz_prime_band_mertens hP hPQ)).2] + +lemma halasz_upper_half_prime_mass {x : ℝ} (hx : 2 ≤ x) : + (∑ p ∈ mrtPrimeBand (x / 2) x, Real.log (p : ℝ) / p) ≤ + Real.log 2 + 2 * halaszMertensConstant := by + have hx0 : 0 < x := by linarith + have hm := halasz_prime_band_mass_le (P := x / 2) (Q := x) + (by linarith) (by linarith) + rw [Real.log_div (ne_of_gt hx0) (by norm_num)] at hm + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeMeanSquare.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeMeanSquare.lean new file mode 100644 index 0000000000000000000000000000000000000000..3132888c77ceb689daeff95a2540d30ca2d42b3c --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeMeanSquare.lean @@ -0,0 +1,50 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimeWindows + +namespace OAI + +/-! A prime-supported mean-value theorem with one von Mangoldt weight, +proved from the Brun--Titchmarsh theorem and the exact Fourier +kernel. This is the sparse mean-square input to Halasz's argument. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped BigOperators + +/-- Arbitrary complex prime coefficients are permitted. The constant is +independent of the upper end of the finite prime set. -/ +theorem halasz_prime_mean_square : ∃ C B : ℝ, 0 < C ∧ 2 ≤ B ∧ + ∀ (T : ℝ) (P : Finset ℕ), B ≤ T → + (∀ p ∈ P, p.Prime ∧ T ^ 2 ≤ (p : ℝ)) → ∀ a : ℕ → ℂ, + (∫ t in -T..T, + ‖mrtExponentialPolynomial P + (fun p => a p * ((Real.log (p : ℝ) / (p : ℝ) : ℝ) : ℂ)) + (fun p => -Real.log (p : ℝ)) t‖ ^ 2) ≤ + C * ∑ p ∈ P, ‖a p‖ ^ 2 * (Real.log (p : ℝ) / (p : ℝ)) := by + obtain ⟨C, B, hC, hB, hwindow⟩ := halasz_prime_windows_above_square + refine ⟨Real.exp 1 * (16 * C), B, by positivity, hB, ?_⟩ + intro T P hBT hP a + have hT : 0 < T := lt_of_lt_of_le (by norm_num) (hB.trans hBT) + have hw : ∀ p ∈ P, 0 ≤ Real.log (p : ℝ) / (p : ℝ) := by + intro p hp + exact div_nonneg (Real.log_nonneg (by exact_mod_cast (hP p hp).1.one_le)) + (Nat.cast_nonneg _) + have hrow : ∀ p ∈ P, + (∑ q ∈ P, (Real.log (q : ℝ) / (q : ℝ)) * + (2 * T / (1 + T ^ 2 * (-Real.log (p : ℝ) - -Real.log (q : ℝ)) ^ 2))) ≤ + 16 * C := by + intro p hp + have hh := halasz_frequency_row_of_windows P (fun q => Real.log (q : ℝ)) + (fun q => Real.log (q : ℝ) / (q : ℝ)) (Real.log (p : ℝ)) hT hC.le hw + (hwindow T P hBT hP) + convert hh using 1 + apply sum_congr rfl + intro q _ + rw [show (-Real.log (p : ℝ) - -Real.log (q : ℝ)) ^ 2 = + (Real.log (q : ℝ) - Real.log (p : ℝ)) ^ 2 by ring] + exact halasz_mean_square_of_weighted_rows P a + (fun p => Real.log (p : ℝ) / (p : ℝ)) (fun p => -Real.log (p : ℝ)) hT hw hrow + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeMoment.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..f0574b16b1027ed8558f909f04c28bdae7bcbb1a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeMoment.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimeEnergyCover +import OAI.NumberTheory.TwoPoint.Halasz.HalaszNonsingularMoment + +namespace OAI + +/-! The selected-prime cover meets the proved nonsingular moment +estimate, with the original short-variable endpoint retained. -/ +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +lemma halasz_residue_good_product (s k N p : ℕ) : + halaszFiberEnergy + (halaszResidueGoodTuples (N := N) (fun i : Fin k => i.castAdd s) p) + (halaszVinogradovFrequency k) = + halaszFiberEnergy + ((univ.filter (fun z : Fin k → Fin N => Function.Injective + (fun i => (((z i).val+1:ℕ):ZMod p))))×ˢ(univ : Finset (Fin s → Fin N))) + (fun x j => halaszNatPowerFrequency k x.1 j+halaszNatPowerFrequency k x.2 j) := by + let Z := (univ : Finset (Fin k → Fin N)).filter (fun z => Function.Injective + (fun i => (((z i).val+1:ℕ):ZMod p))) + let F := Z×ˢ(univ : Finset (Fin s → Fin N)) + let e := halaszTupleJoin k s N + have himage : F.image e = + halaszResidueGoodTuples (N := N) (fun i : Fin k => i.castAdd s) p := by + ext x + constructor + · rintro hx + obtain ⟨z,hz,rfl⟩ := mem_image.mp hx + have hzI := (mem_filter.mp (mem_product.mp hz).1).2 + apply mem_filter.mpr + refine ⟨mem_univ _,?_⟩ + simpa only [e,halaszTupleJoin,Equiv.coe_fn_mk,Fin.append_left] using hzI + · intro hx + refine mem_image.mpr ⟨e.symm x,?_,e.apply_symm_apply x⟩ + apply mem_product.mpr + refine ⟨mem_filter.mpr ⟨mem_univ _,?_⟩,mem_univ _⟩ + exact (mem_filter.mp hx).2 + have hf (z : (Fin k → Fin N) × (Fin s → Fin N)) : + halaszVinogradovFrequency k (e z) = + (fun j => ((halaszNatPowerFrequency k z.1 j+ + halaszNatPowerFrequency k z.2 j:ℕ):ℤ)) := by + funext j + simp only [halaszVinogradovFrequency,e,halaszTupleJoin,Equiv.coe_fn_mk, + Fin.sum_univ_add,Fin.append_left,Fin.append_right,halaszNatPowerFrequency, + Nat.cast_add,Nat.cast_sum] + have he := halasz_fiber_energy_transfer F e e.injective.injOn + (fun z j => ((halaszNatPowerFrequency k z.1 j+ + halaszNatPowerFrequency k z.2 j:ℕ):ℤ)) (halaszVinogradovFrequency k) + (fun z _ => hf z) + rw [halasz_fiber_energy_natCast] at he + convert he.symm using 1 + congr 1 + convert himage.symm using 1 + ext x + simp only [mem_image] + +theorem halasz_residue_good_moment {s k N p : ℕ} [Fact p.Prime] + (hs : 0 i.castAdd s) p) + (halaszVinogradovFrequency k) ≤ + p^(2*s)*((k^k*p^(k*(k-1)/2))*(N^k*halaszVinogradovCount s k (N/p+1))) := by + rw [halasz_residue_good_product] + have hk1 : k-1+1=k := Nat.sub_add_cancel hk + have h := halasz_nonsingular_moment (s := s) (M := N) (r := k-1) hs hkp (by omega) + (by simpa only [hk1] using hNp) + ((univ : Finset (Fin k → Fin N)).filter (fun z => Function.Injective + (fun i => (((z i).val+1:ℕ):ZMod p)))) + (fun z hz => (mem_filter.mp hz).2) + simpa only [hk1] using h + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeOscillation.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeOscillation.lean new file mode 100644 index 0000000000000000000000000000000000000000..adade24b8ca3a1257e4098cc60fadb413d694ae7 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimeOscillation.lean @@ -0,0 +1,97 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPretentiousCenter +import OAI.NumberTheory.TwoPoint.Bounds.OscillatoryThetaError + +namespace OAI + +/-! The moderate-frequency prime-phase step in MRT Lemma A.4. +The frequency dependence of partial summation is explicit, so a growing +frequency range can be paid for by the exponential prime-number error. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +lemma halasz_oscillatory_weight_bounds (t x : ℝ) (hx : 1 < x) + (hl : 1 ≤ Real.log x) : + |oscillatoryReciprocalLog t x| ≤ 2 / x ∧ + |deriv (oscillatoryReciprocalLog t) x| ≤ (|t| + 4) / x ^ 2 := by + have hx0 : 0 < x := zero_lt_one.trans hx + have hg : |1 - Real.cos (t * Real.log x)| ≤ 2 := by + rw [abs_of_nonneg (sub_nonneg.mpr (Real.cos_le_one _))] + linarith [Real.neg_one_le_cos (t * Real.log x)] + have hs : |t * Real.sin (t * Real.log x) / x| ≤ |t| / x := by + rw [abs_div, abs_mul, abs_of_pos hx0] + apply div_le_div_of_nonneg_right _ hx0.le + simpa only [mul_one] using mul_le_mul_of_nonneg_left + (Real.abs_sin_le_one (t * Real.log x)) (abs_nonneg t) + have hrec := reciprocalLog_size hx hl + have hdrec := reciprocalLog_deriv_size hx hl + constructor + · unfold oscillatoryReciprocalLog + rw [abs_mul] + calc + _ ≤ 2 * (1 / x) := mul_le_mul hg hrec (abs_nonneg _) (by norm_num) + _ = _ := by ring + · rw [(oscillatoryReciprocalLog_hasDerivAt t x hx).deriv] + apply (abs_add_le _ _).trans + rw [abs_mul, abs_mul] + calc + _ ≤ (|t| / x) * (1 / x) + 2 * (2 / x ^ 2) := + add_le_add (mul_le_mul hs hrec (abs_nonneg _) (by positivity)) + (mul_le_mul hg hdrec (abs_nonneg _) (by norm_num)) + _ = _ := by ring + +theorem halasz_oscillatory_theta_error (c : ℕ → ℝ) (α K a b t : ℝ) + (hK : 0 ≤ K) (ha : Real.exp 1 ≤ a) (hab : a ≤ b) + (hE : ∀ x ∈ Set.Icc a b, + |partialCoefficientSum c x - α * x| ≤ K * x / Real.log x ^ 2) : + |(∑ n ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, oscillatoryReciprocalLog t n * c n) - + α * (∫ x in a..b, oscillatoryReciprocalLog t x)| ≤ + (8 + |t|) * K / Real.log a := by + have ha1 : 1 < a := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le ha + have hx1 (x : ℝ) (hx : x ∈ Set.Icc a b) : 1 < x := ha1.trans_le hx.1 + have hl (x : ℝ) (hx : x ∈ Set.Icc a b) : 1 ≤ Real.log x := by + calc + 1 = Real.log (Real.exp 1) := (Real.log_exp 1).symm + _ ≤ _ := Real.log_le_log (Real.exp_pos 1) (ha.trans hx.1) + have hh := weighted_theta_error c α K 2 (|t| + 4) a b hK (by norm_num) + (by positivity) ha hab (oscillatoryReciprocalLog t) + (fun x hx => (oscillatoryReciprocalLog_hasDerivAt t x (hx1 x hx)).differentiableAt) + (fun x hx => ?_) + (fun x hx => (halasz_oscillatory_weight_bounds t x (hx1 x hx) (hl x hx)).1) + (fun x hx => (halasz_oscillatory_weight_bounds t x (hx1 x hx) (hl x hx)).2) hE + · convert hh using 1 + ring + · have hxn : x ≠ 0 := (zero_lt_one.trans (hx1 x hx)).ne' + have hln : Real.log x ≠ 0 := (Real.log_pos (hx1 x hx)).ne' + have hc : ContDiffAt ℝ 2 (oscillatoryReciprocalLog t) x := by + unfold oscillatoryReciprocalLog reciprocalLog + fun_prop (disch := assumption) + exact (hc.derivWithin (m := 0) (by norm_num)).continuousAt.continuousWithinAt + +lemma halasz_cosine_defect (x : ℝ) : + (1 - Real.cos (2 * x)) / 4 ≤ 1 - |Real.cos x| := by + have hc := Real.abs_cos_le_one x + have hn := sq_nonneg (1 - |Real.cos x|) + rw [Real.cos_two_mul] + nlinarith [sq_abs (Real.cos x)] + +lemma halasz_prime_cosine_defect (N : ℕ) (Y t : ℝ) : + (∑ p ∈ (primesUpTo N).filter (fun p : ℕ => Y < (p : ℝ)), + (1 - Real.cos (t * Real.log (p : ℝ))) / (p : ℝ)) ≤ + 4 * ∑ p ∈ (primesUpTo N).filter (fun p : ℕ => Y < (p : ℝ)), + (1 - |Real.cos (t * Real.log (p : ℝ) / 2)|) / (p : ℝ) := by + rw [mul_sum] + apply sum_le_sum + intro p _ + have h := halasz_cosine_defect (t * Real.log (p : ℝ) / 2) + have he : 2 * (t * Real.log (p : ℝ) / 2) = t * Real.log (p : ℝ) := by ring + rw [he] at h + have h' : 1 - Real.cos (t * Real.log (p : ℝ)) ≤ + 4 * (1 - |Real.cos (t * Real.log (p : ℝ) / 2)|) := by linarith + simpa only [mul_div_assoc] using div_le_div_of_nonneg_right h' (Nat.cast_nonneg p) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePartialSummation.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePartialSummation.lean new file mode 100644 index 0000000000000000000000000000000000000000..43fef4e01d485f89293e2b23815d618aa0a93910 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePartialSummation.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimeMass +import OAI.NumberTheory.TwoPoint.Bounds.PrimePartialSummation + +namespace OAI + +/-! Partial summation centered at Mertens' logarithmic main term. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +noncomputable def halaszPrimeWeight (n : ℕ) : ℝ := + if n.Prime then Real.log (n : ℝ) / n else 0 + +lemma halasz_prime_weight_prefix (x : ℝ) : + partialCoefficientSum halaszPrimeWeight x = + ∑ p ∈ sievePrimesUpTo x, Real.log (p : ℝ) / p := by + have he : Icc 0 ⌊x⌋₊ = Iic ⌊x⌋₊ := by ext n; simp + simp only [partialCoefficientSum, he, sievePrimesUpTo, halaszPrimeWeight, sum_filter] + +lemma halasz_prime_weight_band (f : ℝ → ℝ) {a b : ℝ} : + (∑ p ∈ mrtPrimeBand a b, f p * (Real.log (p : ℝ) / p)) = + ∑ n ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, f n * halaszPrimeWeight n := by + have he : mrtPrimeBand a b = (Ioc ⌊a⌋₊ ⌊b⌋₊).filter Nat.Prime := by + ext n + simp only [mrtPrimeBand, sievePrimesUpTo, mem_sdiff, mem_filter, mem_Iic, mem_Ioc] + by_cases hn : n.Prime <;> simp [hn, not_le, and_comm] + rw [he, sum_filter] + apply sum_congr rfl + intro n _ + by_cases hn : n.Prime <;> simp [halaszPrimeWeight, hn] + +theorem halasz_prime_partial_summation (a b : ℝ) (ha : 0 < a) (hab : a ≤ b) + (f : ℝ → ℝ) (hf : ∀ x ∈ Set.Icc a b, DifferentiableAt ℝ f x) + (hdf : ContinuousOn (deriv f) (Set.Icc a b)) : + (∑ p ∈ mrtPrimeBand a b, f p * (Real.log (p : ℝ) / p)) - + (∫ t in a..b, f t / t) = + f b * (partialCoefficientSum halaszPrimeWeight b - Real.log b) - + f a * (partialCoefficientSum halaszPrimeWeight a - Real.log a) - + ∫ t in a..b, deriv f t * + (partialCoefficientSum halaszPrimeWeight t - Real.log t) := by + have hxn : ∀ x ∈ Set.Icc a b, x ≠ 0 := fun x hx => (ha.trans_le hx.1).ne' + have hclog : ContinuousOn Real.log (Set.Icc a b) := + fun x hx => (Real.continuousAt_log (hxn x hx)).continuousWithinAt + have hfc : ContinuousOn f (Set.Icc a b) := + fun x hx => (hf x hx).continuousAt.continuousWithinAt + have hdfi : IntervalIntegrable (deriv f) volume a b := hdf.intervalIntegrable_of_Icc hab + have hlogi : IntervalIntegrable (fun x : ℝ => x⁻¹) volume a b := + (continuousOn_id.inv₀ hxn).intervalIntegrable_of_Icc hab + have hfi : IntervalIntegrable (fun x => f x / x) volume a b := + (hfc.div continuousOn_id hxn).intervalIntegrable_of_Icc hab + have hdmain : IntervalIntegrable (fun x => deriv f x * Real.log x) volume a b := + (hdf.mul hclog).intervalIntegrable_of_Icc hab + have hsum : IntervalIntegrable + (fun t => deriv f t * partialCoefficientSum halaszPrimeWeight t) volume a b := by + apply (intervalIntegrable_iff_integrableOn_Icc_of_le hab).mpr + exact integrableOn_mul_sum_Icc halaszPrimeWeight ha.le hdf.integrableOn_Icc + have hAbel := sum_mul_eq_sub_sub_integral_mul halaszPrimeWeight ha.le hab hf + hdf.integrableOn_Icc + rw [← intervalIntegral.integral_of_le hab, ← halasz_prime_weight_band f] at hAbel + have hparts := intervalIntegral.integral_deriv_mul_eq_sub + (fun x hx => (hf x (by simpa [Set.uIcc_of_le hab] using hx)).hasDerivAt) + (fun x hx => Real.hasDerivAt_log (hxn x (by simpa [Set.uIcc_of_le hab] using hx))) + hdfi hlogi + have hsplit : (∫ t in a..b, deriv f t * Real.log t + f t * t⁻¹) = + (∫ t in a..b, deriv f t * Real.log t) + ∫ t in a..b, f t / t := by + simp only [← div_eq_mul_inv] + exact intervalIntegral.integral_add hdmain hfi + rw [hsplit] at hparts + have herr : (∫ t in a..b, deriv f t * + (partialCoefficientSum halaszPrimeWeight t - Real.log t)) = + (∫ t in a..b, deriv f t * partialCoefficientSum halaszPrimeWeight t) - + ∫ t in a..b, deriv f t * Real.log t := by + simp only [mul_sub] + exact intervalIntegral.integral_sub hsum hdmain + rw [herr, hAbel] + dsimp [partialCoefficientSum] at * + linarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePhase.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePhase.lean new file mode 100644 index 0000000000000000000000000000000000000000..e681a2fd02aa0ca87392d8b0de867cc121c92393 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePhase.lean @@ -0,0 +1,161 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimeTheta +import OAI.NumberTheory.TwoPoint.Bounds.CosineLogIntegral + +namespace OAI + +/-! Prime phase sums on a finite real interval. The prime-number error +retains its exponentially small lower-endpoint factor and its explicit +frequency dependence. -/ + +namespace TwoPointCorrelations + +open Finset MeasureTheory +open scoped Classical + +lemma halasz_prime_band_filter (a b : ℝ) : + mrtPrimeBand a b = (Ioc ⌊a⌋₊ ⌊b⌋₊).filter Nat.Prime := by + ext p + simp only [mrtPrimeBand, sievePrimesUpTo, mem_sdiff, mem_filter, mem_Iic, mem_Ioc] + by_cases hp : p.Prime <;> simp only [hp, and_true, and_false, not_false_eq_true] + omega + +lemma halasz_prime_phase_sum (a b t : ℝ) : + (∑ p ∈ mrtPrimeBand a b, (1 - Real.cos (t * Real.log p)) / p) = + ∑ n ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, oscillatoryReciprocalLog t n * halaszPrimeLogWeight n := by + rw [halasz_prime_band_filter, sum_filter] + apply sum_congr rfl + intro n _ + by_cases hp : n.Prime + · rw [ite_eq_left hp, halaszPrimeLogWeight, ite_eq_left hp] + have hl : Real.log (n : ℝ) ≠ 0 := + (Real.log_pos (by exact_mod_cast hp.one_lt)).ne' + unfold oscillatoryReciprocalLog reciprocalLog + field_simp + · simp [halaszPrimeLogWeight, hp] + +theorem ModFiveThetaInput.halasz_prime_phase_error (hP : ModFiveThetaInput) : + ∃ c K : ℝ, 0 < c ∧ 0 ≤ K ∧ ∀ a b t : ℝ, Real.exp 1 ≤ a → a ≤ b → + |(∑ p ∈ mrtPrimeBand a b, (1 - Real.cos (t * Real.log p)) / p) - + (∫ x in a..b, oscillatoryReciprocalLog t x)| ≤ + (8 + |t|) * K * Real.exp (-c * Real.sqrt (Real.log a)) / Real.log a := by + obtain ⟨c, K, hc, hK, htail⟩ := hP.halasz_prime_tail_error + refine ⟨c, K, hc, hK, ?_⟩ + intro a b t ha hab + have ha2 : 2 ≤ a := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hh := halasz_oscillatory_theta_error halaszPrimeLogWeight 1 + (K * Real.exp (-c * Real.sqrt (Real.log a))) a b t (by positivity) ha hab + (fun x hx => by simpa only [one_mul] using htail a x ha2 hx.1) + rw [← halasz_prime_phase_sum, one_mul] at hh + convert hh using 1 + ring + +lemma halasz_log_phase_substitution (a b t : ℝ) (ha : 1 < a) (hab : a ≤ b) : + (∫ x in a..b, oscillatoryReciprocalLog t x) = + ∫ y in Real.log a..Real.log b, (1 - Real.cos (t * y)) / y := by + have hxp (x : ℝ) (hx : x ∈ Set.uIcc a b) : 0 < x := by + rw [Set.uIcc_of_le hab] at hx + exact (zero_lt_one.trans ha).trans_le hx.1 + have hd (x : ℝ) (hx : x ∈ Set.uIcc a b) := Real.hasDerivAt_log (hxp x hx).ne' + have hc : ContinuousOn (fun x : ℝ => x⁻¹) (Set.uIcc a b) := + continuousOn_id.inv₀ (fun x hx => (hxp x hx).ne') + have hg : ContinuousOn (fun y : ℝ => (1 - Real.cos (t * y)) / y) + (Real.log '' Set.uIcc a b) := by + rintro y ⟨x, hx, rfl⟩ + have hx' : a ≤ x := by rw [Set.uIcc_of_le hab] at hx; exact hx.1 + have hn : Real.log x ≠ 0 := (Real.log_pos (ha.trans_le hx')).ne' + exact (by fun_prop (disch := assumption) : + ContinuousAt (fun y : ℝ => (1 - Real.cos (t * y)) / y) (Real.log x)).continuousWithinAt + rw [← intervalIntegral.integral_comp_mul_deriv' hd hc hg] + apply intervalIntegral.integral_congr + intro x _ + unfold oscillatoryReciprocalLog reciprocalLog + simp only [Function.comp_def, div_eq_mul_inv] + ring + +lemma halasz_log_phase_lower (a b t : ℝ) (ha : 1 < a) (hab : a ≤ b) + (ht : 1 ≤ |t| * Real.log a) : + Real.log (Real.log b / Real.log a) - 3 ≤ + ∫ x in a..b, oscillatoryReciprocalLog t x := by + have hla : 0 < Real.log a := Real.log_pos ha + have hlab : Real.log a ≤ Real.log b := Real.log_le_log (zero_lt_one.trans ha) hab + have hlb : 0 < Real.log b := hla.trans_le hlab + have ht0 : 0 < |t| := by + by_contra hn + have hz : |t| = 0 := le_antisymm (le_of_not_gt hn) (abs_nonneg t) + rw [hz, zero_mul] at ht + norm_num at ht + have hcos (y : ℝ) : Real.cos (|t| * y) = Real.cos (t * y) := by + rcases le_or_gt 0 t with h | h + · rw [abs_of_nonneg h] + · rw [abs_of_neg h, neg_mul, Real.cos_neg] + have htail := (abs_le.mp (cosine_log_tail |t| (Real.log a) (Real.log b) + ht0 hla hlab ht)).2 + simp_rw [hcos] at htail + rw [halasz_log_phase_substitution a b t ha hab] + have hi₁ : IntervalIntegrable (fun y : ℝ => 1 / y) volume (Real.log a) (Real.log b) := by + apply ContinuousOn.intervalIntegrable_of_Icc hlab + intro y hy + exact (continuousAt_const.div continuousAt_id (hla.trans_le hy.1).ne').continuousWithinAt + have hi₂ : IntervalIntegrable (fun y : ℝ => Real.cos (t * y) / y) + volume (Real.log a) (Real.log b) := by + apply ContinuousOn.intervalIntegrable_of_Icc hlab + intro y hy + have hn := (hla.trans_le hy.1).ne' + exact (by fun_prop (disch := assumption) : + ContinuousAt (fun y : ℝ => Real.cos (t * y) / y) y).continuousWithinAt + have he : (∫ y in Real.log a..Real.log b, (1 - Real.cos (t * y)) / y) = + Real.log (Real.log b / Real.log a) - + ∫ y in Real.log a..Real.log b, Real.cos (t * y) / y := by + rw [← integral_one_div_of_pos hla hlb, ← intervalIntegral.integral_sub hi₁ hi₂] + apply intervalIntegral.integral_congr + intro y _ + ring + rw [he] + linarith + +lemma halasz_prime_band_tail (N : ℕ) (Y : ℝ) (hY : 0 ≤ Y) : + mrtPrimeBand Y N = (primesUpTo N).filter (fun p : ℕ => Y < (p : ℝ)) := by + rw [halasz_prime_band_filter] + ext p + simp only [mem_filter, mem_Ioc, Nat.floor_natCast, primesUpTo, mem_range] + rw [Nat.floor_lt hY] + rw [Nat.lt_succ_iff] + tauto + +theorem ModFiveThetaInput.halasz_prime_phase_lower (hP : ModFiveThetaInput) : + ∃ c K : ℝ, 0 < c ∧ 0 ≤ K ∧ ∀ a b t : ℝ, + Real.exp 1 ≤ a → a ≤ b → 1 ≤ |t| * Real.log a → + Real.log (Real.log b / Real.log a) - 3 - + (8 + |t|) * K * Real.exp (-c * Real.sqrt (Real.log a)) / Real.log a ≤ + ∑ p ∈ mrtPrimeBand a b, (1 - Real.cos (t * Real.log p)) / p := by + obtain ⟨c, K, hc, hK, hh⟩ := hP.halasz_prime_phase_error + refine ⟨c, K, hc, hK, ?_⟩ + intro a b t ha hab ht + have ha1 : 1 < a := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le ha + have hi := halasz_log_phase_lower a b t ha1 hab ht + have he := (abs_le.mp (hh a b t ha hab)).1 + linarith + +/-- A finite quantitative repulsion bound, retaining the actual PNT error. -/ +theorem ModFiveThetaInput.halasz_masked_phase_lower (hP : ModFiveThetaInput) : + ∃ c K : ℝ, 0 < c ∧ 0 ≤ K ∧ ∀ (F : ℕ → ℂ), OneBounded F → + ∀ (Q : Finset ℕ) (N : ℕ) (Y t t₁ : ℝ), + Real.exp 1 ≤ Y → Y ≤ N → 1 ≤ |t - t₁| * Real.log Y → + squaredDistance F (mrtArchimedeanTwist t₁) N ≤ + squaredDistance F (mrtArchimedeanTwist t) N → + (Real.log (Real.log N / Real.log Y) - 3 - + (8 + |t - t₁|) * K * Real.exp (-c * Real.sqrt (Real.log Y)) / Real.log Y) / 8 ≤ + squaredDistance (mrtMissingCoefficient F Q) (mrtArchimedeanTwist t) N := by + obtain ⟨c, K, hc, hK, hh⟩ := hP.halasz_prime_phase_lower + refine ⟨c, K, hc, hK, ?_⟩ + intro F hF Q N Y t t₁ hY hYN ht hmin + have hY0 : 0 ≤ Y := (Real.exp_pos 1).le.trans hY + have hphase := hh Y N (t - t₁) hY hYN ht + rw [halasz_prime_band_tail N Y hY0] at hphase + have hcos := halasz_prime_cosine_defect N Y (t - t₁) + have hdist := halasz_masked_cosine_tail_lower F hF Q N Y t t₁ hmin + nlinarith + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePolynomial.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePolynomial.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea9cc6b55b8ebd1d4a7037e42771322d0d052c52 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePolynomial.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszWindowIntegral +import OAI.NumberTheory.TwoPoint.Halasz.HalaszSmoothSeries + +namespace OAI + +/-! The finite prime factors in the Perron integrand, with the same +normalization as the prime mean-square theorem. -/ + +namespace TwoPointCorrelations + +open Finset Complex +open scoped Classical + +noncomputable def halaszPrimePolynomial (P : Finset ℕ) (a : ℕ → ℂ) (t : ℝ) : ℂ := + mrtExponentialPolynomial P + (fun p => a p * ((Real.log (p : ℝ) / p : ℝ) : ℂ)) (fun p => -Real.log (p : ℝ)) t + +lemma halasz_prime_polynomial_series (P : Finset ℕ) (a : ℕ → ℂ) + (hP : ∀ p ∈ P, p.Prime) (t : ℝ) : + (∑ p ∈ P, LSeries.term (fun p => (Real.log (p : ℝ) : ℂ) * a p) + (1 + (t : ℂ) * I) p) = halaszPrimePolynomial P a t := by + unfold halaszPrimePolynomial mrtExponentialPolynomial + apply sum_congr rfl + intro p hp + rw [mrt_line_one_term _ (hP p hp).ne_zero t] + push_cast + ring + +lemma halasz_prime_polynomial_continuous (P : Finset ℕ) (a : ℕ → ℂ) : + Continuous (halaszPrimePolynomial P a) := halasz_polynomial_continuous P _ _ + +lemma halasz_prime_polynomial_norm (P : Finset ℕ) (a : ℕ → ℂ) + (hP : ∀ p ∈ P, p.Prime) (t : ℝ) : + ‖halaszPrimePolynomial P a t‖ ≤ ∑ p ∈ P, ‖a p‖ * (Real.log (p : ℝ) / p) := by + apply (halasz_polynomial_norm_le P _ _ t).trans_eq + apply sum_congr rfl + intro p hp + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg] + exact div_nonneg (Real.log_nonneg (by exact_mod_cast (hP p hp).one_le)) (Nat.cast_nonneg _) + +lemma halasz_prime_polynomial_bounded (P : Finset ℕ) (a : ℕ → ℂ) + (hP : ∀ p ∈ P, p.Prime) {R : ℝ} (ha : ∀ p ∈ P, ‖a p‖ ≤ R) (t : ℝ) : + ‖halaszPrimePolynomial P a t‖ ≤ R * ∑ p ∈ P, Real.log (p : ℝ) / p := by + apply (halasz_prime_polynomial_norm P a hP t).trans + rw [mul_sum] + apply sum_le_sum + intro p hp + exact mul_le_mul_of_nonneg_right (ha p hp) + (div_nonneg (Real.log_nonneg (by exact_mod_cast (hP p hp).one_le)) (Nat.cast_nonneg _)) + +lemma halasz_prime_coefficient_square_mass (P : Finset ℕ) (a : ℕ → ℂ) + (hP : ∀ p ∈ P, p.Prime) {R : ℝ} (ha : ∀ p ∈ P, ‖a p‖ ≤ R) : + (∑ p ∈ P, ‖a p‖ ^ 2 * (Real.log (p : ℝ) / p)) ≤ + R ^ 2 * ∑ p ∈ P, Real.log (p : ℝ) / p := by + rw [mul_sum] + apply sum_le_sum + intro p hp + exact mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (norm_nonneg _) (ha p hp) 2) + (div_nonneg (Real.log_nonneg (by exact_mod_cast (hP p hp).one_le)) (Nat.cast_nonneg _)) + +lemma halasz_adaptive_coefficient_bound (f : ℕ → ℂ) (hf : OneBounded f) + {X v : ℝ} (hv : 0 < v) {p : ℕ} (hp : 0 < p) + (hlog : v ≤ Real.log (X / p)) : + ‖f p / (Real.log (X / p) : ℂ)‖ ≤ v⁻¹ := by + rw [norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos (hv.trans_le hlog)] + exact (div_le_div_of_nonneg_right (hf p hp) (hv.le.trans hlog)).trans + (by simpa only [one_div] using one_div_le_one_div_of_le hv hlog) + +lemma halasz_finite_prime_mangoldt_bound (P : Finset ℕ) (a : ℕ → ℂ) + (hP : ∀ p ∈ P, p.Prime) {R : ℝ} (hR : 0 ≤ R) (ha : ∀ p ∈ P, ‖a p‖ ≤ R) (n : ℕ) : + ‖halaszFiniteCoefficient P (fun p => (Real.log (p : ℝ) : ℂ) * a p) n‖ ≤ + R * ArithmeticFunction.vonMangoldt n := by + by_cases hn : n ∈ P + · rw [halaszFiniteCoefficient, ite_eq_left hn, norm_mul, Complex.norm_real, + Real.norm_eq_abs, abs_of_nonneg (Real.log_nonneg (by exact_mod_cast (hP n hn).one_le)), + ArithmeticFunction.vonMangoldt_apply_prime (hP n hn)] + simpa only [mul_comm] using mul_le_mul_of_nonneg_left (ha n hn) + (Real.log_nonneg (by exact_mod_cast (hP n hn).one_le)) + · rw [halaszFiniteCoefficient, ite_eq_right hn, norm_zero] + exact mul_nonneg hR ArithmeticFunction.vonMangoldt_nonneg + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePowerCongruences.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePowerCongruences.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4d1942d4b5ce62f78016d269d102aebcbe94d89 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePowerCongruences.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPrimePowerSums + +namespace OAI + +/-! Triangular systems of univariate polynomials reduce to power sums. +The leading coefficients need only be units, so the result applies to +the translated and differenced systems over prime-power residue rings. -/ +namespace TwoPointCorrelations + +open Finset Polynomial + +theorem halasz_power_sums_of_polynomial_sums {R : Type*} [CommRing R] {k : ℕ} + (P : Fin k → R[X]) (x y : Fin k → R) + (hdeg : ∀ i, (P i).natDegree ≤ i.val+1) + (hunit : ∀ i, IsUnit ((P i).coeff (i.val+1))) + (hsum : ∀ i, ∑ j, (P i).eval (x j)=∑ j, (P i).eval (y j)) : + ∀ j : ℕ, 1≤j → j≤k → ∑ i, x i^j=∑ i, y i^j := by + intro j + induction j using Nat.strong_induction_on with + | h j ih => + intro hj hjk + let l : Fin k := ⟨j-1,by omega⟩ + let Q := P l + have hd : Q.natDegree < j+1 := by + exact Nat.lt_succ_of_le (by + simpa only [Q,l,Nat.sub_add_cancel hj] using hdeg l) + have heval (z : Fin k → R) : + (∑ i, Q.eval (z i)) = ∑ m ∈ range (j+1), Q.coeff m*(∑ i, z i^m) := by + simp_rw [Polynomial.eval_eq_sum_range' hd] + rw [sum_comm] + simp_rw [← mul_sum] + have hs := hsum l + change (∑ i, Q.eval (x i)) = ∑ i, Q.eval (y i) at hs + rw [heval,heval,sum_range_succ,sum_range_succ] at hs + have hsmall : (∑ m ∈ range j, Q.coeff m*(∑ i, x i^m)) = + ∑ m ∈ range j, Q.coeff m*(∑ i, y i^m) := by + apply sum_congr rfl + intro m hm + have hmj := mem_range.mp hm + by_cases hm0 : m=0 + · simp [hm0] + · rw [ih m hmj (by omega) (by omega)] + rw [hsmall] at hs + have hu : IsUnit (Q.coeff j) := by + simpa only [Q,l,Nat.sub_add_cancel hj] using hunit l + exact hu.mul_right_inj.mp (add_left_cancel hs) + +theorem halasz_prime_power_polynomial_count {p r k : ℕ} [Fact p.Prime] + (hkp : k halaszPrimePowerReduction p r (x i))) + (F : Finset (Fin k → ZMod (p^(r+1)))) + (hF : ∀ y∈F, ∀ i, ∑ j, (P i).eval (x j)=∑ j, (P i).eval (y j)) : + F.card ≤ k^k := by + apply halasz_prime_power_solution_count hkp x hx F + intro y hy + exact halasz_power_sums_of_polynomial_sums P x y hdeg hunit (hF y hy) + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePowerLogBound.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePowerLogBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce6d29804c9dd951a997ef7576ba50111978448d --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePowerLogBound.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszPositiveLog +import OAI.NumberTheory.TwoPoint.Bounds.ThetaLogError +import Mathlib.NumberTheory.Chebyshev + +namespace OAI + +/-! A Chebyshev bound for the prime-power logarithmic kernel appearing in +the positive correction mean. Higher prime powers cost only an absolute +constant times the cutoff. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def halaszPrimePowerLogConstant : ℝ := + 2 * Real.log 4 + 32 / Real.log 2 + +lemma halasz_log_sq_sqrt (x : ℝ) (hx : 1 ≤ x) : + Real.sqrt x * Real.log x ^ 2 ≤ 8 * x := by + have hs1 : 1 ≤ Real.sqrt x := (Real.le_sqrt (by norm_num) (by linarith)).mpr (by simpa using hx) + have hh := log_sq_le_two_mul (Real.sqrt x) hs1 + rw [Real.log_sqrt (by linarith : 0 ≤ x)] at hh + have hm := mul_le_mul_of_nonneg_left hh (Real.sqrt_nonneg x) + nlinarith [Real.sq_sqrt (by linarith : 0 ≤ x)] + +lemma halasz_prime_power_log_term (N n : ℕ) (hN : 1 ≤ N) + (hn : n ∈ Icc 1 N) : + halaszPrimePowerLog n ≤ (2 * Real.log N / Real.log 2) * ArithmeticFunction.vonMangoldt n := by + have hlogN : 0 ≤ Real.log (N : ℝ) := Real.log_nonneg (by exact_mod_cast hN) + have hl2 : 0 < Real.log 2 := Real.log_pos (by norm_num) + by_cases hnpp : IsPrimePow n + · have hn1 : n ≠ 1 := (ne_of_gt hnpp.one_lt) + have hmin : 2 ≤ n.minFac := (Nat.minFac_prime hn1).two_le + have hΛ : Real.log 2 ≤ ArithmeticFunction.vonMangoldt n := by + rw [ArithmeticFunction.vonMangoldt_apply, ite_eq_left hnpp] + exact Real.log_le_log (by norm_num) (by exact_mod_cast hmin) + have hln : Real.log (n : ℝ) ≤ Real.log N := + Real.log_le_log (by exact_mod_cast (mem_Icc.mp hn).1) (by exact_mod_cast (mem_Icc.mp hn).2) + rw [halaszPrimePowerLog, ite_eq_left hnpp] + have hh := mul_le_mul_of_nonneg_left hΛ (show 0 ≤ 2 * Real.log N / Real.log 2 by positivity) + have he : (2 * Real.log N / Real.log 2) * Real.log 2 = 2 * Real.log N := by field_simp + rw [he] at hh + linarith + · rw [halaszPrimePowerLog, ite_eq_right hnpp] + exact mul_nonneg (by positivity) ArithmeticFunction.vonMangoldt_nonneg + +lemma halasz_prime_power_log_sum (N : ℕ) (hN : 1 ≤ N) : + (∑ n ∈ Icc 1 N, halaszPrimePowerLog n) ≤ halaszPrimePowerLogConstant * N := by + have hNr : (1 : ℝ) ≤ N := by exact_mod_cast hN + have hl2 : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hlogN : 0 ≤ Real.log (N : ℝ) := Real.log_nonneg hNr + have hset : Ioc 0 N = Icc 1 N := by ext n; simp only [mem_Ioc, mem_Icc]; omega + have hsplit : (∑ n ∈ Icc 1 N, halaszPrimePowerLog n) ≤ + 2 * Chebyshev.theta N + (2 * Real.log N / Real.log 2) * + (Chebyshev.psi N - Chebyshev.theta N) := by + rw [Chebyshev.psi_sub_theta_eq_sum_not_prime, Chebyshev.theta, + Nat.floor_natCast, hset, mul_sum, mul_sum, sum_filter, sum_filter, ← sum_add_distrib] + apply sum_le_sum + intro n hn + by_cases hp : n.Prime + · simp [hp, halaszPrimePowerLog, hp.prime.isPrimePow] + · simpa only [hp, not_false_eq_true, ite_false, ite_true, zero_add] using + halasz_prime_power_log_term N n hN hn + have htheta := Chebyshev.theta_le_log4_mul_x (x := (N : ℝ)) (by positivity) + have htail := Chebyshev.psi_sub_theta_le hNr + have hsq := halasz_log_sq_sqrt N hNr + calc + _ ≤ 2 * Chebyshev.theta N + (2 * Real.log N / Real.log 2) * + (Chebyshev.psi N - Chebyshev.theta N) := hsplit + _ ≤ 2 * (Real.log 4 * N) + (2 * Real.log N / Real.log 2) * + (2 * Real.sqrt N * Real.log N) := by gcongr + _ = 2 * (Real.log 4 * N) + (4 / Real.log 2) * (Real.sqrt N * Real.log N ^ 2) := by ring + _ ≤ 2 * (Real.log 4 * N) + (4 / Real.log 2) * (8 * N) := by gcongr + _ = _ := by unfold halaszPrimePowerLogConstant; ring + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePowerRoots.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePowerRoots.lean new file mode 100644 index 0000000000000000000000000000000000000000..749c658fb6730bd84945e70c0d4317438b89670a --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePowerRoots.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszVinogradovJacobian + +namespace OAI + +/-! A split polynomial with distinct roots modulo p has no additional +roots modulo a power of p. This is the uniqueness part needed in the +nonsingular congruence count. -/ +namespace TwoPointCorrelations + +open Finset + +noncomputable def halaszPrimePowerReduction (p r : ℕ) : + ZMod (p^(r+1)) →+* ZMod p := + ZMod.castHom (dvd_pow_self p (by omega : r+1≠0)) (ZMod p) + +lemma halasz_prime_power_unit_iff {p r : ℕ} [Fact p.Prime] (z : ZMod (p^(r+1))) : + IsUnit z ↔ halaszPrimePowerReduction p r z≠0 := by + have hp : p.Prime := Fact.out + have : NeZero (p^(r+1)) := ⟨pow_ne_zero _ hp.ne_zero⟩ + have hz : (z.val : ZMod (p^(r+1))) = z := ZMod.natCast_zmod_val z + calc + IsUnit z ↔ IsUnit (z.val : ZMod (p^(r+1))) := by rw [hz] + _ ↔ ¬p∣z.val := ZMod.isUnit_natCast_iff_not_dvd_pow hp (by omega) + _ ↔ halaszPrimePowerReduction p r z≠0 := by + have he : halaszPrimePowerReduction p r z = (z.val:ZMod p) := by + calc + _ = halaszPrimePowerReduction p r (z.val:ZMod (p^(r+1))) := congrArg _ hz.symm + _ = _ := map_natCast _ _ + rw [he] + exact (ZMod.natCast_eq_zero_iff _ _).not.symm + +theorem halasz_prime_power_split_roots {p r k : ℕ} [Fact p.Prime] + (x : Fin k → ZMod (p^(r+1))) + (hx : Function.Injective (fun i => halaszPrimePowerReduction p r (x i))) + (z : ZMod (p^(r+1))) (hz : ∏ i, (z-x i)=0) : ∃ i, z=x i := by + classical + let φ := halaszPrimePowerReduction p r + have hred : ∏ i, (φ z-φ (x i))=0 := by + simpa only [map_prod,map_sub,map_zero] using congrArg φ hz + obtain ⟨i,_,hi⟩ := prod_eq_zero_iff.mp hred + have hi' : φ z=φ (x i) := sub_eq_zero.mp hi + have hu : IsUnit (∏ j ∈ (univ:Finset (Fin k)).erase i, (z-x j)) := by + apply IsUnit.prod_iff.mpr + intro j hj + apply (halasz_prime_power_unit_iff _).mpr + change φ (z-x j)≠0 + rw [map_sub,hi',sub_ne_zero] + intro he + exact (mem_erase.mp hj).1 (hx he).symm + have hfactor : (z-x i)*(∏ j ∈ (univ:Finset (Fin k)).erase i, (z-x j))=0 := by + rw [mul_prod_erase univ (fun j => z-x j) (mem_univ i)] + exact hz + exact ⟨i,sub_eq_zero.mp (hu.mul_left_eq_zero.mp hfactor)⟩ + +end TwoPointCorrelations + +end OAI diff --git a/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePowers.lean b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePowers.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f1d28a356c647c0cececc7b53620edbde0c4b61 --- /dev/null +++ b/lean/OAI/NumberTheory/TwoPoint/Halasz/HalaszPrimePowers.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.TwoPoint.Halasz.HalaszHyperbolaRows +import Mathlib.NumberTheory.LSeries.PrimesInAP + +namespace OAI + +/-! The total reciprocal contribution of higher prime powers is finite. +The modulus-one specialization of the prime-power series bounds +the finite hyperbola error. -/ + +namespace TwoPointCorrelations + +open Finset +open scoped Classical + +noncomputable def halaszPrimePowerWeight (n : ℕ) : ℝ := + if n.Prime then 0 else ArithmeticFunction.vonMangoldt n + +lemma halaszPrimePowerWeight_nonneg (n : ℕ) : 0 ≤ halaszPrimePowerWeight n := by + unfold halaszPrimePowerWeight + split_ifs + · exact le_rfl + · exact ArithmeticFunction.vonMangoldt_nonneg + +lemma halaszPrimePowerWeight_summable : + Summable (fun n : ℕ => halaszPrimePowerWeight n / (n : ℝ)) := by + have hh := ArithmeticFunction.vonMangoldt.summable_residueClass_non_primes_div + (0 : ZMod 1) + convert hh using 1 + funext n + simp only [halaszPrimePowerWeight, ArithmeticFunction.vonMangoldt.residueClass] + have he : (n : ZMod 1) = 0 := Subsingleton.elim _ _ + simp [he] + +noncomputable def halaszPrimePowerConstant : ℝ := + ∑' n : ℕ, halaszPrimePowerWeight n / (n : ℝ) + +lemma halaszPrimePowerConstant_nonneg : 0 ≤ halaszPrimePowerConstant := + tsum_nonneg (fun n => div_nonneg (halaszPrimePowerWeight_nonneg n) (Nat.cast_nonneg _)) + +lemma halasz_bounded_prefix_norm (f : ℕ → ℂ) (hf : OneBounded f) (N : ℕ) : + ‖∑ n ∈ Icc 1 N, f n‖ ≤ (N : ℝ) := by + calc + _ ≤ ∑ n ∈ Icc 1 N, ‖f n‖ := norm_sum_le _ _ + _ ≤ ∑ _n ∈ Icc 1 N, (1 : ℝ) := + sum_le_sum (fun n hn => hf n (mem_Icc.mp hn).1) + _ = _ := by simp + +/-- Discarding all higher prime powers in the logarithmic hyperbola incurs +at most an absolute constant times its outer cutoff. -/ +theorem halasz_prime_power_error (f : ℕ → ℂ) (hf : OneBounded f) (N : ℕ) : + ‖∑ d ∈ Icc 1 N, (halaszPrimePowerWeight d : ℂ) * f d * + (∑ m ∈ Icc 1 (N / d), f m)‖ ≤ (N : ℝ) * halaszPrimePowerConstant := by + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ d ∈ Icc 1 N, (N : ℝ) * (halaszPrimePowerWeight d / (d : ℝ)) := by + apply sum_le_sum + intro d hd + have hdpos := (mem_Icc.mp hd).1 + have hdr : (0 : ℝ) < d := by exact_mod_cast hdpos + have hw := halaszPrimePowerWeight_nonneg d + have hdiv : ((N / d : ℕ) : ℝ) ≤ (N : ℝ) / (d : ℝ) := by + apply (le_div_iff₀ hdr).mpr + exact_mod_cast Nat.div_mul_le_self N d + rw [norm_mul, norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg hw] + calc + _ ≤ halaszPrimePowerWeight d * 1 * ((N / d : ℕ) : ℝ) := by + gcongr + · exact hf d hdpos + · exact halasz_bounded_prefix_norm f hf (N / d) + _ ≤ halaszPrimePowerWeight d * ((N : ℝ) / (d : ℝ)) := by + simpa only [mul_one] using mul_le_mul_of_nonneg_left hdiv hw + _ = _ := by ring + _ = (N : ℝ) * ∑ d ∈ Icc 1 N, halaszPrimePowerWeight d / (d : ℝ) := + (mul_sum _ _ _).symm + _ ≤ _ := by + apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) + exact halaszPrimePowerWeight_summable.sum_le_tsum _ + (fun d _ => div_nonneg (halaszPrimePowerWeight_nonneg d) (Nat.cast_nonneg _)) + +end TwoPointCorrelations + +end OAI